documentation.d.ts 3.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4619. /**
  4620. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4621. * This function works in left handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4630. * This function works in left handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5160. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6411. */
  6412. attachControl(noPreventDefault?: boolean): void;
  6413. /**
  6414. * Detach the current controls from the specified dom element.
  6415. */
  6416. detachControl(): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedToElement: boolean;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Class used to host copy specific utilities
  7783. */
  7784. export class CopyTools {
  7785. /**
  7786. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  7787. * @param texture defines the texture to read pixels from
  7788. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7789. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7790. * @returns The base64 encoded string or null
  7791. */
  7792. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. /**
  7797. * Define options used to create a depth texture
  7798. */
  7799. export class DepthTextureCreationOptions {
  7800. /** Specifies whether or not a stencil should be allocated in the texture */
  7801. generateStencil?: boolean;
  7802. /** Specifies whether or not bilinear filtering is enable on the texture */
  7803. bilinearFiltering?: boolean;
  7804. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7805. comparisonFunction?: number;
  7806. /** Specifies if the created texture is a cube texture */
  7807. isCube?: boolean;
  7808. }
  7809. }
  7810. declare module BABYLON {
  7811. interface ThinEngine {
  7812. /**
  7813. * Creates a depth stencil cube texture.
  7814. * This is only available in WebGL 2.
  7815. * @param size The size of face edge in the cube texture.
  7816. * @param options The options defining the cube texture.
  7817. * @returns The cube texture
  7818. */
  7819. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7820. /**
  7821. * Creates a cube texture
  7822. * @param rootUrl defines the url where the files to load is located
  7823. * @param scene defines the current scene
  7824. * @param files defines the list of files to load (1 per face)
  7825. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7826. * @param onLoad defines an optional callback raised when the texture is loaded
  7827. * @param onError defines an optional callback raised if there is an issue to load the texture
  7828. * @param format defines the format of the data
  7829. * @param forcedExtension defines the extension to use to pick the right loader
  7830. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7833. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7834. * @param loaderOptions options to be passed to the loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7838. /**
  7839. * Creates a cube texture
  7840. * @param rootUrl defines the url where the files to load is located
  7841. * @param scene defines the current scene
  7842. * @param files defines the list of files to load (1 per face)
  7843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7844. * @param onLoad defines an optional callback raised when the texture is loaded
  7845. * @param onError defines an optional callback raised if there is an issue to load the texture
  7846. * @param format defines the format of the data
  7847. * @param forcedExtension defines the extension to use to pick the right loader
  7848. * @returns the cube texture as an InternalTexture
  7849. */
  7850. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7851. /**
  7852. * Creates a cube texture
  7853. * @param rootUrl defines the url where the files to load is located
  7854. * @param scene defines the current scene
  7855. * @param files defines the list of files to load (1 per face)
  7856. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7857. * @param onLoad defines an optional callback raised when the texture is loaded
  7858. * @param onError defines an optional callback raised if there is an issue to load the texture
  7859. * @param format defines the format of the data
  7860. * @param forcedExtension defines the extension to use to pick the right loader
  7861. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7862. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7863. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7864. * @returns the cube texture as an InternalTexture
  7865. */
  7866. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7867. /** @hidden */
  7868. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7869. /** @hidden */
  7870. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7871. /** @hidden */
  7872. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7873. /** @hidden */
  7874. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7875. /**
  7876. * @hidden
  7877. */
  7878. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Class for creating a cube texture
  7884. */
  7885. export class CubeTexture extends BaseTexture {
  7886. private _delayedOnLoad;
  7887. /**
  7888. * Observable triggered once the texture has been loaded.
  7889. */
  7890. onLoadObservable: Observable<CubeTexture>;
  7891. /**
  7892. * The url of the texture
  7893. */
  7894. url: string;
  7895. /**
  7896. * Gets or sets the center of the bounding box associated with the cube texture.
  7897. * It must define where the camera used to render the texture was set
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. boundingBoxPosition: Vector3;
  7901. private _boundingBoxSize;
  7902. /**
  7903. * Gets or sets the size of the bounding box associated with the cube texture
  7904. * When defined, the cubemap will switch to local mode
  7905. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7906. * @example https://www.babylonjs-playground.com/#RNASML
  7907. */
  7908. set boundingBoxSize(value: Vector3);
  7909. /**
  7910. * Returns the bounding box size
  7911. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7912. */
  7913. get boundingBoxSize(): Vector3;
  7914. protected _rotationY: number;
  7915. /**
  7916. * Sets texture matrix rotation angle around Y axis in radians.
  7917. */
  7918. set rotationY(value: number);
  7919. /**
  7920. * Gets texture matrix rotation angle around Y axis radians.
  7921. */
  7922. get rotationY(): number;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. private _noMipmap;
  7928. private _files;
  7929. protected _forcedExtension: Nullable<string>;
  7930. private _extensions;
  7931. private _textureMatrix;
  7932. private _format;
  7933. private _createPolynomials;
  7934. private _loaderOptions;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @param loaderOptions options to be passed to the loader
  7969. * @return the cube texture
  7970. */
  7971. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7972. /**
  7973. * Get the current class name of the texture useful for serialization or dynamic coding.
  7974. * @returns "CubeTexture"
  7975. */
  7976. getClassName(): string;
  7977. /**
  7978. * Update the url (and optional buffer) of this texture if url was null during construction.
  7979. * @param url the url of the texture
  7980. * @param forcedExtension defines the extension to use
  7981. * @param onLoad callback called when the texture is loaded (defaults to null)
  7982. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7983. */
  7984. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7985. /**
  7986. * Delays loading of the cube texture
  7987. * @param forcedExtension defines the extension to use
  7988. */
  7989. delayLoad(forcedExtension?: string): void;
  7990. /**
  7991. * Returns the reflection texture matrix
  7992. * @returns the reflection texture matrix
  7993. */
  7994. getReflectionTextureMatrix(): Matrix;
  7995. /**
  7996. * Sets the reflection texture matrix
  7997. * @param value Reflection texture matrix
  7998. */
  7999. setReflectionTextureMatrix(value: Matrix): void;
  8000. /**
  8001. * Parses text to create a cube texture
  8002. * @param parsedTexture define the serialized text to read from
  8003. * @param scene defines the hosting scene
  8004. * @param rootUrl defines the root url of the cube texture
  8005. * @returns a cube texture
  8006. */
  8007. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8008. /**
  8009. * Makes a clone, or deep copy, of the cube texture
  8010. * @returns a new cube texture
  8011. */
  8012. clone(): CubeTexture;
  8013. }
  8014. }
  8015. declare module BABYLON {
  8016. /**
  8017. * Manages the defines for the Material
  8018. */
  8019. export class MaterialDefines {
  8020. /** @hidden */
  8021. protected _keys: string[];
  8022. private _isDirty;
  8023. /** @hidden */
  8024. _renderId: number;
  8025. /** @hidden */
  8026. _areLightsDirty: boolean;
  8027. /** @hidden */
  8028. _areLightsDisposed: boolean;
  8029. /** @hidden */
  8030. _areAttributesDirty: boolean;
  8031. /** @hidden */
  8032. _areTexturesDirty: boolean;
  8033. /** @hidden */
  8034. _areFresnelDirty: boolean;
  8035. /** @hidden */
  8036. _areMiscDirty: boolean;
  8037. /** @hidden */
  8038. _arePrePassDirty: boolean;
  8039. /** @hidden */
  8040. _areImageProcessingDirty: boolean;
  8041. /** @hidden */
  8042. _normals: boolean;
  8043. /** @hidden */
  8044. _uvs: boolean;
  8045. /** @hidden */
  8046. _needNormals: boolean;
  8047. /** @hidden */
  8048. _needUVs: boolean;
  8049. [id: string]: any;
  8050. /**
  8051. * Specifies if the material needs to be re-calculated
  8052. */
  8053. get isDirty(): boolean;
  8054. /**
  8055. * Marks the material to indicate that it has been re-calculated
  8056. */
  8057. markAsProcessed(): void;
  8058. /**
  8059. * Marks the material to indicate that it needs to be re-calculated
  8060. */
  8061. markAsUnprocessed(): void;
  8062. /**
  8063. * Marks the material to indicate all of its defines need to be re-calculated
  8064. */
  8065. markAllAsDirty(): void;
  8066. /**
  8067. * Marks the material to indicate that image processing needs to be re-calculated
  8068. */
  8069. markAsImageProcessingDirty(): void;
  8070. /**
  8071. * Marks the material to indicate the lights need to be re-calculated
  8072. * @param disposed Defines whether the light is dirty due to dispose or not
  8073. */
  8074. markAsLightDirty(disposed?: boolean): void;
  8075. /**
  8076. * Marks the attribute state as changed
  8077. */
  8078. markAsAttributesDirty(): void;
  8079. /**
  8080. * Marks the texture state as changed
  8081. */
  8082. markAsTexturesDirty(): void;
  8083. /**
  8084. * Marks the fresnel state as changed
  8085. */
  8086. markAsFresnelDirty(): void;
  8087. /**
  8088. * Marks the misc state as changed
  8089. */
  8090. markAsMiscDirty(): void;
  8091. /**
  8092. * Marks the prepass state as changed
  8093. */
  8094. markAsPrePassDirty(): void;
  8095. /**
  8096. * Rebuilds the material defines
  8097. */
  8098. rebuild(): void;
  8099. /**
  8100. * Specifies if two material defines are equal
  8101. * @param other - A material define instance to compare to
  8102. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8103. */
  8104. isEqual(other: MaterialDefines): boolean;
  8105. /**
  8106. * Clones this instance's defines to another instance
  8107. * @param other - material defines to clone values to
  8108. */
  8109. cloneTo(other: MaterialDefines): void;
  8110. /**
  8111. * Resets the material define values
  8112. */
  8113. reset(): void;
  8114. /**
  8115. * Converts the material define values to a string
  8116. * @returns - String of material define information
  8117. */
  8118. toString(): string;
  8119. }
  8120. }
  8121. declare module BABYLON {
  8122. /**
  8123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8125. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8127. */
  8128. export class ColorCurves {
  8129. private _dirty;
  8130. private _tempColor;
  8131. private _globalCurve;
  8132. private _highlightsCurve;
  8133. private _midtonesCurve;
  8134. private _shadowsCurve;
  8135. private _positiveCurve;
  8136. private _negativeCurve;
  8137. private _globalHue;
  8138. private _globalDensity;
  8139. private _globalSaturation;
  8140. private _globalExposure;
  8141. /**
  8142. * Gets the global Hue value.
  8143. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8144. */
  8145. get globalHue(): number;
  8146. /**
  8147. * Sets the global Hue value.
  8148. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8149. */
  8150. set globalHue(value: number);
  8151. /**
  8152. * Gets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get globalDensity(): number;
  8157. /**
  8158. * Sets the global Density value.
  8159. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set globalDensity(value: number);
  8163. /**
  8164. * Gets the global Saturation value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8166. */
  8167. get globalSaturation(): number;
  8168. /**
  8169. * Sets the global Saturation value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8171. */
  8172. set globalSaturation(value: number);
  8173. /**
  8174. * Gets the global Exposure value.
  8175. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8176. */
  8177. get globalExposure(): number;
  8178. /**
  8179. * Sets the global Exposure value.
  8180. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8181. */
  8182. set globalExposure(value: number);
  8183. private _highlightsHue;
  8184. private _highlightsDensity;
  8185. private _highlightsSaturation;
  8186. private _highlightsExposure;
  8187. /**
  8188. * Gets the highlights Hue value.
  8189. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8190. */
  8191. get highlightsHue(): number;
  8192. /**
  8193. * Sets the highlights Hue value.
  8194. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8195. */
  8196. set highlightsHue(value: number);
  8197. /**
  8198. * Gets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get highlightsDensity(): number;
  8203. /**
  8204. * Sets the highlights Density value.
  8205. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set highlightsDensity(value: number);
  8209. /**
  8210. * Gets the highlights Saturation value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8212. */
  8213. get highlightsSaturation(): number;
  8214. /**
  8215. * Sets the highlights Saturation value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8217. */
  8218. set highlightsSaturation(value: number);
  8219. /**
  8220. * Gets the highlights Exposure value.
  8221. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8222. */
  8223. get highlightsExposure(): number;
  8224. /**
  8225. * Sets the highlights Exposure value.
  8226. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8227. */
  8228. set highlightsExposure(value: number);
  8229. private _midtonesHue;
  8230. private _midtonesDensity;
  8231. private _midtonesSaturation;
  8232. private _midtonesExposure;
  8233. /**
  8234. * Gets the midtones Hue value.
  8235. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8236. */
  8237. get midtonesHue(): number;
  8238. /**
  8239. * Sets the midtones Hue value.
  8240. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8241. */
  8242. set midtonesHue(value: number);
  8243. /**
  8244. * Gets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. get midtonesDensity(): number;
  8249. /**
  8250. * Sets the midtones Density value.
  8251. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8252. * Values less than zero provide a filter of opposite hue.
  8253. */
  8254. set midtonesDensity(value: number);
  8255. /**
  8256. * Gets the midtones Saturation value.
  8257. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8258. */
  8259. get midtonesSaturation(): number;
  8260. /**
  8261. * Sets the midtones Saturation value.
  8262. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8263. */
  8264. set midtonesSaturation(value: number);
  8265. /**
  8266. * Gets the midtones Exposure value.
  8267. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8268. */
  8269. get midtonesExposure(): number;
  8270. /**
  8271. * Sets the midtones Exposure value.
  8272. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8273. */
  8274. set midtonesExposure(value: number);
  8275. private _shadowsHue;
  8276. private _shadowsDensity;
  8277. private _shadowsSaturation;
  8278. private _shadowsExposure;
  8279. /**
  8280. * Gets the shadows Hue value.
  8281. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8282. */
  8283. get shadowsHue(): number;
  8284. /**
  8285. * Sets the shadows Hue value.
  8286. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8287. */
  8288. set shadowsHue(value: number);
  8289. /**
  8290. * Gets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. get shadowsDensity(): number;
  8295. /**
  8296. * Sets the shadows Density value.
  8297. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8298. * Values less than zero provide a filter of opposite hue.
  8299. */
  8300. set shadowsDensity(value: number);
  8301. /**
  8302. * Gets the shadows Saturation value.
  8303. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8304. */
  8305. get shadowsSaturation(): number;
  8306. /**
  8307. * Sets the shadows Saturation value.
  8308. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8309. */
  8310. set shadowsSaturation(value: number);
  8311. /**
  8312. * Gets the shadows Exposure value.
  8313. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8314. */
  8315. get shadowsExposure(): number;
  8316. /**
  8317. * Sets the shadows Exposure value.
  8318. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8319. */
  8320. set shadowsExposure(value: number);
  8321. /**
  8322. * Returns the class name
  8323. * @returns The class name
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Binds the color curves to the shader.
  8328. * @param colorCurves The color curve to bind
  8329. * @param effect The effect to bind to
  8330. * @param positiveUniform The positive uniform shader parameter
  8331. * @param neutralUniform The neutral uniform shader parameter
  8332. * @param negativeUniform The negative uniform shader parameter
  8333. */
  8334. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8335. /**
  8336. * Prepare the list of uniforms associated with the ColorCurves effects.
  8337. * @param uniformsList The list of uniforms used in the effect
  8338. */
  8339. static PrepareUniforms(uniformsList: string[]): void;
  8340. /**
  8341. * Returns color grading data based on a hue, density, saturation and exposure value.
  8342. * @param filterHue The hue of the color filter.
  8343. * @param filterDensity The density of the color filter.
  8344. * @param saturation The saturation.
  8345. * @param exposure The exposure.
  8346. * @param result The result data container.
  8347. */
  8348. private getColorGradingDataToRef;
  8349. /**
  8350. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8351. * @param value The input slider value in range [-100,100].
  8352. * @returns Adjusted value.
  8353. */
  8354. private static applyColorGradingSliderNonlinear;
  8355. /**
  8356. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8357. * @param hue The hue (H) input.
  8358. * @param saturation The saturation (S) input.
  8359. * @param brightness The brightness (B) input.
  8360. * @result An RGBA color represented as Vector4.
  8361. */
  8362. private static fromHSBToRef;
  8363. /**
  8364. * Returns a value clamped between min and max
  8365. * @param value The value to clamp
  8366. * @param min The minimum of value
  8367. * @param max The maximum of value
  8368. * @returns The clamped value.
  8369. */
  8370. private static clamp;
  8371. /**
  8372. * Clones the current color curve instance.
  8373. * @return The cloned curves
  8374. */
  8375. clone(): ColorCurves;
  8376. /**
  8377. * Serializes the current color curve instance to a json representation.
  8378. * @return a JSON representation
  8379. */
  8380. serialize(): any;
  8381. /**
  8382. * Parses the color curve from a json representation.
  8383. * @param source the JSON source to parse
  8384. * @return The parsed curves
  8385. */
  8386. static Parse(source: any): ColorCurves;
  8387. }
  8388. }
  8389. declare module BABYLON {
  8390. /**
  8391. * Interface to follow in your material defines to integrate easily the
  8392. * Image proccessing functions.
  8393. * @hidden
  8394. */
  8395. export interface IImageProcessingConfigurationDefines {
  8396. IMAGEPROCESSING: boolean;
  8397. VIGNETTE: boolean;
  8398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8399. VIGNETTEBLENDMODEOPAQUE: boolean;
  8400. TONEMAPPING: boolean;
  8401. TONEMAPPING_ACES: boolean;
  8402. CONTRAST: boolean;
  8403. EXPOSURE: boolean;
  8404. COLORCURVES: boolean;
  8405. COLORGRADING: boolean;
  8406. COLORGRADING3D: boolean;
  8407. SAMPLER3DGREENDEPTH: boolean;
  8408. SAMPLER3DBGRMAP: boolean;
  8409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8410. }
  8411. /**
  8412. * @hidden
  8413. */
  8414. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8415. IMAGEPROCESSING: boolean;
  8416. VIGNETTE: boolean;
  8417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8418. VIGNETTEBLENDMODEOPAQUE: boolean;
  8419. TONEMAPPING: boolean;
  8420. TONEMAPPING_ACES: boolean;
  8421. CONTRAST: boolean;
  8422. COLORCURVES: boolean;
  8423. COLORGRADING: boolean;
  8424. COLORGRADING3D: boolean;
  8425. SAMPLER3DGREENDEPTH: boolean;
  8426. SAMPLER3DBGRMAP: boolean;
  8427. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8428. EXPOSURE: boolean;
  8429. constructor();
  8430. }
  8431. /**
  8432. * This groups together the common properties used for image processing either in direct forward pass
  8433. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8434. * or not.
  8435. */
  8436. export class ImageProcessingConfiguration {
  8437. /**
  8438. * Default tone mapping applied in BabylonJS.
  8439. */
  8440. static readonly TONEMAPPING_STANDARD: number;
  8441. /**
  8442. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8443. * to other engines rendering to increase portability.
  8444. */
  8445. static readonly TONEMAPPING_ACES: number;
  8446. /**
  8447. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8448. */
  8449. colorCurves: Nullable<ColorCurves>;
  8450. private _colorCurvesEnabled;
  8451. /**
  8452. * Gets wether the color curves effect is enabled.
  8453. */
  8454. get colorCurvesEnabled(): boolean;
  8455. /**
  8456. * Sets wether the color curves effect is enabled.
  8457. */
  8458. set colorCurvesEnabled(value: boolean);
  8459. private _colorGradingTexture;
  8460. /**
  8461. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8462. */
  8463. get colorGradingTexture(): Nullable<BaseTexture>;
  8464. /**
  8465. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8466. */
  8467. set colorGradingTexture(value: Nullable<BaseTexture>);
  8468. private _colorGradingEnabled;
  8469. /**
  8470. * Gets wether the color grading effect is enabled.
  8471. */
  8472. get colorGradingEnabled(): boolean;
  8473. /**
  8474. * Sets wether the color grading effect is enabled.
  8475. */
  8476. set colorGradingEnabled(value: boolean);
  8477. private _colorGradingWithGreenDepth;
  8478. /**
  8479. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8480. */
  8481. get colorGradingWithGreenDepth(): boolean;
  8482. /**
  8483. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8484. */
  8485. set colorGradingWithGreenDepth(value: boolean);
  8486. private _colorGradingBGR;
  8487. /**
  8488. * Gets wether the color grading texture contains BGR values.
  8489. */
  8490. get colorGradingBGR(): boolean;
  8491. /**
  8492. * Sets wether the color grading texture contains BGR values.
  8493. */
  8494. set colorGradingBGR(value: boolean);
  8495. /** @hidden */
  8496. _exposure: number;
  8497. /**
  8498. * Gets the Exposure used in the effect.
  8499. */
  8500. get exposure(): number;
  8501. /**
  8502. * Sets the Exposure used in the effect.
  8503. */
  8504. set exposure(value: number);
  8505. private _toneMappingEnabled;
  8506. /**
  8507. * Gets wether the tone mapping effect is enabled.
  8508. */
  8509. get toneMappingEnabled(): boolean;
  8510. /**
  8511. * Sets wether the tone mapping effect is enabled.
  8512. */
  8513. set toneMappingEnabled(value: boolean);
  8514. private _toneMappingType;
  8515. /**
  8516. * Gets the type of tone mapping effect.
  8517. */
  8518. get toneMappingType(): number;
  8519. /**
  8520. * Sets the type of tone mapping effect used in BabylonJS.
  8521. */
  8522. set toneMappingType(value: number);
  8523. protected _contrast: number;
  8524. /**
  8525. * Gets the contrast used in the effect.
  8526. */
  8527. get contrast(): number;
  8528. /**
  8529. * Sets the contrast used in the effect.
  8530. */
  8531. set contrast(value: number);
  8532. /**
  8533. * Vignette stretch size.
  8534. */
  8535. vignetteStretch: number;
  8536. /**
  8537. * Vignette centre X Offset.
  8538. */
  8539. vignetteCentreX: number;
  8540. /**
  8541. * Vignette centre Y Offset.
  8542. */
  8543. vignetteCentreY: number;
  8544. /**
  8545. * Vignette weight or intensity of the vignette effect.
  8546. */
  8547. vignetteWeight: number;
  8548. /**
  8549. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8550. * if vignetteEnabled is set to true.
  8551. */
  8552. vignetteColor: Color4;
  8553. /**
  8554. * Camera field of view used by the Vignette effect.
  8555. */
  8556. vignetteCameraFov: number;
  8557. private _vignetteBlendMode;
  8558. /**
  8559. * Gets the vignette blend mode allowing different kind of effect.
  8560. */
  8561. get vignetteBlendMode(): number;
  8562. /**
  8563. * Sets the vignette blend mode allowing different kind of effect.
  8564. */
  8565. set vignetteBlendMode(value: number);
  8566. private _vignetteEnabled;
  8567. /**
  8568. * Gets wether the vignette effect is enabled.
  8569. */
  8570. get vignetteEnabled(): boolean;
  8571. /**
  8572. * Sets wether the vignette effect is enabled.
  8573. */
  8574. set vignetteEnabled(value: boolean);
  8575. private _applyByPostProcess;
  8576. /**
  8577. * Gets wether the image processing is applied through a post process or not.
  8578. */
  8579. get applyByPostProcess(): boolean;
  8580. /**
  8581. * Sets wether the image processing is applied through a post process or not.
  8582. */
  8583. set applyByPostProcess(value: boolean);
  8584. private _isEnabled;
  8585. /**
  8586. * Gets wether the image processing is enabled or not.
  8587. */
  8588. get isEnabled(): boolean;
  8589. /**
  8590. * Sets wether the image processing is enabled or not.
  8591. */
  8592. set isEnabled(value: boolean);
  8593. /**
  8594. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8595. */
  8596. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8597. /**
  8598. * Method called each time the image processing information changes requires to recompile the effect.
  8599. */
  8600. protected _updateParameters(): void;
  8601. /**
  8602. * Gets the current class name.
  8603. * @return "ImageProcessingConfiguration"
  8604. */
  8605. getClassName(): string;
  8606. /**
  8607. * Prepare the list of uniforms associated with the Image Processing effects.
  8608. * @param uniforms The list of uniforms used in the effect
  8609. * @param defines the list of defines currently in use
  8610. */
  8611. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8612. /**
  8613. * Prepare the list of samplers associated with the Image Processing effects.
  8614. * @param samplersList The list of uniforms used in the effect
  8615. * @param defines the list of defines currently in use
  8616. */
  8617. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8618. /**
  8619. * Prepare the list of defines associated to the shader.
  8620. * @param defines the list of defines to complete
  8621. * @param forPostProcess Define if we are currently in post process mode or not
  8622. */
  8623. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8624. /**
  8625. * Returns true if all the image processing information are ready.
  8626. * @returns True if ready, otherwise, false
  8627. */
  8628. isReady(): boolean;
  8629. /**
  8630. * Binds the image processing to the shader.
  8631. * @param effect The effect to bind to
  8632. * @param overrideAspectRatio Override the aspect ratio of the effect
  8633. */
  8634. bind(effect: Effect, overrideAspectRatio?: number): void;
  8635. /**
  8636. * Clones the current image processing instance.
  8637. * @return The cloned image processing
  8638. */
  8639. clone(): ImageProcessingConfiguration;
  8640. /**
  8641. * Serializes the current image processing instance to a json representation.
  8642. * @return a JSON representation
  8643. */
  8644. serialize(): any;
  8645. /**
  8646. * Parses the image processing from a json representation.
  8647. * @param source the JSON source to parse
  8648. * @return The parsed image processing
  8649. */
  8650. static Parse(source: any): ImageProcessingConfiguration;
  8651. private static _VIGNETTEMODE_MULTIPLY;
  8652. private static _VIGNETTEMODE_OPAQUE;
  8653. /**
  8654. * Used to apply the vignette as a mix with the pixel color.
  8655. */
  8656. static get VIGNETTEMODE_MULTIPLY(): number;
  8657. /**
  8658. * Used to apply the vignette as a replacement of the pixel color.
  8659. */
  8660. static get VIGNETTEMODE_OPAQUE(): number;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /** @hidden */
  8665. export var postprocessVertexShader: {
  8666. name: string;
  8667. shader: string;
  8668. };
  8669. }
  8670. declare module BABYLON {
  8671. /**
  8672. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8673. */
  8674. export type RenderTargetTextureSize = number | {
  8675. width: number;
  8676. height: number;
  8677. layers?: number;
  8678. };
  8679. interface ThinEngine {
  8680. /**
  8681. * Creates a new render target texture
  8682. * @param size defines the size of the texture
  8683. * @param options defines the options used to create the texture
  8684. * @returns a new render target texture stored in an InternalTexture
  8685. */
  8686. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8687. /**
  8688. * Creates a depth stencil texture.
  8689. * This is only available in WebGL 2 or with the depth texture extension available.
  8690. * @param size The size of face edge in the texture.
  8691. * @param options The options defining the texture.
  8692. * @returns The texture
  8693. */
  8694. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8695. /** @hidden */
  8696. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Defines the kind of connection point for node based material
  8702. */
  8703. export enum NodeMaterialBlockConnectionPointTypes {
  8704. /** Float */
  8705. Float = 1,
  8706. /** Int */
  8707. Int = 2,
  8708. /** Vector2 */
  8709. Vector2 = 4,
  8710. /** Vector3 */
  8711. Vector3 = 8,
  8712. /** Vector4 */
  8713. Vector4 = 16,
  8714. /** Color3 */
  8715. Color3 = 32,
  8716. /** Color4 */
  8717. Color4 = 64,
  8718. /** Matrix */
  8719. Matrix = 128,
  8720. /** Custom object */
  8721. Object = 256,
  8722. /** Detect type based on connection */
  8723. AutoDetect = 1024,
  8724. /** Output type that will be defined by input type */
  8725. BasedOnInput = 2048
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Enum used to define the target of a block
  8731. */
  8732. export enum NodeMaterialBlockTargets {
  8733. /** Vertex shader */
  8734. Vertex = 1,
  8735. /** Fragment shader */
  8736. Fragment = 2,
  8737. /** Neutral */
  8738. Neutral = 4,
  8739. /** Vertex and Fragment */
  8740. VertexAndFragment = 3
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8746. */
  8747. export enum NodeMaterialBlockConnectionPointMode {
  8748. /** Value is an uniform */
  8749. Uniform = 0,
  8750. /** Value is a mesh attribute */
  8751. Attribute = 1,
  8752. /** Value is a varying between vertex and fragment shaders */
  8753. Varying = 2,
  8754. /** Mode is undefined */
  8755. Undefined = 3
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * Enum used to define system values e.g. values automatically provided by the system
  8761. */
  8762. export enum NodeMaterialSystemValues {
  8763. /** World */
  8764. World = 1,
  8765. /** View */
  8766. View = 2,
  8767. /** Projection */
  8768. Projection = 3,
  8769. /** ViewProjection */
  8770. ViewProjection = 4,
  8771. /** WorldView */
  8772. WorldView = 5,
  8773. /** WorldViewProjection */
  8774. WorldViewProjection = 6,
  8775. /** CameraPosition */
  8776. CameraPosition = 7,
  8777. /** Fog Color */
  8778. FogColor = 8,
  8779. /** Delta time */
  8780. DeltaTime = 9
  8781. }
  8782. }
  8783. declare module BABYLON {
  8784. /** Defines supported spaces */
  8785. export enum Space {
  8786. /** Local (object) space */
  8787. LOCAL = 0,
  8788. /** World space */
  8789. WORLD = 1,
  8790. /** Bone space */
  8791. BONE = 2
  8792. }
  8793. /** Defines the 3 main axes */
  8794. export class Axis {
  8795. /** X axis */
  8796. static X: Vector3;
  8797. /** Y axis */
  8798. static Y: Vector3;
  8799. /** Z axis */
  8800. static Z: Vector3;
  8801. }
  8802. /**
  8803. * Defines cartesian components.
  8804. */
  8805. export enum Coordinate {
  8806. /** X axis */
  8807. X = 0,
  8808. /** Y axis */
  8809. Y = 1,
  8810. /** Z axis */
  8811. Z = 2
  8812. }
  8813. }
  8814. declare module BABYLON {
  8815. /**
  8816. * Represents a camera frustum
  8817. */
  8818. export class Frustum {
  8819. /**
  8820. * Gets the planes representing the frustum
  8821. * @param transform matrix to be applied to the returned planes
  8822. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8823. */
  8824. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8825. /**
  8826. * Gets the near frustum plane transformed by the transform matrix
  8827. * @param transform transformation matrix to be applied to the resulting frustum plane
  8828. * @param frustumPlane the resuling frustum plane
  8829. */
  8830. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8831. /**
  8832. * Gets the far frustum plane transformed by the transform matrix
  8833. * @param transform transformation matrix to be applied to the resulting frustum plane
  8834. * @param frustumPlane the resuling frustum plane
  8835. */
  8836. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8837. /**
  8838. * Gets the left frustum plane transformed by the transform matrix
  8839. * @param transform transformation matrix to be applied to the resulting frustum plane
  8840. * @param frustumPlane the resuling frustum plane
  8841. */
  8842. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8843. /**
  8844. * Gets the right frustum plane transformed by the transform matrix
  8845. * @param transform transformation matrix to be applied to the resulting frustum plane
  8846. * @param frustumPlane the resuling frustum plane
  8847. */
  8848. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8849. /**
  8850. * Gets the top frustum plane transformed by the transform matrix
  8851. * @param transform transformation matrix to be applied to the resulting frustum plane
  8852. * @param frustumPlane the resuling frustum plane
  8853. */
  8854. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8855. /**
  8856. * Gets the bottom frustum plane transformed by the transform matrix
  8857. * @param transform transformation matrix to be applied to the resulting frustum plane
  8858. * @param frustumPlane the resuling frustum plane
  8859. */
  8860. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8861. /**
  8862. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8863. * @param transform transformation matrix to be applied to the resulting frustum planes
  8864. * @param frustumPlanes the resuling frustum planes
  8865. */
  8866. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8867. }
  8868. }
  8869. declare module BABYLON {
  8870. /**
  8871. * Interface for the size containing width and height
  8872. */
  8873. export interface ISize {
  8874. /**
  8875. * Width
  8876. */
  8877. width: number;
  8878. /**
  8879. * Heighht
  8880. */
  8881. height: number;
  8882. }
  8883. /**
  8884. * Size containing widht and height
  8885. */
  8886. export class Size implements ISize {
  8887. /**
  8888. * Width
  8889. */
  8890. width: number;
  8891. /**
  8892. * Height
  8893. */
  8894. height: number;
  8895. /**
  8896. * Creates a Size object from the given width and height (floats).
  8897. * @param width width of the new size
  8898. * @param height height of the new size
  8899. */
  8900. constructor(width: number, height: number);
  8901. /**
  8902. * Returns a string with the Size width and height
  8903. * @returns a string with the Size width and height
  8904. */
  8905. toString(): string;
  8906. /**
  8907. * "Size"
  8908. * @returns the string "Size"
  8909. */
  8910. getClassName(): string;
  8911. /**
  8912. * Returns the Size hash code.
  8913. * @returns a hash code for a unique width and height
  8914. */
  8915. getHashCode(): number;
  8916. /**
  8917. * Updates the current size from the given one.
  8918. * @param src the given size
  8919. */
  8920. copyFrom(src: Size): void;
  8921. /**
  8922. * Updates in place the current Size from the given floats.
  8923. * @param width width of the new size
  8924. * @param height height of the new size
  8925. * @returns the updated Size.
  8926. */
  8927. copyFromFloats(width: number, height: number): Size;
  8928. /**
  8929. * Updates in place the current Size from the given floats.
  8930. * @param width width to set
  8931. * @param height height to set
  8932. * @returns the updated Size.
  8933. */
  8934. set(width: number, height: number): Size;
  8935. /**
  8936. * Multiplies the width and height by numbers
  8937. * @param w factor to multiple the width by
  8938. * @param h factor to multiple the height by
  8939. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8940. */
  8941. multiplyByFloats(w: number, h: number): Size;
  8942. /**
  8943. * Clones the size
  8944. * @returns a new Size copied from the given one.
  8945. */
  8946. clone(): Size;
  8947. /**
  8948. * True if the current Size and the given one width and height are strictly equal.
  8949. * @param other the other size to compare against
  8950. * @returns True if the current Size and the given one width and height are strictly equal.
  8951. */
  8952. equals(other: Size): boolean;
  8953. /**
  8954. * The surface of the Size : width * height (float).
  8955. */
  8956. get surface(): number;
  8957. /**
  8958. * Create a new size of zero
  8959. * @returns a new Size set to (0.0, 0.0)
  8960. */
  8961. static Zero(): Size;
  8962. /**
  8963. * Sums the width and height of two sizes
  8964. * @param otherSize size to add to this size
  8965. * @returns a new Size set as the addition result of the current Size and the given one.
  8966. */
  8967. add(otherSize: Size): Size;
  8968. /**
  8969. * Subtracts the width and height of two
  8970. * @param otherSize size to subtract to this size
  8971. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8972. */
  8973. subtract(otherSize: Size): Size;
  8974. /**
  8975. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8976. * @param start starting size to lerp between
  8977. * @param end end size to lerp between
  8978. * @param amount amount to lerp between the start and end values
  8979. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8980. */
  8981. static Lerp(start: Size, end: Size, amount: number): Size;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Contains position and normal vectors for a vertex
  8987. */
  8988. export class PositionNormalVertex {
  8989. /** the position of the vertex (defaut: 0,0,0) */
  8990. position: Vector3;
  8991. /** the normal of the vertex (defaut: 0,1,0) */
  8992. normal: Vector3;
  8993. /**
  8994. * Creates a PositionNormalVertex
  8995. * @param position the position of the vertex (defaut: 0,0,0)
  8996. * @param normal the normal of the vertex (defaut: 0,1,0)
  8997. */
  8998. constructor(
  8999. /** the position of the vertex (defaut: 0,0,0) */
  9000. position?: Vector3,
  9001. /** the normal of the vertex (defaut: 0,1,0) */
  9002. normal?: Vector3);
  9003. /**
  9004. * Clones the PositionNormalVertex
  9005. * @returns the cloned PositionNormalVertex
  9006. */
  9007. clone(): PositionNormalVertex;
  9008. }
  9009. /**
  9010. * Contains position, normal and uv vectors for a vertex
  9011. */
  9012. export class PositionNormalTextureVertex {
  9013. /** the position of the vertex (defaut: 0,0,0) */
  9014. position: Vector3;
  9015. /** the normal of the vertex (defaut: 0,1,0) */
  9016. normal: Vector3;
  9017. /** the uv of the vertex (default: 0,0) */
  9018. uv: Vector2;
  9019. /**
  9020. * Creates a PositionNormalTextureVertex
  9021. * @param position the position of the vertex (defaut: 0,0,0)
  9022. * @param normal the normal of the vertex (defaut: 0,1,0)
  9023. * @param uv the uv of the vertex (default: 0,0)
  9024. */
  9025. constructor(
  9026. /** the position of the vertex (defaut: 0,0,0) */
  9027. position?: Vector3,
  9028. /** the normal of the vertex (defaut: 0,1,0) */
  9029. normal?: Vector3,
  9030. /** the uv of the vertex (default: 0,0) */
  9031. uv?: Vector2);
  9032. /**
  9033. * Clones the PositionNormalTextureVertex
  9034. * @returns the cloned PositionNormalTextureVertex
  9035. */
  9036. clone(): PositionNormalTextureVertex;
  9037. }
  9038. }
  9039. declare module BABYLON {
  9040. /**
  9041. * Enum defining the type of animations supported by InputBlock
  9042. */
  9043. export enum AnimatedInputBlockTypes {
  9044. /** No animation */
  9045. None = 0,
  9046. /** Time based animation. Will only work for floats */
  9047. Time = 1
  9048. }
  9049. }
  9050. declare module BABYLON {
  9051. /**
  9052. * Interface describing all the common properties and methods a shadow light needs to implement.
  9053. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9054. * as well as binding the different shadow properties to the effects.
  9055. */
  9056. export interface IShadowLight extends Light {
  9057. /**
  9058. * The light id in the scene (used in scene.findLighById for instance)
  9059. */
  9060. id: string;
  9061. /**
  9062. * The position the shdow will be casted from.
  9063. */
  9064. position: Vector3;
  9065. /**
  9066. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9067. */
  9068. direction: Vector3;
  9069. /**
  9070. * The transformed position. Position of the light in world space taking parenting in account.
  9071. */
  9072. transformedPosition: Vector3;
  9073. /**
  9074. * The transformed direction. Direction of the light in world space taking parenting in account.
  9075. */
  9076. transformedDirection: Vector3;
  9077. /**
  9078. * The friendly name of the light in the scene.
  9079. */
  9080. name: string;
  9081. /**
  9082. * Defines the shadow projection clipping minimum z value.
  9083. */
  9084. shadowMinZ: number;
  9085. /**
  9086. * Defines the shadow projection clipping maximum z value.
  9087. */
  9088. shadowMaxZ: number;
  9089. /**
  9090. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9091. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9092. */
  9093. computeTransformedInformation(): boolean;
  9094. /**
  9095. * Gets the scene the light belongs to.
  9096. * @returns The scene
  9097. */
  9098. getScene(): Scene;
  9099. /**
  9100. * Callback defining a custom Projection Matrix Builder.
  9101. * This can be used to override the default projection matrix computation.
  9102. */
  9103. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9104. /**
  9105. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9106. * @param matrix The materix to updated with the projection information
  9107. * @param viewMatrix The transform matrix of the light
  9108. * @param renderList The list of mesh to render in the map
  9109. * @returns The current light
  9110. */
  9111. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9112. /**
  9113. * Gets the current depth scale used in ESM.
  9114. * @returns The scale
  9115. */
  9116. getDepthScale(): number;
  9117. /**
  9118. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9119. * @returns true if a cube texture needs to be use
  9120. */
  9121. needCube(): boolean;
  9122. /**
  9123. * Detects if the projection matrix requires to be recomputed this frame.
  9124. * @returns true if it requires to be recomputed otherwise, false.
  9125. */
  9126. needProjectionMatrixCompute(): boolean;
  9127. /**
  9128. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9129. */
  9130. forceProjectionMatrixCompute(): void;
  9131. /**
  9132. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9133. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9134. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9135. */
  9136. getShadowDirection(faceIndex?: number): Vector3;
  9137. /**
  9138. * Gets the minZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the min for
  9140. * @returns the depth min z
  9141. */
  9142. getDepthMinZ(activeCamera: Camera): number;
  9143. /**
  9144. * Gets the maxZ used for shadow according to both the scene and the light.
  9145. * @param activeCamera The camera we are returning the max for
  9146. * @returns the depth max z
  9147. */
  9148. getDepthMaxZ(activeCamera: Camera): number;
  9149. }
  9150. /**
  9151. * Base implementation IShadowLight
  9152. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9153. */
  9154. export abstract class ShadowLight extends Light implements IShadowLight {
  9155. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9156. protected _position: Vector3;
  9157. protected _setPosition(value: Vector3): void;
  9158. /**
  9159. * Sets the position the shadow will be casted from. Also use as the light position for both
  9160. * point and spot lights.
  9161. */
  9162. get position(): Vector3;
  9163. /**
  9164. * Sets the position the shadow will be casted from. Also use as the light position for both
  9165. * point and spot lights.
  9166. */
  9167. set position(value: Vector3);
  9168. protected _direction: Vector3;
  9169. protected _setDirection(value: Vector3): void;
  9170. /**
  9171. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9172. * Also use as the light direction on spot and directional lights.
  9173. */
  9174. get direction(): Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9177. * Also use as the light direction on spot and directional lights.
  9178. */
  9179. set direction(value: Vector3);
  9180. protected _shadowMinZ: number;
  9181. /**
  9182. * Gets the shadow projection clipping minimum z value.
  9183. */
  9184. get shadowMinZ(): number;
  9185. /**
  9186. * Sets the shadow projection clipping minimum z value.
  9187. */
  9188. set shadowMinZ(value: number);
  9189. protected _shadowMaxZ: number;
  9190. /**
  9191. * Sets the shadow projection clipping maximum z value.
  9192. */
  9193. get shadowMaxZ(): number;
  9194. /**
  9195. * Gets the shadow projection clipping maximum z value.
  9196. */
  9197. set shadowMaxZ(value: number);
  9198. /**
  9199. * Callback defining a custom Projection Matrix Builder.
  9200. * This can be used to override the default projection matrix computation.
  9201. */
  9202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9203. /**
  9204. * The transformed position. Position of the light in world space taking parenting in account.
  9205. */
  9206. transformedPosition: Vector3;
  9207. /**
  9208. * The transformed direction. Direction of the light in world space taking parenting in account.
  9209. */
  9210. transformedDirection: Vector3;
  9211. private _needProjectionMatrixCompute;
  9212. /**
  9213. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9214. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9215. */
  9216. computeTransformedInformation(): boolean;
  9217. /**
  9218. * Return the depth scale used for the shadow map.
  9219. * @returns the depth scale.
  9220. */
  9221. getDepthScale(): number;
  9222. /**
  9223. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9224. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9225. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9226. */
  9227. getShadowDirection(faceIndex?: number): Vector3;
  9228. /**
  9229. * Returns the ShadowLight absolute position in the World.
  9230. * @returns the position vector in world space
  9231. */
  9232. getAbsolutePosition(): Vector3;
  9233. /**
  9234. * Sets the ShadowLight direction toward the passed target.
  9235. * @param target The point to target in local space
  9236. * @returns the updated ShadowLight direction
  9237. */
  9238. setDirectionToTarget(target: Vector3): Vector3;
  9239. /**
  9240. * Returns the light rotation in euler definition.
  9241. * @returns the x y z rotation in local space.
  9242. */
  9243. getRotation(): Vector3;
  9244. /**
  9245. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9246. * @returns true if a cube texture needs to be use
  9247. */
  9248. needCube(): boolean;
  9249. /**
  9250. * Detects if the projection matrix requires to be recomputed this frame.
  9251. * @returns true if it requires to be recomputed otherwise, false.
  9252. */
  9253. needProjectionMatrixCompute(): boolean;
  9254. /**
  9255. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9256. */
  9257. forceProjectionMatrixCompute(): void;
  9258. /** @hidden */
  9259. _initCache(): void;
  9260. /** @hidden */
  9261. _isSynchronized(): boolean;
  9262. /**
  9263. * Computes the world matrix of the node
  9264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9265. * @returns the world matrix
  9266. */
  9267. computeWorldMatrix(force?: boolean): Matrix;
  9268. /**
  9269. * Gets the minZ used for shadow according to both the scene and the light.
  9270. * @param activeCamera The camera we are returning the min for
  9271. * @returns the depth min z
  9272. */
  9273. getDepthMinZ(activeCamera: Camera): number;
  9274. /**
  9275. * Gets the maxZ used for shadow according to both the scene and the light.
  9276. * @param activeCamera The camera we are returning the max for
  9277. * @returns the depth max z
  9278. */
  9279. getDepthMaxZ(activeCamera: Camera): number;
  9280. /**
  9281. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9282. * @param matrix The materix to updated with the projection information
  9283. * @param viewMatrix The transform matrix of the light
  9284. * @param renderList The list of mesh to render in the map
  9285. * @returns The current light
  9286. */
  9287. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9288. }
  9289. }
  9290. declare module BABYLON {
  9291. /** @hidden */
  9292. export var packingFunctions: {
  9293. name: string;
  9294. shader: string;
  9295. };
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. export var bayerDitherFunctions: {
  9300. name: string;
  9301. shader: string;
  9302. };
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var shadowMapFragmentDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var clipPlaneFragmentDeclaration: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var clipPlaneFragment: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var shadowMapFragment: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var shadowMapPixelShader: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var bonesDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var morphTargetsVertexGlobalDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var morphTargetsVertexDeclaration: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var instancesDeclaration: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var helperFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var shadowMapVertexDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var clipPlaneVertexDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var morphTargetsVertex: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /** @hidden */
  9397. export var instancesVertex: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module BABYLON {
  9403. /** @hidden */
  9404. export var bonesVertex: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module BABYLON {
  9410. /** @hidden */
  9411. export var shadowMapVertexNormalBias: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module BABYLON {
  9417. /** @hidden */
  9418. export var shadowMapVertexMetric: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module BABYLON {
  9424. /** @hidden */
  9425. export var clipPlaneVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module BABYLON {
  9431. /** @hidden */
  9432. export var shadowMapVertexShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module BABYLON {
  9438. /** @hidden */
  9439. export var depthBoxBlurPixelShader: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module BABYLON {
  9445. /** @hidden */
  9446. export var shadowMapFragmentSoftTransparentShadow: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module BABYLON {
  9452. /**
  9453. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9454. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9455. */
  9456. export class EffectFallbacks implements IEffectFallbacks {
  9457. private _defines;
  9458. private _currentRank;
  9459. private _maxRank;
  9460. private _mesh;
  9461. /**
  9462. * Removes the fallback from the bound mesh.
  9463. */
  9464. unBindMesh(): void;
  9465. /**
  9466. * Adds a fallback on the specified property.
  9467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9468. * @param define The name of the define in the shader
  9469. */
  9470. addFallback(rank: number, define: string): void;
  9471. /**
  9472. * Sets the mesh to use CPU skinning when needing to fallback.
  9473. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9474. * @param mesh The mesh to use the fallbacks.
  9475. */
  9476. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9477. /**
  9478. * Checks to see if more fallbacks are still availible.
  9479. */
  9480. get hasMoreFallbacks(): boolean;
  9481. /**
  9482. * Removes the defines that should be removed when falling back.
  9483. * @param currentDefines defines the current define statements for the shader.
  9484. * @param effect defines the current effect we try to compile
  9485. * @returns The resulting defines with defines of the current rank removed.
  9486. */
  9487. reduce(currentDefines: string, effect: Effect): string;
  9488. }
  9489. }
  9490. declare module BABYLON {
  9491. /**
  9492. * Interface used to define Action
  9493. */
  9494. export interface IAction {
  9495. /**
  9496. * Trigger for the action
  9497. */
  9498. trigger: number;
  9499. /** Options of the trigger */
  9500. triggerOptions: any;
  9501. /**
  9502. * Gets the trigger parameters
  9503. * @returns the trigger parameters
  9504. */
  9505. getTriggerParameter(): any;
  9506. /**
  9507. * Internal only - executes current action event
  9508. * @hidden
  9509. */
  9510. _executeCurrent(evt?: ActionEvent): void;
  9511. /**
  9512. * Serialize placeholder for child classes
  9513. * @param parent of child
  9514. * @returns the serialized object
  9515. */
  9516. serialize(parent: any): any;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. _prepare(): void;
  9522. /**
  9523. * Internal only - manager for action
  9524. * @hidden
  9525. */
  9526. _actionManager: Nullable<AbstractActionManager>;
  9527. /**
  9528. * Adds action to chain of actions, may be a DoNothingAction
  9529. * @param action defines the next action to execute
  9530. * @returns The action passed in
  9531. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9532. */
  9533. then(action: IAction): IAction;
  9534. }
  9535. /**
  9536. * The action to be carried out following a trigger
  9537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9538. */
  9539. export class Action implements IAction {
  9540. /** the trigger, with or without parameters, for the action */
  9541. triggerOptions: any;
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /**
  9547. * Internal only - manager for action
  9548. * @hidden
  9549. */
  9550. _actionManager: ActionManager;
  9551. private _nextActiveAction;
  9552. private _child;
  9553. private _condition?;
  9554. private _triggerParameter;
  9555. /**
  9556. * An event triggered prior to action being executed.
  9557. */
  9558. onBeforeExecuteObservable: Observable<Action>;
  9559. /**
  9560. * Creates a new Action
  9561. * @param triggerOptions the trigger, with or without parameters, for the action
  9562. * @param condition an optional determinant of action
  9563. */
  9564. constructor(
  9565. /** the trigger, with or without parameters, for the action */
  9566. triggerOptions: any, condition?: Condition);
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Gets the trigger parameters
  9574. * @returns the trigger parameters
  9575. */
  9576. getTriggerParameter(): any;
  9577. /**
  9578. * Internal only - executes current action event
  9579. * @hidden
  9580. */
  9581. _executeCurrent(evt?: ActionEvent): void;
  9582. /**
  9583. * Execute placeholder for child classes
  9584. * @param evt optional action event
  9585. */
  9586. execute(evt?: ActionEvent): void;
  9587. /**
  9588. * Skips to next active action
  9589. */
  9590. skipToNextActiveAction(): void;
  9591. /**
  9592. * Adds action to chain of actions, may be a DoNothingAction
  9593. * @param action defines the next action to execute
  9594. * @returns The action passed in
  9595. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9596. */
  9597. then(action: Action): Action;
  9598. /**
  9599. * Internal only
  9600. * @hidden
  9601. */
  9602. _getProperty(propertyPath: string): string;
  9603. /**
  9604. * Internal only
  9605. * @hidden
  9606. */
  9607. _getEffectiveTarget(target: any, propertyPath: string): any;
  9608. /**
  9609. * Serialize placeholder for child classes
  9610. * @param parent of child
  9611. * @returns the serialized object
  9612. */
  9613. serialize(parent: any): any;
  9614. /**
  9615. * Internal only called by serialize
  9616. * @hidden
  9617. */
  9618. protected _serialize(serializedAction: any, parent?: any): any;
  9619. /**
  9620. * Internal only
  9621. * @hidden
  9622. */
  9623. static _SerializeValueAsString: (value: any) => string;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. static _GetTargetProperty: (target: Scene | Node) => {
  9629. name: string;
  9630. targetType: string;
  9631. value: string;
  9632. };
  9633. }
  9634. }
  9635. declare module BABYLON {
  9636. /**
  9637. * A Condition applied to an Action
  9638. */
  9639. export class Condition {
  9640. /**
  9641. * Internal only - manager for action
  9642. * @hidden
  9643. */
  9644. _actionManager: ActionManager;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _evaluationId: number;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _currentResult: boolean;
  9655. /**
  9656. * Creates a new Condition
  9657. * @param actionManager the manager of the action the condition is applied to
  9658. */
  9659. constructor(actionManager: ActionManager);
  9660. /**
  9661. * Check if the current condition is valid
  9662. * @returns a boolean
  9663. */
  9664. isValid(): boolean;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. _getProperty(propertyPath: string): string;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. _getEffectiveTarget(target: any, propertyPath: string): any;
  9675. /**
  9676. * Serialize placeholder for child classes
  9677. * @returns the serialized object
  9678. */
  9679. serialize(): any;
  9680. /**
  9681. * Internal only
  9682. * @hidden
  9683. */
  9684. protected _serialize(serializedCondition: any): any;
  9685. }
  9686. /**
  9687. * Defines specific conditional operators as extensions of Condition
  9688. */
  9689. export class ValueCondition extends Condition {
  9690. /** path to specify the property of the target the conditional operator uses */
  9691. propertyPath: string;
  9692. /** the value compared by the conditional operator against the current value of the property */
  9693. value: any;
  9694. /** the conditional operator, default ValueCondition.IsEqual */
  9695. operator: number;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. private static _IsEqual;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. private static _IsDifferent;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. private static _IsGreater;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. private static _IsLesser;
  9716. /**
  9717. * returns the number for IsEqual
  9718. */
  9719. static get IsEqual(): number;
  9720. /**
  9721. * Returns the number for IsDifferent
  9722. */
  9723. static get IsDifferent(): number;
  9724. /**
  9725. * Returns the number for IsGreater
  9726. */
  9727. static get IsGreater(): number;
  9728. /**
  9729. * Returns the number for IsLesser
  9730. */
  9731. static get IsLesser(): number;
  9732. /**
  9733. * Internal only The action manager for the condition
  9734. * @hidden
  9735. */
  9736. _actionManager: ActionManager;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. private _target;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. private _effectiveTarget;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private _property;
  9752. /**
  9753. * Creates a new ValueCondition
  9754. * @param actionManager manager for the action the condition applies to
  9755. * @param target for the action
  9756. * @param propertyPath path to specify the property of the target the conditional operator uses
  9757. * @param value the value compared by the conditional operator against the current value of the property
  9758. * @param operator the conditional operator, default ValueCondition.IsEqual
  9759. */
  9760. constructor(actionManager: ActionManager, target: any,
  9761. /** path to specify the property of the target the conditional operator uses */
  9762. propertyPath: string,
  9763. /** the value compared by the conditional operator against the current value of the property */
  9764. value: any,
  9765. /** the conditional operator, default ValueCondition.IsEqual */
  9766. operator?: number);
  9767. /**
  9768. * Compares the given value with the property value for the specified conditional operator
  9769. * @returns the result of the comparison
  9770. */
  9771. isValid(): boolean;
  9772. /**
  9773. * Serialize the ValueCondition into a JSON compatible object
  9774. * @returns serialization object
  9775. */
  9776. serialize(): any;
  9777. /**
  9778. * Gets the name of the conditional operator for the ValueCondition
  9779. * @param operator the conditional operator
  9780. * @returns the name
  9781. */
  9782. static GetOperatorName(operator: number): string;
  9783. }
  9784. /**
  9785. * Defines a predicate condition as an extension of Condition
  9786. */
  9787. export class PredicateCondition extends Condition {
  9788. /** defines the predicate function used to validate the condition */
  9789. predicate: () => boolean;
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Creates a new PredicateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param predicate defines the predicate function used to validate the condition
  9799. */
  9800. constructor(actionManager: ActionManager,
  9801. /** defines the predicate function used to validate the condition */
  9802. predicate: () => boolean);
  9803. /**
  9804. * @returns the validity of the predicate condition
  9805. */
  9806. isValid(): boolean;
  9807. }
  9808. /**
  9809. * Defines a state condition as an extension of Condition
  9810. */
  9811. export class StateCondition extends Condition {
  9812. /** Value to compare with target state */
  9813. value: string;
  9814. /**
  9815. * Internal only - manager for action
  9816. * @hidden
  9817. */
  9818. _actionManager: ActionManager;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private _target;
  9824. /**
  9825. * Creates a new StateCondition
  9826. * @param actionManager manager for the action the condition applies to
  9827. * @param target of the condition
  9828. * @param value to compare with target state
  9829. */
  9830. constructor(actionManager: ActionManager, target: any,
  9831. /** Value to compare with target state */
  9832. value: string);
  9833. /**
  9834. * Gets a boolean indicating if the current condition is met
  9835. * @returns the validity of the state
  9836. */
  9837. isValid(): boolean;
  9838. /**
  9839. * Serialize the StateCondition into a JSON compatible object
  9840. * @returns serialization object
  9841. */
  9842. serialize(): any;
  9843. }
  9844. }
  9845. declare module BABYLON {
  9846. /**
  9847. * This defines an action responsible to toggle a boolean once triggered.
  9848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9849. */
  9850. export class SwitchBooleanAction extends Action {
  9851. /**
  9852. * The path to the boolean property in the target object
  9853. */
  9854. propertyPath: string;
  9855. private _target;
  9856. private _effectiveTarget;
  9857. private _property;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the boolean
  9862. * @param propertyPath defines the path to the boolean property in the target object
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9866. /** @hidden */
  9867. _prepare(): void;
  9868. /**
  9869. * Execute the action toggle the boolean value.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a the state field of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetStateAction extends Action {
  9885. /**
  9886. * The value to store in the state field.
  9887. */
  9888. value: string;
  9889. private _target;
  9890. /**
  9891. * Instantiate the action
  9892. * @param triggerOptions defines the trigger options
  9893. * @param target defines the object containing the state property
  9894. * @param value defines the value to store in the state field
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9898. /**
  9899. * Execute the action and store the value on the target state property.
  9900. */
  9901. execute(): void;
  9902. /**
  9903. * Serializes the actions and its related information.
  9904. * @param parent defines the object to serialize in
  9905. * @returns the serialized object
  9906. */
  9907. serialize(parent: any): any;
  9908. }
  9909. /**
  9910. * This defines an action responsible to set a property of the target
  9911. * to a desired value once triggered.
  9912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9913. */
  9914. export class SetValueAction extends Action {
  9915. /**
  9916. * The path of the property to set in the target.
  9917. */
  9918. propertyPath: string;
  9919. /**
  9920. * The value to set in the property
  9921. */
  9922. value: any;
  9923. private _target;
  9924. private _effectiveTarget;
  9925. private _property;
  9926. /**
  9927. * Instantiate the action
  9928. * @param triggerOptions defines the trigger options
  9929. * @param target defines the object containing the property
  9930. * @param propertyPath defines the path of the property to set in the target
  9931. * @param value defines the value to set in the property
  9932. * @param condition defines the trigger related conditions
  9933. */
  9934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9935. /** @hidden */
  9936. _prepare(): void;
  9937. /**
  9938. * Execute the action and set the targetted property to the desired value.
  9939. */
  9940. execute(): void;
  9941. /**
  9942. * Serializes the actions and its related information.
  9943. * @param parent defines the object to serialize in
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. }
  9948. /**
  9949. * This defines an action responsible to increment the target value
  9950. * to a desired value once triggered.
  9951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9952. */
  9953. export class IncrementValueAction extends Action {
  9954. /**
  9955. * The path of the property to increment in the target.
  9956. */
  9957. propertyPath: string;
  9958. /**
  9959. * The value we should increment the property by.
  9960. */
  9961. value: any;
  9962. private _target;
  9963. private _effectiveTarget;
  9964. private _property;
  9965. /**
  9966. * Instantiate the action
  9967. * @param triggerOptions defines the trigger options
  9968. * @param target defines the object containing the property
  9969. * @param propertyPath defines the path of the property to increment in the target
  9970. * @param value defines the value value we should increment the property by
  9971. * @param condition defines the trigger related conditions
  9972. */
  9973. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9974. /** @hidden */
  9975. _prepare(): void;
  9976. /**
  9977. * Execute the action and increment the target of the value amount.
  9978. */
  9979. execute(): void;
  9980. /**
  9981. * Serializes the actions and its related information.
  9982. * @param parent defines the object to serialize in
  9983. * @returns the serialized object
  9984. */
  9985. serialize(parent: any): any;
  9986. }
  9987. /**
  9988. * This defines an action responsible to start an animation once triggered.
  9989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9990. */
  9991. export class PlayAnimationAction extends Action {
  9992. /**
  9993. * Where the animation should start (animation frame)
  9994. */
  9995. from: number;
  9996. /**
  9997. * Where the animation should stop (animation frame)
  9998. */
  9999. to: number;
  10000. /**
  10001. * Define if the animation should loop or stop after the first play.
  10002. */
  10003. loop?: boolean;
  10004. private _target;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param target defines the target animation or animation name
  10009. * @param from defines from where the animation should start (animation frame)
  10010. * @param end defines where the animation should stop (animation frame)
  10011. * @param loop defines if the animation should loop or stop after the first play
  10012. * @param condition defines the trigger related conditions
  10013. */
  10014. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10015. /** @hidden */
  10016. _prepare(): void;
  10017. /**
  10018. * Execute the action and play the animation.
  10019. */
  10020. execute(): void;
  10021. /**
  10022. * Serializes the actions and its related information.
  10023. * @param parent defines the object to serialize in
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. }
  10028. /**
  10029. * This defines an action responsible to stop an animation once triggered.
  10030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10031. */
  10032. export class StopAnimationAction extends Action {
  10033. private _target;
  10034. /**
  10035. * Instantiate the action
  10036. * @param triggerOptions defines the trigger options
  10037. * @param target defines the target animation or animation name
  10038. * @param condition defines the trigger related conditions
  10039. */
  10040. constructor(triggerOptions: any, target: any, condition?: Condition);
  10041. /** @hidden */
  10042. _prepare(): void;
  10043. /**
  10044. * Execute the action and stop the animation.
  10045. */
  10046. execute(): void;
  10047. /**
  10048. * Serializes the actions and its related information.
  10049. * @param parent defines the object to serialize in
  10050. * @returns the serialized object
  10051. */
  10052. serialize(parent: any): any;
  10053. }
  10054. /**
  10055. * This defines an action responsible that does nothing once triggered.
  10056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10057. */
  10058. export class DoNothingAction extends Action {
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param condition defines the trigger related conditions
  10063. */
  10064. constructor(triggerOptions?: any, condition?: Condition);
  10065. /**
  10066. * Execute the action and do nothing.
  10067. */
  10068. execute(): void;
  10069. /**
  10070. * Serializes the actions and its related information.
  10071. * @param parent defines the object to serialize in
  10072. * @returns the serialized object
  10073. */
  10074. serialize(parent: any): any;
  10075. }
  10076. /**
  10077. * This defines an action responsible to trigger several actions once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class CombineAction extends Action {
  10081. /**
  10082. * The list of aggregated animations to run.
  10083. */
  10084. children: Action[];
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param children defines the list of aggregated animations to run
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and executes all the aggregated actions.
  10096. */
  10097. execute(evt: ActionEvent): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible to run code (external event) once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class ExecuteCodeAction extends Action {
  10110. /**
  10111. * The callback function to run.
  10112. */
  10113. func: (evt: ActionEvent) => void;
  10114. /**
  10115. * Instantiate the action
  10116. * @param triggerOptions defines the trigger options
  10117. * @param func defines the callback function to run
  10118. * @param condition defines the trigger related conditions
  10119. */
  10120. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10121. /**
  10122. * Execute the action and run the attached code.
  10123. */
  10124. execute(evt: ActionEvent): void;
  10125. }
  10126. /**
  10127. * This defines an action responsible to set the parent property of the target once triggered.
  10128. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10129. */
  10130. export class SetParentAction extends Action {
  10131. private _parent;
  10132. private _target;
  10133. /**
  10134. * Instantiate the action
  10135. * @param triggerOptions defines the trigger options
  10136. * @param target defines the target containing the parent property
  10137. * @param parent defines from where the animation should start (animation frame)
  10138. * @param condition defines the trigger related conditions
  10139. */
  10140. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10141. /** @hidden */
  10142. _prepare(): void;
  10143. /**
  10144. * Execute the action and set the parent property.
  10145. */
  10146. execute(): void;
  10147. /**
  10148. * Serializes the actions and its related information.
  10149. * @param parent defines the object to serialize in
  10150. * @returns the serialized object
  10151. */
  10152. serialize(parent: any): any;
  10153. }
  10154. }
  10155. declare module BABYLON {
  10156. /**
  10157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10160. */
  10161. export class ActionManager extends AbstractActionManager {
  10162. /**
  10163. * Nothing
  10164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly NothingTrigger: number;
  10167. /**
  10168. * On pick
  10169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnPickTrigger: number;
  10172. /**
  10173. * On left pick
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnLeftPickTrigger: number;
  10177. /**
  10178. * On right pick
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnRightPickTrigger: number;
  10182. /**
  10183. * On center pick
  10184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnCenterPickTrigger: number;
  10187. /**
  10188. * On pick down
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPickDownTrigger: number;
  10192. /**
  10193. * On double pick
  10194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnDoublePickTrigger: number;
  10197. /**
  10198. * On pick up
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnPickUpTrigger: number;
  10202. /**
  10203. * On pick out.
  10204. * This trigger will only be raised if you also declared a OnPickDown
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnPickOutTrigger: number;
  10208. /**
  10209. * On long press
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnLongPressTrigger: number;
  10213. /**
  10214. * On pointer over
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnPointerOverTrigger: number;
  10218. /**
  10219. * On pointer out
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnPointerOutTrigger: number;
  10223. /**
  10224. * On every frame
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnEveryFrameTrigger: number;
  10228. /**
  10229. * On intersection enter
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnIntersectionEnterTrigger: number;
  10233. /**
  10234. * On intersection exit
  10235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10236. */
  10237. static readonly OnIntersectionExitTrigger: number;
  10238. /**
  10239. * On key down
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10241. */
  10242. static readonly OnKeyDownTrigger: number;
  10243. /**
  10244. * On key up
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly OnKeyUpTrigger: number;
  10248. private _scene;
  10249. /**
  10250. * Creates a new action manager
  10251. * @param scene defines the hosting scene
  10252. */
  10253. constructor(scene: Scene);
  10254. /**
  10255. * Releases all associated resources
  10256. */
  10257. dispose(): void;
  10258. /**
  10259. * Gets hosting scene
  10260. * @returns the hosting scene
  10261. */
  10262. getScene(): Scene;
  10263. /**
  10264. * Does this action manager handles actions of any of the given triggers
  10265. * @param triggers defines the triggers to be tested
  10266. * @return a boolean indicating whether one (or more) of the triggers is handled
  10267. */
  10268. hasSpecificTriggers(triggers: number[]): boolean;
  10269. /**
  10270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10271. * speed.
  10272. * @param triggerA defines the trigger to be tested
  10273. * @param triggerB defines the trigger to be tested
  10274. * @return a boolean indicating whether one (or more) of the triggers is handled
  10275. */
  10276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10277. /**
  10278. * Does this action manager handles actions of a given trigger
  10279. * @param trigger defines the trigger to be tested
  10280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10281. * @return whether the trigger is handled
  10282. */
  10283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10284. /**
  10285. * Does this action manager has pointer triggers
  10286. */
  10287. get hasPointerTriggers(): boolean;
  10288. /**
  10289. * Does this action manager has pick triggers
  10290. */
  10291. get hasPickTriggers(): boolean;
  10292. /**
  10293. * Registers an action to this action manager
  10294. * @param action defines the action to be registered
  10295. * @return the action amended (prepared) after registration
  10296. */
  10297. registerAction(action: IAction): Nullable<IAction>;
  10298. /**
  10299. * Unregisters an action to this action manager
  10300. * @param action defines the action to be unregistered
  10301. * @return a boolean indicating whether the action has been unregistered
  10302. */
  10303. unregisterAction(action: IAction): Boolean;
  10304. /**
  10305. * Process a specific trigger
  10306. * @param trigger defines the trigger to process
  10307. * @param evt defines the event details to be processed
  10308. */
  10309. processTrigger(trigger: number, evt?: IActionEvent): void;
  10310. /** @hidden */
  10311. _getEffectiveTarget(target: any, propertyPath: string): any;
  10312. /** @hidden */
  10313. _getProperty(propertyPath: string): string;
  10314. /**
  10315. * Serialize this manager to a JSON object
  10316. * @param name defines the property name to store this manager
  10317. * @returns a JSON representation of this manager
  10318. */
  10319. serialize(name: string): any;
  10320. /**
  10321. * Creates a new ActionManager from a JSON data
  10322. * @param parsedActions defines the JSON data to read from
  10323. * @param object defines the hosting mesh
  10324. * @param scene defines the hosting scene
  10325. */
  10326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10327. /**
  10328. * Get a trigger name by index
  10329. * @param trigger defines the trigger index
  10330. * @returns a trigger name
  10331. */
  10332. static GetTriggerName(trigger: number): string;
  10333. }
  10334. }
  10335. declare module BABYLON {
  10336. /**
  10337. * Class used to represent a sprite
  10338. * @see https://doc.babylonjs.com/babylon101/sprites
  10339. */
  10340. export class Sprite implements IAnimatable {
  10341. /** defines the name */
  10342. name: string;
  10343. /** Gets or sets the current world position */
  10344. position: Vector3;
  10345. /** Gets or sets the main color */
  10346. color: Color4;
  10347. /** Gets or sets the width */
  10348. width: number;
  10349. /** Gets or sets the height */
  10350. height: number;
  10351. /** Gets or sets rotation angle */
  10352. angle: number;
  10353. /** Gets or sets the cell index in the sprite sheet */
  10354. cellIndex: number;
  10355. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10356. cellRef: string;
  10357. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10358. invertU: boolean;
  10359. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10360. invertV: boolean;
  10361. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10362. disposeWhenFinishedAnimating: boolean;
  10363. /** Gets the list of attached animations */
  10364. animations: Nullable<Array<Animation>>;
  10365. /** Gets or sets a boolean indicating if the sprite can be picked */
  10366. isPickable: boolean;
  10367. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10368. useAlphaForPicking: boolean;
  10369. /** @hidden */
  10370. _xOffset: number;
  10371. /** @hidden */
  10372. _yOffset: number;
  10373. /** @hidden */
  10374. _xSize: number;
  10375. /** @hidden */
  10376. _ySize: number;
  10377. /**
  10378. * Gets or sets the associated action manager
  10379. */
  10380. actionManager: Nullable<ActionManager>;
  10381. /**
  10382. * An event triggered when the control has been disposed
  10383. */
  10384. onDisposeObservable: Observable<Sprite>;
  10385. private _animationStarted;
  10386. private _loopAnimation;
  10387. private _fromIndex;
  10388. private _toIndex;
  10389. private _delay;
  10390. private _direction;
  10391. private _manager;
  10392. private _time;
  10393. private _onAnimationEnd;
  10394. /**
  10395. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10396. */
  10397. isVisible: boolean;
  10398. /**
  10399. * Gets or sets the sprite size
  10400. */
  10401. get size(): number;
  10402. set size(value: number);
  10403. /**
  10404. * Returns a boolean indicating if the animation is started
  10405. */
  10406. get animationStarted(): boolean;
  10407. /**
  10408. * Gets or sets the unique id of the sprite
  10409. */
  10410. uniqueId: number;
  10411. /**
  10412. * Gets the manager of this sprite
  10413. */
  10414. get manager(): ISpriteManager;
  10415. /**
  10416. * Creates a new Sprite
  10417. * @param name defines the name
  10418. * @param manager defines the manager
  10419. */
  10420. constructor(
  10421. /** defines the name */
  10422. name: string, manager: ISpriteManager);
  10423. /**
  10424. * Returns the string "Sprite"
  10425. * @returns "Sprite"
  10426. */
  10427. getClassName(): string;
  10428. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10429. get fromIndex(): number;
  10430. set fromIndex(value: number);
  10431. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10432. get toIndex(): number;
  10433. set toIndex(value: number);
  10434. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10435. get loopAnimation(): boolean;
  10436. set loopAnimation(value: boolean);
  10437. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10438. get delay(): number;
  10439. set delay(value: number);
  10440. /**
  10441. * Starts an animation
  10442. * @param from defines the initial key
  10443. * @param to defines the end key
  10444. * @param loop defines if the animation must loop
  10445. * @param delay defines the start delay (in ms)
  10446. * @param onAnimationEnd defines a callback to call when animation ends
  10447. */
  10448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10449. /** Stops current animation (if any) */
  10450. stopAnimation(): void;
  10451. /** @hidden */
  10452. _animate(deltaTime: number): void;
  10453. /** Release associated resources */
  10454. dispose(): void;
  10455. /**
  10456. * Serializes the sprite to a JSON object
  10457. * @returns the JSON object
  10458. */
  10459. serialize(): any;
  10460. /**
  10461. * Parses a JSON object to create a new sprite
  10462. * @param parsedSprite The JSON object to parse
  10463. * @param manager defines the hosting manager
  10464. * @returns the new sprite
  10465. */
  10466. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10467. }
  10468. }
  10469. declare module BABYLON {
  10470. /**
  10471. * Information about the result of picking within a scene
  10472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10473. */
  10474. export class PickingInfo {
  10475. /** @hidden */
  10476. _pickingUnavailable: boolean;
  10477. /**
  10478. * If the pick collided with an object
  10479. */
  10480. hit: boolean;
  10481. /**
  10482. * Distance away where the pick collided
  10483. */
  10484. distance: number;
  10485. /**
  10486. * The location of pick collision
  10487. */
  10488. pickedPoint: Nullable<Vector3>;
  10489. /**
  10490. * The mesh corresponding the the pick collision
  10491. */
  10492. pickedMesh: Nullable<AbstractMesh>;
  10493. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10494. bu: number;
  10495. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10496. bv: number;
  10497. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10498. faceId: number;
  10499. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10500. subMeshFaceId: number;
  10501. /** Id of the the submesh that was picked */
  10502. subMeshId: number;
  10503. /** If a sprite was picked, this will be the sprite the pick collided with */
  10504. pickedSprite: Nullable<Sprite>;
  10505. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10506. thinInstanceIndex: number;
  10507. /**
  10508. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10509. */
  10510. originMesh: Nullable<AbstractMesh>;
  10511. /**
  10512. * The ray that was used to perform the picking.
  10513. */
  10514. ray: Nullable<Ray>;
  10515. /**
  10516. * Gets the normal correspodning to the face the pick collided with
  10517. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10518. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10519. * @returns The normal correspodning to the face the pick collided with
  10520. */
  10521. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10522. /**
  10523. * Gets the texture coordinates of where the pick occured
  10524. * @returns the vector containing the coordnates of the texture
  10525. */
  10526. getTextureCoordinates(): Nullable<Vector2>;
  10527. }
  10528. }
  10529. declare module BABYLON {
  10530. /**
  10531. * Class representing a ray with position and direction
  10532. */
  10533. export class Ray {
  10534. /** origin point */
  10535. origin: Vector3;
  10536. /** direction */
  10537. direction: Vector3;
  10538. /** length of the ray */
  10539. length: number;
  10540. private static readonly _TmpVector3;
  10541. private _tmpRay;
  10542. /**
  10543. * Creates a new ray
  10544. * @param origin origin point
  10545. * @param direction direction
  10546. * @param length length of the ray
  10547. */
  10548. constructor(
  10549. /** origin point */
  10550. origin: Vector3,
  10551. /** direction */
  10552. direction: Vector3,
  10553. /** length of the ray */
  10554. length?: number);
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param minimum bound of the box
  10559. * @param maximum bound of the box
  10560. * @param intersectionTreshold extra extend to be added to the box in all direction
  10561. * @returns if the box was hit
  10562. */
  10563. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * Checks if the ray intersects a box
  10566. * This does not account for the ray lenght by design to improve perfs.
  10567. * @param box the bounding box to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10569. * @returns if the box was hit
  10570. */
  10571. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a sphere
  10574. * @param sphere the bounding sphere to check
  10575. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10576. * @returns true if it hits the sphere
  10577. */
  10578. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10579. /**
  10580. * If the ray hits a triange
  10581. * @param vertex0 triangle vertex
  10582. * @param vertex1 triangle vertex
  10583. * @param vertex2 triangle vertex
  10584. * @returns intersection information if hit
  10585. */
  10586. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10587. /**
  10588. * Checks if ray intersects a plane
  10589. * @param plane the plane to check
  10590. * @returns the distance away it was hit
  10591. */
  10592. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10593. /**
  10594. * Calculate the intercept of a ray on a given axis
  10595. * @param axis to check 'x' | 'y' | 'z'
  10596. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10597. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10598. */
  10599. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param mesh the mesh to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @returns picking info of the intersecton
  10605. */
  10606. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10607. /**
  10608. * Checks if ray intersects a mesh
  10609. * @param meshes the meshes to check
  10610. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10611. * @param results array to store result in
  10612. * @returns Array of picking infos
  10613. */
  10614. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10615. private _comparePickingInfo;
  10616. private static smallnum;
  10617. private static rayl;
  10618. /**
  10619. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10620. * @param sega the first point of the segment to test the intersection against
  10621. * @param segb the second point of the segment to test the intersection against
  10622. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10623. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10624. */
  10625. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10626. /**
  10627. * Update the ray from viewport position
  10628. * @param x position
  10629. * @param y y position
  10630. * @param viewportWidth viewport width
  10631. * @param viewportHeight viewport height
  10632. * @param world world matrix
  10633. * @param view view matrix
  10634. * @param projection projection matrix
  10635. * @returns this ray updated
  10636. */
  10637. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10638. /**
  10639. * Creates a ray with origin and direction of 0,0,0
  10640. * @returns the new ray
  10641. */
  10642. static Zero(): Ray;
  10643. /**
  10644. * Creates a new ray from screen space and viewport
  10645. * @param x position
  10646. * @param y y position
  10647. * @param viewportWidth viewport width
  10648. * @param viewportHeight viewport height
  10649. * @param world world matrix
  10650. * @param view view matrix
  10651. * @param projection projection matrix
  10652. * @returns new ray
  10653. */
  10654. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10657. * transformed to the given world matrix.
  10658. * @param origin The origin point
  10659. * @param end The end point
  10660. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10661. * @returns the new ray
  10662. */
  10663. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @returns the resulting new ray
  10669. */
  10670. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10671. /**
  10672. * Transforms a ray by a matrix
  10673. * @param ray ray to transform
  10674. * @param matrix matrix to apply
  10675. * @param result ray to store result in
  10676. */
  10677. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10678. /**
  10679. * Unproject a ray from screen space to object space
  10680. * @param sourceX defines the screen space x coordinate to use
  10681. * @param sourceY defines the screen space y coordinate to use
  10682. * @param viewportWidth defines the current width of the viewport
  10683. * @param viewportHeight defines the current height of the viewport
  10684. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10685. * @param view defines the view matrix to use
  10686. * @param projection defines the projection matrix to use
  10687. */
  10688. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10689. }
  10690. /**
  10691. * Type used to define predicate used to select faces when a mesh intersection is detected
  10692. */
  10693. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10694. interface Scene {
  10695. /** @hidden */
  10696. _tempPickingRay: Nullable<Ray>;
  10697. /** @hidden */
  10698. _cachedRayForTransform: Ray;
  10699. /** @hidden */
  10700. _pickWithRayInverseMatrix: Matrix;
  10701. /** @hidden */
  10702. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10703. /** @hidden */
  10704. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10705. /** @hidden */
  10706. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. /**
  10711. * Groups all the scene component constants in one place to ease maintenance.
  10712. * @hidden
  10713. */
  10714. export class SceneComponentConstants {
  10715. static readonly NAME_EFFECTLAYER: string;
  10716. static readonly NAME_LAYER: string;
  10717. static readonly NAME_LENSFLARESYSTEM: string;
  10718. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10719. static readonly NAME_PARTICLESYSTEM: string;
  10720. static readonly NAME_GAMEPAD: string;
  10721. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10722. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10723. static readonly NAME_PREPASSRENDERER: string;
  10724. static readonly NAME_DEPTHRENDERER: string;
  10725. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10726. static readonly NAME_SPRITE: string;
  10727. static readonly NAME_SUBSURFACE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10742. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10749. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10750. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10754. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10755. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10763. static readonly STEP_POINTERMOVE_SPRITE: number;
  10764. static readonly STEP_POINTERDOWN_SPRITE: number;
  10765. static readonly STEP_POINTERUP_SPRITE: number;
  10766. }
  10767. /**
  10768. * This represents a scene component.
  10769. *
  10770. * This is used to decouple the dependency the scene is having on the different workloads like
  10771. * layers, post processes...
  10772. */
  10773. export interface ISceneComponent {
  10774. /**
  10775. * The name of the component. Each component must have a unique name.
  10776. */
  10777. name: string;
  10778. /**
  10779. * The scene the component belongs to.
  10780. */
  10781. scene: Scene;
  10782. /**
  10783. * Register the component to one instance of a scene.
  10784. */
  10785. register(): void;
  10786. /**
  10787. * Rebuilds the elements related to this component in case of
  10788. * context lost for instance.
  10789. */
  10790. rebuild(): void;
  10791. /**
  10792. * Disposes the component and the associated ressources.
  10793. */
  10794. dispose(): void;
  10795. }
  10796. /**
  10797. * This represents a SERIALIZABLE scene component.
  10798. *
  10799. * This extends Scene Component to add Serialization methods on top.
  10800. */
  10801. export interface ISceneSerializableComponent extends ISceneComponent {
  10802. /**
  10803. * Adds all the elements from the container to the scene
  10804. * @param container the container holding the elements
  10805. */
  10806. addFromContainer(container: AbstractScene): void;
  10807. /**
  10808. * Removes all the elements in the container from the scene
  10809. * @param container contains the elements to remove
  10810. * @param dispose if the removed element should be disposed (default: false)
  10811. */
  10812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10813. /**
  10814. * Serializes the component data to the specified json object
  10815. * @param serializationObject The object to serialize to
  10816. */
  10817. serialize(serializationObject: any): void;
  10818. }
  10819. /**
  10820. * Strong typing of a Mesh related stage step action
  10821. */
  10822. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10823. /**
  10824. * Strong typing of a Evaluate Sub Mesh related stage step action
  10825. */
  10826. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10827. /**
  10828. * Strong typing of a pre active Mesh related stage step action
  10829. */
  10830. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10831. /**
  10832. * Strong typing of a Camera related stage step action
  10833. */
  10834. export type CameraStageAction = (camera: Camera) => void;
  10835. /**
  10836. * Strong typing of a Camera Frame buffer related stage step action
  10837. */
  10838. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10839. /**
  10840. * Strong typing of a Render Target related stage step action
  10841. */
  10842. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10843. /**
  10844. * Strong typing of a RenderingGroup related stage step action
  10845. */
  10846. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10847. /**
  10848. * Strong typing of a Mesh Render related stage step action
  10849. */
  10850. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10851. /**
  10852. * Strong typing of a simple stage step action
  10853. */
  10854. export type SimpleStageAction = () => void;
  10855. /**
  10856. * Strong typing of a render target action.
  10857. */
  10858. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10859. /**
  10860. * Strong typing of a pointer move action.
  10861. */
  10862. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10863. /**
  10864. * Strong typing of a pointer up/down action.
  10865. */
  10866. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10867. /**
  10868. * Representation of a stage in the scene (Basically a list of ordered steps)
  10869. * @hidden
  10870. */
  10871. export class Stage<T extends Function> extends Array<{
  10872. index: number;
  10873. component: ISceneComponent;
  10874. action: T;
  10875. }> {
  10876. /**
  10877. * Hide ctor from the rest of the world.
  10878. * @param items The items to add.
  10879. */
  10880. private constructor();
  10881. /**
  10882. * Creates a new Stage.
  10883. * @returns A new instance of a Stage
  10884. */
  10885. static Create<T extends Function>(): Stage<T>;
  10886. /**
  10887. * Registers a step in an ordered way in the targeted stage.
  10888. * @param index Defines the position to register the step in
  10889. * @param component Defines the component attached to the step
  10890. * @param action Defines the action to launch during the step
  10891. */
  10892. registerStep(index: number, component: ISceneComponent, action: T): void;
  10893. /**
  10894. * Clears all the steps from the stage.
  10895. */
  10896. clear(): void;
  10897. }
  10898. }
  10899. declare module BABYLON {
  10900. interface Scene {
  10901. /** @hidden */
  10902. _pointerOverSprite: Nullable<Sprite>;
  10903. /** @hidden */
  10904. _pickedDownSprite: Nullable<Sprite>;
  10905. /** @hidden */
  10906. _tempSpritePickingRay: Nullable<Ray>;
  10907. /**
  10908. * All of the sprite managers added to this scene
  10909. * @see https://doc.babylonjs.com/babylon101/sprites
  10910. */
  10911. spriteManagers: Array<ISpriteManager>;
  10912. /**
  10913. * An event triggered when sprites rendering is about to start
  10914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10915. */
  10916. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10917. /**
  10918. * An event triggered when sprites rendering is done
  10919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10920. */
  10921. onAfterSpritesRenderingObservable: Observable<Scene>;
  10922. /** @hidden */
  10923. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10924. /** Launch a ray to try to pick a sprite in the scene
  10925. * @param x position on screen
  10926. * @param y position on screen
  10927. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10928. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10930. * @returns a PickingInfo
  10931. */
  10932. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Use the given ray to pick a sprite in the scene
  10934. * @param ray The ray (in world space) to use to pick meshes
  10935. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10936. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10937. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10938. * @returns a PickingInfo
  10939. */
  10940. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10941. /** @hidden */
  10942. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10943. /** Launch a ray to try to pick sprites in the scene
  10944. * @param x position on screen
  10945. * @param y position on screen
  10946. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10947. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10948. * @returns a PickingInfo array
  10949. */
  10950. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10951. /** Use the given ray to pick sprites in the scene
  10952. * @param ray The ray (in world space) to use to pick meshes
  10953. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10954. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /**
  10959. * Force the sprite under the pointer
  10960. * @param sprite defines the sprite to use
  10961. */
  10962. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10963. /**
  10964. * Gets the sprite under the pointer
  10965. * @returns a Sprite or null if no sprite is under the pointer
  10966. */
  10967. getPointerOverSprite(): Nullable<Sprite>;
  10968. }
  10969. /**
  10970. * Defines the sprite scene component responsible to manage sprites
  10971. * in a given scene.
  10972. */
  10973. export class SpriteSceneComponent implements ISceneComponent {
  10974. /**
  10975. * The component name helpfull to identify the component in the list of scene components.
  10976. */
  10977. readonly name: string;
  10978. /**
  10979. * The scene the component belongs to.
  10980. */
  10981. scene: Scene;
  10982. /** @hidden */
  10983. private _spritePredicate;
  10984. /**
  10985. * Creates a new instance of the component for the given scene
  10986. * @param scene Defines the scene to register the component in
  10987. */
  10988. constructor(scene: Scene);
  10989. /**
  10990. * Registers the component in a given scene
  10991. */
  10992. register(): void;
  10993. /**
  10994. * Rebuilds the elements related to this component in case of
  10995. * context lost for instance.
  10996. */
  10997. rebuild(): void;
  10998. /**
  10999. * Disposes the component and the associated ressources.
  11000. */
  11001. dispose(): void;
  11002. private _pickSpriteButKeepRay;
  11003. private _pointerMove;
  11004. private _pointerDown;
  11005. private _pointerUp;
  11006. }
  11007. }
  11008. declare module BABYLON {
  11009. /** @hidden */
  11010. export var fogFragmentDeclaration: {
  11011. name: string;
  11012. shader: string;
  11013. };
  11014. }
  11015. declare module BABYLON {
  11016. /** @hidden */
  11017. export var fogFragment: {
  11018. name: string;
  11019. shader: string;
  11020. };
  11021. }
  11022. declare module BABYLON {
  11023. /** @hidden */
  11024. export var imageProcessingCompatibility: {
  11025. name: string;
  11026. shader: string;
  11027. };
  11028. }
  11029. declare module BABYLON {
  11030. /** @hidden */
  11031. export var spritesPixelShader: {
  11032. name: string;
  11033. shader: string;
  11034. };
  11035. }
  11036. declare module BABYLON {
  11037. /** @hidden */
  11038. export var fogVertexDeclaration: {
  11039. name: string;
  11040. shader: string;
  11041. };
  11042. }
  11043. declare module BABYLON {
  11044. /** @hidden */
  11045. export var spritesVertexShader: {
  11046. name: string;
  11047. shader: string;
  11048. };
  11049. }
  11050. declare module BABYLON {
  11051. /**
  11052. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11053. */
  11054. export interface ISpriteManager extends IDisposable {
  11055. /**
  11056. * Gets manager's name
  11057. */
  11058. name: string;
  11059. /**
  11060. * Restricts the camera to viewing objects with the same layerMask.
  11061. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11062. */
  11063. layerMask: number;
  11064. /**
  11065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11066. */
  11067. isPickable: boolean;
  11068. /**
  11069. * Gets the hosting scene
  11070. */
  11071. scene: Scene;
  11072. /**
  11073. * Specifies the rendering group id for this mesh (0 by default)
  11074. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11075. */
  11076. renderingGroupId: number;
  11077. /**
  11078. * Defines the list of sprites managed by the manager.
  11079. */
  11080. sprites: Array<Sprite>;
  11081. /**
  11082. * Gets or sets the spritesheet texture
  11083. */
  11084. texture: Texture;
  11085. /** Defines the default width of a cell in the spritesheet */
  11086. cellWidth: number;
  11087. /** Defines the default height of a cell in the spritesheet */
  11088. cellHeight: number;
  11089. /**
  11090. * Tests the intersection of a sprite with a specific ray.
  11091. * @param ray The ray we are sending to test the collision
  11092. * @param camera The camera space we are sending rays in
  11093. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11094. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11095. * @returns picking info or null.
  11096. */
  11097. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11098. /**
  11099. * Intersects the sprites with a ray
  11100. * @param ray defines the ray to intersect with
  11101. * @param camera defines the current active camera
  11102. * @param predicate defines a predicate used to select candidate sprites
  11103. * @returns null if no hit or a PickingInfo array
  11104. */
  11105. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11106. /**
  11107. * Renders the list of sprites on screen.
  11108. */
  11109. render(): void;
  11110. }
  11111. /**
  11112. * Class used to manage multiple sprites on the same spritesheet
  11113. * @see https://doc.babylonjs.com/babylon101/sprites
  11114. */
  11115. export class SpriteManager implements ISpriteManager {
  11116. /** defines the manager's name */
  11117. name: string;
  11118. /** Define the Url to load snippets */
  11119. static SnippetUrl: string;
  11120. /** Snippet ID if the manager was created from the snippet server */
  11121. snippetId: string;
  11122. /** Gets the list of sprites */
  11123. sprites: Sprite[];
  11124. /** Gets or sets the rendering group id (0 by default) */
  11125. renderingGroupId: number;
  11126. /** Gets or sets camera layer mask */
  11127. layerMask: number;
  11128. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11129. fogEnabled: boolean;
  11130. /** Gets or sets a boolean indicating if the sprites are pickable */
  11131. isPickable: boolean;
  11132. /** Defines the default width of a cell in the spritesheet */
  11133. cellWidth: number;
  11134. /** Defines the default height of a cell in the spritesheet */
  11135. cellHeight: number;
  11136. /** Associative array from JSON sprite data file */
  11137. private _cellData;
  11138. /** Array of sprite names from JSON sprite data file */
  11139. private _spriteMap;
  11140. /** True when packed cell data from JSON file is ready*/
  11141. private _packedAndReady;
  11142. private _textureContent;
  11143. private _useInstancing;
  11144. /**
  11145. * An event triggered when the manager is disposed.
  11146. */
  11147. onDisposeObservable: Observable<SpriteManager>;
  11148. private _onDisposeObserver;
  11149. /**
  11150. * Callback called when the manager is disposed
  11151. */
  11152. set onDispose(callback: () => void);
  11153. private _capacity;
  11154. private _fromPacked;
  11155. private _spriteTexture;
  11156. private _epsilon;
  11157. private _scene;
  11158. private _vertexData;
  11159. private _buffer;
  11160. private _vertexBuffers;
  11161. private _spriteBuffer;
  11162. private _indexBuffer;
  11163. private _effectBase;
  11164. private _effectFog;
  11165. private _vertexBufferSize;
  11166. /**
  11167. * Gets or sets the unique id of the sprite
  11168. */
  11169. uniqueId: number;
  11170. /**
  11171. * Gets the array of sprites
  11172. */
  11173. get children(): Sprite[];
  11174. /**
  11175. * Gets the hosting scene
  11176. */
  11177. get scene(): Scene;
  11178. /**
  11179. * Gets the capacity of the manager
  11180. */
  11181. get capacity(): number;
  11182. /**
  11183. * Gets or sets the spritesheet texture
  11184. */
  11185. get texture(): Texture;
  11186. set texture(value: Texture);
  11187. private _blendMode;
  11188. /**
  11189. * Blend mode use to render the particle, it can be any of
  11190. * the static Constants.ALPHA_x properties provided in this class.
  11191. * Default value is Constants.ALPHA_COMBINE
  11192. */
  11193. get blendMode(): number;
  11194. set blendMode(blendMode: number);
  11195. /** Disables writing to the depth buffer when rendering the sprites.
  11196. * It can be handy to disable depth writing when using textures without alpha channel
  11197. * and setting some specific blend modes.
  11198. */
  11199. disableDepthWrite: boolean;
  11200. /**
  11201. * Creates a new sprite manager
  11202. * @param name defines the manager's name
  11203. * @param imgUrl defines the sprite sheet url
  11204. * @param capacity defines the maximum allowed number of sprites
  11205. * @param cellSize defines the size of a sprite cell
  11206. * @param scene defines the hosting scene
  11207. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11208. * @param samplingMode defines the smapling mode to use with spritesheet
  11209. * @param fromPacked set to false; do not alter
  11210. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11211. */
  11212. constructor(
  11213. /** defines the manager's name */
  11214. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11215. /**
  11216. * Returns the string "SpriteManager"
  11217. * @returns "SpriteManager"
  11218. */
  11219. getClassName(): string;
  11220. private _makePacked;
  11221. private _appendSpriteVertex;
  11222. private _checkTextureAlpha;
  11223. /**
  11224. * Intersects the sprites with a ray
  11225. * @param ray defines the ray to intersect with
  11226. * @param camera defines the current active camera
  11227. * @param predicate defines a predicate used to select candidate sprites
  11228. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11229. * @returns null if no hit or a PickingInfo
  11230. */
  11231. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11232. /**
  11233. * Intersects the sprites with a ray
  11234. * @param ray defines the ray to intersect with
  11235. * @param camera defines the current active camera
  11236. * @param predicate defines a predicate used to select candidate sprites
  11237. * @returns null if no hit or a PickingInfo array
  11238. */
  11239. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11240. /**
  11241. * Render all child sprites
  11242. */
  11243. render(): void;
  11244. /**
  11245. * Release associated resources
  11246. */
  11247. dispose(): void;
  11248. /**
  11249. * Serializes the sprite manager to a JSON object
  11250. * @param serializeTexture defines if the texture must be serialized as well
  11251. * @returns the JSON object
  11252. */
  11253. serialize(serializeTexture?: boolean): any;
  11254. /**
  11255. * Parses a JSON object to create a new sprite manager.
  11256. * @param parsedManager The JSON object to parse
  11257. * @param scene The scene to create the sprite managerin
  11258. * @param rootUrl The root url to use to load external dependencies like texture
  11259. * @returns the new sprite manager
  11260. */
  11261. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11262. /**
  11263. * Creates a sprite manager from a snippet saved in a remote file
  11264. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11265. * @param url defines the url to load from
  11266. * @param scene defines the hosting scene
  11267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11268. * @returns a promise that will resolve to the new sprite manager
  11269. */
  11270. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11271. /**
  11272. * Creates a sprite manager from a snippet saved by the sprite editor
  11273. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11274. * @param scene defines the hosting scene
  11275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11276. * @returns a promise that will resolve to the new sprite manager
  11277. */
  11278. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11279. }
  11280. }
  11281. declare module BABYLON {
  11282. /** Interface used by value gradients (color, factor, ...) */
  11283. export interface IValueGradient {
  11284. /**
  11285. * Gets or sets the gradient value (between 0 and 1)
  11286. */
  11287. gradient: number;
  11288. }
  11289. /** Class used to store color4 gradient */
  11290. export class ColorGradient implements IValueGradient {
  11291. /**
  11292. * Gets or sets the gradient value (between 0 and 1)
  11293. */
  11294. gradient: number;
  11295. /**
  11296. * Gets or sets first associated color
  11297. */
  11298. color1: Color4;
  11299. /**
  11300. * Gets or sets second associated color
  11301. */
  11302. color2?: Color4 | undefined;
  11303. /**
  11304. * Creates a new color4 gradient
  11305. * @param gradient gets or sets the gradient value (between 0 and 1)
  11306. * @param color1 gets or sets first associated color
  11307. * @param color2 gets or sets first second color
  11308. */
  11309. constructor(
  11310. /**
  11311. * Gets or sets the gradient value (between 0 and 1)
  11312. */
  11313. gradient: number,
  11314. /**
  11315. * Gets or sets first associated color
  11316. */
  11317. color1: Color4,
  11318. /**
  11319. * Gets or sets second associated color
  11320. */
  11321. color2?: Color4 | undefined);
  11322. /**
  11323. * Will get a color picked randomly between color1 and color2.
  11324. * If color2 is undefined then color1 will be used
  11325. * @param result defines the target Color4 to store the result in
  11326. */
  11327. getColorToRef(result: Color4): void;
  11328. }
  11329. /** Class used to store color 3 gradient */
  11330. export class Color3Gradient implements IValueGradient {
  11331. /**
  11332. * Gets or sets the gradient value (between 0 and 1)
  11333. */
  11334. gradient: number;
  11335. /**
  11336. * Gets or sets the associated color
  11337. */
  11338. color: Color3;
  11339. /**
  11340. * Creates a new color3 gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param color gets or sets associated color
  11343. */
  11344. constructor(
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number,
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3);
  11353. }
  11354. /** Class used to store factor gradient */
  11355. export class FactorGradient implements IValueGradient {
  11356. /**
  11357. * Gets or sets the gradient value (between 0 and 1)
  11358. */
  11359. gradient: number;
  11360. /**
  11361. * Gets or sets first associated factor
  11362. */
  11363. factor1: number;
  11364. /**
  11365. * Gets or sets second associated factor
  11366. */
  11367. factor2?: number | undefined;
  11368. /**
  11369. * Creates a new factor gradient
  11370. * @param gradient gets or sets the gradient value (between 0 and 1)
  11371. * @param factor1 gets or sets first associated factor
  11372. * @param factor2 gets or sets second associated factor
  11373. */
  11374. constructor(
  11375. /**
  11376. * Gets or sets the gradient value (between 0 and 1)
  11377. */
  11378. gradient: number,
  11379. /**
  11380. * Gets or sets first associated factor
  11381. */
  11382. factor1: number,
  11383. /**
  11384. * Gets or sets second associated factor
  11385. */
  11386. factor2?: number | undefined);
  11387. /**
  11388. * Will get a number picked randomly between factor1 and factor2.
  11389. * If factor2 is undefined then factor1 will be used
  11390. * @returns the picked number
  11391. */
  11392. getFactor(): number;
  11393. }
  11394. /**
  11395. * Helper used to simplify some generic gradient tasks
  11396. */
  11397. export class GradientHelper {
  11398. /**
  11399. * Gets the current gradient from an array of IValueGradient
  11400. * @param ratio defines the current ratio to get
  11401. * @param gradients defines the array of IValueGradient
  11402. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11403. */
  11404. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11405. }
  11406. }
  11407. declare module BABYLON {
  11408. interface ThinEngine {
  11409. /**
  11410. * Creates a raw texture
  11411. * @param data defines the data to store in the texture
  11412. * @param width defines the width of the texture
  11413. * @param height defines the height of the texture
  11414. * @param format defines the format of the data
  11415. * @param generateMipMaps defines if the engine should generate the mip levels
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11418. * @param compression defines the compression used (null by default)
  11419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11420. * @returns the raw texture inside an InternalTexture
  11421. */
  11422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11423. /**
  11424. * Update a raw texture
  11425. * @param texture defines the texture to update
  11426. * @param data defines the data to store in the texture
  11427. * @param format defines the format of the data
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. */
  11430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11431. /**
  11432. * Update a raw texture
  11433. * @param texture defines the texture to update
  11434. * @param data defines the data to store in the texture
  11435. * @param format defines the format of the data
  11436. * @param invertY defines if data must be stored with Y axis inverted
  11437. * @param compression defines the compression used (null by default)
  11438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11439. */
  11440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11441. /**
  11442. * Creates a new raw cube texture
  11443. * @param data defines the array of data to use to create each face
  11444. * @param size defines the size of the textures
  11445. * @param format defines the format of the data
  11446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11447. * @param generateMipMaps defines if the engine should generate the mip levels
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11450. * @param compression defines the compression used (null by default)
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11454. /**
  11455. * Update a raw cube texture
  11456. * @param texture defines the texture to udpdate
  11457. * @param data defines the data to store
  11458. * @param format defines the data format
  11459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. */
  11462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11463. /**
  11464. * Update a raw cube texture
  11465. * @param texture defines the texture to udpdate
  11466. * @param data defines the data to store
  11467. * @param format defines the data format
  11468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11469. * @param invertY defines if data must be stored with Y axis inverted
  11470. * @param compression defines the compression used (null by default)
  11471. */
  11472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11473. /**
  11474. * Update a raw cube texture
  11475. * @param texture defines the texture to udpdate
  11476. * @param data defines the data to store
  11477. * @param format defines the data format
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. * @param invertY defines if data must be stored with Y axis inverted
  11480. * @param compression defines the compression used (null by default)
  11481. * @param level defines which level of the texture to update
  11482. */
  11483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11484. /**
  11485. * Creates a new raw cube texture from a specified url
  11486. * @param url defines the url where the data is located
  11487. * @param scene defines the current scene
  11488. * @param size defines the size of the textures
  11489. * @param format defines the format of the data
  11490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11491. * @param noMipmap defines if the engine should avoid generating the mip levels
  11492. * @param callback defines a callback used to extract texture data from loaded data
  11493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11494. * @param onLoad defines a callback called when texture is loaded
  11495. * @param onError defines a callback called if there is an error
  11496. * @returns the cube texture as an InternalTexture
  11497. */
  11498. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11499. /**
  11500. * Creates a new raw cube texture from a specified url
  11501. * @param url defines the url where the data is located
  11502. * @param scene defines the current scene
  11503. * @param size defines the size of the textures
  11504. * @param format defines the format of the data
  11505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11506. * @param noMipmap defines if the engine should avoid generating the mip levels
  11507. * @param callback defines a callback used to extract texture data from loaded data
  11508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11509. * @param onLoad defines a callback called when texture is loaded
  11510. * @param onError defines a callback called if there is an error
  11511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11516. /**
  11517. * Creates a new raw 3D texture
  11518. * @param data defines the data used to create the texture
  11519. * @param width defines the width of the texture
  11520. * @param height defines the height of the texture
  11521. * @param depth defines the depth of the texture
  11522. * @param format defines the format of the texture
  11523. * @param generateMipMaps defines if the engine must generate mip levels
  11524. * @param invertY defines if data must be stored with Y axis inverted
  11525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11526. * @param compression defines the compressed used (can be null)
  11527. * @param textureType defines the compressed used (can be null)
  11528. * @returns a new raw 3D texture (stored in an InternalTexture)
  11529. */
  11530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11531. /**
  11532. * Update a raw 3D texture
  11533. * @param texture defines the texture to update
  11534. * @param data defines the data to store
  11535. * @param format defines the data format
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. */
  11538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11539. /**
  11540. * Update a raw 3D texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store
  11543. * @param format defines the data format
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. * @param compression defines the used compression (can be null)
  11546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11547. */
  11548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11549. /**
  11550. * Creates a new raw 2D array texture
  11551. * @param data defines the data used to create the texture
  11552. * @param width defines the width of the texture
  11553. * @param height defines the height of the texture
  11554. * @param depth defines the number of layers of the texture
  11555. * @param format defines the format of the texture
  11556. * @param generateMipMaps defines if the engine must generate mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11559. * @param compression defines the compressed used (can be null)
  11560. * @param textureType defines the compressed used (can be null)
  11561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11562. */
  11563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11564. /**
  11565. * Update a raw 2D array texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store
  11568. * @param format defines the data format
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw 2D array texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store
  11576. * @param format defines the data format
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the used compression (can be null)
  11579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11580. */
  11581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11582. }
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * Raw texture can help creating a texture directly from an array of data.
  11587. * This can be super useful if you either get the data from an uncompressed source or
  11588. * if you wish to create your texture pixel by pixel.
  11589. */
  11590. export class RawTexture extends Texture {
  11591. /**
  11592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11593. */
  11594. format: number;
  11595. /**
  11596. * Instantiates a new RawTexture.
  11597. * Raw texture can help creating a texture directly from an array of data.
  11598. * This can be super useful if you either get the data from an uncompressed source or
  11599. * if you wish to create your texture pixel by pixel.
  11600. * @param data define the array of data to use to create the texture
  11601. * @param width define the width of the texture
  11602. * @param height define the height of the texture
  11603. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11604. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11605. * @param generateMipMaps define whether mip maps should be generated or not
  11606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11608. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11609. */
  11610. constructor(data: ArrayBufferView, width: number, height: number,
  11611. /**
  11612. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11613. */
  11614. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11615. /**
  11616. * Updates the texture underlying data.
  11617. * @param data Define the new data of the texture
  11618. */
  11619. update(data: ArrayBufferView): void;
  11620. /**
  11621. * Creates a luminance texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @returns the luminance texture
  11630. */
  11631. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11632. /**
  11633. * Creates a luminance alpha texture from some data.
  11634. * @param data Define the texture data
  11635. * @param width Define the width of the texture
  11636. * @param height Define the height of the texture
  11637. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11641. * @returns the luminance alpha texture
  11642. */
  11643. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11644. /**
  11645. * Creates an alpha texture from some data.
  11646. * @param data Define the texture data
  11647. * @param width Define the width of the texture
  11648. * @param height Define the height of the texture
  11649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11653. * @returns the alpha texture
  11654. */
  11655. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11656. /**
  11657. * Creates a RGB texture from some data.
  11658. * @param data Define the texture data
  11659. * @param width Define the width of the texture
  11660. * @param height Define the height of the texture
  11661. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11666. * @returns the RGB alpha texture
  11667. */
  11668. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11669. /**
  11670. * Creates a RGBA texture from some data.
  11671. * @param data Define the texture data
  11672. * @param width Define the width of the texture
  11673. * @param height Define the height of the texture
  11674. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11675. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11679. * @returns the RGBA texture
  11680. */
  11681. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11682. /**
  11683. * Creates a R texture from some data.
  11684. * @param data Define the texture data
  11685. * @param width Define the width of the texture
  11686. * @param height Define the height of the texture
  11687. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11691. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11692. * @returns the R texture
  11693. */
  11694. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11695. }
  11696. }
  11697. declare module BABYLON {
  11698. interface ThinEngine {
  11699. /**
  11700. * Update a dynamic index buffer
  11701. * @param indexBuffer defines the target index buffer
  11702. * @param indices defines the data to update
  11703. * @param offset defines the offset in the target index buffer where update should start
  11704. */
  11705. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11706. /**
  11707. * Updates a dynamic vertex buffer.
  11708. * @param vertexBuffer the vertex buffer to update
  11709. * @param data the data used to update the vertex buffer
  11710. * @param byteOffset the byte offset of the data
  11711. * @param byteLength the byte length of the data
  11712. */
  11713. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11714. }
  11715. }
  11716. declare module BABYLON {
  11717. interface AbstractScene {
  11718. /**
  11719. * The list of procedural textures added to the scene
  11720. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11721. */
  11722. proceduralTextures: Array<ProceduralTexture>;
  11723. }
  11724. /**
  11725. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11726. * in a given scene.
  11727. */
  11728. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11729. /**
  11730. * The component name helpfull to identify the component in the list of scene components.
  11731. */
  11732. readonly name: string;
  11733. /**
  11734. * The scene the component belongs to.
  11735. */
  11736. scene: Scene;
  11737. /**
  11738. * Creates a new instance of the component for the given scene
  11739. * @param scene Defines the scene to register the component in
  11740. */
  11741. constructor(scene: Scene);
  11742. /**
  11743. * Registers the component in a given scene
  11744. */
  11745. register(): void;
  11746. /**
  11747. * Rebuilds the elements related to this component in case of
  11748. * context lost for instance.
  11749. */
  11750. rebuild(): void;
  11751. /**
  11752. * Disposes the component and the associated ressources.
  11753. */
  11754. dispose(): void;
  11755. private _beforeClear;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. interface ThinEngine {
  11760. /**
  11761. * Creates a new render target cube texture
  11762. * @param size defines the size of the texture
  11763. * @param options defines the options used to create the texture
  11764. * @returns a new render target cube texture stored in an InternalTexture
  11765. */
  11766. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11767. }
  11768. }
  11769. declare module BABYLON {
  11770. /** @hidden */
  11771. export var proceduralVertexShader: {
  11772. name: string;
  11773. shader: string;
  11774. };
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11779. * This is the base class of any Procedural texture and contains most of the shareable code.
  11780. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11781. */
  11782. export class ProceduralTexture extends Texture {
  11783. /**
  11784. * Define if the texture is enabled or not (disabled texture will not render)
  11785. */
  11786. isEnabled: boolean;
  11787. /**
  11788. * Define if the texture must be cleared before rendering (default is true)
  11789. */
  11790. autoClear: boolean;
  11791. /**
  11792. * Callback called when the texture is generated
  11793. */
  11794. onGenerated: () => void;
  11795. /**
  11796. * Event raised when the texture is generated
  11797. */
  11798. onGeneratedObservable: Observable<ProceduralTexture>;
  11799. /**
  11800. * Event raised before the texture is generated
  11801. */
  11802. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11803. /**
  11804. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11805. */
  11806. nodeMaterialSource: Nullable<NodeMaterial>;
  11807. /** @hidden */
  11808. _generateMipMaps: boolean;
  11809. /** @hidden **/
  11810. _effect: Effect;
  11811. /** @hidden */
  11812. _textures: {
  11813. [key: string]: Texture;
  11814. };
  11815. /** @hidden */
  11816. protected _fallbackTexture: Nullable<Texture>;
  11817. private _size;
  11818. private _currentRefreshId;
  11819. private _frameId;
  11820. private _refreshRate;
  11821. private _vertexBuffers;
  11822. private _indexBuffer;
  11823. private _uniforms;
  11824. private _samplers;
  11825. private _fragment;
  11826. private _floats;
  11827. private _ints;
  11828. private _floatsArrays;
  11829. private _colors3;
  11830. private _colors4;
  11831. private _vectors2;
  11832. private _vectors3;
  11833. private _matrices;
  11834. private _fallbackTextureUsed;
  11835. private _fullEngine;
  11836. private _cachedDefines;
  11837. private _contentUpdateId;
  11838. private _contentData;
  11839. /**
  11840. * Instantiates a new procedural texture.
  11841. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11842. * This is the base class of any Procedural texture and contains most of the shareable code.
  11843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11844. * @param name Define the name of the texture
  11845. * @param size Define the size of the texture to create
  11846. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11847. * @param scene Define the scene the texture belongs to
  11848. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11849. * @param generateMipMaps Define if the texture should creates mip maps or not
  11850. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11851. * @param textureType The FBO internal texture type
  11852. */
  11853. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11854. /**
  11855. * The effect that is created when initializing the post process.
  11856. * @returns The created effect corresponding the the postprocess.
  11857. */
  11858. getEffect(): Effect;
  11859. /**
  11860. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11861. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11862. */
  11863. getContent(): Nullable<ArrayBufferView>;
  11864. private _createIndexBuffer;
  11865. /** @hidden */
  11866. _rebuild(): void;
  11867. /**
  11868. * Resets the texture in order to recreate its associated resources.
  11869. * This can be called in case of context loss
  11870. */
  11871. reset(): void;
  11872. protected _getDefines(): string;
  11873. /**
  11874. * Is the texture ready to be used ? (rendered at least once)
  11875. * @returns true if ready, otherwise, false.
  11876. */
  11877. isReady(): boolean;
  11878. /**
  11879. * Resets the refresh counter of the texture and start bak from scratch.
  11880. * Could be useful to regenerate the texture if it is setup to render only once.
  11881. */
  11882. resetRefreshCounter(): void;
  11883. /**
  11884. * Set the fragment shader to use in order to render the texture.
  11885. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11886. */
  11887. setFragment(fragment: any): void;
  11888. /**
  11889. * Define the refresh rate of the texture or the rendering frequency.
  11890. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11891. */
  11892. get refreshRate(): number;
  11893. set refreshRate(value: number);
  11894. /** @hidden */
  11895. _shouldRender(): boolean;
  11896. /**
  11897. * Get the size the texture is rendering at.
  11898. * @returns the size (on cube texture it is always squared)
  11899. */
  11900. getRenderSize(): RenderTargetTextureSize;
  11901. /**
  11902. * Resize the texture to new value.
  11903. * @param size Define the new size the texture should have
  11904. * @param generateMipMaps Define whether the new texture should create mip maps
  11905. */
  11906. resize(size: number, generateMipMaps: boolean): void;
  11907. private _checkUniform;
  11908. /**
  11909. * Set a texture in the shader program used to render.
  11910. * @param name Define the name of the uniform samplers as defined in the shader
  11911. * @param texture Define the texture to bind to this sampler
  11912. * @return the texture itself allowing "fluent" like uniform updates
  11913. */
  11914. setTexture(name: string, texture: Texture): ProceduralTexture;
  11915. /**
  11916. * Set a float in the shader.
  11917. * @param name Define the name of the uniform as defined in the shader
  11918. * @param value Define the value to give to the uniform
  11919. * @return the texture itself allowing "fluent" like uniform updates
  11920. */
  11921. setFloat(name: string, value: number): ProceduralTexture;
  11922. /**
  11923. * Set a int in the shader.
  11924. * @param name Define the name of the uniform as defined in the shader
  11925. * @param value Define the value to give to the uniform
  11926. * @return the texture itself allowing "fluent" like uniform updates
  11927. */
  11928. setInt(name: string, value: number): ProceduralTexture;
  11929. /**
  11930. * Set an array of floats in the shader.
  11931. * @param name Define the name of the uniform as defined in the shader
  11932. * @param value Define the value to give to the uniform
  11933. * @return the texture itself allowing "fluent" like uniform updates
  11934. */
  11935. setFloats(name: string, value: number[]): ProceduralTexture;
  11936. /**
  11937. * Set a vec3 in the shader from a Color3.
  11938. * @param name Define the name of the uniform as defined in the shader
  11939. * @param value Define the value to give to the uniform
  11940. * @return the texture itself allowing "fluent" like uniform updates
  11941. */
  11942. setColor3(name: string, value: Color3): ProceduralTexture;
  11943. /**
  11944. * Set a vec4 in the shader from a Color4.
  11945. * @param name Define the name of the uniform as defined in the shader
  11946. * @param value Define the value to give to the uniform
  11947. * @return the texture itself allowing "fluent" like uniform updates
  11948. */
  11949. setColor4(name: string, value: Color4): ProceduralTexture;
  11950. /**
  11951. * Set a vec2 in the shader from a Vector2.
  11952. * @param name Define the name of the uniform as defined in the shader
  11953. * @param value Define the value to give to the uniform
  11954. * @return the texture itself allowing "fluent" like uniform updates
  11955. */
  11956. setVector2(name: string, value: Vector2): ProceduralTexture;
  11957. /**
  11958. * Set a vec3 in the shader from a Vector3.
  11959. * @param name Define the name of the uniform as defined in the shader
  11960. * @param value Define the value to give to the uniform
  11961. * @return the texture itself allowing "fluent" like uniform updates
  11962. */
  11963. setVector3(name: string, value: Vector3): ProceduralTexture;
  11964. /**
  11965. * Set a mat4 in the shader from a MAtrix.
  11966. * @param name Define the name of the uniform as defined in the shader
  11967. * @param value Define the value to give to the uniform
  11968. * @return the texture itself allowing "fluent" like uniform updates
  11969. */
  11970. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11971. /**
  11972. * Render the texture to its associated render target.
  11973. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11974. */
  11975. render(useCameraPostProcess?: boolean): void;
  11976. /**
  11977. * Clone the texture.
  11978. * @returns the cloned texture
  11979. */
  11980. clone(): ProceduralTexture;
  11981. /**
  11982. * Dispose the texture and release its asoociated resources.
  11983. */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module BABYLON {
  11988. /**
  11989. * This represents the base class for particle system in Babylon.
  11990. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11991. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11992. * @example https://doc.babylonjs.com/babylon101/particles
  11993. */
  11994. export class BaseParticleSystem {
  11995. /**
  11996. * Source color is added to the destination color without alpha affecting the result
  11997. */
  11998. static BLENDMODE_ONEONE: number;
  11999. /**
  12000. * Blend current color and particle color using particle’s alpha
  12001. */
  12002. static BLENDMODE_STANDARD: number;
  12003. /**
  12004. * Add current color and particle color multiplied by particle’s alpha
  12005. */
  12006. static BLENDMODE_ADD: number;
  12007. /**
  12008. * Multiply current color with particle color
  12009. */
  12010. static BLENDMODE_MULTIPLY: number;
  12011. /**
  12012. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12013. */
  12014. static BLENDMODE_MULTIPLYADD: number;
  12015. /**
  12016. * List of animations used by the particle system.
  12017. */
  12018. animations: Animation[];
  12019. /**
  12020. * Gets or sets the unique id of the particle system
  12021. */
  12022. uniqueId: number;
  12023. /**
  12024. * The id of the Particle system.
  12025. */
  12026. id: string;
  12027. /**
  12028. * The friendly name of the Particle system.
  12029. */
  12030. name: string;
  12031. /**
  12032. * Snippet ID if the particle system was created from the snippet server
  12033. */
  12034. snippetId: string;
  12035. /**
  12036. * The rendering group used by the Particle system to chose when to render.
  12037. */
  12038. renderingGroupId: number;
  12039. /**
  12040. * The emitter represents the Mesh or position we are attaching the particle system to.
  12041. */
  12042. emitter: Nullable<AbstractMesh | Vector3>;
  12043. /**
  12044. * The maximum number of particles to emit per frame
  12045. */
  12046. emitRate: number;
  12047. /**
  12048. * If you want to launch only a few particles at once, that can be done, as well.
  12049. */
  12050. manualEmitCount: number;
  12051. /**
  12052. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12053. */
  12054. updateSpeed: number;
  12055. /**
  12056. * The amount of time the particle system is running (depends of the overall update speed).
  12057. */
  12058. targetStopDuration: number;
  12059. /**
  12060. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12061. */
  12062. disposeOnStop: boolean;
  12063. /**
  12064. * Minimum power of emitting particles.
  12065. */
  12066. minEmitPower: number;
  12067. /**
  12068. * Maximum power of emitting particles.
  12069. */
  12070. maxEmitPower: number;
  12071. /**
  12072. * Minimum life time of emitting particles.
  12073. */
  12074. minLifeTime: number;
  12075. /**
  12076. * Maximum life time of emitting particles.
  12077. */
  12078. maxLifeTime: number;
  12079. /**
  12080. * Minimum Size of emitting particles.
  12081. */
  12082. minSize: number;
  12083. /**
  12084. * Maximum Size of emitting particles.
  12085. */
  12086. maxSize: number;
  12087. /**
  12088. * Minimum scale of emitting particles on X axis.
  12089. */
  12090. minScaleX: number;
  12091. /**
  12092. * Maximum scale of emitting particles on X axis.
  12093. */
  12094. maxScaleX: number;
  12095. /**
  12096. * Minimum scale of emitting particles on Y axis.
  12097. */
  12098. minScaleY: number;
  12099. /**
  12100. * Maximum scale of emitting particles on Y axis.
  12101. */
  12102. maxScaleY: number;
  12103. /**
  12104. * Gets or sets the minimal initial rotation in radians.
  12105. */
  12106. minInitialRotation: number;
  12107. /**
  12108. * Gets or sets the maximal initial rotation in radians.
  12109. */
  12110. maxInitialRotation: number;
  12111. /**
  12112. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12113. */
  12114. minAngularSpeed: number;
  12115. /**
  12116. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12117. */
  12118. maxAngularSpeed: number;
  12119. /**
  12120. * The texture used to render each particle. (this can be a spritesheet)
  12121. */
  12122. particleTexture: Nullable<BaseTexture>;
  12123. /**
  12124. * The layer mask we are rendering the particles through.
  12125. */
  12126. layerMask: number;
  12127. /**
  12128. * This can help using your own shader to render the particle system.
  12129. * The according effect will be created
  12130. */
  12131. customShader: any;
  12132. /**
  12133. * By default particle system starts as soon as they are created. This prevents the
  12134. * automatic start to happen and let you decide when to start emitting particles.
  12135. */
  12136. preventAutoStart: boolean;
  12137. private _noiseTexture;
  12138. /**
  12139. * Gets or sets a texture used to add random noise to particle positions
  12140. */
  12141. get noiseTexture(): Nullable<ProceduralTexture>;
  12142. set noiseTexture(value: Nullable<ProceduralTexture>);
  12143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12144. noiseStrength: Vector3;
  12145. /**
  12146. * Callback triggered when the particle animation is ending.
  12147. */
  12148. onAnimationEnd: Nullable<() => void>;
  12149. /**
  12150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12151. */
  12152. blendMode: number;
  12153. /**
  12154. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12155. * to override the particles.
  12156. */
  12157. forceDepthWrite: boolean;
  12158. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12159. preWarmCycles: number;
  12160. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12161. preWarmStepOffset: number;
  12162. /**
  12163. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12164. */
  12165. spriteCellChangeSpeed: number;
  12166. /**
  12167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12168. */
  12169. startSpriteCellID: number;
  12170. /**
  12171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12172. */
  12173. endSpriteCellID: number;
  12174. /**
  12175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12176. */
  12177. spriteCellWidth: number;
  12178. /**
  12179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12180. */
  12181. spriteCellHeight: number;
  12182. /**
  12183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12184. */
  12185. spriteRandomStartCell: boolean;
  12186. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12187. translationPivot: Vector2;
  12188. /** @hidden */
  12189. protected _isAnimationSheetEnabled: boolean;
  12190. /**
  12191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12192. */
  12193. beginAnimationOnStart: boolean;
  12194. /**
  12195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12196. */
  12197. beginAnimationFrom: number;
  12198. /**
  12199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12200. */
  12201. beginAnimationTo: number;
  12202. /**
  12203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12204. */
  12205. beginAnimationLoop: boolean;
  12206. /**
  12207. * Gets or sets a world offset applied to all particles
  12208. */
  12209. worldOffset: Vector3;
  12210. /**
  12211. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12212. */
  12213. get isAnimationSheetEnabled(): boolean;
  12214. set isAnimationSheetEnabled(value: boolean);
  12215. /**
  12216. * Get hosting scene
  12217. * @returns the scene
  12218. */
  12219. getScene(): Nullable<Scene>;
  12220. /**
  12221. * You can use gravity if you want to give an orientation to your particles.
  12222. */
  12223. gravity: Vector3;
  12224. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12225. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12226. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12227. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12228. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12229. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12230. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12231. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12232. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12233. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12234. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12235. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12236. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12237. /**
  12238. * Defines the delay in milliseconds before starting the system (0 by default)
  12239. */
  12240. startDelay: number;
  12241. /**
  12242. * Gets the current list of drag gradients.
  12243. * You must use addDragGradient and removeDragGradient to udpate this list
  12244. * @returns the list of drag gradients
  12245. */
  12246. getDragGradients(): Nullable<Array<FactorGradient>>;
  12247. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12248. limitVelocityDamping: number;
  12249. /**
  12250. * Gets the current list of limit velocity gradients.
  12251. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12252. * @returns the list of limit velocity gradients
  12253. */
  12254. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12255. /**
  12256. * Gets the current list of color gradients.
  12257. * You must use addColorGradient and removeColorGradient to udpate this list
  12258. * @returns the list of color gradients
  12259. */
  12260. getColorGradients(): Nullable<Array<ColorGradient>>;
  12261. /**
  12262. * Gets the current list of size gradients.
  12263. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12264. * @returns the list of size gradients
  12265. */
  12266. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12267. /**
  12268. * Gets the current list of color remap gradients.
  12269. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12270. * @returns the list of color remap gradients
  12271. */
  12272. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12273. /**
  12274. * Gets the current list of alpha remap gradients.
  12275. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12276. * @returns the list of alpha remap gradients
  12277. */
  12278. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12279. /**
  12280. * Gets the current list of life time gradients.
  12281. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12282. * @returns the list of life time gradients
  12283. */
  12284. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12285. /**
  12286. * Gets the current list of angular speed gradients.
  12287. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12288. * @returns the list of angular speed gradients
  12289. */
  12290. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12291. /**
  12292. * Gets the current list of velocity gradients.
  12293. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12294. * @returns the list of velocity gradients
  12295. */
  12296. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12297. /**
  12298. * Gets the current list of start size gradients.
  12299. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12300. * @returns the list of start size gradients
  12301. */
  12302. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12303. /**
  12304. * Gets the current list of emit rate gradients.
  12305. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12306. * @returns the list of emit rate gradients
  12307. */
  12308. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12309. /**
  12310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12311. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12312. */
  12313. get direction1(): Vector3;
  12314. set direction1(value: Vector3);
  12315. /**
  12316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12318. */
  12319. get direction2(): Vector3;
  12320. set direction2(value: Vector3);
  12321. /**
  12322. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12324. */
  12325. get minEmitBox(): Vector3;
  12326. set minEmitBox(value: Vector3);
  12327. /**
  12328. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12329. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12330. */
  12331. get maxEmitBox(): Vector3;
  12332. set maxEmitBox(value: Vector3);
  12333. /**
  12334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12335. */
  12336. color1: Color4;
  12337. /**
  12338. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12339. */
  12340. color2: Color4;
  12341. /**
  12342. * Color the particle will have at the end of its lifetime
  12343. */
  12344. colorDead: Color4;
  12345. /**
  12346. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12347. */
  12348. textureMask: Color4;
  12349. /**
  12350. * The particle emitter type defines the emitter used by the particle system.
  12351. * It can be for example box, sphere, or cone...
  12352. */
  12353. particleEmitterType: IParticleEmitterType;
  12354. /** @hidden */
  12355. _isSubEmitter: boolean;
  12356. /**
  12357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12359. */
  12360. billboardMode: number;
  12361. protected _isBillboardBased: boolean;
  12362. /**
  12363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12364. */
  12365. get isBillboardBased(): boolean;
  12366. set isBillboardBased(value: boolean);
  12367. /**
  12368. * The scene the particle system belongs to.
  12369. */
  12370. protected _scene: Nullable<Scene>;
  12371. /**
  12372. * The engine the particle system belongs to.
  12373. */
  12374. protected _engine: ThinEngine;
  12375. /**
  12376. * Local cache of defines for image processing.
  12377. */
  12378. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12379. /**
  12380. * Default configuration related to image processing available in the standard Material.
  12381. */
  12382. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12383. /**
  12384. * Gets the image processing configuration used either in this material.
  12385. */
  12386. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12387. /**
  12388. * Sets the Default image processing configuration used either in the this material.
  12389. *
  12390. * If sets to null, the scene one is in use.
  12391. */
  12392. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12393. /**
  12394. * Attaches a new image processing configuration to the Standard Material.
  12395. * @param configuration
  12396. */
  12397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12398. /** @hidden */
  12399. protected _reset(): void;
  12400. /** @hidden */
  12401. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12402. /**
  12403. * Instantiates a particle system.
  12404. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12405. * @param name The name of the particle system
  12406. */
  12407. constructor(name: string);
  12408. /**
  12409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12412. * @returns the emitter
  12413. */
  12414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12415. /**
  12416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12417. * @param radius The radius of the hemisphere to emit from
  12418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12419. * @returns the emitter
  12420. */
  12421. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12422. /**
  12423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12424. * @param radius The radius of the sphere to emit from
  12425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12426. * @returns the emitter
  12427. */
  12428. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12429. /**
  12430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12431. * @param radius The radius of the sphere to emit from
  12432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12434. * @returns the emitter
  12435. */
  12436. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12437. /**
  12438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12439. * @param radius The radius of the emission cylinder
  12440. * @param height The height of the emission cylinder
  12441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12443. * @returns the emitter
  12444. */
  12445. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12446. /**
  12447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12448. * @param radius The radius of the cylinder to emit from
  12449. * @param height The height of the emission cylinder
  12450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12453. * @returns the emitter
  12454. */
  12455. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12456. /**
  12457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12458. * @param radius The radius of the cone to emit from
  12459. * @param angle The base angle of the cone
  12460. * @returns the emitter
  12461. */
  12462. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12463. /**
  12464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12469. * @returns the emitter
  12470. */
  12471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12472. }
  12473. }
  12474. declare module BABYLON {
  12475. /**
  12476. * Type of sub emitter
  12477. */
  12478. export enum SubEmitterType {
  12479. /**
  12480. * Attached to the particle over it's lifetime
  12481. */
  12482. ATTACHED = 0,
  12483. /**
  12484. * Created when the particle dies
  12485. */
  12486. END = 1
  12487. }
  12488. /**
  12489. * Sub emitter class used to emit particles from an existing particle
  12490. */
  12491. export class SubEmitter {
  12492. /**
  12493. * the particle system to be used by the sub emitter
  12494. */
  12495. particleSystem: ParticleSystem;
  12496. /**
  12497. * Type of the submitter (Default: END)
  12498. */
  12499. type: SubEmitterType;
  12500. /**
  12501. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12502. * Note: This only is supported when using an emitter of type Mesh
  12503. */
  12504. inheritDirection: boolean;
  12505. /**
  12506. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12507. */
  12508. inheritedVelocityAmount: number;
  12509. /**
  12510. * Creates a sub emitter
  12511. * @param particleSystem the particle system to be used by the sub emitter
  12512. */
  12513. constructor(
  12514. /**
  12515. * the particle system to be used by the sub emitter
  12516. */
  12517. particleSystem: ParticleSystem);
  12518. /**
  12519. * Clones the sub emitter
  12520. * @returns the cloned sub emitter
  12521. */
  12522. clone(): SubEmitter;
  12523. /**
  12524. * Serialize current object to a JSON object
  12525. * @returns the serialized object
  12526. */
  12527. serialize(): any;
  12528. /** @hidden */
  12529. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12530. /**
  12531. * Creates a new SubEmitter from a serialized JSON version
  12532. * @param serializationObject defines the JSON object to read from
  12533. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12534. * @param rootUrl defines the rootUrl for data loading
  12535. * @returns a new SubEmitter
  12536. */
  12537. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12538. /** Release associated resources */
  12539. dispose(): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /** @hidden */
  12544. export var imageProcessingDeclaration: {
  12545. name: string;
  12546. shader: string;
  12547. };
  12548. }
  12549. declare module BABYLON {
  12550. /** @hidden */
  12551. export var imageProcessingFunctions: {
  12552. name: string;
  12553. shader: string;
  12554. };
  12555. }
  12556. declare module BABYLON {
  12557. /** @hidden */
  12558. export var particlesPixelShader: {
  12559. name: string;
  12560. shader: string;
  12561. };
  12562. }
  12563. declare module BABYLON {
  12564. /** @hidden */
  12565. export var particlesVertexShader: {
  12566. name: string;
  12567. shader: string;
  12568. };
  12569. }
  12570. declare module BABYLON {
  12571. /**
  12572. * Interface used to define entities containing multiple clip planes
  12573. */
  12574. export interface IClipPlanesHolder {
  12575. /**
  12576. * Gets or sets the active clipplane 1
  12577. */
  12578. clipPlane: Nullable<Plane>;
  12579. /**
  12580. * Gets or sets the active clipplane 2
  12581. */
  12582. clipPlane2: Nullable<Plane>;
  12583. /**
  12584. * Gets or sets the active clipplane 3
  12585. */
  12586. clipPlane3: Nullable<Plane>;
  12587. /**
  12588. * Gets or sets the active clipplane 4
  12589. */
  12590. clipPlane4: Nullable<Plane>;
  12591. /**
  12592. * Gets or sets the active clipplane 5
  12593. */
  12594. clipPlane5: Nullable<Plane>;
  12595. /**
  12596. * Gets or sets the active clipplane 6
  12597. */
  12598. clipPlane6: Nullable<Plane>;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12604. *
  12605. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12606. *
  12607. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12608. */
  12609. export class ThinMaterialHelper {
  12610. /**
  12611. * Binds the clip plane information from the holder to the effect.
  12612. * @param effect The effect we are binding the data to
  12613. * @param holder The entity containing the clip plane information
  12614. */
  12615. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12616. }
  12617. }
  12618. declare module BABYLON {
  12619. interface ThinEngine {
  12620. /**
  12621. * Sets alpha constants used by some alpha blending modes
  12622. * @param r defines the red component
  12623. * @param g defines the green component
  12624. * @param b defines the blue component
  12625. * @param a defines the alpha component
  12626. */
  12627. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12628. /**
  12629. * Sets the current alpha mode
  12630. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12632. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12633. */
  12634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12635. /**
  12636. * Gets the current alpha mode
  12637. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12638. * @returns the current alpha mode
  12639. */
  12640. getAlphaMode(): number;
  12641. /**
  12642. * Sets the current alpha equation
  12643. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12644. */
  12645. setAlphaEquation(equation: number): void;
  12646. /**
  12647. * Gets the current alpha equation.
  12648. * @returns the current alpha equation
  12649. */
  12650. getAlphaEquation(): number;
  12651. }
  12652. }
  12653. declare module BABYLON {
  12654. /**
  12655. * This represents a particle system in Babylon.
  12656. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12657. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12658. * @example https://doc.babylonjs.com/babylon101/particles
  12659. */
  12660. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12661. /**
  12662. * Billboard mode will only apply to Y axis
  12663. */
  12664. static readonly BILLBOARDMODE_Y: number;
  12665. /**
  12666. * Billboard mode will apply to all axes
  12667. */
  12668. static readonly BILLBOARDMODE_ALL: number;
  12669. /**
  12670. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12671. */
  12672. static readonly BILLBOARDMODE_STRETCHED: number;
  12673. /**
  12674. * This function can be defined to provide custom update for active particles.
  12675. * This function will be called instead of regular update (age, position, color, etc.).
  12676. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12677. */
  12678. updateFunction: (particles: Particle[]) => void;
  12679. private _emitterWorldMatrix;
  12680. /**
  12681. * This function can be defined to specify initial direction for every new particle.
  12682. * It by default use the emitterType defined function
  12683. */
  12684. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12685. /**
  12686. * This function can be defined to specify initial position for every new particle.
  12687. * It by default use the emitterType defined function
  12688. */
  12689. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12690. /**
  12691. * @hidden
  12692. */
  12693. _inheritedVelocityOffset: Vector3;
  12694. /**
  12695. * An event triggered when the system is disposed
  12696. */
  12697. onDisposeObservable: Observable<IParticleSystem>;
  12698. /**
  12699. * An event triggered when the system is stopped
  12700. */
  12701. onStoppedObservable: Observable<IParticleSystem>;
  12702. private _onDisposeObserver;
  12703. /**
  12704. * Sets a callback that will be triggered when the system is disposed
  12705. */
  12706. set onDispose(callback: () => void);
  12707. private _particles;
  12708. private _epsilon;
  12709. private _capacity;
  12710. private _stockParticles;
  12711. private _newPartsExcess;
  12712. private _vertexData;
  12713. private _vertexBuffer;
  12714. private _vertexBuffers;
  12715. private _spriteBuffer;
  12716. private _indexBuffer;
  12717. private _effect;
  12718. private _customEffect;
  12719. private _cachedDefines;
  12720. private _scaledColorStep;
  12721. private _colorDiff;
  12722. private _scaledDirection;
  12723. private _scaledGravity;
  12724. private _currentRenderId;
  12725. private _alive;
  12726. private _useInstancing;
  12727. private _vertexArrayObject;
  12728. private _started;
  12729. private _stopped;
  12730. private _actualFrame;
  12731. private _scaledUpdateSpeed;
  12732. private _vertexBufferSize;
  12733. /** @hidden */
  12734. _currentEmitRateGradient: Nullable<FactorGradient>;
  12735. /** @hidden */
  12736. _currentEmitRate1: number;
  12737. /** @hidden */
  12738. _currentEmitRate2: number;
  12739. /** @hidden */
  12740. _currentStartSizeGradient: Nullable<FactorGradient>;
  12741. /** @hidden */
  12742. _currentStartSize1: number;
  12743. /** @hidden */
  12744. _currentStartSize2: number;
  12745. private readonly _rawTextureWidth;
  12746. private _rampGradientsTexture;
  12747. private _useRampGradients;
  12748. /** Gets or sets a matrix to use to compute projection */
  12749. defaultProjectionMatrix: Matrix;
  12750. /** Gets or sets a matrix to use to compute view */
  12751. defaultViewMatrix: Matrix;
  12752. /** Gets or sets a boolean indicating that ramp gradients must be used
  12753. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12754. */
  12755. get useRampGradients(): boolean;
  12756. set useRampGradients(value: boolean);
  12757. /**
  12758. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12759. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12760. */
  12761. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12762. private _subEmitters;
  12763. /**
  12764. * @hidden
  12765. * If the particle systems emitter should be disposed when the particle system is disposed
  12766. */
  12767. _disposeEmitterOnDispose: boolean;
  12768. /**
  12769. * The current active Sub-systems, this property is used by the root particle system only.
  12770. */
  12771. activeSubSystems: Array<ParticleSystem>;
  12772. /**
  12773. * Specifies if the particles are updated in emitter local space or world space
  12774. */
  12775. isLocal: boolean;
  12776. private _rootParticleSystem;
  12777. /**
  12778. * Gets the current list of active particles
  12779. */
  12780. get particles(): Particle[];
  12781. /**
  12782. * Gets the number of particles active at the same time.
  12783. * @returns The number of active particles.
  12784. */
  12785. getActiveCount(): number;
  12786. /**
  12787. * Returns the string "ParticleSystem"
  12788. * @returns a string containing the class name
  12789. */
  12790. getClassName(): string;
  12791. /**
  12792. * Gets a boolean indicating that the system is stopping
  12793. * @returns true if the system is currently stopping
  12794. */
  12795. isStopping(): boolean;
  12796. /**
  12797. * Gets the custom effect used to render the particles
  12798. * @param blendMode Blend mode for which the effect should be retrieved
  12799. * @returns The effect
  12800. */
  12801. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12802. /**
  12803. * Sets the custom effect used to render the particles
  12804. * @param effect The effect to set
  12805. * @param blendMode Blend mode for which the effect should be set
  12806. */
  12807. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12808. /** @hidden */
  12809. private _onBeforeDrawParticlesObservable;
  12810. /**
  12811. * Observable that will be called just before the particles are drawn
  12812. */
  12813. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12814. /**
  12815. * Gets the name of the particle vertex shader
  12816. */
  12817. get vertexShaderName(): string;
  12818. /**
  12819. * Instantiates a particle system.
  12820. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12821. * @param name The name of the particle system
  12822. * @param capacity The max number of particles alive at the same time
  12823. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12824. * @param customEffect a custom effect used to change the way particles are rendered by default
  12825. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12826. * @param epsilon Offset used to render the particles
  12827. */
  12828. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12829. private _addFactorGradient;
  12830. private _removeFactorGradient;
  12831. /**
  12832. * Adds a new life time gradient
  12833. * @param gradient defines the gradient to use (between 0 and 1)
  12834. * @param factor defines the life time factor to affect to the specified gradient
  12835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12836. * @returns the current particle system
  12837. */
  12838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12839. /**
  12840. * Remove a specific life time gradient
  12841. * @param gradient defines the gradient to remove
  12842. * @returns the current particle system
  12843. */
  12844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12845. /**
  12846. * Adds a new size gradient
  12847. * @param gradient defines the gradient to use (between 0 and 1)
  12848. * @param factor defines the size factor to affect to the specified gradient
  12849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12850. * @returns the current particle system
  12851. */
  12852. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12853. /**
  12854. * Remove a specific size gradient
  12855. * @param gradient defines the gradient to remove
  12856. * @returns the current particle system
  12857. */
  12858. removeSizeGradient(gradient: number): IParticleSystem;
  12859. /**
  12860. * Adds a new color remap gradient
  12861. * @param gradient defines the gradient to use (between 0 and 1)
  12862. * @param min defines the color remap minimal range
  12863. * @param max defines the color remap maximal range
  12864. * @returns the current particle system
  12865. */
  12866. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12867. /**
  12868. * Remove a specific color remap gradient
  12869. * @param gradient defines the gradient to remove
  12870. * @returns the current particle system
  12871. */
  12872. removeColorRemapGradient(gradient: number): IParticleSystem;
  12873. /**
  12874. * Adds a new alpha remap gradient
  12875. * @param gradient defines the gradient to use (between 0 and 1)
  12876. * @param min defines the alpha remap minimal range
  12877. * @param max defines the alpha remap maximal range
  12878. * @returns the current particle system
  12879. */
  12880. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12881. /**
  12882. * Remove a specific alpha remap gradient
  12883. * @param gradient defines the gradient to remove
  12884. * @returns the current particle system
  12885. */
  12886. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12887. /**
  12888. * Adds a new angular speed gradient
  12889. * @param gradient defines the gradient to use (between 0 and 1)
  12890. * @param factor defines the angular speed to affect to the specified gradient
  12891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12892. * @returns the current particle system
  12893. */
  12894. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12895. /**
  12896. * Remove a specific angular speed gradient
  12897. * @param gradient defines the gradient to remove
  12898. * @returns the current particle system
  12899. */
  12900. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12901. /**
  12902. * Adds a new velocity gradient
  12903. * @param gradient defines the gradient to use (between 0 and 1)
  12904. * @param factor defines the velocity to affect to the specified gradient
  12905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12906. * @returns the current particle system
  12907. */
  12908. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12909. /**
  12910. * Remove a specific velocity gradient
  12911. * @param gradient defines the gradient to remove
  12912. * @returns the current particle system
  12913. */
  12914. removeVelocityGradient(gradient: number): IParticleSystem;
  12915. /**
  12916. * Adds a new limit velocity gradient
  12917. * @param gradient defines the gradient to use (between 0 and 1)
  12918. * @param factor defines the limit velocity value to affect to the specified gradient
  12919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12920. * @returns the current particle system
  12921. */
  12922. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12923. /**
  12924. * Remove a specific limit velocity gradient
  12925. * @param gradient defines the gradient to remove
  12926. * @returns the current particle system
  12927. */
  12928. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12929. /**
  12930. * Adds a new drag gradient
  12931. * @param gradient defines the gradient to use (between 0 and 1)
  12932. * @param factor defines the drag value to affect to the specified gradient
  12933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12934. * @returns the current particle system
  12935. */
  12936. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12937. /**
  12938. * Remove a specific drag gradient
  12939. * @param gradient defines the gradient to remove
  12940. * @returns the current particle system
  12941. */
  12942. removeDragGradient(gradient: number): IParticleSystem;
  12943. /**
  12944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12945. * @param gradient defines the gradient to use (between 0 and 1)
  12946. * @param factor defines the emit rate value to affect to the specified gradient
  12947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12948. * @returns the current particle system
  12949. */
  12950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12951. /**
  12952. * Remove a specific emit rate gradient
  12953. * @param gradient defines the gradient to remove
  12954. * @returns the current particle system
  12955. */
  12956. removeEmitRateGradient(gradient: number): IParticleSystem;
  12957. /**
  12958. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12959. * @param gradient defines the gradient to use (between 0 and 1)
  12960. * @param factor defines the start size value to affect to the specified gradient
  12961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12962. * @returns the current particle system
  12963. */
  12964. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12965. /**
  12966. * Remove a specific start size gradient
  12967. * @param gradient defines the gradient to remove
  12968. * @returns the current particle system
  12969. */
  12970. removeStartSizeGradient(gradient: number): IParticleSystem;
  12971. private _createRampGradientTexture;
  12972. /**
  12973. * Gets the current list of ramp gradients.
  12974. * You must use addRampGradient and removeRampGradient to udpate this list
  12975. * @returns the list of ramp gradients
  12976. */
  12977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12978. /** Force the system to rebuild all gradients that need to be resync */
  12979. forceRefreshGradients(): void;
  12980. private _syncRampGradientTexture;
  12981. /**
  12982. * Adds a new ramp gradient used to remap particle colors
  12983. * @param gradient defines the gradient to use (between 0 and 1)
  12984. * @param color defines the color to affect to the specified gradient
  12985. * @returns the current particle system
  12986. */
  12987. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12988. /**
  12989. * Remove a specific ramp gradient
  12990. * @param gradient defines the gradient to remove
  12991. * @returns the current particle system
  12992. */
  12993. removeRampGradient(gradient: number): ParticleSystem;
  12994. /**
  12995. * Adds a new color gradient
  12996. * @param gradient defines the gradient to use (between 0 and 1)
  12997. * @param color1 defines the color to affect to the specified gradient
  12998. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12999. * @returns this particle system
  13000. */
  13001. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13002. /**
  13003. * Remove a specific color gradient
  13004. * @param gradient defines the gradient to remove
  13005. * @returns this particle system
  13006. */
  13007. removeColorGradient(gradient: number): IParticleSystem;
  13008. private _fetchR;
  13009. protected _reset(): void;
  13010. private _resetEffect;
  13011. private _createVertexBuffers;
  13012. private _createIndexBuffer;
  13013. /**
  13014. * Gets the maximum number of particles active at the same time.
  13015. * @returns The max number of active particles.
  13016. */
  13017. getCapacity(): number;
  13018. /**
  13019. * Gets whether there are still active particles in the system.
  13020. * @returns True if it is alive, otherwise false.
  13021. */
  13022. isAlive(): boolean;
  13023. /**
  13024. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13025. * @returns True if it has been started, otherwise false.
  13026. */
  13027. isStarted(): boolean;
  13028. private _prepareSubEmitterInternalArray;
  13029. /**
  13030. * Starts the particle system and begins to emit
  13031. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13032. */
  13033. start(delay?: number): void;
  13034. /**
  13035. * Stops the particle system.
  13036. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13037. */
  13038. stop(stopSubEmitters?: boolean): void;
  13039. /**
  13040. * Remove all active particles
  13041. */
  13042. reset(): void;
  13043. /**
  13044. * @hidden (for internal use only)
  13045. */
  13046. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13047. /**
  13048. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13049. * Its lifetime will start back at 0.
  13050. */
  13051. recycleParticle: (particle: Particle) => void;
  13052. private _stopSubEmitters;
  13053. private _createParticle;
  13054. private _removeFromRoot;
  13055. private _emitFromParticle;
  13056. private _update;
  13057. /** @hidden */
  13058. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13059. /** @hidden */
  13060. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13061. /**
  13062. * Fill the defines array according to the current settings of the particle system
  13063. * @param defines Array to be updated
  13064. * @param blendMode blend mode to take into account when updating the array
  13065. */
  13066. fillDefines(defines: Array<string>, blendMode: number): void;
  13067. /**
  13068. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13069. * @param uniforms Uniforms array to fill
  13070. * @param attributes Attributes array to fill
  13071. * @param samplers Samplers array to fill
  13072. */
  13073. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13074. /** @hidden */
  13075. private _getEffect;
  13076. /**
  13077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13079. */
  13080. animate(preWarmOnly?: boolean): void;
  13081. private _appendParticleVertices;
  13082. /**
  13083. * Rebuilds the particle system.
  13084. */
  13085. rebuild(): void;
  13086. /**
  13087. * Is this system ready to be used/rendered
  13088. * @return true if the system is ready
  13089. */
  13090. isReady(): boolean;
  13091. private _render;
  13092. /**
  13093. * Renders the particle system in its current state.
  13094. * @returns the current number of particles
  13095. */
  13096. render(): number;
  13097. /**
  13098. * Disposes the particle system and free the associated resources
  13099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13100. */
  13101. dispose(disposeTexture?: boolean): void;
  13102. /**
  13103. * Clones the particle system.
  13104. * @param name The name of the cloned object
  13105. * @param newEmitter The new emitter to use
  13106. * @returns the cloned particle system
  13107. */
  13108. clone(name: string, newEmitter: any): ParticleSystem;
  13109. /**
  13110. * Serializes the particle system to a JSON object
  13111. * @param serializeTexture defines if the texture must be serialized as well
  13112. * @returns the JSON object
  13113. */
  13114. serialize(serializeTexture?: boolean): any;
  13115. /** @hidden */
  13116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13117. /** @hidden */
  13118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13119. /**
  13120. * Parses a JSON object to create a particle system.
  13121. * @param parsedParticleSystem The JSON object to parse
  13122. * @param sceneOrEngine The scene or the engine to create the particle system in
  13123. * @param rootUrl The root url to use to load external dependencies like texture
  13124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13125. * @returns the Parsed particle system
  13126. */
  13127. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. /**
  13132. * A particle represents one of the element emitted by a particle system.
  13133. * This is mainly define by its coordinates, direction, velocity and age.
  13134. */
  13135. export class Particle {
  13136. /**
  13137. * The particle system the particle belongs to.
  13138. */
  13139. particleSystem: ParticleSystem;
  13140. private static _Count;
  13141. /**
  13142. * Unique ID of the particle
  13143. */
  13144. id: number;
  13145. /**
  13146. * The world position of the particle in the scene.
  13147. */
  13148. position: Vector3;
  13149. /**
  13150. * The world direction of the particle in the scene.
  13151. */
  13152. direction: Vector3;
  13153. /**
  13154. * The color of the particle.
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * The color change of the particle per step.
  13159. */
  13160. colorStep: Color4;
  13161. /**
  13162. * Defines how long will the life of the particle be.
  13163. */
  13164. lifeTime: number;
  13165. /**
  13166. * The current age of the particle.
  13167. */
  13168. age: number;
  13169. /**
  13170. * The current size of the particle.
  13171. */
  13172. size: number;
  13173. /**
  13174. * The current scale of the particle.
  13175. */
  13176. scale: Vector2;
  13177. /**
  13178. * The current angle of the particle.
  13179. */
  13180. angle: number;
  13181. /**
  13182. * Defines how fast is the angle changing.
  13183. */
  13184. angularSpeed: number;
  13185. /**
  13186. * Defines the cell index used by the particle to be rendered from a sprite.
  13187. */
  13188. cellIndex: number;
  13189. /**
  13190. * The information required to support color remapping
  13191. */
  13192. remapData: Vector4;
  13193. /** @hidden */
  13194. _randomCellOffset?: number;
  13195. /** @hidden */
  13196. _initialDirection: Nullable<Vector3>;
  13197. /** @hidden */
  13198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13199. /** @hidden */
  13200. _initialStartSpriteCellID: number;
  13201. /** @hidden */
  13202. _initialEndSpriteCellID: number;
  13203. /** @hidden */
  13204. _currentColorGradient: Nullable<ColorGradient>;
  13205. /** @hidden */
  13206. _currentColor1: Color4;
  13207. /** @hidden */
  13208. _currentColor2: Color4;
  13209. /** @hidden */
  13210. _currentSizeGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentSize1: number;
  13213. /** @hidden */
  13214. _currentSize2: number;
  13215. /** @hidden */
  13216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13217. /** @hidden */
  13218. _currentAngularSpeed1: number;
  13219. /** @hidden */
  13220. _currentAngularSpeed2: number;
  13221. /** @hidden */
  13222. _currentVelocityGradient: Nullable<FactorGradient>;
  13223. /** @hidden */
  13224. _currentVelocity1: number;
  13225. /** @hidden */
  13226. _currentVelocity2: number;
  13227. /** @hidden */
  13228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13229. /** @hidden */
  13230. _currentLimitVelocity1: number;
  13231. /** @hidden */
  13232. _currentLimitVelocity2: number;
  13233. /** @hidden */
  13234. _currentDragGradient: Nullable<FactorGradient>;
  13235. /** @hidden */
  13236. _currentDrag1: number;
  13237. /** @hidden */
  13238. _currentDrag2: number;
  13239. /** @hidden */
  13240. _randomNoiseCoordinates1: Vector3;
  13241. /** @hidden */
  13242. _randomNoiseCoordinates2: Vector3;
  13243. /** @hidden */
  13244. _localPosition?: Vector3;
  13245. /**
  13246. * Creates a new instance Particle
  13247. * @param particleSystem the particle system the particle belongs to
  13248. */
  13249. constructor(
  13250. /**
  13251. * The particle system the particle belongs to.
  13252. */
  13253. particleSystem: ParticleSystem);
  13254. private updateCellInfoFromSystem;
  13255. /**
  13256. * Defines how the sprite cell index is updated for the particle
  13257. */
  13258. updateCellIndex(): void;
  13259. /** @hidden */
  13260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13261. /** @hidden */
  13262. _inheritParticleInfoToSubEmitters(): void;
  13263. /** @hidden */
  13264. _reset(): void;
  13265. /**
  13266. * Copy the properties of particle to another one.
  13267. * @param other the particle to copy the information to.
  13268. */
  13269. copyTo(other: Particle): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * Particle emitter represents a volume emitting particles.
  13275. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13276. */
  13277. export interface IParticleEmitterType {
  13278. /**
  13279. * Called by the particle System when the direction is computed for the created particle.
  13280. * @param worldMatrix is the world matrix of the particle system
  13281. * @param directionToUpdate is the direction vector to update with the result
  13282. * @param particle is the particle we are computed the direction for
  13283. * @param isLocal defines if the direction should be set in local space
  13284. */
  13285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13286. /**
  13287. * Called by the particle System when the position is computed for the created particle.
  13288. * @param worldMatrix is the world matrix of the particle system
  13289. * @param positionToUpdate is the position vector to update with the result
  13290. * @param particle is the particle we are computed the position for
  13291. * @param isLocal defines if the position should be set in local space
  13292. */
  13293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13294. /**
  13295. * Clones the current emitter and returns a copy of it
  13296. * @returns the new emitter
  13297. */
  13298. clone(): IParticleEmitterType;
  13299. /**
  13300. * Called by the GPUParticleSystem to setup the update shader
  13301. * @param effect defines the update shader
  13302. */
  13303. applyToShader(effect: Effect): void;
  13304. /**
  13305. * Returns a string to use to update the GPU particles update shader
  13306. * @returns the effect defines string
  13307. */
  13308. getEffectDefines(): string;
  13309. /**
  13310. * Returns a string representing the class name
  13311. * @returns a string containing the class name
  13312. */
  13313. getClassName(): string;
  13314. /**
  13315. * Serializes the particle system to a JSON object.
  13316. * @returns the JSON object
  13317. */
  13318. serialize(): any;
  13319. /**
  13320. * Parse properties from a JSON object
  13321. * @param serializationObject defines the JSON object
  13322. * @param scene defines the hosting scene
  13323. */
  13324. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. /**
  13329. * Particle emitter emitting particles from the inside of a box.
  13330. * It emits the particles randomly between 2 given directions.
  13331. */
  13332. export class BoxParticleEmitter implements IParticleEmitterType {
  13333. /**
  13334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13335. */
  13336. direction1: Vector3;
  13337. /**
  13338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13339. */
  13340. direction2: Vector3;
  13341. /**
  13342. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13343. */
  13344. minEmitBox: Vector3;
  13345. /**
  13346. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13347. */
  13348. maxEmitBox: Vector3;
  13349. /**
  13350. * Creates a new instance BoxParticleEmitter
  13351. */
  13352. constructor();
  13353. /**
  13354. * Called by the particle System when the direction is computed for the created particle.
  13355. * @param worldMatrix is the world matrix of the particle system
  13356. * @param directionToUpdate is the direction vector to update with the result
  13357. * @param particle is the particle we are computed the direction for
  13358. * @param isLocal defines if the direction should be set in local space
  13359. */
  13360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13361. /**
  13362. * Called by the particle System when the position is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param positionToUpdate is the position vector to update with the result
  13365. * @param particle is the particle we are computed the position for
  13366. * @param isLocal defines if the position should be set in local space
  13367. */
  13368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Clones the current emitter and returns a copy of it
  13371. * @returns the new emitter
  13372. */
  13373. clone(): BoxParticleEmitter;
  13374. /**
  13375. * Called by the GPUParticleSystem to setup the update shader
  13376. * @param effect defines the update shader
  13377. */
  13378. applyToShader(effect: Effect): void;
  13379. /**
  13380. * Returns a string to use to update the GPU particles update shader
  13381. * @returns a string containng the defines string
  13382. */
  13383. getEffectDefines(): string;
  13384. /**
  13385. * Returns the string "BoxParticleEmitter"
  13386. * @returns a string containing the class name
  13387. */
  13388. getClassName(): string;
  13389. /**
  13390. * Serializes the particle system to a JSON object.
  13391. * @returns the JSON object
  13392. */
  13393. serialize(): any;
  13394. /**
  13395. * Parse properties from a JSON object
  13396. * @param serializationObject defines the JSON object
  13397. */
  13398. parse(serializationObject: any): void;
  13399. }
  13400. }
  13401. declare module BABYLON {
  13402. /**
  13403. * Particle emitter emitting particles from the inside of a cone.
  13404. * It emits the particles alongside the cone volume from the base to the particle.
  13405. * The emission direction might be randomized.
  13406. */
  13407. export class ConeParticleEmitter implements IParticleEmitterType {
  13408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13409. directionRandomizer: number;
  13410. private _radius;
  13411. private _angle;
  13412. private _height;
  13413. /**
  13414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13415. */
  13416. radiusRange: number;
  13417. /**
  13418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13419. */
  13420. heightRange: number;
  13421. /**
  13422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13423. */
  13424. emitFromSpawnPointOnly: boolean;
  13425. /**
  13426. * Gets or sets the radius of the emission cone
  13427. */
  13428. get radius(): number;
  13429. set radius(value: number);
  13430. /**
  13431. * Gets or sets the angle of the emission cone
  13432. */
  13433. get angle(): number;
  13434. set angle(value: number);
  13435. private _buildHeight;
  13436. /**
  13437. * Creates a new instance ConeParticleEmitter
  13438. * @param radius the radius of the emission cone (1 by default)
  13439. * @param angle the cone base angle (PI by default)
  13440. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13441. */
  13442. constructor(radius?: number, angle?: number,
  13443. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13444. directionRandomizer?: number);
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): ConeParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "ConeParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Particle emitter emitting particles from the inside of a cylinder.
  13496. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13497. */
  13498. export class CylinderParticleEmitter implements IParticleEmitterType {
  13499. /**
  13500. * The radius of the emission cylinder.
  13501. */
  13502. radius: number;
  13503. /**
  13504. * The height of the emission cylinder.
  13505. */
  13506. height: number;
  13507. /**
  13508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * How much to randomize the particle direction [0-1].
  13513. */
  13514. directionRandomizer: number;
  13515. /**
  13516. * Creates a new instance CylinderParticleEmitter
  13517. * @param radius the radius of the emission cylinder (1 by default)
  13518. * @param height the height of the emission cylinder (1 by default)
  13519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13521. */
  13522. constructor(
  13523. /**
  13524. * The radius of the emission cylinder.
  13525. */
  13526. radius?: number,
  13527. /**
  13528. * The height of the emission cylinder.
  13529. */
  13530. height?: number,
  13531. /**
  13532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13533. */
  13534. radiusRange?: number,
  13535. /**
  13536. * How much to randomize the particle direction [0-1].
  13537. */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): CylinderParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "CylinderParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. /**
  13587. * Particle emitter emitting particles from the inside of a cylinder.
  13588. * It emits the particles randomly between two vectors.
  13589. */
  13590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13591. /**
  13592. * The min limit of the emission direction.
  13593. */
  13594. direction1: Vector3;
  13595. /**
  13596. * The max limit of the emission direction.
  13597. */
  13598. direction2: Vector3;
  13599. /**
  13600. * Creates a new instance CylinderDirectedParticleEmitter
  13601. * @param radius the radius of the emission cylinder (1 by default)
  13602. * @param height the height of the emission cylinder (1 by default)
  13603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13604. * @param direction1 the min limit of the emission direction (up vector by default)
  13605. * @param direction2 the max limit of the emission direction (up vector by default)
  13606. */
  13607. constructor(radius?: number, height?: number, radiusRange?: number,
  13608. /**
  13609. * The min limit of the emission direction.
  13610. */
  13611. direction1?: Vector3,
  13612. /**
  13613. * The max limit of the emission direction.
  13614. */
  13615. direction2?: Vector3);
  13616. /**
  13617. * Called by the particle System when the direction is computed for the created particle.
  13618. * @param worldMatrix is the world matrix of the particle system
  13619. * @param directionToUpdate is the direction vector to update with the result
  13620. * @param particle is the particle we are computed the direction for
  13621. */
  13622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13623. /**
  13624. * Clones the current emitter and returns a copy of it
  13625. * @returns the new emitter
  13626. */
  13627. clone(): CylinderDirectedParticleEmitter;
  13628. /**
  13629. * Called by the GPUParticleSystem to setup the update shader
  13630. * @param effect defines the update shader
  13631. */
  13632. applyToShader(effect: Effect): void;
  13633. /**
  13634. * Returns a string to use to update the GPU particles update shader
  13635. * @returns a string containng the defines string
  13636. */
  13637. getEffectDefines(): string;
  13638. /**
  13639. * Returns the string "CylinderDirectedParticleEmitter"
  13640. * @returns a string containing the class name
  13641. */
  13642. getClassName(): string;
  13643. /**
  13644. * Serializes the particle system to a JSON object.
  13645. * @returns the JSON object
  13646. */
  13647. serialize(): any;
  13648. /**
  13649. * Parse properties from a JSON object
  13650. * @param serializationObject defines the JSON object
  13651. */
  13652. parse(serializationObject: any): void;
  13653. }
  13654. }
  13655. declare module BABYLON {
  13656. /**
  13657. * Particle emitter emitting particles from the inside of a hemisphere.
  13658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13659. */
  13660. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13661. /**
  13662. * The radius of the emission hemisphere.
  13663. */
  13664. radius: number;
  13665. /**
  13666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13667. */
  13668. radiusRange: number;
  13669. /**
  13670. * How much to randomize the particle direction [0-1].
  13671. */
  13672. directionRandomizer: number;
  13673. /**
  13674. * Creates a new instance HemisphericParticleEmitter
  13675. * @param radius the radius of the emission hemisphere (1 by default)
  13676. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13678. */
  13679. constructor(
  13680. /**
  13681. * The radius of the emission hemisphere.
  13682. */
  13683. radius?: number,
  13684. /**
  13685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13686. */
  13687. radiusRange?: number,
  13688. /**
  13689. * How much to randomize the particle direction [0-1].
  13690. */
  13691. directionRandomizer?: number);
  13692. /**
  13693. * Called by the particle System when the direction is computed for the created particle.
  13694. * @param worldMatrix is the world matrix of the particle system
  13695. * @param directionToUpdate is the direction vector to update with the result
  13696. * @param particle is the particle we are computed the direction for
  13697. * @param isLocal defines if the direction should be set in local space
  13698. */
  13699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13700. /**
  13701. * Called by the particle System when the position is computed for the created particle.
  13702. * @param worldMatrix is the world matrix of the particle system
  13703. * @param positionToUpdate is the position vector to update with the result
  13704. * @param particle is the particle we are computed the position for
  13705. * @param isLocal defines if the position should be set in local space
  13706. */
  13707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): HemisphericParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "HemisphericParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a point.
  13743. * It emits the particles randomly between 2 given directions.
  13744. */
  13745. export class PointParticleEmitter implements IParticleEmitterType {
  13746. /**
  13747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13748. */
  13749. direction1: Vector3;
  13750. /**
  13751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13752. */
  13753. direction2: Vector3;
  13754. /**
  13755. * Creates a new instance PointParticleEmitter
  13756. */
  13757. constructor();
  13758. /**
  13759. * Called by the particle System when the direction is computed for the created particle.
  13760. * @param worldMatrix is the world matrix of the particle system
  13761. * @param directionToUpdate is the direction vector to update with the result
  13762. * @param particle is the particle we are computed the direction for
  13763. * @param isLocal defines if the direction should be set in local space
  13764. */
  13765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13766. /**
  13767. * Called by the particle System when the position is computed for the created particle.
  13768. * @param worldMatrix is the world matrix of the particle system
  13769. * @param positionToUpdate is the position vector to update with the result
  13770. * @param particle is the particle we are computed the position for
  13771. * @param isLocal defines if the position should be set in local space
  13772. */
  13773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13774. /**
  13775. * Clones the current emitter and returns a copy of it
  13776. * @returns the new emitter
  13777. */
  13778. clone(): PointParticleEmitter;
  13779. /**
  13780. * Called by the GPUParticleSystem to setup the update shader
  13781. * @param effect defines the update shader
  13782. */
  13783. applyToShader(effect: Effect): void;
  13784. /**
  13785. * Returns a string to use to update the GPU particles update shader
  13786. * @returns a string containng the defines string
  13787. */
  13788. getEffectDefines(): string;
  13789. /**
  13790. * Returns the string "PointParticleEmitter"
  13791. * @returns a string containing the class name
  13792. */
  13793. getClassName(): string;
  13794. /**
  13795. * Serializes the particle system to a JSON object.
  13796. * @returns the JSON object
  13797. */
  13798. serialize(): any;
  13799. /**
  13800. * Parse properties from a JSON object
  13801. * @param serializationObject defines the JSON object
  13802. */
  13803. parse(serializationObject: any): void;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a sphere.
  13809. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13810. */
  13811. export class SphereParticleEmitter implements IParticleEmitterType {
  13812. /**
  13813. * The radius of the emission sphere.
  13814. */
  13815. radius: number;
  13816. /**
  13817. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13818. */
  13819. radiusRange: number;
  13820. /**
  13821. * How much to randomize the particle direction [0-1].
  13822. */
  13823. directionRandomizer: number;
  13824. /**
  13825. * Creates a new instance SphereParticleEmitter
  13826. * @param radius the radius of the emission sphere (1 by default)
  13827. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13828. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13829. */
  13830. constructor(
  13831. /**
  13832. * The radius of the emission sphere.
  13833. */
  13834. radius?: number,
  13835. /**
  13836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13837. */
  13838. radiusRange?: number,
  13839. /**
  13840. * How much to randomize the particle direction [0-1].
  13841. */
  13842. directionRandomizer?: number);
  13843. /**
  13844. * Called by the particle System when the direction is computed for the created particle.
  13845. * @param worldMatrix is the world matrix of the particle system
  13846. * @param directionToUpdate is the direction vector to update with the result
  13847. * @param particle is the particle we are computed the direction for
  13848. * @param isLocal defines if the direction should be set in local space
  13849. */
  13850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13851. /**
  13852. * Called by the particle System when the position is computed for the created particle.
  13853. * @param worldMatrix is the world matrix of the particle system
  13854. * @param positionToUpdate is the position vector to update with the result
  13855. * @param particle is the particle we are computed the position for
  13856. * @param isLocal defines if the position should be set in local space
  13857. */
  13858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13859. /**
  13860. * Clones the current emitter and returns a copy of it
  13861. * @returns the new emitter
  13862. */
  13863. clone(): SphereParticleEmitter;
  13864. /**
  13865. * Called by the GPUParticleSystem to setup the update shader
  13866. * @param effect defines the update shader
  13867. */
  13868. applyToShader(effect: Effect): void;
  13869. /**
  13870. * Returns a string to use to update the GPU particles update shader
  13871. * @returns a string containng the defines string
  13872. */
  13873. getEffectDefines(): string;
  13874. /**
  13875. * Returns the string "SphereParticleEmitter"
  13876. * @returns a string containing the class name
  13877. */
  13878. getClassName(): string;
  13879. /**
  13880. * Serializes the particle system to a JSON object.
  13881. * @returns the JSON object
  13882. */
  13883. serialize(): any;
  13884. /**
  13885. * Parse properties from a JSON object
  13886. * @param serializationObject defines the JSON object
  13887. */
  13888. parse(serializationObject: any): void;
  13889. }
  13890. /**
  13891. * Particle emitter emitting particles from the inside of a sphere.
  13892. * It emits the particles randomly between two vectors.
  13893. */
  13894. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13895. /**
  13896. * The min limit of the emission direction.
  13897. */
  13898. direction1: Vector3;
  13899. /**
  13900. * The max limit of the emission direction.
  13901. */
  13902. direction2: Vector3;
  13903. /**
  13904. * Creates a new instance SphereDirectedParticleEmitter
  13905. * @param radius the radius of the emission sphere (1 by default)
  13906. * @param direction1 the min limit of the emission direction (up vector by default)
  13907. * @param direction2 the max limit of the emission direction (up vector by default)
  13908. */
  13909. constructor(radius?: number,
  13910. /**
  13911. * The min limit of the emission direction.
  13912. */
  13913. direction1?: Vector3,
  13914. /**
  13915. * The max limit of the emission direction.
  13916. */
  13917. direction2?: Vector3);
  13918. /**
  13919. * Called by the particle System when the direction is computed for the created particle.
  13920. * @param worldMatrix is the world matrix of the particle system
  13921. * @param directionToUpdate is the direction vector to update with the result
  13922. * @param particle is the particle we are computed the direction for
  13923. */
  13924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13925. /**
  13926. * Clones the current emitter and returns a copy of it
  13927. * @returns the new emitter
  13928. */
  13929. clone(): SphereDirectedParticleEmitter;
  13930. /**
  13931. * Called by the GPUParticleSystem to setup the update shader
  13932. * @param effect defines the update shader
  13933. */
  13934. applyToShader(effect: Effect): void;
  13935. /**
  13936. * Returns a string to use to update the GPU particles update shader
  13937. * @returns a string containng the defines string
  13938. */
  13939. getEffectDefines(): string;
  13940. /**
  13941. * Returns the string "SphereDirectedParticleEmitter"
  13942. * @returns a string containing the class name
  13943. */
  13944. getClassName(): string;
  13945. /**
  13946. * Serializes the particle system to a JSON object.
  13947. * @returns the JSON object
  13948. */
  13949. serialize(): any;
  13950. /**
  13951. * Parse properties from a JSON object
  13952. * @param serializationObject defines the JSON object
  13953. */
  13954. parse(serializationObject: any): void;
  13955. }
  13956. }
  13957. declare module BABYLON {
  13958. /**
  13959. * Particle emitter emitting particles from a custom list of positions.
  13960. */
  13961. export class CustomParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * Gets or sets the position generator that will create the inital position of each particle.
  13964. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13965. */
  13966. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13967. /**
  13968. * Gets or sets the destination generator that will create the final destination of each particle.
  13969. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13970. */
  13971. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13972. /**
  13973. * Creates a new instance CustomParticleEmitter
  13974. */
  13975. constructor();
  13976. /**
  13977. * Called by the particle System when the direction is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param directionToUpdate is the direction vector to update with the result
  13980. * @param particle is the particle we are computed the direction for
  13981. * @param isLocal defines if the direction should be set in local space
  13982. */
  13983. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Called by the particle System when the position is computed for the created particle.
  13986. * @param worldMatrix is the world matrix of the particle system
  13987. * @param positionToUpdate is the position vector to update with the result
  13988. * @param particle is the particle we are computed the position for
  13989. * @param isLocal defines if the position should be set in local space
  13990. */
  13991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13992. /**
  13993. * Clones the current emitter and returns a copy of it
  13994. * @returns the new emitter
  13995. */
  13996. clone(): CustomParticleEmitter;
  13997. /**
  13998. * Called by the GPUParticleSystem to setup the update shader
  13999. * @param effect defines the update shader
  14000. */
  14001. applyToShader(effect: Effect): void;
  14002. /**
  14003. * Returns a string to use to update the GPU particles update shader
  14004. * @returns a string containng the defines string
  14005. */
  14006. getEffectDefines(): string;
  14007. /**
  14008. * Returns the string "PointParticleEmitter"
  14009. * @returns a string containing the class name
  14010. */
  14011. getClassName(): string;
  14012. /**
  14013. * Serializes the particle system to a JSON object.
  14014. * @returns the JSON object
  14015. */
  14016. serialize(): any;
  14017. /**
  14018. * Parse properties from a JSON object
  14019. * @param serializationObject defines the JSON object
  14020. */
  14021. parse(serializationObject: any): void;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. /**
  14026. * Particle emitter emitting particles from the inside of a box.
  14027. * It emits the particles randomly between 2 given directions.
  14028. */
  14029. export class MeshParticleEmitter implements IParticleEmitterType {
  14030. private _indices;
  14031. private _positions;
  14032. private _normals;
  14033. private _storedNormal;
  14034. private _mesh;
  14035. /**
  14036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14037. */
  14038. direction1: Vector3;
  14039. /**
  14040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14041. */
  14042. direction2: Vector3;
  14043. /**
  14044. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14045. */
  14046. useMeshNormalsForDirection: boolean;
  14047. /** Defines the mesh to use as source */
  14048. get mesh(): Nullable<AbstractMesh>;
  14049. set mesh(value: Nullable<AbstractMesh>);
  14050. /**
  14051. * Creates a new instance MeshParticleEmitter
  14052. * @param mesh defines the mesh to use as source
  14053. */
  14054. constructor(mesh?: Nullable<AbstractMesh>);
  14055. /**
  14056. * Called by the particle System when the direction is computed for the created particle.
  14057. * @param worldMatrix is the world matrix of the particle system
  14058. * @param directionToUpdate is the direction vector to update with the result
  14059. * @param particle is the particle we are computed the direction for
  14060. * @param isLocal defines if the direction should be set in local space
  14061. */
  14062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14063. /**
  14064. * Called by the particle System when the position is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param positionToUpdate is the position vector to update with the result
  14067. * @param particle is the particle we are computed the position for
  14068. * @param isLocal defines if the position should be set in local space
  14069. */
  14070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Clones the current emitter and returns a copy of it
  14073. * @returns the new emitter
  14074. */
  14075. clone(): MeshParticleEmitter;
  14076. /**
  14077. * Called by the GPUParticleSystem to setup the update shader
  14078. * @param effect defines the update shader
  14079. */
  14080. applyToShader(effect: Effect): void;
  14081. /**
  14082. * Returns a string to use to update the GPU particles update shader
  14083. * @returns a string containng the defines string
  14084. */
  14085. getEffectDefines(): string;
  14086. /**
  14087. * Returns the string "BoxParticleEmitter"
  14088. * @returns a string containing the class name
  14089. */
  14090. getClassName(): string;
  14091. /**
  14092. * Serializes the particle system to a JSON object.
  14093. * @returns the JSON object
  14094. */
  14095. serialize(): any;
  14096. /**
  14097. * Parse properties from a JSON object
  14098. * @param serializationObject defines the JSON object
  14099. * @param scene defines the hosting scene
  14100. */
  14101. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14102. }
  14103. }
  14104. declare module BABYLON {
  14105. /**
  14106. * Interface representing a particle system in Babylon.js.
  14107. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14108. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14109. */
  14110. export interface IParticleSystem {
  14111. /**
  14112. * List of animations used by the particle system.
  14113. */
  14114. animations: Animation[];
  14115. /**
  14116. * The id of the Particle system.
  14117. */
  14118. id: string;
  14119. /**
  14120. * The name of the Particle system.
  14121. */
  14122. name: string;
  14123. /**
  14124. * The emitter represents the Mesh or position we are attaching the particle system to.
  14125. */
  14126. emitter: Nullable<AbstractMesh | Vector3>;
  14127. /**
  14128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14129. */
  14130. isBillboardBased: boolean;
  14131. /**
  14132. * The rendering group used by the Particle system to chose when to render.
  14133. */
  14134. renderingGroupId: number;
  14135. /**
  14136. * The layer mask we are rendering the particles through.
  14137. */
  14138. layerMask: number;
  14139. /**
  14140. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14141. */
  14142. updateSpeed: number;
  14143. /**
  14144. * The amount of time the particle system is running (depends of the overall update speed).
  14145. */
  14146. targetStopDuration: number;
  14147. /**
  14148. * The texture used to render each particle. (this can be a spritesheet)
  14149. */
  14150. particleTexture: Nullable<BaseTexture>;
  14151. /**
  14152. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14153. */
  14154. blendMode: number;
  14155. /**
  14156. * Minimum life time of emitting particles.
  14157. */
  14158. minLifeTime: number;
  14159. /**
  14160. * Maximum life time of emitting particles.
  14161. */
  14162. maxLifeTime: number;
  14163. /**
  14164. * Minimum Size of emitting particles.
  14165. */
  14166. minSize: number;
  14167. /**
  14168. * Maximum Size of emitting particles.
  14169. */
  14170. maxSize: number;
  14171. /**
  14172. * Minimum scale of emitting particles on X axis.
  14173. */
  14174. minScaleX: number;
  14175. /**
  14176. * Maximum scale of emitting particles on X axis.
  14177. */
  14178. maxScaleX: number;
  14179. /**
  14180. * Minimum scale of emitting particles on Y axis.
  14181. */
  14182. minScaleY: number;
  14183. /**
  14184. * Maximum scale of emitting particles on Y axis.
  14185. */
  14186. maxScaleY: number;
  14187. /**
  14188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14189. */
  14190. color1: Color4;
  14191. /**
  14192. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14193. */
  14194. color2: Color4;
  14195. /**
  14196. * Color the particle will have at the end of its lifetime.
  14197. */
  14198. colorDead: Color4;
  14199. /**
  14200. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14201. */
  14202. emitRate: number;
  14203. /**
  14204. * You can use gravity if you want to give an orientation to your particles.
  14205. */
  14206. gravity: Vector3;
  14207. /**
  14208. * Minimum power of emitting particles.
  14209. */
  14210. minEmitPower: number;
  14211. /**
  14212. * Maximum power of emitting particles.
  14213. */
  14214. maxEmitPower: number;
  14215. /**
  14216. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14217. */
  14218. minAngularSpeed: number;
  14219. /**
  14220. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. maxAngularSpeed: number;
  14223. /**
  14224. * Gets or sets the minimal initial rotation in radians.
  14225. */
  14226. minInitialRotation: number;
  14227. /**
  14228. * Gets or sets the maximal initial rotation in radians.
  14229. */
  14230. maxInitialRotation: number;
  14231. /**
  14232. * The particle emitter type defines the emitter used by the particle system.
  14233. * It can be for example box, sphere, or cone...
  14234. */
  14235. particleEmitterType: Nullable<IParticleEmitterType>;
  14236. /**
  14237. * Defines the delay in milliseconds before starting the system (0 by default)
  14238. */
  14239. startDelay: number;
  14240. /**
  14241. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14242. */
  14243. preWarmCycles: number;
  14244. /**
  14245. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14246. */
  14247. preWarmStepOffset: number;
  14248. /**
  14249. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14250. */
  14251. spriteCellChangeSpeed: number;
  14252. /**
  14253. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14254. */
  14255. startSpriteCellID: number;
  14256. /**
  14257. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14258. */
  14259. endSpriteCellID: number;
  14260. /**
  14261. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14262. */
  14263. spriteCellWidth: number;
  14264. /**
  14265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14266. */
  14267. spriteCellHeight: number;
  14268. /**
  14269. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14270. */
  14271. spriteRandomStartCell: boolean;
  14272. /**
  14273. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14274. */
  14275. isAnimationSheetEnabled: boolean;
  14276. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14277. translationPivot: Vector2;
  14278. /**
  14279. * Gets or sets a texture used to add random noise to particle positions
  14280. */
  14281. noiseTexture: Nullable<BaseTexture>;
  14282. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14283. noiseStrength: Vector3;
  14284. /**
  14285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14287. */
  14288. billboardMode: number;
  14289. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14290. limitVelocityDamping: number;
  14291. /**
  14292. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14293. */
  14294. beginAnimationOnStart: boolean;
  14295. /**
  14296. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14297. */
  14298. beginAnimationFrom: number;
  14299. /**
  14300. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14301. */
  14302. beginAnimationTo: number;
  14303. /**
  14304. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14305. */
  14306. beginAnimationLoop: boolean;
  14307. /**
  14308. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14309. */
  14310. disposeOnStop: boolean;
  14311. /**
  14312. * Specifies if the particles are updated in emitter local space or world space
  14313. */
  14314. isLocal: boolean;
  14315. /** Snippet ID if the particle system was created from the snippet server */
  14316. snippetId: string;
  14317. /** Gets or sets a matrix to use to compute projection */
  14318. defaultProjectionMatrix: Matrix;
  14319. /**
  14320. * Gets the maximum number of particles active at the same time.
  14321. * @returns The max number of active particles.
  14322. */
  14323. getCapacity(): number;
  14324. /**
  14325. * Gets the number of particles active at the same time.
  14326. * @returns The number of active particles.
  14327. */
  14328. getActiveCount(): number;
  14329. /**
  14330. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14331. * @returns True if it has been started, otherwise false.
  14332. */
  14333. isStarted(): boolean;
  14334. /**
  14335. * Animates the particle system for this frame.
  14336. */
  14337. animate(): void;
  14338. /**
  14339. * Renders the particle system in its current state.
  14340. * @returns the current number of particles
  14341. */
  14342. render(): number;
  14343. /**
  14344. * Dispose the particle system and frees its associated resources.
  14345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14346. */
  14347. dispose(disposeTexture?: boolean): void;
  14348. /**
  14349. * An event triggered when the system is disposed
  14350. */
  14351. onDisposeObservable: Observable<IParticleSystem>;
  14352. /**
  14353. * An event triggered when the system is stopped
  14354. */
  14355. onStoppedObservable: Observable<IParticleSystem>;
  14356. /**
  14357. * Clones the particle system.
  14358. * @param name The name of the cloned object
  14359. * @param newEmitter The new emitter to use
  14360. * @returns the cloned particle system
  14361. */
  14362. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14363. /**
  14364. * Serializes the particle system to a JSON object
  14365. * @param serializeTexture defines if the texture must be serialized as well
  14366. * @returns the JSON object
  14367. */
  14368. serialize(serializeTexture: boolean): any;
  14369. /**
  14370. * Rebuild the particle system
  14371. */
  14372. rebuild(): void;
  14373. /** Force the system to rebuild all gradients that need to be resync */
  14374. forceRefreshGradients(): void;
  14375. /**
  14376. * Starts the particle system and begins to emit
  14377. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14378. */
  14379. start(delay?: number): void;
  14380. /**
  14381. * Stops the particle system.
  14382. */
  14383. stop(): void;
  14384. /**
  14385. * Remove all active particles
  14386. */
  14387. reset(): void;
  14388. /**
  14389. * Gets a boolean indicating that the system is stopping
  14390. * @returns true if the system is currently stopping
  14391. */
  14392. isStopping(): boolean;
  14393. /**
  14394. * Is this system ready to be used/rendered
  14395. * @return true if the system is ready
  14396. */
  14397. isReady(): boolean;
  14398. /**
  14399. * Returns the string "ParticleSystem"
  14400. * @returns a string containing the class name
  14401. */
  14402. getClassName(): string;
  14403. /**
  14404. * Gets the custom effect used to render the particles
  14405. * @param blendMode Blend mode for which the effect should be retrieved
  14406. * @returns The effect
  14407. */
  14408. getCustomEffect(blendMode: number): Nullable<Effect>;
  14409. /**
  14410. * Sets the custom effect used to render the particles
  14411. * @param effect The effect to set
  14412. * @param blendMode Blend mode for which the effect should be set
  14413. */
  14414. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14415. /**
  14416. * Fill the defines array according to the current settings of the particle system
  14417. * @param defines Array to be updated
  14418. * @param blendMode blend mode to take into account when updating the array
  14419. */
  14420. fillDefines(defines: Array<string>, blendMode: number): void;
  14421. /**
  14422. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14423. * @param uniforms Uniforms array to fill
  14424. * @param attributes Attributes array to fill
  14425. * @param samplers Samplers array to fill
  14426. */
  14427. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14428. /**
  14429. * Observable that will be called just before the particles are drawn
  14430. */
  14431. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14432. /**
  14433. * Gets the name of the particle vertex shader
  14434. */
  14435. vertexShaderName: string;
  14436. /**
  14437. * Adds a new color gradient
  14438. * @param gradient defines the gradient to use (between 0 and 1)
  14439. * @param color1 defines the color to affect to the specified gradient
  14440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14441. * @returns the current particle system
  14442. */
  14443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14444. /**
  14445. * Remove a specific color gradient
  14446. * @param gradient defines the gradient to remove
  14447. * @returns the current particle system
  14448. */
  14449. removeColorGradient(gradient: number): IParticleSystem;
  14450. /**
  14451. * Adds a new size gradient
  14452. * @param gradient defines the gradient to use (between 0 and 1)
  14453. * @param factor defines the size factor to affect to the specified gradient
  14454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14455. * @returns the current particle system
  14456. */
  14457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14458. /**
  14459. * Remove a specific size gradient
  14460. * @param gradient defines the gradient to remove
  14461. * @returns the current particle system
  14462. */
  14463. removeSizeGradient(gradient: number): IParticleSystem;
  14464. /**
  14465. * Gets the current list of color gradients.
  14466. * You must use addColorGradient and removeColorGradient to udpate this list
  14467. * @returns the list of color gradients
  14468. */
  14469. getColorGradients(): Nullable<Array<ColorGradient>>;
  14470. /**
  14471. * Gets the current list of size gradients.
  14472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14473. * @returns the list of size gradients
  14474. */
  14475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14476. /**
  14477. * Gets the current list of angular speed gradients.
  14478. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14479. * @returns the list of angular speed gradients
  14480. */
  14481. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Adds a new angular speed gradient
  14484. * @param gradient defines the gradient to use (between 0 and 1)
  14485. * @param factor defines the angular speed to affect to the specified gradient
  14486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14487. * @returns the current particle system
  14488. */
  14489. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14490. /**
  14491. * Remove a specific angular speed gradient
  14492. * @param gradient defines the gradient to remove
  14493. * @returns the current particle system
  14494. */
  14495. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14496. /**
  14497. * Gets the current list of velocity gradients.
  14498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14499. * @returns the list of velocity gradients
  14500. */
  14501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14502. /**
  14503. * Adds a new velocity gradient
  14504. * @param gradient defines the gradient to use (between 0 and 1)
  14505. * @param factor defines the velocity to affect to the specified gradient
  14506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14507. * @returns the current particle system
  14508. */
  14509. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14510. /**
  14511. * Remove a specific velocity gradient
  14512. * @param gradient defines the gradient to remove
  14513. * @returns the current particle system
  14514. */
  14515. removeVelocityGradient(gradient: number): IParticleSystem;
  14516. /**
  14517. * Gets the current list of limit velocity gradients.
  14518. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14519. * @returns the list of limit velocity gradients
  14520. */
  14521. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14522. /**
  14523. * Adds a new limit velocity gradient
  14524. * @param gradient defines the gradient to use (between 0 and 1)
  14525. * @param factor defines the limit velocity to affect to the specified gradient
  14526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14527. * @returns the current particle system
  14528. */
  14529. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14530. /**
  14531. * Remove a specific limit velocity gradient
  14532. * @param gradient defines the gradient to remove
  14533. * @returns the current particle system
  14534. */
  14535. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14536. /**
  14537. * Adds a new drag gradient
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the drag to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific drag gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeDragGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Gets the current list of drag gradients.
  14552. * You must use addDragGradient and removeDragGradient to udpate this list
  14553. * @returns the list of drag gradients
  14554. */
  14555. getDragGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the emit rate to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific emit rate gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeEmitRateGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of emit rate gradients.
  14572. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14573. * @returns the list of emit rate gradients
  14574. */
  14575. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14578. * @param gradient defines the gradient to use (between 0 and 1)
  14579. * @param factor defines the start size to affect to the specified gradient
  14580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14581. * @returns the current particle system
  14582. */
  14583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14584. /**
  14585. * Remove a specific start size gradient
  14586. * @param gradient defines the gradient to remove
  14587. * @returns the current particle system
  14588. */
  14589. removeStartSizeGradient(gradient: number): IParticleSystem;
  14590. /**
  14591. * Gets the current list of start size gradients.
  14592. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14593. * @returns the list of start size gradients
  14594. */
  14595. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14596. /**
  14597. * Adds a new life time gradient
  14598. * @param gradient defines the gradient to use (between 0 and 1)
  14599. * @param factor defines the life time factor to affect to the specified gradient
  14600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14601. * @returns the current particle system
  14602. */
  14603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14604. /**
  14605. * Remove a specific life time gradient
  14606. * @param gradient defines the gradient to remove
  14607. * @returns the current particle system
  14608. */
  14609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14610. /**
  14611. * Gets the current list of life time gradients.
  14612. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14613. * @returns the list of life time gradients
  14614. */
  14615. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14616. /**
  14617. * Gets the current list of color gradients.
  14618. * You must use addColorGradient and removeColorGradient to udpate this list
  14619. * @returns the list of color gradients
  14620. */
  14621. getColorGradients(): Nullable<Array<ColorGradient>>;
  14622. /**
  14623. * Adds a new ramp gradient used to remap particle colors
  14624. * @param gradient defines the gradient to use (between 0 and 1)
  14625. * @param color defines the color to affect to the specified gradient
  14626. * @returns the current particle system
  14627. */
  14628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14629. /**
  14630. * Gets the current list of ramp gradients.
  14631. * You must use addRampGradient and removeRampGradient to udpate this list
  14632. * @returns the list of ramp gradients
  14633. */
  14634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14635. /** Gets or sets a boolean indicating that ramp gradients must be used
  14636. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14637. */
  14638. useRampGradients: boolean;
  14639. /**
  14640. * Adds a new color remap gradient
  14641. * @param gradient defines the gradient to use (between 0 and 1)
  14642. * @param min defines the color remap minimal range
  14643. * @param max defines the color remap maximal range
  14644. * @returns the current particle system
  14645. */
  14646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14647. /**
  14648. * Gets the current list of color remap gradients.
  14649. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14650. * @returns the list of color remap gradients
  14651. */
  14652. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14653. /**
  14654. * Adds a new alpha remap gradient
  14655. * @param gradient defines the gradient to use (between 0 and 1)
  14656. * @param min defines the alpha remap minimal range
  14657. * @param max defines the alpha remap maximal range
  14658. * @returns the current particle system
  14659. */
  14660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14661. /**
  14662. * Gets the current list of alpha remap gradients.
  14663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14664. * @returns the list of alpha remap gradients
  14665. */
  14666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14667. /**
  14668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14671. * @returns the emitter
  14672. */
  14673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14674. /**
  14675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14676. * @param radius The radius of the hemisphere to emit from
  14677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14678. * @returns the emitter
  14679. */
  14680. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14681. /**
  14682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14683. * @param radius The radius of the sphere to emit from
  14684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14685. * @returns the emitter
  14686. */
  14687. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14688. /**
  14689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14690. * @param radius The radius of the sphere to emit from
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14693. * @returns the emitter
  14694. */
  14695. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14696. /**
  14697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14698. * @param radius The radius of the emission cylinder
  14699. * @param height The height of the emission cylinder
  14700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14702. * @returns the emitter
  14703. */
  14704. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14705. /**
  14706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14707. * @param radius The radius of the cylinder to emit from
  14708. * @param height The height of the emission cylinder
  14709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14712. * @returns the emitter
  14713. */
  14714. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14715. /**
  14716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14717. * @param radius The radius of the cone to emit from
  14718. * @param angle The base angle of the cone
  14719. * @returns the emitter
  14720. */
  14721. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14722. /**
  14723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14728. * @returns the emitter
  14729. */
  14730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14731. /**
  14732. * Get hosting scene
  14733. * @returns the scene
  14734. */
  14735. getScene(): Nullable<Scene>;
  14736. }
  14737. }
  14738. declare module BABYLON {
  14739. /**
  14740. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14741. * @see https://doc.babylonjs.com/how_to/transformnode
  14742. */
  14743. export class TransformNode extends Node {
  14744. /**
  14745. * Object will not rotate to face the camera
  14746. */
  14747. static BILLBOARDMODE_NONE: number;
  14748. /**
  14749. * Object will rotate to face the camera but only on the x axis
  14750. */
  14751. static BILLBOARDMODE_X: number;
  14752. /**
  14753. * Object will rotate to face the camera but only on the y axis
  14754. */
  14755. static BILLBOARDMODE_Y: number;
  14756. /**
  14757. * Object will rotate to face the camera but only on the z axis
  14758. */
  14759. static BILLBOARDMODE_Z: number;
  14760. /**
  14761. * Object will rotate to face the camera
  14762. */
  14763. static BILLBOARDMODE_ALL: number;
  14764. /**
  14765. * Object will rotate to face the camera's position instead of orientation
  14766. */
  14767. static BILLBOARDMODE_USE_POSITION: number;
  14768. private static _TmpRotation;
  14769. private static _TmpScaling;
  14770. private static _TmpTranslation;
  14771. private _forward;
  14772. private _forwardInverted;
  14773. private _up;
  14774. private _right;
  14775. private _rightInverted;
  14776. private _position;
  14777. private _rotation;
  14778. private _rotationQuaternion;
  14779. protected _scaling: Vector3;
  14780. protected _isDirty: boolean;
  14781. private _transformToBoneReferal;
  14782. private _isAbsoluteSynced;
  14783. private _billboardMode;
  14784. /**
  14785. * Gets or sets the billboard mode. Default is 0.
  14786. *
  14787. * | Value | Type | Description |
  14788. * | --- | --- | --- |
  14789. * | 0 | BILLBOARDMODE_NONE | |
  14790. * | 1 | BILLBOARDMODE_X | |
  14791. * | 2 | BILLBOARDMODE_Y | |
  14792. * | 4 | BILLBOARDMODE_Z | |
  14793. * | 7 | BILLBOARDMODE_ALL | |
  14794. *
  14795. */
  14796. get billboardMode(): number;
  14797. set billboardMode(value: number);
  14798. private _preserveParentRotationForBillboard;
  14799. /**
  14800. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14801. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14802. */
  14803. get preserveParentRotationForBillboard(): boolean;
  14804. set preserveParentRotationForBillboard(value: boolean);
  14805. /**
  14806. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14807. */
  14808. scalingDeterminant: number;
  14809. private _infiniteDistance;
  14810. /**
  14811. * Gets or sets the distance of the object to max, often used by skybox
  14812. */
  14813. get infiniteDistance(): boolean;
  14814. set infiniteDistance(value: boolean);
  14815. /**
  14816. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14817. * By default the system will update normals to compensate
  14818. */
  14819. ignoreNonUniformScaling: boolean;
  14820. /**
  14821. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14822. */
  14823. reIntegrateRotationIntoRotationQuaternion: boolean;
  14824. /** @hidden */
  14825. _poseMatrix: Nullable<Matrix>;
  14826. /** @hidden */
  14827. _localMatrix: Matrix;
  14828. private _usePivotMatrix;
  14829. private _absolutePosition;
  14830. private _absoluteScaling;
  14831. private _absoluteRotationQuaternion;
  14832. private _pivotMatrix;
  14833. private _pivotMatrixInverse;
  14834. /** @hidden */
  14835. _postMultiplyPivotMatrix: boolean;
  14836. protected _isWorldMatrixFrozen: boolean;
  14837. /** @hidden */
  14838. _indexInSceneTransformNodesArray: number;
  14839. /**
  14840. * An event triggered after the world matrix is updated
  14841. */
  14842. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14843. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14844. /**
  14845. * Gets a string identifying the name of the class
  14846. * @returns "TransformNode" string
  14847. */
  14848. getClassName(): string;
  14849. /**
  14850. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14851. */
  14852. get position(): Vector3;
  14853. set position(newPosition: Vector3);
  14854. /**
  14855. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14856. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14857. */
  14858. get rotation(): Vector3;
  14859. set rotation(newRotation: Vector3);
  14860. /**
  14861. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14862. */
  14863. get scaling(): Vector3;
  14864. set scaling(newScaling: Vector3);
  14865. /**
  14866. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14867. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14868. */
  14869. get rotationQuaternion(): Nullable<Quaternion>;
  14870. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14871. /**
  14872. * The forward direction of that transform in world space.
  14873. */
  14874. get forward(): Vector3;
  14875. /**
  14876. * The up direction of that transform in world space.
  14877. */
  14878. get up(): Vector3;
  14879. /**
  14880. * The right direction of that transform in world space.
  14881. */
  14882. get right(): Vector3;
  14883. /**
  14884. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14885. * @param matrix the matrix to copy the pose from
  14886. * @returns this TransformNode.
  14887. */
  14888. updatePoseMatrix(matrix: Matrix): TransformNode;
  14889. /**
  14890. * Returns the mesh Pose matrix.
  14891. * @returns the pose matrix
  14892. */
  14893. getPoseMatrix(): Matrix;
  14894. /** @hidden */
  14895. _isSynchronized(): boolean;
  14896. /** @hidden */
  14897. _initCache(): void;
  14898. /**
  14899. * Flag the transform node as dirty (Forcing it to update everything)
  14900. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14901. * @returns this transform node
  14902. */
  14903. markAsDirty(property: string): TransformNode;
  14904. /**
  14905. * Returns the current mesh absolute position.
  14906. * Returns a Vector3.
  14907. */
  14908. get absolutePosition(): Vector3;
  14909. /**
  14910. * Returns the current mesh absolute scaling.
  14911. * Returns a Vector3.
  14912. */
  14913. get absoluteScaling(): Vector3;
  14914. /**
  14915. * Returns the current mesh absolute rotation.
  14916. * Returns a Quaternion.
  14917. */
  14918. get absoluteRotationQuaternion(): Quaternion;
  14919. /**
  14920. * Sets a new matrix to apply before all other transformation
  14921. * @param matrix defines the transform matrix
  14922. * @returns the current TransformNode
  14923. */
  14924. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14925. /**
  14926. * Sets a new pivot matrix to the current node
  14927. * @param matrix defines the new pivot matrix to use
  14928. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14929. * @returns the current TransformNode
  14930. */
  14931. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14932. /**
  14933. * Returns the mesh pivot matrix.
  14934. * Default : Identity.
  14935. * @returns the matrix
  14936. */
  14937. getPivotMatrix(): Matrix;
  14938. /**
  14939. * Instantiate (when possible) or clone that node with its hierarchy
  14940. * @param newParent defines the new parent to use for the instance (or clone)
  14941. * @param options defines options to configure how copy is done
  14942. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14943. * @returns an instance (or a clone) of the current node with its hiearchy
  14944. */
  14945. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14946. doNotInstantiate: boolean;
  14947. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14948. /**
  14949. * Prevents the World matrix to be computed any longer
  14950. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14951. * @returns the TransformNode.
  14952. */
  14953. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14954. /**
  14955. * Allows back the World matrix computation.
  14956. * @returns the TransformNode.
  14957. */
  14958. unfreezeWorldMatrix(): this;
  14959. /**
  14960. * True if the World matrix has been frozen.
  14961. */
  14962. get isWorldMatrixFrozen(): boolean;
  14963. /**
  14964. * Retuns the mesh absolute position in the World.
  14965. * @returns a Vector3.
  14966. */
  14967. getAbsolutePosition(): Vector3;
  14968. /**
  14969. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14970. * @param absolutePosition the absolute position to set
  14971. * @returns the TransformNode.
  14972. */
  14973. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14974. /**
  14975. * Sets the mesh position in its local space.
  14976. * @param vector3 the position to set in localspace
  14977. * @returns the TransformNode.
  14978. */
  14979. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14980. /**
  14981. * Returns the mesh position in the local space from the current World matrix values.
  14982. * @returns a new Vector3.
  14983. */
  14984. getPositionExpressedInLocalSpace(): Vector3;
  14985. /**
  14986. * Translates the mesh along the passed Vector3 in its local space.
  14987. * @param vector3 the distance to translate in localspace
  14988. * @returns the TransformNode.
  14989. */
  14990. locallyTranslate(vector3: Vector3): TransformNode;
  14991. private static _lookAtVectorCache;
  14992. /**
  14993. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14994. * @param targetPoint the position (must be in same space as current mesh) to look at
  14995. * @param yawCor optional yaw (y-axis) correction in radians
  14996. * @param pitchCor optional pitch (x-axis) correction in radians
  14997. * @param rollCor optional roll (z-axis) correction in radians
  14998. * @param space the choosen space of the target
  14999. * @returns the TransformNode.
  15000. */
  15001. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15002. /**
  15003. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15004. * This Vector3 is expressed in the World space.
  15005. * @param localAxis axis to rotate
  15006. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15007. */
  15008. getDirection(localAxis: Vector3): Vector3;
  15009. /**
  15010. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15011. * localAxis is expressed in the mesh local space.
  15012. * result is computed in the Wordl space from the mesh World matrix.
  15013. * @param localAxis axis to rotate
  15014. * @param result the resulting transformnode
  15015. * @returns this TransformNode.
  15016. */
  15017. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15018. /**
  15019. * Sets this transform node rotation to the given local axis.
  15020. * @param localAxis the axis in local space
  15021. * @param yawCor optional yaw (y-axis) correction in radians
  15022. * @param pitchCor optional pitch (x-axis) correction in radians
  15023. * @param rollCor optional roll (z-axis) correction in radians
  15024. * @returns this TransformNode
  15025. */
  15026. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15027. /**
  15028. * Sets a new pivot point to the current node
  15029. * @param point defines the new pivot point to use
  15030. * @param space defines if the point is in world or local space (local by default)
  15031. * @returns the current TransformNode
  15032. */
  15033. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15034. /**
  15035. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15036. * @returns the pivot point
  15037. */
  15038. getPivotPoint(): Vector3;
  15039. /**
  15040. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15041. * @param result the vector3 to store the result
  15042. * @returns this TransformNode.
  15043. */
  15044. getPivotPointToRef(result: Vector3): TransformNode;
  15045. /**
  15046. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15047. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15048. */
  15049. getAbsolutePivotPoint(): Vector3;
  15050. /**
  15051. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15052. * @param result vector3 to store the result
  15053. * @returns this TransformNode.
  15054. */
  15055. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15056. /**
  15057. * Defines the passed node as the parent of the current node.
  15058. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15059. * @see https://doc.babylonjs.com/how_to/parenting
  15060. * @param node the node ot set as the parent
  15061. * @returns this TransformNode.
  15062. */
  15063. setParent(node: Nullable<Node>): TransformNode;
  15064. private _nonUniformScaling;
  15065. /**
  15066. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15067. */
  15068. get nonUniformScaling(): boolean;
  15069. /** @hidden */
  15070. _updateNonUniformScalingState(value: boolean): boolean;
  15071. /**
  15072. * Attach the current TransformNode to another TransformNode associated with a bone
  15073. * @param bone Bone affecting the TransformNode
  15074. * @param affectedTransformNode TransformNode associated with the bone
  15075. * @returns this object
  15076. */
  15077. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15078. /**
  15079. * Detach the transform node if its associated with a bone
  15080. * @returns this object
  15081. */
  15082. detachFromBone(): TransformNode;
  15083. private static _rotationAxisCache;
  15084. /**
  15085. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15086. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15087. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15088. * The passed axis is also normalized.
  15089. * @param axis the axis to rotate around
  15090. * @param amount the amount to rotate in radians
  15091. * @param space Space to rotate in (Default: local)
  15092. * @returns the TransformNode.
  15093. */
  15094. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15095. /**
  15096. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15097. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15098. * The passed axis is also normalized. .
  15099. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15100. * @param point the point to rotate around
  15101. * @param axis the axis to rotate around
  15102. * @param amount the amount to rotate in radians
  15103. * @returns the TransformNode
  15104. */
  15105. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15106. /**
  15107. * Translates the mesh along the axis vector for the passed distance in the given space.
  15108. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15109. * @param axis the axis to translate in
  15110. * @param distance the distance to translate
  15111. * @param space Space to rotate in (Default: local)
  15112. * @returns the TransformNode.
  15113. */
  15114. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15115. /**
  15116. * Adds a rotation step to the mesh current rotation.
  15117. * x, y, z are Euler angles expressed in radians.
  15118. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15119. * This means this rotation is made in the mesh local space only.
  15120. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15121. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15122. * ```javascript
  15123. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15124. * ```
  15125. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15126. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15127. * @param x Rotation to add
  15128. * @param y Rotation to add
  15129. * @param z Rotation to add
  15130. * @returns the TransformNode.
  15131. */
  15132. addRotation(x: number, y: number, z: number): TransformNode;
  15133. /**
  15134. * @hidden
  15135. */
  15136. protected _getEffectiveParent(): Nullable<Node>;
  15137. /**
  15138. * Computes the world matrix of the node
  15139. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15140. * @returns the world matrix
  15141. */
  15142. computeWorldMatrix(force?: boolean): Matrix;
  15143. /**
  15144. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15145. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15146. */
  15147. resetLocalMatrix(independentOfChildren?: boolean): void;
  15148. protected _afterComputeWorldMatrix(): void;
  15149. /**
  15150. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15151. * @param func callback function to add
  15152. *
  15153. * @returns the TransformNode.
  15154. */
  15155. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15156. /**
  15157. * Removes a registered callback function.
  15158. * @param func callback function to remove
  15159. * @returns the TransformNode.
  15160. */
  15161. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15162. /**
  15163. * Gets the position of the current mesh in camera space
  15164. * @param camera defines the camera to use
  15165. * @returns a position
  15166. */
  15167. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15168. /**
  15169. * Returns the distance from the mesh to the active camera
  15170. * @param camera defines the camera to use
  15171. * @returns the distance
  15172. */
  15173. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15174. /**
  15175. * Clone the current transform node
  15176. * @param name Name of the new clone
  15177. * @param newParent New parent for the clone
  15178. * @param doNotCloneChildren Do not clone children hierarchy
  15179. * @returns the new transform node
  15180. */
  15181. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15182. /**
  15183. * Serializes the objects information.
  15184. * @param currentSerializationObject defines the object to serialize in
  15185. * @returns the serialized object
  15186. */
  15187. serialize(currentSerializationObject?: any): any;
  15188. /**
  15189. * Returns a new TransformNode object parsed from the source provided.
  15190. * @param parsedTransformNode is the source.
  15191. * @param scene the scne the object belongs to
  15192. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15193. * @returns a new TransformNode object parsed from the source provided.
  15194. */
  15195. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15196. /**
  15197. * Get all child-transformNodes of this node
  15198. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15199. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15200. * @returns an array of TransformNode
  15201. */
  15202. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15203. /**
  15204. * Releases resources associated with this transform node.
  15205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15207. */
  15208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15209. /**
  15210. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15211. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15212. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15213. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15214. * @returns the current mesh
  15215. */
  15216. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15217. private _syncAbsoluteScalingAndRotation;
  15218. }
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * Class used to override all child animations of a given target
  15223. */
  15224. export class AnimationPropertiesOverride {
  15225. /**
  15226. * Gets or sets a value indicating if animation blending must be used
  15227. */
  15228. enableBlending: boolean;
  15229. /**
  15230. * Gets or sets the blending speed to use when enableBlending is true
  15231. */
  15232. blendingSpeed: number;
  15233. /**
  15234. * Gets or sets the default loop mode to use
  15235. */
  15236. loopMode: number;
  15237. }
  15238. }
  15239. declare module BABYLON {
  15240. /**
  15241. * Class used to store bone information
  15242. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15243. */
  15244. export class Bone extends Node {
  15245. /**
  15246. * defines the bone name
  15247. */
  15248. name: string;
  15249. private static _tmpVecs;
  15250. private static _tmpQuat;
  15251. private static _tmpMats;
  15252. /**
  15253. * Gets the list of child bones
  15254. */
  15255. children: Bone[];
  15256. /** Gets the animations associated with this bone */
  15257. animations: Animation[];
  15258. /**
  15259. * Gets or sets bone length
  15260. */
  15261. length: number;
  15262. /**
  15263. * @hidden Internal only
  15264. * Set this value to map this bone to a different index in the transform matrices
  15265. * Set this value to -1 to exclude the bone from the transform matrices
  15266. */
  15267. _index: Nullable<number>;
  15268. private _skeleton;
  15269. private _localMatrix;
  15270. private _restPose;
  15271. private _bindPose;
  15272. private _baseMatrix;
  15273. private _absoluteTransform;
  15274. private _invertedAbsoluteTransform;
  15275. private _parent;
  15276. private _scalingDeterminant;
  15277. private _worldTransform;
  15278. private _localScaling;
  15279. private _localRotation;
  15280. private _localPosition;
  15281. private _needToDecompose;
  15282. private _needToCompose;
  15283. /** @hidden */
  15284. _linkedTransformNode: Nullable<TransformNode>;
  15285. /** @hidden */
  15286. _waitingTransformNodeId: Nullable<string>;
  15287. /** @hidden */
  15288. get _matrix(): Matrix;
  15289. /** @hidden */
  15290. set _matrix(value: Matrix);
  15291. /**
  15292. * Create a new bone
  15293. * @param name defines the bone name
  15294. * @param skeleton defines the parent skeleton
  15295. * @param parentBone defines the parent (can be null if the bone is the root)
  15296. * @param localMatrix defines the local matrix
  15297. * @param restPose defines the rest pose matrix
  15298. * @param baseMatrix defines the base matrix
  15299. * @param index defines index of the bone in the hiearchy
  15300. */
  15301. constructor(
  15302. /**
  15303. * defines the bone name
  15304. */
  15305. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15306. /**
  15307. * Gets the current object class name.
  15308. * @return the class name
  15309. */
  15310. getClassName(): string;
  15311. /**
  15312. * Gets the parent skeleton
  15313. * @returns a skeleton
  15314. */
  15315. getSkeleton(): Skeleton;
  15316. /**
  15317. * Gets parent bone
  15318. * @returns a bone or null if the bone is the root of the bone hierarchy
  15319. */
  15320. getParent(): Nullable<Bone>;
  15321. /**
  15322. * Returns an array containing the root bones
  15323. * @returns an array containing the root bones
  15324. */
  15325. getChildren(): Array<Bone>;
  15326. /**
  15327. * Gets the node index in matrix array generated for rendering
  15328. * @returns the node index
  15329. */
  15330. getIndex(): number;
  15331. /**
  15332. * Sets the parent bone
  15333. * @param parent defines the parent (can be null if the bone is the root)
  15334. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15335. */
  15336. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15337. /**
  15338. * Gets the local matrix
  15339. * @returns a matrix
  15340. */
  15341. getLocalMatrix(): Matrix;
  15342. /**
  15343. * Gets the base matrix (initial matrix which remains unchanged)
  15344. * @returns a matrix
  15345. */
  15346. getBaseMatrix(): Matrix;
  15347. /**
  15348. * Gets the rest pose matrix
  15349. * @returns a matrix
  15350. */
  15351. getRestPose(): Matrix;
  15352. /**
  15353. * Sets the rest pose matrix
  15354. * @param matrix the local-space rest pose to set for this bone
  15355. */
  15356. setRestPose(matrix: Matrix): void;
  15357. /**
  15358. * Gets the bind pose matrix
  15359. * @returns the bind pose matrix
  15360. */
  15361. getBindPose(): Matrix;
  15362. /**
  15363. * Sets the bind pose matrix
  15364. * @param matrix the local-space bind pose to set for this bone
  15365. */
  15366. setBindPose(matrix: Matrix): void;
  15367. /**
  15368. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15369. */
  15370. getWorldMatrix(): Matrix;
  15371. /**
  15372. * Sets the local matrix to rest pose matrix
  15373. */
  15374. returnToRest(): void;
  15375. /**
  15376. * Gets the inverse of the absolute transform matrix.
  15377. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15378. * @returns a matrix
  15379. */
  15380. getInvertedAbsoluteTransform(): Matrix;
  15381. /**
  15382. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15383. * @returns a matrix
  15384. */
  15385. getAbsoluteTransform(): Matrix;
  15386. /**
  15387. * Links with the given transform node.
  15388. * The local matrix of this bone is copied from the transform node every frame.
  15389. * @param transformNode defines the transform node to link to
  15390. */
  15391. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15392. /**
  15393. * Gets the node used to drive the bone's transformation
  15394. * @returns a transform node or null
  15395. */
  15396. getTransformNode(): Nullable<TransformNode>;
  15397. /** Gets or sets current position (in local space) */
  15398. get position(): Vector3;
  15399. set position(newPosition: Vector3);
  15400. /** Gets or sets current rotation (in local space) */
  15401. get rotation(): Vector3;
  15402. set rotation(newRotation: Vector3);
  15403. /** Gets or sets current rotation quaternion (in local space) */
  15404. get rotationQuaternion(): Quaternion;
  15405. set rotationQuaternion(newRotation: Quaternion);
  15406. /** Gets or sets current scaling (in local space) */
  15407. get scaling(): Vector3;
  15408. set scaling(newScaling: Vector3);
  15409. /**
  15410. * Gets the animation properties override
  15411. */
  15412. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15413. private _decompose;
  15414. private _compose;
  15415. /**
  15416. * Update the base and local matrices
  15417. * @param matrix defines the new base or local matrix
  15418. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15419. * @param updateLocalMatrix defines if the local matrix should be updated
  15420. */
  15421. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15422. /** @hidden */
  15423. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15424. /**
  15425. * Flag the bone as dirty (Forcing it to update everything)
  15426. */
  15427. markAsDirty(): void;
  15428. /** @hidden */
  15429. _markAsDirtyAndCompose(): void;
  15430. private _markAsDirtyAndDecompose;
  15431. /**
  15432. * Translate the bone in local or world space
  15433. * @param vec The amount to translate the bone
  15434. * @param space The space that the translation is in
  15435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15436. */
  15437. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15438. /**
  15439. * Set the postion of the bone in local or world space
  15440. * @param position The position to set the bone
  15441. * @param space The space that the position is in
  15442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15443. */
  15444. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15445. /**
  15446. * Set the absolute position of the bone (world space)
  15447. * @param position The position to set the bone
  15448. * @param mesh The mesh that this bone is attached to
  15449. */
  15450. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15451. /**
  15452. * Scale the bone on the x, y and z axes (in local space)
  15453. * @param x The amount to scale the bone on the x axis
  15454. * @param y The amount to scale the bone on the y axis
  15455. * @param z The amount to scale the bone on the z axis
  15456. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15457. */
  15458. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15459. /**
  15460. * Set the bone scaling in local space
  15461. * @param scale defines the scaling vector
  15462. */
  15463. setScale(scale: Vector3): void;
  15464. /**
  15465. * Gets the current scaling in local space
  15466. * @returns the current scaling vector
  15467. */
  15468. getScale(): Vector3;
  15469. /**
  15470. * Gets the current scaling in local space and stores it in a target vector
  15471. * @param result defines the target vector
  15472. */
  15473. getScaleToRef(result: Vector3): void;
  15474. /**
  15475. * Set the yaw, pitch, and roll of the bone in local or world space
  15476. * @param yaw The rotation of the bone on the y axis
  15477. * @param pitch The rotation of the bone on the x axis
  15478. * @param roll The rotation of the bone on the z axis
  15479. * @param space The space that the axes of rotation are in
  15480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15481. */
  15482. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15483. /**
  15484. * Add a rotation to the bone on an axis in local or world space
  15485. * @param axis The axis to rotate the bone on
  15486. * @param amount The amount to rotate the bone
  15487. * @param space The space that the axis is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15491. /**
  15492. * Set the rotation of the bone to a particular axis angle in local or world space
  15493. * @param axis The axis to rotate the bone on
  15494. * @param angle The angle that the bone should be rotated to
  15495. * @param space The space that the axis is in
  15496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15497. */
  15498. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15499. /**
  15500. * Set the euler rotation of the bone in local or world space
  15501. * @param rotation The euler rotation that the bone should be set to
  15502. * @param space The space that the rotation is in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Set the quaternion rotation of the bone in local or world space
  15508. * @param quat The quaternion rotation that the bone should be set to
  15509. * @param space The space that the rotation is in
  15510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15511. */
  15512. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15513. /**
  15514. * Set the rotation matrix of the bone in local or world space
  15515. * @param rotMat The rotation matrix that the bone should be set to
  15516. * @param space The space that the rotation is in
  15517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15518. */
  15519. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15520. private _rotateWithMatrix;
  15521. private _getNegativeRotationToRef;
  15522. /**
  15523. * Get the position of the bone in local or world space
  15524. * @param space The space that the returned position is in
  15525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15526. * @returns The position of the bone
  15527. */
  15528. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15529. /**
  15530. * Copy the position of the bone to a vector3 in local or world space
  15531. * @param space The space that the returned position is in
  15532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15533. * @param result The vector3 to copy the position to
  15534. */
  15535. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15536. /**
  15537. * Get the absolute position of the bone (world space)
  15538. * @param mesh The mesh that this bone is attached to
  15539. * @returns The absolute position of the bone
  15540. */
  15541. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15542. /**
  15543. * Copy the absolute position of the bone (world space) to the result param
  15544. * @param mesh The mesh that this bone is attached to
  15545. * @param result The vector3 to copy the absolute position to
  15546. */
  15547. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15548. /**
  15549. * Compute the absolute transforms of this bone and its children
  15550. */
  15551. computeAbsoluteTransforms(): void;
  15552. /**
  15553. * Get the world direction from an axis that is in the local space of the bone
  15554. * @param localAxis The local direction that is used to compute the world direction
  15555. * @param mesh The mesh that this bone is attached to
  15556. * @returns The world direction
  15557. */
  15558. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15559. /**
  15560. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15561. * @param localAxis The local direction that is used to compute the world direction
  15562. * @param mesh The mesh that this bone is attached to
  15563. * @param result The vector3 that the world direction will be copied to
  15564. */
  15565. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15566. /**
  15567. * Get the euler rotation of the bone in local or world space
  15568. * @param space The space that the rotation should be in
  15569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15570. * @returns The euler rotation
  15571. */
  15572. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15573. /**
  15574. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15575. * @param space The space that the rotation should be in
  15576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15577. * @param result The vector3 that the rotation should be copied to
  15578. */
  15579. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15580. /**
  15581. * Get the quaternion rotation of the bone in either local or world space
  15582. * @param space The space that the rotation should be in
  15583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15584. * @returns The quaternion rotation
  15585. */
  15586. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15587. /**
  15588. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15589. * @param space The space that the rotation should be in
  15590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15591. * @param result The quaternion that the rotation should be copied to
  15592. */
  15593. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15594. /**
  15595. * Get the rotation matrix of the bone in local or world space
  15596. * @param space The space that the rotation should be in
  15597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15598. * @returns The rotation matrix
  15599. */
  15600. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15601. /**
  15602. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15603. * @param space The space that the rotation should be in
  15604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15605. * @param result The quaternion that the rotation should be copied to
  15606. */
  15607. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15608. /**
  15609. * Get the world position of a point that is in the local space of the bone
  15610. * @param position The local position
  15611. * @param mesh The mesh that this bone is attached to
  15612. * @returns The world position
  15613. */
  15614. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15615. /**
  15616. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15617. * @param position The local position
  15618. * @param mesh The mesh that this bone is attached to
  15619. * @param result The vector3 that the world position should be copied to
  15620. */
  15621. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15622. /**
  15623. * Get the local position of a point that is in world space
  15624. * @param position The world position
  15625. * @param mesh The mesh that this bone is attached to
  15626. * @returns The local position
  15627. */
  15628. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15629. /**
  15630. * Get the local position of a point that is in world space and copy it to the result param
  15631. * @param position The world position
  15632. * @param mesh The mesh that this bone is attached to
  15633. * @param result The vector3 that the local position should be copied to
  15634. */
  15635. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15636. /**
  15637. * Set the current local matrix as the restPose for this bone.
  15638. */
  15639. setCurrentPoseAsRest(): void;
  15640. }
  15641. }
  15642. declare module BABYLON {
  15643. /**
  15644. * Defines a runtime animation
  15645. */
  15646. export class RuntimeAnimation {
  15647. private _events;
  15648. /**
  15649. * The current frame of the runtime animation
  15650. */
  15651. private _currentFrame;
  15652. /**
  15653. * The animation used by the runtime animation
  15654. */
  15655. private _animation;
  15656. /**
  15657. * The target of the runtime animation
  15658. */
  15659. private _target;
  15660. /**
  15661. * The initiating animatable
  15662. */
  15663. private _host;
  15664. /**
  15665. * The original value of the runtime animation
  15666. */
  15667. private _originalValue;
  15668. /**
  15669. * The original blend value of the runtime animation
  15670. */
  15671. private _originalBlendValue;
  15672. /**
  15673. * The offsets cache of the runtime animation
  15674. */
  15675. private _offsetsCache;
  15676. /**
  15677. * The high limits cache of the runtime animation
  15678. */
  15679. private _highLimitsCache;
  15680. /**
  15681. * Specifies if the runtime animation has been stopped
  15682. */
  15683. private _stopped;
  15684. /**
  15685. * The blending factor of the runtime animation
  15686. */
  15687. private _blendingFactor;
  15688. /**
  15689. * The BabylonJS scene
  15690. */
  15691. private _scene;
  15692. /**
  15693. * The current value of the runtime animation
  15694. */
  15695. private _currentValue;
  15696. /** @hidden */
  15697. _animationState: _IAnimationState;
  15698. /**
  15699. * The active target of the runtime animation
  15700. */
  15701. private _activeTargets;
  15702. private _currentActiveTarget;
  15703. private _directTarget;
  15704. /**
  15705. * The target path of the runtime animation
  15706. */
  15707. private _targetPath;
  15708. /**
  15709. * The weight of the runtime animation
  15710. */
  15711. private _weight;
  15712. /**
  15713. * The ratio offset of the runtime animation
  15714. */
  15715. private _ratioOffset;
  15716. /**
  15717. * The previous delay of the runtime animation
  15718. */
  15719. private _previousDelay;
  15720. /**
  15721. * The previous ratio of the runtime animation
  15722. */
  15723. private _previousRatio;
  15724. private _enableBlending;
  15725. private _keys;
  15726. private _minFrame;
  15727. private _maxFrame;
  15728. private _minValue;
  15729. private _maxValue;
  15730. private _targetIsArray;
  15731. /**
  15732. * Gets the current frame of the runtime animation
  15733. */
  15734. get currentFrame(): number;
  15735. /**
  15736. * Gets the weight of the runtime animation
  15737. */
  15738. get weight(): number;
  15739. /**
  15740. * Gets the current value of the runtime animation
  15741. */
  15742. get currentValue(): any;
  15743. /**
  15744. * Gets the target path of the runtime animation
  15745. */
  15746. get targetPath(): string;
  15747. /**
  15748. * Gets the actual target of the runtime animation
  15749. */
  15750. get target(): any;
  15751. /**
  15752. * Gets the additive state of the runtime animation
  15753. */
  15754. get isAdditive(): boolean;
  15755. /** @hidden */
  15756. _onLoop: () => void;
  15757. /**
  15758. * Create a new RuntimeAnimation object
  15759. * @param target defines the target of the animation
  15760. * @param animation defines the source animation object
  15761. * @param scene defines the hosting scene
  15762. * @param host defines the initiating Animatable
  15763. */
  15764. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15765. private _preparePath;
  15766. /**
  15767. * Gets the animation from the runtime animation
  15768. */
  15769. get animation(): Animation;
  15770. /**
  15771. * Resets the runtime animation to the beginning
  15772. * @param restoreOriginal defines whether to restore the target property to the original value
  15773. */
  15774. reset(restoreOriginal?: boolean): void;
  15775. /**
  15776. * Specifies if the runtime animation is stopped
  15777. * @returns Boolean specifying if the runtime animation is stopped
  15778. */
  15779. isStopped(): boolean;
  15780. /**
  15781. * Disposes of the runtime animation
  15782. */
  15783. dispose(): void;
  15784. /**
  15785. * Apply the interpolated value to the target
  15786. * @param currentValue defines the value computed by the animation
  15787. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15788. */
  15789. setValue(currentValue: any, weight: number): void;
  15790. private _getOriginalValues;
  15791. private _setValue;
  15792. /**
  15793. * Gets the loop pmode of the runtime animation
  15794. * @returns Loop Mode
  15795. */
  15796. private _getCorrectLoopMode;
  15797. /**
  15798. * Move the current animation to a given frame
  15799. * @param frame defines the frame to move to
  15800. */
  15801. goToFrame(frame: number): void;
  15802. /**
  15803. * @hidden Internal use only
  15804. */
  15805. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15806. /**
  15807. * Execute the current animation
  15808. * @param delay defines the delay to add to the current frame
  15809. * @param from defines the lower bound of the animation range
  15810. * @param to defines the upper bound of the animation range
  15811. * @param loop defines if the current animation must loop
  15812. * @param speedRatio defines the current speed ratio
  15813. * @param weight defines the weight of the animation (default is -1 so no weight)
  15814. * @param onLoop optional callback called when animation loops
  15815. * @returns a boolean indicating if the animation is running
  15816. */
  15817. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15818. }
  15819. }
  15820. declare module BABYLON {
  15821. /**
  15822. * Class used to store an actual running animation
  15823. */
  15824. export class Animatable {
  15825. /** defines the target object */
  15826. target: any;
  15827. /** defines the starting frame number (default is 0) */
  15828. fromFrame: number;
  15829. /** defines the ending frame number (default is 100) */
  15830. toFrame: number;
  15831. /** defines if the animation must loop (default is false) */
  15832. loopAnimation: boolean;
  15833. /** defines a callback to call when animation ends if it is not looping */
  15834. onAnimationEnd?: (() => void) | null | undefined;
  15835. /** defines a callback to call when animation loops */
  15836. onAnimationLoop?: (() => void) | null | undefined;
  15837. /** defines whether the animation should be evaluated additively */
  15838. isAdditive: boolean;
  15839. private _localDelayOffset;
  15840. private _pausedDelay;
  15841. private _runtimeAnimations;
  15842. private _paused;
  15843. private _scene;
  15844. private _speedRatio;
  15845. private _weight;
  15846. private _syncRoot;
  15847. /**
  15848. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15849. * This will only apply for non looping animation (default is true)
  15850. */
  15851. disposeOnEnd: boolean;
  15852. /**
  15853. * Gets a boolean indicating if the animation has started
  15854. */
  15855. animationStarted: boolean;
  15856. /**
  15857. * Observer raised when the animation ends
  15858. */
  15859. onAnimationEndObservable: Observable<Animatable>;
  15860. /**
  15861. * Observer raised when the animation loops
  15862. */
  15863. onAnimationLoopObservable: Observable<Animatable>;
  15864. /**
  15865. * Gets the root Animatable used to synchronize and normalize animations
  15866. */
  15867. get syncRoot(): Nullable<Animatable>;
  15868. /**
  15869. * Gets the current frame of the first RuntimeAnimation
  15870. * Used to synchronize Animatables
  15871. */
  15872. get masterFrame(): number;
  15873. /**
  15874. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15875. */
  15876. get weight(): number;
  15877. set weight(value: number);
  15878. /**
  15879. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15880. */
  15881. get speedRatio(): number;
  15882. set speedRatio(value: number);
  15883. /**
  15884. * Creates a new Animatable
  15885. * @param scene defines the hosting scene
  15886. * @param target defines the target object
  15887. * @param fromFrame defines the starting frame number (default is 0)
  15888. * @param toFrame defines the ending frame number (default is 100)
  15889. * @param loopAnimation defines if the animation must loop (default is false)
  15890. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15891. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15892. * @param animations defines a group of animation to add to the new Animatable
  15893. * @param onAnimationLoop defines a callback to call when animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively
  15895. */
  15896. constructor(scene: Scene,
  15897. /** defines the target object */
  15898. target: any,
  15899. /** defines the starting frame number (default is 0) */
  15900. fromFrame?: number,
  15901. /** defines the ending frame number (default is 100) */
  15902. toFrame?: number,
  15903. /** defines if the animation must loop (default is false) */
  15904. loopAnimation?: boolean, speedRatio?: number,
  15905. /** defines a callback to call when animation ends if it is not looping */
  15906. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15907. /** defines a callback to call when animation loops */
  15908. onAnimationLoop?: (() => void) | null | undefined,
  15909. /** defines whether the animation should be evaluated additively */
  15910. isAdditive?: boolean);
  15911. /**
  15912. * Synchronize and normalize current Animatable with a source Animatable
  15913. * This is useful when using animation weights and when animations are not of the same length
  15914. * @param root defines the root Animatable to synchronize with
  15915. * @returns the current Animatable
  15916. */
  15917. syncWith(root: Animatable): Animatable;
  15918. /**
  15919. * Gets the list of runtime animations
  15920. * @returns an array of RuntimeAnimation
  15921. */
  15922. getAnimations(): RuntimeAnimation[];
  15923. /**
  15924. * Adds more animations to the current animatable
  15925. * @param target defines the target of the animations
  15926. * @param animations defines the new animations to add
  15927. */
  15928. appendAnimations(target: any, animations: Animation[]): void;
  15929. /**
  15930. * Gets the source animation for a specific property
  15931. * @param property defines the propertyu to look for
  15932. * @returns null or the source animation for the given property
  15933. */
  15934. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15935. /**
  15936. * Gets the runtime animation for a specific property
  15937. * @param property defines the propertyu to look for
  15938. * @returns null or the runtime animation for the given property
  15939. */
  15940. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15941. /**
  15942. * Resets the animatable to its original state
  15943. */
  15944. reset(): void;
  15945. /**
  15946. * Allows the animatable to blend with current running animations
  15947. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15948. * @param blendingSpeed defines the blending speed to use
  15949. */
  15950. enableBlending(blendingSpeed: number): void;
  15951. /**
  15952. * Disable animation blending
  15953. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15954. */
  15955. disableBlending(): void;
  15956. /**
  15957. * Jump directly to a given frame
  15958. * @param frame defines the frame to jump to
  15959. */
  15960. goToFrame(frame: number): void;
  15961. /**
  15962. * Pause the animation
  15963. */
  15964. pause(): void;
  15965. /**
  15966. * Restart the animation
  15967. */
  15968. restart(): void;
  15969. private _raiseOnAnimationEnd;
  15970. /**
  15971. * Stop and delete the current animation
  15972. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15973. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15974. */
  15975. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15976. /**
  15977. * Wait asynchronously for the animation to end
  15978. * @returns a promise which will be fullfilled when the animation ends
  15979. */
  15980. waitAsync(): Promise<Animatable>;
  15981. /** @hidden */
  15982. _animate(delay: number): boolean;
  15983. }
  15984. interface Scene {
  15985. /** @hidden */
  15986. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15987. /** @hidden */
  15988. _processLateAnimationBindingsForMatrices(holder: {
  15989. totalWeight: number;
  15990. totalAdditiveWeight: number;
  15991. animations: RuntimeAnimation[];
  15992. additiveAnimations: RuntimeAnimation[];
  15993. originalValue: Matrix;
  15994. }): any;
  15995. /** @hidden */
  15996. _processLateAnimationBindingsForQuaternions(holder: {
  15997. totalWeight: number;
  15998. totalAdditiveWeight: number;
  15999. animations: RuntimeAnimation[];
  16000. additiveAnimations: RuntimeAnimation[];
  16001. originalValue: Quaternion;
  16002. }, refQuaternion: Quaternion): Quaternion;
  16003. /** @hidden */
  16004. _processLateAnimationBindings(): void;
  16005. /**
  16006. * Will start the animation sequence of a given target
  16007. * @param target defines the target
  16008. * @param from defines from which frame should animation start
  16009. * @param to defines until which frame should animation run.
  16010. * @param weight defines the weight to apply to the animation (1.0 by default)
  16011. * @param loop defines if the animation loops
  16012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16013. * @param onAnimationEnd defines the function to be executed when the animation ends
  16014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16015. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16016. * @param onAnimationLoop defines the callback to call when an animation loops
  16017. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16018. * @returns the animatable object created for this animation
  16019. */
  16020. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16021. /**
  16022. * Will start the animation sequence of a given target
  16023. * @param target defines the target
  16024. * @param from defines from which frame should animation start
  16025. * @param to defines until which frame should animation run.
  16026. * @param loop defines if the animation loops
  16027. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16028. * @param onAnimationEnd defines the function to be executed when the animation ends
  16029. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16030. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16031. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16032. * @param onAnimationLoop defines the callback to call when an animation loops
  16033. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16034. * @returns the animatable object created for this animation
  16035. */
  16036. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16037. /**
  16038. * Will start the animation sequence of a given target and its hierarchy
  16039. * @param target defines the target
  16040. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16041. * @param from defines from which frame should animation start
  16042. * @param to defines until which frame should animation run.
  16043. * @param loop defines if the animation loops
  16044. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16045. * @param onAnimationEnd defines the function to be executed when the animation ends
  16046. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16047. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16048. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16049. * @param onAnimationLoop defines the callback to call when an animation loops
  16050. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16051. * @returns the list of created animatables
  16052. */
  16053. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16054. /**
  16055. * Begin a new animation on a given node
  16056. * @param target defines the target where the animation will take place
  16057. * @param animations defines the list of animations to start
  16058. * @param from defines the initial value
  16059. * @param to defines the final value
  16060. * @param loop defines if you want animation to loop (off by default)
  16061. * @param speedRatio defines the speed ratio to apply to all animations
  16062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16063. * @param onAnimationLoop defines the callback to call when an animation loops
  16064. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16065. * @returns the list of created animatables
  16066. */
  16067. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16068. /**
  16069. * Begin a new animation on a given node and its hierarchy
  16070. * @param target defines the root node where the animation will take place
  16071. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16072. * @param animations defines the list of animations to start
  16073. * @param from defines the initial value
  16074. * @param to defines the final value
  16075. * @param loop defines if you want animation to loop (off by default)
  16076. * @param speedRatio defines the speed ratio to apply to all animations
  16077. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16078. * @param onAnimationLoop defines the callback to call when an animation loops
  16079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16080. * @returns the list of animatables created for all nodes
  16081. */
  16082. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16083. /**
  16084. * Gets the animatable associated with a specific target
  16085. * @param target defines the target of the animatable
  16086. * @returns the required animatable if found
  16087. */
  16088. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16089. /**
  16090. * Gets all animatables associated with a given target
  16091. * @param target defines the target to look animatables for
  16092. * @returns an array of Animatables
  16093. */
  16094. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16095. /**
  16096. * Stops and removes all animations that have been applied to the scene
  16097. */
  16098. stopAllAnimations(): void;
  16099. /**
  16100. * Gets the current delta time used by animation engine
  16101. */
  16102. deltaTime: number;
  16103. }
  16104. interface Bone {
  16105. /**
  16106. * Copy an animation range from another bone
  16107. * @param source defines the source bone
  16108. * @param rangeName defines the range name to copy
  16109. * @param frameOffset defines the frame offset
  16110. * @param rescaleAsRequired defines if rescaling must be applied if required
  16111. * @param skelDimensionsRatio defines the scaling ratio
  16112. * @returns true if operation was successful
  16113. */
  16114. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Class used to handle skinning animations
  16120. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16121. */
  16122. export class Skeleton implements IAnimatable {
  16123. /** defines the skeleton name */
  16124. name: string;
  16125. /** defines the skeleton Id */
  16126. id: string;
  16127. /**
  16128. * Defines the list of child bones
  16129. */
  16130. bones: Bone[];
  16131. /**
  16132. * Defines an estimate of the dimension of the skeleton at rest
  16133. */
  16134. dimensionsAtRest: Vector3;
  16135. /**
  16136. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16137. */
  16138. needInitialSkinMatrix: boolean;
  16139. /**
  16140. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16141. */
  16142. overrideMesh: Nullable<AbstractMesh>;
  16143. /**
  16144. * Gets the list of animations attached to this skeleton
  16145. */
  16146. animations: Array<Animation>;
  16147. private _scene;
  16148. private _isDirty;
  16149. private _transformMatrices;
  16150. private _transformMatrixTexture;
  16151. private _meshesWithPoseMatrix;
  16152. private _animatables;
  16153. private _identity;
  16154. private _synchronizedWithMesh;
  16155. private _ranges;
  16156. private _lastAbsoluteTransformsUpdateId;
  16157. private _canUseTextureForBones;
  16158. private _uniqueId;
  16159. /** @hidden */
  16160. _numBonesWithLinkedTransformNode: number;
  16161. /** @hidden */
  16162. _hasWaitingData: Nullable<boolean>;
  16163. /** @hidden */
  16164. _waitingOverrideMeshId: Nullable<string>;
  16165. /**
  16166. * Specifies if the skeleton should be serialized
  16167. */
  16168. doNotSerialize: boolean;
  16169. private _useTextureToStoreBoneMatrices;
  16170. /**
  16171. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16172. * Please note that this option is not available if the hardware does not support it
  16173. */
  16174. get useTextureToStoreBoneMatrices(): boolean;
  16175. set useTextureToStoreBoneMatrices(value: boolean);
  16176. private _animationPropertiesOverride;
  16177. /**
  16178. * Gets or sets the animation properties override
  16179. */
  16180. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16181. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16182. /**
  16183. * List of inspectable custom properties (used by the Inspector)
  16184. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16185. */
  16186. inspectableCustomProperties: IInspectable[];
  16187. /**
  16188. * An observable triggered before computing the skeleton's matrices
  16189. */
  16190. onBeforeComputeObservable: Observable<Skeleton>;
  16191. /**
  16192. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16193. */
  16194. get isUsingTextureForMatrices(): boolean;
  16195. /**
  16196. * Gets the unique ID of this skeleton
  16197. */
  16198. get uniqueId(): number;
  16199. /**
  16200. * Creates a new skeleton
  16201. * @param name defines the skeleton name
  16202. * @param id defines the skeleton Id
  16203. * @param scene defines the hosting scene
  16204. */
  16205. constructor(
  16206. /** defines the skeleton name */
  16207. name: string,
  16208. /** defines the skeleton Id */
  16209. id: string, scene: Scene);
  16210. /**
  16211. * Gets the current object class name.
  16212. * @return the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Returns an array containing the root bones
  16217. * @returns an array containing the root bones
  16218. */
  16219. getChildren(): Array<Bone>;
  16220. /**
  16221. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16222. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16223. * @returns a Float32Array containing matrices data
  16224. */
  16225. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16226. /**
  16227. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16228. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16229. * @returns a raw texture containing the data
  16230. */
  16231. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16232. /**
  16233. * Gets the current hosting scene
  16234. * @returns a scene object
  16235. */
  16236. getScene(): Scene;
  16237. /**
  16238. * Gets a string representing the current skeleton data
  16239. * @param fullDetails defines a boolean indicating if we want a verbose version
  16240. * @returns a string representing the current skeleton data
  16241. */
  16242. toString(fullDetails?: boolean): string;
  16243. /**
  16244. * Get bone's index searching by name
  16245. * @param name defines bone's name to search for
  16246. * @return the indice of the bone. Returns -1 if not found
  16247. */
  16248. getBoneIndexByName(name: string): number;
  16249. /**
  16250. * Creater a new animation range
  16251. * @param name defines the name of the range
  16252. * @param from defines the start key
  16253. * @param to defines the end key
  16254. */
  16255. createAnimationRange(name: string, from: number, to: number): void;
  16256. /**
  16257. * Delete a specific animation range
  16258. * @param name defines the name of the range
  16259. * @param deleteFrames defines if frames must be removed as well
  16260. */
  16261. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16262. /**
  16263. * Gets a specific animation range
  16264. * @param name defines the name of the range to look for
  16265. * @returns the requested animation range or null if not found
  16266. */
  16267. getAnimationRange(name: string): Nullable<AnimationRange>;
  16268. /**
  16269. * Gets the list of all animation ranges defined on this skeleton
  16270. * @returns an array
  16271. */
  16272. getAnimationRanges(): Nullable<AnimationRange>[];
  16273. /**
  16274. * Copy animation range from a source skeleton.
  16275. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16276. * @param source defines the source skeleton
  16277. * @param name defines the name of the range to copy
  16278. * @param rescaleAsRequired defines if rescaling must be applied if required
  16279. * @returns true if operation was successful
  16280. */
  16281. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16282. /**
  16283. * Forces the skeleton to go to rest pose
  16284. */
  16285. returnToRest(): void;
  16286. private _getHighestAnimationFrame;
  16287. /**
  16288. * Begin a specific animation range
  16289. * @param name defines the name of the range to start
  16290. * @param loop defines if looping must be turned on (false by default)
  16291. * @param speedRatio defines the speed ratio to apply (1 by default)
  16292. * @param onAnimationEnd defines a callback which will be called when animation will end
  16293. * @returns a new animatable
  16294. */
  16295. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16296. /**
  16297. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16298. * @param skeleton defines the Skeleton containing the animation range to convert
  16299. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16300. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16301. * @returns the original skeleton
  16302. */
  16303. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16304. /** @hidden */
  16305. _markAsDirty(): void;
  16306. /** @hidden */
  16307. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16308. /** @hidden */
  16309. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16310. private _computeTransformMatrices;
  16311. /**
  16312. * Build all resources required to render a skeleton
  16313. */
  16314. prepare(): void;
  16315. /**
  16316. * Gets the list of animatables currently running for this skeleton
  16317. * @returns an array of animatables
  16318. */
  16319. getAnimatables(): IAnimatable[];
  16320. /**
  16321. * Clone the current skeleton
  16322. * @param name defines the name of the new skeleton
  16323. * @param id defines the id of the new skeleton
  16324. * @returns the new skeleton
  16325. */
  16326. clone(name: string, id?: string): Skeleton;
  16327. /**
  16328. * Enable animation blending for this skeleton
  16329. * @param blendingSpeed defines the blending speed to apply
  16330. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16331. */
  16332. enableBlending(blendingSpeed?: number): void;
  16333. /**
  16334. * Releases all resources associated with the current skeleton
  16335. */
  16336. dispose(): void;
  16337. /**
  16338. * Serialize the skeleton in a JSON object
  16339. * @returns a JSON object
  16340. */
  16341. serialize(): any;
  16342. /**
  16343. * Creates a new skeleton from serialized data
  16344. * @param parsedSkeleton defines the serialized data
  16345. * @param scene defines the hosting scene
  16346. * @returns a new skeleton
  16347. */
  16348. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16349. /**
  16350. * Compute all node absolute transforms
  16351. * @param forceUpdate defines if computation must be done even if cache is up to date
  16352. */
  16353. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16354. /**
  16355. * Gets the root pose matrix
  16356. * @returns a matrix
  16357. */
  16358. getPoseMatrix(): Nullable<Matrix>;
  16359. /**
  16360. * Sorts bones per internal index
  16361. */
  16362. sortBones(): void;
  16363. private _sortBones;
  16364. /**
  16365. * Set the current local matrix as the restPose for all bones in the skeleton.
  16366. */
  16367. setCurrentPoseAsRest(): void;
  16368. }
  16369. }
  16370. declare module BABYLON {
  16371. /**
  16372. * Creates an instance based on a source mesh.
  16373. */
  16374. export class InstancedMesh extends AbstractMesh {
  16375. private _sourceMesh;
  16376. private _currentLOD;
  16377. /** @hidden */
  16378. _indexInSourceMeshInstanceArray: number;
  16379. constructor(name: string, source: Mesh);
  16380. /**
  16381. * Returns the string "InstancedMesh".
  16382. */
  16383. getClassName(): string;
  16384. /** Gets the list of lights affecting that mesh */
  16385. get lightSources(): Light[];
  16386. _resyncLightSources(): void;
  16387. _resyncLightSource(light: Light): void;
  16388. _removeLightSource(light: Light, dispose: boolean): void;
  16389. /**
  16390. * If the source mesh receives shadows
  16391. */
  16392. get receiveShadows(): boolean;
  16393. /**
  16394. * The material of the source mesh
  16395. */
  16396. get material(): Nullable<Material>;
  16397. /**
  16398. * Visibility of the source mesh
  16399. */
  16400. get visibility(): number;
  16401. /**
  16402. * Skeleton of the source mesh
  16403. */
  16404. get skeleton(): Nullable<Skeleton>;
  16405. /**
  16406. * Rendering ground id of the source mesh
  16407. */
  16408. get renderingGroupId(): number;
  16409. set renderingGroupId(value: number);
  16410. /**
  16411. * Returns the total number of vertices (integer).
  16412. */
  16413. getTotalVertices(): number;
  16414. /**
  16415. * Returns a positive integer : the total number of indices in this mesh geometry.
  16416. * @returns the numner of indices or zero if the mesh has no geometry.
  16417. */
  16418. getTotalIndices(): number;
  16419. /**
  16420. * The source mesh of the instance
  16421. */
  16422. get sourceMesh(): Mesh;
  16423. /**
  16424. * Creates a new InstancedMesh object from the mesh model.
  16425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16426. * @param name defines the name of the new instance
  16427. * @returns a new InstancedMesh
  16428. */
  16429. createInstance(name: string): InstancedMesh;
  16430. /**
  16431. * Is this node ready to be used/rendered
  16432. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16433. * @return {boolean} is it ready
  16434. */
  16435. isReady(completeCheck?: boolean): boolean;
  16436. /**
  16437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16438. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16439. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16440. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16441. */
  16442. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16443. /**
  16444. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16445. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16446. * The `data` are either a numeric array either a Float32Array.
  16447. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16448. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16449. * Note that a new underlying VertexBuffer object is created each call.
  16450. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16451. *
  16452. * Possible `kind` values :
  16453. * - VertexBuffer.PositionKind
  16454. * - VertexBuffer.UVKind
  16455. * - VertexBuffer.UV2Kind
  16456. * - VertexBuffer.UV3Kind
  16457. * - VertexBuffer.UV4Kind
  16458. * - VertexBuffer.UV5Kind
  16459. * - VertexBuffer.UV6Kind
  16460. * - VertexBuffer.ColorKind
  16461. * - VertexBuffer.MatricesIndicesKind
  16462. * - VertexBuffer.MatricesIndicesExtraKind
  16463. * - VertexBuffer.MatricesWeightsKind
  16464. * - VertexBuffer.MatricesWeightsExtraKind
  16465. *
  16466. * Returns the Mesh.
  16467. */
  16468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16469. /**
  16470. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16471. * If the mesh has no geometry, it is simply returned as it is.
  16472. * The `data` are either a numeric array either a Float32Array.
  16473. * No new underlying VertexBuffer object is created.
  16474. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16475. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16476. *
  16477. * Possible `kind` values :
  16478. * - VertexBuffer.PositionKind
  16479. * - VertexBuffer.UVKind
  16480. * - VertexBuffer.UV2Kind
  16481. * - VertexBuffer.UV3Kind
  16482. * - VertexBuffer.UV4Kind
  16483. * - VertexBuffer.UV5Kind
  16484. * - VertexBuffer.UV6Kind
  16485. * - VertexBuffer.ColorKind
  16486. * - VertexBuffer.MatricesIndicesKind
  16487. * - VertexBuffer.MatricesIndicesExtraKind
  16488. * - VertexBuffer.MatricesWeightsKind
  16489. * - VertexBuffer.MatricesWeightsExtraKind
  16490. *
  16491. * Returns the Mesh.
  16492. */
  16493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16494. /**
  16495. * Sets the mesh indices.
  16496. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16497. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16498. * This method creates a new index buffer each call.
  16499. * Returns the Mesh.
  16500. */
  16501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16502. /**
  16503. * Boolean : True if the mesh owns the requested kind of data.
  16504. */
  16505. isVerticesDataPresent(kind: string): boolean;
  16506. /**
  16507. * Returns an array of indices (IndicesArray).
  16508. */
  16509. getIndices(): Nullable<IndicesArray>;
  16510. get _positions(): Nullable<Vector3[]>;
  16511. /**
  16512. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16513. * This means the mesh underlying bounding box and sphere are recomputed.
  16514. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16515. * @returns the current mesh
  16516. */
  16517. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16518. /** @hidden */
  16519. _preActivate(): InstancedMesh;
  16520. /** @hidden */
  16521. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16522. /** @hidden */
  16523. _postActivate(): void;
  16524. getWorldMatrix(): Matrix;
  16525. get isAnInstance(): boolean;
  16526. /**
  16527. * Returns the current associated LOD AbstractMesh.
  16528. */
  16529. getLOD(camera: Camera): AbstractMesh;
  16530. /** @hidden */
  16531. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16532. /** @hidden */
  16533. _syncSubMeshes(): InstancedMesh;
  16534. /** @hidden */
  16535. _generatePointsArray(): boolean;
  16536. /** @hidden */
  16537. _updateBoundingInfo(): AbstractMesh;
  16538. /**
  16539. * Creates a new InstancedMesh from the current mesh.
  16540. * - name (string) : the cloned mesh name
  16541. * - newParent (optional Node) : the optional Node to parent the clone to.
  16542. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16543. *
  16544. * Returns the clone.
  16545. */
  16546. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16547. /**
  16548. * Disposes the InstancedMesh.
  16549. * Returns nothing.
  16550. */
  16551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16552. }
  16553. interface Mesh {
  16554. /**
  16555. * Register a custom buffer that will be instanced
  16556. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16557. * @param kind defines the buffer kind
  16558. * @param stride defines the stride in floats
  16559. */
  16560. registerInstancedBuffer(kind: string, stride: number): void;
  16561. /**
  16562. * true to use the edge renderer for all instances of this mesh
  16563. */
  16564. edgesShareWithInstances: boolean;
  16565. /** @hidden */
  16566. _userInstancedBuffersStorage: {
  16567. data: {
  16568. [key: string]: Float32Array;
  16569. };
  16570. sizes: {
  16571. [key: string]: number;
  16572. };
  16573. vertexBuffers: {
  16574. [key: string]: Nullable<VertexBuffer>;
  16575. };
  16576. strides: {
  16577. [key: string]: number;
  16578. };
  16579. };
  16580. }
  16581. interface AbstractMesh {
  16582. /**
  16583. * Object used to store instanced buffers defined by user
  16584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16585. */
  16586. instancedBuffers: {
  16587. [key: string]: any;
  16588. };
  16589. }
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * Defines the options associated with the creation of a shader material.
  16594. */
  16595. export interface IShaderMaterialOptions {
  16596. /**
  16597. * Does the material work in alpha blend mode
  16598. */
  16599. needAlphaBlending: boolean;
  16600. /**
  16601. * Does the material work in alpha test mode
  16602. */
  16603. needAlphaTesting: boolean;
  16604. /**
  16605. * The list of attribute names used in the shader
  16606. */
  16607. attributes: string[];
  16608. /**
  16609. * The list of unifrom names used in the shader
  16610. */
  16611. uniforms: string[];
  16612. /**
  16613. * The list of UBO names used in the shader
  16614. */
  16615. uniformBuffers: string[];
  16616. /**
  16617. * The list of sampler names used in the shader
  16618. */
  16619. samplers: string[];
  16620. /**
  16621. * The list of defines used in the shader
  16622. */
  16623. defines: string[];
  16624. }
  16625. /**
  16626. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16627. *
  16628. * This returned material effects how the mesh will look based on the code in the shaders.
  16629. *
  16630. * @see https://doc.babylonjs.com/how_to/shader_material
  16631. */
  16632. export class ShaderMaterial extends Material {
  16633. private _shaderPath;
  16634. private _options;
  16635. private _textures;
  16636. private _textureArrays;
  16637. private _floats;
  16638. private _ints;
  16639. private _floatsArrays;
  16640. private _colors3;
  16641. private _colors3Arrays;
  16642. private _colors4;
  16643. private _colors4Arrays;
  16644. private _vectors2;
  16645. private _vectors3;
  16646. private _vectors4;
  16647. private _matrices;
  16648. private _matrixArrays;
  16649. private _matrices3x3;
  16650. private _matrices2x2;
  16651. private _vectors2Arrays;
  16652. private _vectors3Arrays;
  16653. private _vectors4Arrays;
  16654. private _cachedWorldViewMatrix;
  16655. private _cachedWorldViewProjectionMatrix;
  16656. private _renderId;
  16657. private _multiview;
  16658. private _cachedDefines;
  16659. /** Define the Url to load snippets */
  16660. static SnippetUrl: string;
  16661. /** Snippet ID if the material was created from the snippet server */
  16662. snippetId: string;
  16663. /**
  16664. * Instantiate a new shader material.
  16665. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16666. * This returned material effects how the mesh will look based on the code in the shaders.
  16667. * @see https://doc.babylonjs.com/how_to/shader_material
  16668. * @param name Define the name of the material in the scene
  16669. * @param scene Define the scene the material belongs to
  16670. * @param shaderPath Defines the route to the shader code in one of three ways:
  16671. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16672. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16673. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16674. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16675. * @param options Define the options used to create the shader
  16676. */
  16677. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16678. /**
  16679. * Gets the shader path used to define the shader code
  16680. * It can be modified to trigger a new compilation
  16681. */
  16682. get shaderPath(): any;
  16683. /**
  16684. * Sets the shader path used to define the shader code
  16685. * It can be modified to trigger a new compilation
  16686. */
  16687. set shaderPath(shaderPath: any);
  16688. /**
  16689. * Gets the options used to compile the shader.
  16690. * They can be modified to trigger a new compilation
  16691. */
  16692. get options(): IShaderMaterialOptions;
  16693. /**
  16694. * Gets the current class name of the material e.g. "ShaderMaterial"
  16695. * Mainly use in serialization.
  16696. * @returns the class name
  16697. */
  16698. getClassName(): string;
  16699. /**
  16700. * Specifies if the material will require alpha blending
  16701. * @returns a boolean specifying if alpha blending is needed
  16702. */
  16703. needAlphaBlending(): boolean;
  16704. /**
  16705. * Specifies if this material should be rendered in alpha test mode
  16706. * @returns a boolean specifying if an alpha test is needed.
  16707. */
  16708. needAlphaTesting(): boolean;
  16709. private _checkUniform;
  16710. /**
  16711. * Set a texture in the shader.
  16712. * @param name Define the name of the uniform samplers as defined in the shader
  16713. * @param texture Define the texture to bind to this sampler
  16714. * @return the material itself allowing "fluent" like uniform updates
  16715. */
  16716. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16717. /**
  16718. * Set a texture array in the shader.
  16719. * @param name Define the name of the uniform sampler array as defined in the shader
  16720. * @param textures Define the list of textures to bind to this sampler
  16721. * @return the material itself allowing "fluent" like uniform updates
  16722. */
  16723. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16724. /**
  16725. * Set a float in the shader.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the material itself allowing "fluent" like uniform updates
  16729. */
  16730. setFloat(name: string, value: number): ShaderMaterial;
  16731. /**
  16732. * Set a int in the shader.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the material itself allowing "fluent" like uniform updates
  16736. */
  16737. setInt(name: string, value: number): ShaderMaterial;
  16738. /**
  16739. * Set an array of floats in the shader.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the material itself allowing "fluent" like uniform updates
  16743. */
  16744. setFloats(name: string, value: number[]): ShaderMaterial;
  16745. /**
  16746. * Set a vec3 in the shader from a Color3.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setColor3(name: string, value: Color3): ShaderMaterial;
  16752. /**
  16753. * Set a vec3 array in the shader from a Color3 array.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the material itself allowing "fluent" like uniform updates
  16757. */
  16758. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16759. /**
  16760. * Set a vec4 in the shader from a Color4.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setColor4(name: string, value: Color4): ShaderMaterial;
  16766. /**
  16767. * Set a vec4 array in the shader from a Color4 array.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16773. /**
  16774. * Set a vec2 in the shader from a Vector2.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setVector2(name: string, value: Vector2): ShaderMaterial;
  16780. /**
  16781. * Set a vec3 in the shader from a Vector3.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setVector3(name: string, value: Vector3): ShaderMaterial;
  16787. /**
  16788. * Set a vec4 in the shader from a Vector4.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setVector4(name: string, value: Vector4): ShaderMaterial;
  16794. /**
  16795. * Set a mat4 in the shader from a Matrix.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16801. /**
  16802. * Set a float32Array in the shader from a matrix array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16808. /**
  16809. * Set a mat3 in the shader from a Float32Array.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16815. /**
  16816. * Set a mat2 in the shader from a Float32Array.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16822. /**
  16823. * Set a vec2 array in the shader from a number array.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setArray2(name: string, value: number[]): ShaderMaterial;
  16829. /**
  16830. * Set a vec3 array in the shader from a number array.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setArray3(name: string, value: number[]): ShaderMaterial;
  16836. /**
  16837. * Set a vec4 array in the shader from a number array.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setArray4(name: string, value: number[]): ShaderMaterial;
  16843. private _checkCache;
  16844. /**
  16845. * Specifies that the submesh is ready to be used
  16846. * @param mesh defines the mesh to check
  16847. * @param subMesh defines which submesh to check
  16848. * @param useInstances specifies that instances should be used
  16849. * @returns a boolean indicating that the submesh is ready or not
  16850. */
  16851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16852. /**
  16853. * Checks if the material is ready to render the requested mesh
  16854. * @param mesh Define the mesh to render
  16855. * @param useInstances Define whether or not the material is used with instances
  16856. * @returns true if ready, otherwise false
  16857. */
  16858. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16859. /**
  16860. * Binds the world matrix to the material
  16861. * @param world defines the world transformation matrix
  16862. * @param effectOverride - If provided, use this effect instead of internal effect
  16863. */
  16864. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16865. /**
  16866. * Binds the submesh to this material by preparing the effect and shader to draw
  16867. * @param world defines the world transformation matrix
  16868. * @param mesh defines the mesh containing the submesh
  16869. * @param subMesh defines the submesh to bind the material to
  16870. */
  16871. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16872. /**
  16873. * Binds the material to the mesh
  16874. * @param world defines the world transformation matrix
  16875. * @param mesh defines the mesh to bind the material to
  16876. * @param effectOverride - If provided, use this effect instead of internal effect
  16877. */
  16878. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16879. protected _afterBind(mesh?: Mesh): void;
  16880. /**
  16881. * Gets the active textures from the material
  16882. * @returns an array of textures
  16883. */
  16884. getActiveTextures(): BaseTexture[];
  16885. /**
  16886. * Specifies if the material uses a texture
  16887. * @param texture defines the texture to check against the material
  16888. * @returns a boolean specifying if the material uses the texture
  16889. */
  16890. hasTexture(texture: BaseTexture): boolean;
  16891. /**
  16892. * Makes a duplicate of the material, and gives it a new name
  16893. * @param name defines the new name for the duplicated material
  16894. * @returns the cloned material
  16895. */
  16896. clone(name: string): ShaderMaterial;
  16897. /**
  16898. * Disposes the material
  16899. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16900. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16901. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16902. */
  16903. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16904. /**
  16905. * Serializes this material in a JSON representation
  16906. * @returns the serialized material object
  16907. */
  16908. serialize(): any;
  16909. /**
  16910. * Creates a shader material from parsed shader material data
  16911. * @param source defines the JSON represnetation of the material
  16912. * @param scene defines the hosting scene
  16913. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16914. * @returns a new material
  16915. */
  16916. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16917. /**
  16918. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16919. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16920. * @param url defines the url to load from
  16921. * @param scene defines the hosting scene
  16922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16923. * @returns a promise that will resolve to the new ShaderMaterial
  16924. */
  16925. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16926. /**
  16927. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16928. * @param snippetId defines the snippet to load
  16929. * @param scene defines the hosting scene
  16930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16931. * @returns a promise that will resolve to the new ShaderMaterial
  16932. */
  16933. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /** @hidden */
  16938. export var colorPixelShader: {
  16939. name: string;
  16940. shader: string;
  16941. };
  16942. }
  16943. declare module BABYLON {
  16944. /** @hidden */
  16945. export var colorVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module BABYLON {
  16951. /**
  16952. * Line mesh
  16953. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16954. */
  16955. export class LinesMesh extends Mesh {
  16956. /**
  16957. * If vertex color should be applied to the mesh
  16958. */
  16959. readonly useVertexColor?: boolean | undefined;
  16960. /**
  16961. * If vertex alpha should be applied to the mesh
  16962. */
  16963. readonly useVertexAlpha?: boolean | undefined;
  16964. /**
  16965. * Color of the line (Default: White)
  16966. */
  16967. color: Color3;
  16968. /**
  16969. * Alpha of the line (Default: 1)
  16970. */
  16971. alpha: number;
  16972. /**
  16973. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16974. * This margin is expressed in world space coordinates, so its value may vary.
  16975. * Default value is 0.1
  16976. */
  16977. intersectionThreshold: number;
  16978. private _colorShader;
  16979. private color4;
  16980. /**
  16981. * Creates a new LinesMesh
  16982. * @param name defines the name
  16983. * @param scene defines the hosting scene
  16984. * @param parent defines the parent mesh if any
  16985. * @param source defines the optional source LinesMesh used to clone data from
  16986. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16987. * When false, achieved by calling a clone(), also passing False.
  16988. * This will make creation of children, recursive.
  16989. * @param useVertexColor defines if this LinesMesh supports vertex color
  16990. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16991. */
  16992. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16993. /**
  16994. * If vertex color should be applied to the mesh
  16995. */
  16996. useVertexColor?: boolean | undefined,
  16997. /**
  16998. * If vertex alpha should be applied to the mesh
  16999. */
  17000. useVertexAlpha?: boolean | undefined);
  17001. private _addClipPlaneDefine;
  17002. private _removeClipPlaneDefine;
  17003. isReady(): boolean;
  17004. /**
  17005. * Returns the string "LineMesh"
  17006. */
  17007. getClassName(): string;
  17008. /**
  17009. * @hidden
  17010. */
  17011. get material(): Material;
  17012. /**
  17013. * @hidden
  17014. */
  17015. set material(value: Material);
  17016. /**
  17017. * @hidden
  17018. */
  17019. get checkCollisions(): boolean;
  17020. /** @hidden */
  17021. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17022. /** @hidden */
  17023. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17024. /**
  17025. * Disposes of the line mesh
  17026. * @param doNotRecurse If children should be disposed
  17027. */
  17028. dispose(doNotRecurse?: boolean): void;
  17029. /**
  17030. * Returns a new LineMesh object cloned from the current one.
  17031. */
  17032. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17033. /**
  17034. * Creates a new InstancedLinesMesh object from the mesh model.
  17035. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17036. * @param name defines the name of the new instance
  17037. * @returns a new InstancedLinesMesh
  17038. */
  17039. createInstance(name: string): InstancedLinesMesh;
  17040. }
  17041. /**
  17042. * Creates an instance based on a source LinesMesh
  17043. */
  17044. export class InstancedLinesMesh extends InstancedMesh {
  17045. /**
  17046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17047. * This margin is expressed in world space coordinates, so its value may vary.
  17048. * Initilized with the intersectionThreshold value of the source LinesMesh
  17049. */
  17050. intersectionThreshold: number;
  17051. constructor(name: string, source: LinesMesh);
  17052. /**
  17053. * Returns the string "InstancedLinesMesh".
  17054. */
  17055. getClassName(): string;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /** @hidden */
  17060. export var linePixelShader: {
  17061. name: string;
  17062. shader: string;
  17063. };
  17064. }
  17065. declare module BABYLON {
  17066. /** @hidden */
  17067. export var lineVertexShader: {
  17068. name: string;
  17069. shader: string;
  17070. };
  17071. }
  17072. declare module BABYLON {
  17073. interface Scene {
  17074. /** @hidden */
  17075. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17076. }
  17077. interface AbstractMesh {
  17078. /**
  17079. * Gets the edgesRenderer associated with the mesh
  17080. */
  17081. edgesRenderer: Nullable<EdgesRenderer>;
  17082. }
  17083. interface LinesMesh {
  17084. /**
  17085. * Enables the edge rendering mode on the mesh.
  17086. * This mode makes the mesh edges visible
  17087. * @param epsilon defines the maximal distance between two angles to detect a face
  17088. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17089. * @returns the currentAbstractMesh
  17090. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17091. */
  17092. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17093. }
  17094. interface InstancedLinesMesh {
  17095. /**
  17096. * Enables the edge rendering mode on the mesh.
  17097. * This mode makes the mesh edges visible
  17098. * @param epsilon defines the maximal distance between two angles to detect a face
  17099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17100. * @returns the current InstancedLinesMesh
  17101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17102. */
  17103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17104. }
  17105. /**
  17106. * Defines the minimum contract an Edges renderer should follow.
  17107. */
  17108. export interface IEdgesRenderer extends IDisposable {
  17109. /**
  17110. * Gets or sets a boolean indicating if the edgesRenderer is active
  17111. */
  17112. isEnabled: boolean;
  17113. /**
  17114. * Renders the edges of the attached mesh,
  17115. */
  17116. render(): void;
  17117. /**
  17118. * Checks wether or not the edges renderer is ready to render.
  17119. * @return true if ready, otherwise false.
  17120. */
  17121. isReady(): boolean;
  17122. /**
  17123. * List of instances to render in case the source mesh has instances
  17124. */
  17125. customInstances: SmartArray<Matrix>;
  17126. }
  17127. /**
  17128. * Defines the additional options of the edges renderer
  17129. */
  17130. export interface IEdgesRendererOptions {
  17131. /**
  17132. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17133. * If not defined, the default value is true
  17134. */
  17135. useAlternateEdgeFinder?: boolean;
  17136. /**
  17137. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17138. * If not defined, the default value is true.
  17139. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17140. * This option is used only if useAlternateEdgeFinder = true
  17141. */
  17142. useFastVertexMerger?: boolean;
  17143. /**
  17144. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17145. * The default value is 1e-6
  17146. * This option is used only if useAlternateEdgeFinder = true
  17147. */
  17148. epsilonVertexMerge?: number;
  17149. /**
  17150. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17151. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17152. * This option is used only if useAlternateEdgeFinder = true
  17153. */
  17154. applyTessellation?: boolean;
  17155. /**
  17156. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17157. * The default value is 1e-6
  17158. * This option is used only if useAlternateEdgeFinder = true
  17159. */
  17160. epsilonVertexAligned?: number;
  17161. }
  17162. /**
  17163. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17164. */
  17165. export class EdgesRenderer implements IEdgesRenderer {
  17166. /**
  17167. * Define the size of the edges with an orthographic camera
  17168. */
  17169. edgesWidthScalerForOrthographic: number;
  17170. /**
  17171. * Define the size of the edges with a perspective camera
  17172. */
  17173. edgesWidthScalerForPerspective: number;
  17174. protected _source: AbstractMesh;
  17175. protected _linesPositions: number[];
  17176. protected _linesNormals: number[];
  17177. protected _linesIndices: number[];
  17178. protected _epsilon: number;
  17179. protected _indicesCount: number;
  17180. protected _lineShader: ShaderMaterial;
  17181. protected _ib: DataBuffer;
  17182. protected _buffers: {
  17183. [key: string]: Nullable<VertexBuffer>;
  17184. };
  17185. protected _buffersForInstances: {
  17186. [key: string]: Nullable<VertexBuffer>;
  17187. };
  17188. protected _checkVerticesInsteadOfIndices: boolean;
  17189. protected _options: Nullable<IEdgesRendererOptions>;
  17190. private _meshRebuildObserver;
  17191. private _meshDisposeObserver;
  17192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17193. isEnabled: boolean;
  17194. /**
  17195. * List of instances to render in case the source mesh has instances
  17196. */
  17197. customInstances: SmartArray<Matrix>;
  17198. private static GetShader;
  17199. /**
  17200. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17201. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17202. * @param source Mesh used to create edges
  17203. * @param epsilon sum of angles in adjacency to check for edge
  17204. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17205. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17206. * @param options The options to apply when generating the edges
  17207. */
  17208. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17209. protected _prepareRessources(): void;
  17210. /** @hidden */
  17211. _rebuild(): void;
  17212. /**
  17213. * Releases the required resources for the edges renderer
  17214. */
  17215. dispose(): void;
  17216. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17217. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17218. /**
  17219. * Checks if the pair of p0 and p1 is en edge
  17220. * @param faceIndex
  17221. * @param edge
  17222. * @param faceNormals
  17223. * @param p0
  17224. * @param p1
  17225. * @private
  17226. */
  17227. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17228. /**
  17229. * push line into the position, normal and index buffer
  17230. * @protected
  17231. */
  17232. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17233. /**
  17234. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17235. */
  17236. private _tessellateTriangle;
  17237. private _generateEdgesLinesAlternate;
  17238. /**
  17239. * Generates lines edges from adjacencjes
  17240. * @private
  17241. */
  17242. _generateEdgesLines(): void;
  17243. /**
  17244. * Checks wether or not the edges renderer is ready to render.
  17245. * @return true if ready, otherwise false.
  17246. */
  17247. isReady(): boolean;
  17248. /**
  17249. * Renders the edges of the attached mesh,
  17250. */
  17251. render(): void;
  17252. }
  17253. /**
  17254. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17255. */
  17256. export class LineEdgesRenderer extends EdgesRenderer {
  17257. /**
  17258. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17259. * @param source LineMesh used to generate edges
  17260. * @param epsilon not important (specified angle for edge detection)
  17261. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17262. */
  17263. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17264. /**
  17265. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17266. */
  17267. _generateEdgesLines(): void;
  17268. }
  17269. }
  17270. declare module BABYLON {
  17271. /**
  17272. * This represents the object necessary to create a rendering group.
  17273. * This is exclusively used and created by the rendering manager.
  17274. * To modify the behavior, you use the available helpers in your scene or meshes.
  17275. * @hidden
  17276. */
  17277. export class RenderingGroup {
  17278. index: number;
  17279. private static _zeroVector;
  17280. private _scene;
  17281. private _opaqueSubMeshes;
  17282. private _transparentSubMeshes;
  17283. private _alphaTestSubMeshes;
  17284. private _depthOnlySubMeshes;
  17285. private _particleSystems;
  17286. private _spriteManagers;
  17287. private _opaqueSortCompareFn;
  17288. private _alphaTestSortCompareFn;
  17289. private _transparentSortCompareFn;
  17290. private _renderOpaque;
  17291. private _renderAlphaTest;
  17292. private _renderTransparent;
  17293. /** @hidden */
  17294. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17295. onBeforeTransparentRendering: () => void;
  17296. /**
  17297. * Set the opaque sort comparison function.
  17298. * If null the sub meshes will be render in the order they were created
  17299. */
  17300. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17301. /**
  17302. * Set the alpha test sort comparison function.
  17303. * If null the sub meshes will be render in the order they were created
  17304. */
  17305. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17306. /**
  17307. * Set the transparent sort comparison function.
  17308. * If null the sub meshes will be render in the order they were created
  17309. */
  17310. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17311. /**
  17312. * Creates a new rendering group.
  17313. * @param index The rendering group index
  17314. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17315. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17316. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17317. */
  17318. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17319. /**
  17320. * Render all the sub meshes contained in the group.
  17321. * @param customRenderFunction Used to override the default render behaviour of the group.
  17322. * @returns true if rendered some submeshes.
  17323. */
  17324. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17325. /**
  17326. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17327. * @param subMeshes The submeshes to render
  17328. */
  17329. private renderOpaqueSorted;
  17330. /**
  17331. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17332. * @param subMeshes The submeshes to render
  17333. */
  17334. private renderAlphaTestSorted;
  17335. /**
  17336. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17337. * @param subMeshes The submeshes to render
  17338. */
  17339. private renderTransparentSorted;
  17340. /**
  17341. * Renders the submeshes in a specified order.
  17342. * @param subMeshes The submeshes to sort before render
  17343. * @param sortCompareFn The comparison function use to sort
  17344. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17345. * @param transparent Specifies to activate blending if true
  17346. */
  17347. private static renderSorted;
  17348. /**
  17349. * Renders the submeshes in the order they were dispatched (no sort applied).
  17350. * @param subMeshes The submeshes to render
  17351. */
  17352. private static renderUnsorted;
  17353. /**
  17354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17355. * are rendered back to front if in the same alpha index.
  17356. *
  17357. * @param a The first submesh
  17358. * @param b The second submesh
  17359. * @returns The result of the comparison
  17360. */
  17361. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17362. /**
  17363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17364. * are rendered back to front.
  17365. *
  17366. * @param a The first submesh
  17367. * @param b The second submesh
  17368. * @returns The result of the comparison
  17369. */
  17370. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17371. /**
  17372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17373. * are rendered front to back (prevent overdraw).
  17374. *
  17375. * @param a The first submesh
  17376. * @param b The second submesh
  17377. * @returns The result of the comparison
  17378. */
  17379. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17380. /**
  17381. * Resets the different lists of submeshes to prepare a new frame.
  17382. */
  17383. prepare(): void;
  17384. dispose(): void;
  17385. /**
  17386. * Inserts the submesh in its correct queue depending on its material.
  17387. * @param subMesh The submesh to dispatch
  17388. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17389. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17390. */
  17391. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17392. dispatchSprites(spriteManager: ISpriteManager): void;
  17393. dispatchParticles(particleSystem: IParticleSystem): void;
  17394. private _renderParticles;
  17395. private _renderSprites;
  17396. }
  17397. }
  17398. declare module BABYLON {
  17399. /**
  17400. * Interface describing the different options available in the rendering manager
  17401. * regarding Auto Clear between groups.
  17402. */
  17403. export interface IRenderingManagerAutoClearSetup {
  17404. /**
  17405. * Defines whether or not autoclear is enable.
  17406. */
  17407. autoClear: boolean;
  17408. /**
  17409. * Defines whether or not to autoclear the depth buffer.
  17410. */
  17411. depth: boolean;
  17412. /**
  17413. * Defines whether or not to autoclear the stencil buffer.
  17414. */
  17415. stencil: boolean;
  17416. }
  17417. /**
  17418. * This class is used by the onRenderingGroupObservable
  17419. */
  17420. export class RenderingGroupInfo {
  17421. /**
  17422. * The Scene that being rendered
  17423. */
  17424. scene: Scene;
  17425. /**
  17426. * The camera currently used for the rendering pass
  17427. */
  17428. camera: Nullable<Camera>;
  17429. /**
  17430. * The ID of the renderingGroup being processed
  17431. */
  17432. renderingGroupId: number;
  17433. }
  17434. /**
  17435. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17436. * It is enable to manage the different groups as well as the different necessary sort functions.
  17437. * This should not be used directly aside of the few static configurations
  17438. */
  17439. export class RenderingManager {
  17440. /**
  17441. * The max id used for rendering groups (not included)
  17442. */
  17443. static MAX_RENDERINGGROUPS: number;
  17444. /**
  17445. * The min id used for rendering groups (included)
  17446. */
  17447. static MIN_RENDERINGGROUPS: number;
  17448. /**
  17449. * Used to globally prevent autoclearing scenes.
  17450. */
  17451. static AUTOCLEAR: boolean;
  17452. /**
  17453. * @hidden
  17454. */
  17455. _useSceneAutoClearSetup: boolean;
  17456. private _scene;
  17457. private _renderingGroups;
  17458. private _depthStencilBufferAlreadyCleaned;
  17459. private _autoClearDepthStencil;
  17460. private _customOpaqueSortCompareFn;
  17461. private _customAlphaTestSortCompareFn;
  17462. private _customTransparentSortCompareFn;
  17463. private _renderingGroupInfo;
  17464. /**
  17465. * Instantiates a new rendering group for a particular scene
  17466. * @param scene Defines the scene the groups belongs to
  17467. */
  17468. constructor(scene: Scene);
  17469. private _clearDepthStencilBuffer;
  17470. /**
  17471. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17472. * @hidden
  17473. */
  17474. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17475. /**
  17476. * Resets the different information of the group to prepare a new frame
  17477. * @hidden
  17478. */
  17479. reset(): void;
  17480. /**
  17481. * Dispose and release the group and its associated resources.
  17482. * @hidden
  17483. */
  17484. dispose(): void;
  17485. /**
  17486. * Clear the info related to rendering groups preventing retention points during dispose.
  17487. */
  17488. freeRenderingGroups(): void;
  17489. private _prepareRenderingGroup;
  17490. /**
  17491. * Add a sprite manager to the rendering manager in order to render it this frame.
  17492. * @param spriteManager Define the sprite manager to render
  17493. */
  17494. dispatchSprites(spriteManager: ISpriteManager): void;
  17495. /**
  17496. * Add a particle system to the rendering manager in order to render it this frame.
  17497. * @param particleSystem Define the particle system to render
  17498. */
  17499. dispatchParticles(particleSystem: IParticleSystem): void;
  17500. /**
  17501. * Add a submesh to the manager in order to render it this frame
  17502. * @param subMesh The submesh to dispatch
  17503. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17504. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17505. */
  17506. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17507. /**
  17508. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17509. * This allowed control for front to back rendering or reversly depending of the special needs.
  17510. *
  17511. * @param renderingGroupId The rendering group id corresponding to its index
  17512. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17513. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17514. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17515. */
  17516. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17517. /**
  17518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17519. *
  17520. * @param renderingGroupId The rendering group id corresponding to its index
  17521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17522. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17523. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17524. */
  17525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17526. /**
  17527. * Gets the current auto clear configuration for one rendering group of the rendering
  17528. * manager.
  17529. * @param index the rendering group index to get the information for
  17530. * @returns The auto clear setup for the requested rendering group
  17531. */
  17532. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17533. }
  17534. }
  17535. declare module BABYLON {
  17536. /**
  17537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17538. */
  17539. export interface ICustomShaderOptions {
  17540. /**
  17541. * Gets or sets the custom shader name to use
  17542. */
  17543. shaderName: string;
  17544. /**
  17545. * The list of attribute names used in the shader
  17546. */
  17547. attributes?: string[];
  17548. /**
  17549. * The list of unifrom names used in the shader
  17550. */
  17551. uniforms?: string[];
  17552. /**
  17553. * The list of sampler names used in the shader
  17554. */
  17555. samplers?: string[];
  17556. /**
  17557. * The list of defines used in the shader
  17558. */
  17559. defines?: string[];
  17560. }
  17561. /**
  17562. * Interface to implement to create a shadow generator compatible with BJS.
  17563. */
  17564. export interface IShadowGenerator {
  17565. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17566. id: string;
  17567. /**
  17568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17569. * @returns The render target texture if present otherwise, null
  17570. */
  17571. getShadowMap(): Nullable<RenderTargetTexture>;
  17572. /**
  17573. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17574. * @param subMesh The submesh we want to render in the shadow map
  17575. * @param useInstances Defines wether will draw in the map using instances
  17576. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17577. * @returns true if ready otherwise, false
  17578. */
  17579. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17580. /**
  17581. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17582. * @param defines Defines of the material we want to update
  17583. * @param lightIndex Index of the light in the enabled light list of the material
  17584. */
  17585. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17586. /**
  17587. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17588. * defined in the generator but impacting the effect).
  17589. * It implies the unifroms available on the materials are the standard BJS ones.
  17590. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17591. * @param effect The effect we are binfing the information for
  17592. */
  17593. bindShadowLight(lightIndex: string, effect: Effect): void;
  17594. /**
  17595. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17596. * (eq to shadow prjection matrix * light transform matrix)
  17597. * @returns The transform matrix used to create the shadow map
  17598. */
  17599. getTransformMatrix(): Matrix;
  17600. /**
  17601. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17602. * Cube and 2D textures for instance.
  17603. */
  17604. recreateShadowMap(): void;
  17605. /**
  17606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17607. * @param onCompiled Callback triggered at the and of the effects compilation
  17608. * @param options Sets of optional options forcing the compilation with different modes
  17609. */
  17610. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17611. useInstances: boolean;
  17612. }>): void;
  17613. /**
  17614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17615. * @param options Sets of optional options forcing the compilation with different modes
  17616. * @returns A promise that resolves when the compilation completes
  17617. */
  17618. forceCompilationAsync(options?: Partial<{
  17619. useInstances: boolean;
  17620. }>): Promise<void>;
  17621. /**
  17622. * Serializes the shadow generator setup to a json object.
  17623. * @returns The serialized JSON object
  17624. */
  17625. serialize(): any;
  17626. /**
  17627. * Disposes the Shadow map and related Textures and effects.
  17628. */
  17629. dispose(): void;
  17630. }
  17631. /**
  17632. * Default implementation IShadowGenerator.
  17633. * This is the main object responsible of generating shadows in the framework.
  17634. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17635. */
  17636. export class ShadowGenerator implements IShadowGenerator {
  17637. /**
  17638. * Name of the shadow generator class
  17639. */
  17640. static CLASSNAME: string;
  17641. /**
  17642. * Shadow generator mode None: no filtering applied.
  17643. */
  17644. static readonly FILTER_NONE: number;
  17645. /**
  17646. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17648. */
  17649. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17650. /**
  17651. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17652. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17653. */
  17654. static readonly FILTER_POISSONSAMPLING: number;
  17655. /**
  17656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17657. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17658. */
  17659. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17660. /**
  17661. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17662. * edge artifacts on steep falloff.
  17663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17664. */
  17665. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17666. /**
  17667. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17668. * edge artifacts on steep falloff.
  17669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17670. */
  17671. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17672. /**
  17673. * Shadow generator mode PCF: Percentage Closer Filtering
  17674. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17675. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17676. */
  17677. static readonly FILTER_PCF: number;
  17678. /**
  17679. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17680. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17681. * Contact Hardening
  17682. */
  17683. static readonly FILTER_PCSS: number;
  17684. /**
  17685. * Reserved for PCF and PCSS
  17686. * Highest Quality.
  17687. *
  17688. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17689. *
  17690. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17691. */
  17692. static readonly QUALITY_HIGH: number;
  17693. /**
  17694. * Reserved for PCF and PCSS
  17695. * Good tradeoff for quality/perf cross devices
  17696. *
  17697. * Execute PCF on a 3*3 kernel.
  17698. *
  17699. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17700. */
  17701. static readonly QUALITY_MEDIUM: number;
  17702. /**
  17703. * Reserved for PCF and PCSS
  17704. * The lowest quality but the fastest.
  17705. *
  17706. * Execute PCF on a 1*1 kernel.
  17707. *
  17708. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17709. */
  17710. static readonly QUALITY_LOW: number;
  17711. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17712. id: string;
  17713. /** Gets or sets the custom shader name to use */
  17714. customShaderOptions: ICustomShaderOptions;
  17715. /**
  17716. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17717. */
  17718. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17719. /**
  17720. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17721. */
  17722. onAfterShadowMapRenderObservable: Observable<Effect>;
  17723. /**
  17724. * Observable triggered before a mesh is rendered in the shadow map.
  17725. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17726. */
  17727. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17728. /**
  17729. * Observable triggered after a mesh is rendered in the shadow map.
  17730. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17731. */
  17732. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17733. protected _bias: number;
  17734. /**
  17735. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17736. */
  17737. get bias(): number;
  17738. /**
  17739. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17740. */
  17741. set bias(bias: number);
  17742. protected _normalBias: number;
  17743. /**
  17744. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17745. */
  17746. get normalBias(): number;
  17747. /**
  17748. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17749. */
  17750. set normalBias(normalBias: number);
  17751. protected _blurBoxOffset: number;
  17752. /**
  17753. * Gets the blur box offset: offset applied during the blur pass.
  17754. * Only useful if useKernelBlur = false
  17755. */
  17756. get blurBoxOffset(): number;
  17757. /**
  17758. * Sets the blur box offset: offset applied during the blur pass.
  17759. * Only useful if useKernelBlur = false
  17760. */
  17761. set blurBoxOffset(value: number);
  17762. protected _blurScale: number;
  17763. /**
  17764. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17765. * 2 means half of the size.
  17766. */
  17767. get blurScale(): number;
  17768. /**
  17769. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17770. * 2 means half of the size.
  17771. */
  17772. set blurScale(value: number);
  17773. protected _blurKernel: number;
  17774. /**
  17775. * Gets the blur kernel: kernel size of the blur pass.
  17776. * Only useful if useKernelBlur = true
  17777. */
  17778. get blurKernel(): number;
  17779. /**
  17780. * Sets the blur kernel: kernel size of the blur pass.
  17781. * Only useful if useKernelBlur = true
  17782. */
  17783. set blurKernel(value: number);
  17784. protected _useKernelBlur: boolean;
  17785. /**
  17786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17788. */
  17789. get useKernelBlur(): boolean;
  17790. /**
  17791. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17792. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17793. */
  17794. set useKernelBlur(value: boolean);
  17795. protected _depthScale: number;
  17796. /**
  17797. * Gets the depth scale used in ESM mode.
  17798. */
  17799. get depthScale(): number;
  17800. /**
  17801. * Sets the depth scale used in ESM mode.
  17802. * This can override the scale stored on the light.
  17803. */
  17804. set depthScale(value: number);
  17805. protected _validateFilter(filter: number): number;
  17806. protected _filter: number;
  17807. /**
  17808. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17810. */
  17811. get filter(): number;
  17812. /**
  17813. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17815. */
  17816. set filter(value: number);
  17817. /**
  17818. * Gets if the current filter is set to Poisson Sampling.
  17819. */
  17820. get usePoissonSampling(): boolean;
  17821. /**
  17822. * Sets the current filter to Poisson Sampling.
  17823. */
  17824. set usePoissonSampling(value: boolean);
  17825. /**
  17826. * Gets if the current filter is set to ESM.
  17827. */
  17828. get useExponentialShadowMap(): boolean;
  17829. /**
  17830. * Sets the current filter is to ESM.
  17831. */
  17832. set useExponentialShadowMap(value: boolean);
  17833. /**
  17834. * Gets if the current filter is set to filtered ESM.
  17835. */
  17836. get useBlurExponentialShadowMap(): boolean;
  17837. /**
  17838. * Gets if the current filter is set to filtered ESM.
  17839. */
  17840. set useBlurExponentialShadowMap(value: boolean);
  17841. /**
  17842. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17843. * exponential to prevent steep falloff artifacts).
  17844. */
  17845. get useCloseExponentialShadowMap(): boolean;
  17846. /**
  17847. * Sets the current filter to "close ESM" (using the inverse of the
  17848. * exponential to prevent steep falloff artifacts).
  17849. */
  17850. set useCloseExponentialShadowMap(value: boolean);
  17851. /**
  17852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17853. * exponential to prevent steep falloff artifacts).
  17854. */
  17855. get useBlurCloseExponentialShadowMap(): boolean;
  17856. /**
  17857. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17858. * exponential to prevent steep falloff artifacts).
  17859. */
  17860. set useBlurCloseExponentialShadowMap(value: boolean);
  17861. /**
  17862. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17863. */
  17864. get usePercentageCloserFiltering(): boolean;
  17865. /**
  17866. * Sets the current filter to "PCF" (percentage closer filtering).
  17867. */
  17868. set usePercentageCloserFiltering(value: boolean);
  17869. protected _filteringQuality: number;
  17870. /**
  17871. * Gets the PCF or PCSS Quality.
  17872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17873. */
  17874. get filteringQuality(): number;
  17875. /**
  17876. * Sets the PCF or PCSS Quality.
  17877. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17878. */
  17879. set filteringQuality(filteringQuality: number);
  17880. /**
  17881. * Gets if the current filter is set to "PCSS" (contact hardening).
  17882. */
  17883. get useContactHardeningShadow(): boolean;
  17884. /**
  17885. * Sets the current filter to "PCSS" (contact hardening).
  17886. */
  17887. set useContactHardeningShadow(value: boolean);
  17888. protected _contactHardeningLightSizeUVRatio: number;
  17889. /**
  17890. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17891. * Using a ratio helps keeping shape stability independently of the map size.
  17892. *
  17893. * It does not account for the light projection as it was having too much
  17894. * instability during the light setup or during light position changes.
  17895. *
  17896. * Only valid if useContactHardeningShadow is true.
  17897. */
  17898. get contactHardeningLightSizeUVRatio(): number;
  17899. /**
  17900. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17901. * Using a ratio helps keeping shape stability independently of the map size.
  17902. *
  17903. * It does not account for the light projection as it was having too much
  17904. * instability during the light setup or during light position changes.
  17905. *
  17906. * Only valid if useContactHardeningShadow is true.
  17907. */
  17908. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17909. protected _darkness: number;
  17910. /** Gets or sets the actual darkness of a shadow */
  17911. get darkness(): number;
  17912. set darkness(value: number);
  17913. /**
  17914. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17915. * 0 means strongest and 1 would means no shadow.
  17916. * @returns the darkness.
  17917. */
  17918. getDarkness(): number;
  17919. /**
  17920. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17921. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17922. * @returns the shadow generator allowing fluent coding.
  17923. */
  17924. setDarkness(darkness: number): ShadowGenerator;
  17925. protected _transparencyShadow: boolean;
  17926. /** Gets or sets the ability to have transparent shadow */
  17927. get transparencyShadow(): boolean;
  17928. set transparencyShadow(value: boolean);
  17929. /**
  17930. * Sets the ability to have transparent shadow (boolean).
  17931. * @param transparent True if transparent else False
  17932. * @returns the shadow generator allowing fluent coding
  17933. */
  17934. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17935. /**
  17936. * Enables or disables shadows with varying strength based on the transparency
  17937. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17938. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17939. * mesh.visibility * alphaTexture.a
  17940. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17941. */
  17942. enableSoftTransparentShadow: boolean;
  17943. protected _shadowMap: Nullable<RenderTargetTexture>;
  17944. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17945. /**
  17946. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17947. * @returns The render target texture if present otherwise, null
  17948. */
  17949. getShadowMap(): Nullable<RenderTargetTexture>;
  17950. /**
  17951. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17952. * @returns The render target texture if the shadow map is present otherwise, null
  17953. */
  17954. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17955. /**
  17956. * Gets the class name of that object
  17957. * @returns "ShadowGenerator"
  17958. */
  17959. getClassName(): string;
  17960. /**
  17961. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17962. * @param mesh Mesh to add
  17963. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17964. * @returns the Shadow Generator itself
  17965. */
  17966. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17967. /**
  17968. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17969. * @param mesh Mesh to remove
  17970. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17971. * @returns the Shadow Generator itself
  17972. */
  17973. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17974. /**
  17975. * Controls the extent to which the shadows fade out at the edge of the frustum
  17976. */
  17977. frustumEdgeFalloff: number;
  17978. protected _light: IShadowLight;
  17979. /**
  17980. * Returns the associated light object.
  17981. * @returns the light generating the shadow
  17982. */
  17983. getLight(): IShadowLight;
  17984. /**
  17985. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17986. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17987. * It might on the other hand introduce peter panning.
  17988. */
  17989. forceBackFacesOnly: boolean;
  17990. protected _scene: Scene;
  17991. protected _lightDirection: Vector3;
  17992. protected _effect: Effect;
  17993. protected _viewMatrix: Matrix;
  17994. protected _projectionMatrix: Matrix;
  17995. protected _transformMatrix: Matrix;
  17996. protected _cachedPosition: Vector3;
  17997. protected _cachedDirection: Vector3;
  17998. protected _cachedDefines: string;
  17999. protected _currentRenderID: number;
  18000. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18001. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18002. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18003. protected _blurPostProcesses: PostProcess[];
  18004. protected _mapSize: number;
  18005. protected _currentFaceIndex: number;
  18006. protected _currentFaceIndexCache: number;
  18007. protected _textureType: number;
  18008. protected _defaultTextureMatrix: Matrix;
  18009. protected _storedUniqueId: Nullable<number>;
  18010. /** @hidden */
  18011. static _SceneComponentInitialization: (scene: Scene) => void;
  18012. /**
  18013. * Gets or sets the size of the texture what stores the shadows
  18014. */
  18015. get mapSize(): number;
  18016. set mapSize(size: number);
  18017. /**
  18018. * Creates a ShadowGenerator object.
  18019. * A ShadowGenerator is the required tool to use the shadows.
  18020. * Each light casting shadows needs to use its own ShadowGenerator.
  18021. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18022. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18023. * @param light The light object generating the shadows.
  18024. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18025. */
  18026. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18027. protected _initializeGenerator(): void;
  18028. protected _createTargetRenderTexture(): void;
  18029. protected _initializeShadowMap(): void;
  18030. protected _initializeBlurRTTAndPostProcesses(): void;
  18031. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18032. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18033. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18034. protected _applyFilterValues(): void;
  18035. /**
  18036. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18037. * @param onCompiled Callback triggered at the and of the effects compilation
  18038. * @param options Sets of optional options forcing the compilation with different modes
  18039. */
  18040. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18041. useInstances: boolean;
  18042. }>): void;
  18043. /**
  18044. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18045. * @param options Sets of optional options forcing the compilation with different modes
  18046. * @returns A promise that resolves when the compilation completes
  18047. */
  18048. forceCompilationAsync(options?: Partial<{
  18049. useInstances: boolean;
  18050. }>): Promise<void>;
  18051. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18052. private _prepareShadowDefines;
  18053. /**
  18054. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18055. * @param subMesh The submesh we want to render in the shadow map
  18056. * @param useInstances Defines wether will draw in the map using instances
  18057. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18058. * @returns true if ready otherwise, false
  18059. */
  18060. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18061. /**
  18062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18063. * @param defines Defines of the material we want to update
  18064. * @param lightIndex Index of the light in the enabled light list of the material
  18065. */
  18066. prepareDefines(defines: any, lightIndex: number): void;
  18067. /**
  18068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18069. * defined in the generator but impacting the effect).
  18070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18071. * @param effect The effect we are binfing the information for
  18072. */
  18073. bindShadowLight(lightIndex: string, effect: Effect): void;
  18074. /**
  18075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18076. * (eq to shadow prjection matrix * light transform matrix)
  18077. * @returns The transform matrix used to create the shadow map
  18078. */
  18079. getTransformMatrix(): Matrix;
  18080. /**
  18081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18082. * Cube and 2D textures for instance.
  18083. */
  18084. recreateShadowMap(): void;
  18085. protected _disposeBlurPostProcesses(): void;
  18086. protected _disposeRTTandPostProcesses(): void;
  18087. /**
  18088. * Disposes the ShadowGenerator.
  18089. * Returns nothing.
  18090. */
  18091. dispose(): void;
  18092. /**
  18093. * Serializes the shadow generator setup to a json object.
  18094. * @returns The serialized JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18099. * @param parsedShadowGenerator The JSON object to parse
  18100. * @param scene The scene to create the shadow map for
  18101. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18102. * @returns The parsed shadow generator
  18103. */
  18104. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18105. }
  18106. }
  18107. declare module BABYLON {
  18108. /**
  18109. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18110. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18111. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18112. */
  18113. export abstract class Light extends Node {
  18114. /**
  18115. * Falloff Default: light is falling off following the material specification:
  18116. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18117. */
  18118. static readonly FALLOFF_DEFAULT: number;
  18119. /**
  18120. * Falloff Physical: light is falling off following the inverse squared distance law.
  18121. */
  18122. static readonly FALLOFF_PHYSICAL: number;
  18123. /**
  18124. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18125. * to enhance interoperability with other engines.
  18126. */
  18127. static readonly FALLOFF_GLTF: number;
  18128. /**
  18129. * Falloff Standard: light is falling off like in the standard material
  18130. * to enhance interoperability with other materials.
  18131. */
  18132. static readonly FALLOFF_STANDARD: number;
  18133. /**
  18134. * If every light affecting the material is in this lightmapMode,
  18135. * material.lightmapTexture adds or multiplies
  18136. * (depends on material.useLightmapAsShadowmap)
  18137. * after every other light calculations.
  18138. */
  18139. static readonly LIGHTMAP_DEFAULT: number;
  18140. /**
  18141. * material.lightmapTexture as only diffuse lighting from this light
  18142. * adds only specular lighting from this light
  18143. * adds dynamic shadows
  18144. */
  18145. static readonly LIGHTMAP_SPECULAR: number;
  18146. /**
  18147. * material.lightmapTexture as only lighting
  18148. * no light calculation from this light
  18149. * only adds dynamic shadows from this light
  18150. */
  18151. static readonly LIGHTMAP_SHADOWSONLY: number;
  18152. /**
  18153. * Each light type uses the default quantity according to its type:
  18154. * point/spot lights use luminous intensity
  18155. * directional lights use illuminance
  18156. */
  18157. static readonly INTENSITYMODE_AUTOMATIC: number;
  18158. /**
  18159. * lumen (lm)
  18160. */
  18161. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18162. /**
  18163. * candela (lm/sr)
  18164. */
  18165. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18166. /**
  18167. * lux (lm/m^2)
  18168. */
  18169. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18170. /**
  18171. * nit (cd/m^2)
  18172. */
  18173. static readonly INTENSITYMODE_LUMINANCE: number;
  18174. /**
  18175. * Light type const id of the point light.
  18176. */
  18177. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18178. /**
  18179. * Light type const id of the directional light.
  18180. */
  18181. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18182. /**
  18183. * Light type const id of the spot light.
  18184. */
  18185. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18186. /**
  18187. * Light type const id of the hemispheric light.
  18188. */
  18189. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18190. /**
  18191. * Diffuse gives the basic color to an object.
  18192. */
  18193. diffuse: Color3;
  18194. /**
  18195. * Specular produces a highlight color on an object.
  18196. * Note: This is note affecting PBR materials.
  18197. */
  18198. specular: Color3;
  18199. /**
  18200. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18201. * falling off base on range or angle.
  18202. * This can be set to any values in Light.FALLOFF_x.
  18203. *
  18204. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18205. * other types of materials.
  18206. */
  18207. falloffType: number;
  18208. /**
  18209. * Strength of the light.
  18210. * Note: By default it is define in the framework own unit.
  18211. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18212. */
  18213. intensity: number;
  18214. private _range;
  18215. protected _inverseSquaredRange: number;
  18216. /**
  18217. * Defines how far from the source the light is impacting in scene units.
  18218. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18219. */
  18220. get range(): number;
  18221. /**
  18222. * Defines how far from the source the light is impacting in scene units.
  18223. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18224. */
  18225. set range(value: number);
  18226. /**
  18227. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18228. * of light.
  18229. */
  18230. private _photometricScale;
  18231. private _intensityMode;
  18232. /**
  18233. * Gets the photometric scale used to interpret the intensity.
  18234. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18235. */
  18236. get intensityMode(): number;
  18237. /**
  18238. * Sets the photometric scale used to interpret the intensity.
  18239. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18240. */
  18241. set intensityMode(value: number);
  18242. private _radius;
  18243. /**
  18244. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18245. */
  18246. get radius(): number;
  18247. /**
  18248. * sets the light radius used by PBR Materials to simulate soft area lights.
  18249. */
  18250. set radius(value: number);
  18251. private _renderPriority;
  18252. /**
  18253. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18254. * exceeding the number allowed of the materials.
  18255. */
  18256. renderPriority: number;
  18257. private _shadowEnabled;
  18258. /**
  18259. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18260. * the current shadow generator.
  18261. */
  18262. get shadowEnabled(): boolean;
  18263. /**
  18264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18265. * the current shadow generator.
  18266. */
  18267. set shadowEnabled(value: boolean);
  18268. private _includedOnlyMeshes;
  18269. /**
  18270. * Gets the only meshes impacted by this light.
  18271. */
  18272. get includedOnlyMeshes(): AbstractMesh[];
  18273. /**
  18274. * Sets the only meshes impacted by this light.
  18275. */
  18276. set includedOnlyMeshes(value: AbstractMesh[]);
  18277. private _excludedMeshes;
  18278. /**
  18279. * Gets the meshes not impacted by this light.
  18280. */
  18281. get excludedMeshes(): AbstractMesh[];
  18282. /**
  18283. * Sets the meshes not impacted by this light.
  18284. */
  18285. set excludedMeshes(value: AbstractMesh[]);
  18286. private _excludeWithLayerMask;
  18287. /**
  18288. * Gets the layer id use to find what meshes are not impacted by the light.
  18289. * Inactive if 0
  18290. */
  18291. get excludeWithLayerMask(): number;
  18292. /**
  18293. * Sets the layer id use to find what meshes are not impacted by the light.
  18294. * Inactive if 0
  18295. */
  18296. set excludeWithLayerMask(value: number);
  18297. private _includeOnlyWithLayerMask;
  18298. /**
  18299. * Gets the layer id use to find what meshes are impacted by the light.
  18300. * Inactive if 0
  18301. */
  18302. get includeOnlyWithLayerMask(): number;
  18303. /**
  18304. * Sets the layer id use to find what meshes are impacted by the light.
  18305. * Inactive if 0
  18306. */
  18307. set includeOnlyWithLayerMask(value: number);
  18308. private _lightmapMode;
  18309. /**
  18310. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18311. */
  18312. get lightmapMode(): number;
  18313. /**
  18314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18315. */
  18316. set lightmapMode(value: number);
  18317. /**
  18318. * Shadow generator associted to the light.
  18319. * @hidden Internal use only.
  18320. */
  18321. _shadowGenerator: Nullable<IShadowGenerator>;
  18322. /**
  18323. * @hidden Internal use only.
  18324. */
  18325. _excludedMeshesIds: string[];
  18326. /**
  18327. * @hidden Internal use only.
  18328. */
  18329. _includedOnlyMeshesIds: string[];
  18330. /**
  18331. * The current light unifom buffer.
  18332. * @hidden Internal use only.
  18333. */
  18334. _uniformBuffer: UniformBuffer;
  18335. /** @hidden */
  18336. _renderId: number;
  18337. /**
  18338. * Creates a Light object in the scene.
  18339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18340. * @param name The firendly name of the light
  18341. * @param scene The scene the light belongs too
  18342. */
  18343. constructor(name: string, scene: Scene);
  18344. protected abstract _buildUniformLayout(): void;
  18345. /**
  18346. * Sets the passed Effect "effect" with the Light information.
  18347. * @param effect The effect to update
  18348. * @param lightIndex The index of the light in the effect to update
  18349. * @returns The light
  18350. */
  18351. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18352. /**
  18353. * Sets the passed Effect "effect" with the Light textures.
  18354. * @param effect The effect to update
  18355. * @param lightIndex The index of the light in the effect to update
  18356. * @returns The light
  18357. */
  18358. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18359. /**
  18360. * Binds the lights information from the scene to the effect for the given mesh.
  18361. * @param lightIndex Light index
  18362. * @param scene The scene where the light belongs to
  18363. * @param effect The effect we are binding the data to
  18364. * @param useSpecular Defines if specular is supported
  18365. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18366. */
  18367. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18368. /**
  18369. * Sets the passed Effect "effect" with the Light information.
  18370. * @param effect The effect to update
  18371. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18372. * @returns The light
  18373. */
  18374. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18375. /**
  18376. * Returns the string "Light".
  18377. * @returns the class name
  18378. */
  18379. getClassName(): string;
  18380. /** @hidden */
  18381. readonly _isLight: boolean;
  18382. /**
  18383. * Converts the light information to a readable string for debug purpose.
  18384. * @param fullDetails Supports for multiple levels of logging within scene loading
  18385. * @returns the human readable light info
  18386. */
  18387. toString(fullDetails?: boolean): string;
  18388. /** @hidden */
  18389. protected _syncParentEnabledState(): void;
  18390. /**
  18391. * Set the enabled state of this node.
  18392. * @param value - the new enabled state
  18393. */
  18394. setEnabled(value: boolean): void;
  18395. /**
  18396. * Returns the Light associated shadow generator if any.
  18397. * @return the associated shadow generator.
  18398. */
  18399. getShadowGenerator(): Nullable<IShadowGenerator>;
  18400. /**
  18401. * Returns a Vector3, the absolute light position in the World.
  18402. * @returns the world space position of the light
  18403. */
  18404. getAbsolutePosition(): Vector3;
  18405. /**
  18406. * Specifies if the light will affect the passed mesh.
  18407. * @param mesh The mesh to test against the light
  18408. * @return true the mesh is affected otherwise, false.
  18409. */
  18410. canAffectMesh(mesh: AbstractMesh): boolean;
  18411. /**
  18412. * Sort function to order lights for rendering.
  18413. * @param a First Light object to compare to second.
  18414. * @param b Second Light object to compare first.
  18415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18416. */
  18417. static CompareLightsPriority(a: Light, b: Light): number;
  18418. /**
  18419. * Releases resources associated with this node.
  18420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18422. */
  18423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18424. /**
  18425. * Returns the light type ID (integer).
  18426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18427. */
  18428. getTypeID(): number;
  18429. /**
  18430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18431. * @returns the scaled intensity in intensity mode unit
  18432. */
  18433. getScaledIntensity(): number;
  18434. /**
  18435. * Returns a new Light object, named "name", from the current one.
  18436. * @param name The name of the cloned light
  18437. * @param newParent The parent of this light, if it has one
  18438. * @returns the new created light
  18439. */
  18440. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18441. /**
  18442. * Serializes the current light into a Serialization object.
  18443. * @returns the serialized object.
  18444. */
  18445. serialize(): any;
  18446. /**
  18447. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18448. * This new light is named "name" and added to the passed scene.
  18449. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18450. * @param name The friendly name of the light
  18451. * @param scene The scene the new light will belong to
  18452. * @returns the constructor function
  18453. */
  18454. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18455. /**
  18456. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18457. * @param parsedLight The JSON representation of the light
  18458. * @param scene The scene to create the parsed light in
  18459. * @returns the created light after parsing
  18460. */
  18461. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18462. private _hookArrayForExcluded;
  18463. private _hookArrayForIncludedOnly;
  18464. private _resyncMeshes;
  18465. /**
  18466. * Forces the meshes to update their light related information in their rendering used effects
  18467. * @hidden Internal Use Only
  18468. */
  18469. _markMeshesAsLightDirty(): void;
  18470. /**
  18471. * Recomputes the cached photometric scale if needed.
  18472. */
  18473. private _computePhotometricScale;
  18474. /**
  18475. * Returns the Photometric Scale according to the light type and intensity mode.
  18476. */
  18477. private _getPhotometricScale;
  18478. /**
  18479. * Reorder the light in the scene according to their defined priority.
  18480. * @hidden Internal Use Only
  18481. */
  18482. _reorderLightsInScene(): void;
  18483. /**
  18484. * Prepares the list of defines specific to the light type.
  18485. * @param defines the list of defines
  18486. * @param lightIndex defines the index of the light for the effect
  18487. */
  18488. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18489. }
  18490. }
  18491. declare module BABYLON {
  18492. /**
  18493. * Configuration needed for prepass-capable materials
  18494. */
  18495. export class PrePassConfiguration {
  18496. /**
  18497. * Previous world matrices of meshes carrying this material
  18498. * Used for computing velocity
  18499. */
  18500. previousWorldMatrices: {
  18501. [index: number]: Matrix;
  18502. };
  18503. /**
  18504. * Previous view project matrix
  18505. * Used for computing velocity
  18506. */
  18507. previousViewProjection: Matrix;
  18508. /**
  18509. * Previous bones of meshes carrying this material
  18510. * Used for computing velocity
  18511. */
  18512. previousBones: {
  18513. [index: number]: Float32Array;
  18514. };
  18515. /**
  18516. * Add the required uniforms to the current list.
  18517. * @param uniforms defines the current uniform list.
  18518. */
  18519. static AddUniforms(uniforms: string[]): void;
  18520. /**
  18521. * Add the required samplers to the current list.
  18522. * @param samplers defines the current sampler list.
  18523. */
  18524. static AddSamplers(samplers: string[]): void;
  18525. /**
  18526. * Binds the material data.
  18527. * @param effect defines the effect to update
  18528. * @param scene defines the scene the material belongs to.
  18529. * @param mesh The mesh
  18530. * @param world World matrix of this mesh
  18531. * @param isFrozen Is the material frozen
  18532. */
  18533. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18534. }
  18535. }
  18536. declare module BABYLON {
  18537. /**
  18538. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18539. * This is the base of the follow, arc rotate cameras and Free camera
  18540. * @see https://doc.babylonjs.com/features/cameras
  18541. */
  18542. export class TargetCamera extends Camera {
  18543. private static _RigCamTransformMatrix;
  18544. private static _TargetTransformMatrix;
  18545. private static _TargetFocalPoint;
  18546. private _tmpUpVector;
  18547. private _tmpTargetVector;
  18548. /**
  18549. * Define the current direction the camera is moving to
  18550. */
  18551. cameraDirection: Vector3;
  18552. /**
  18553. * Define the current rotation the camera is rotating to
  18554. */
  18555. cameraRotation: Vector2;
  18556. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18557. ignoreParentScaling: boolean;
  18558. /**
  18559. * When set, the up vector of the camera will be updated by the rotation of the camera
  18560. */
  18561. updateUpVectorFromRotation: boolean;
  18562. private _tmpQuaternion;
  18563. /**
  18564. * Define the current rotation of the camera
  18565. */
  18566. rotation: Vector3;
  18567. /**
  18568. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18569. */
  18570. rotationQuaternion: Quaternion;
  18571. /**
  18572. * Define the current speed of the camera
  18573. */
  18574. speed: number;
  18575. /**
  18576. * Add constraint to the camera to prevent it to move freely in all directions and
  18577. * around all axis.
  18578. */
  18579. noRotationConstraint: boolean;
  18580. /**
  18581. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18582. * panning
  18583. */
  18584. invertRotation: boolean;
  18585. /**
  18586. * Speed multiplier for inverse camera panning
  18587. */
  18588. inverseRotationSpeed: number;
  18589. /**
  18590. * Define the current target of the camera as an object or a position.
  18591. */
  18592. lockedTarget: any;
  18593. /** @hidden */
  18594. _currentTarget: Vector3;
  18595. /** @hidden */
  18596. _initialFocalDistance: number;
  18597. /** @hidden */
  18598. _viewMatrix: Matrix;
  18599. /** @hidden */
  18600. _camMatrix: Matrix;
  18601. /** @hidden */
  18602. _cameraTransformMatrix: Matrix;
  18603. /** @hidden */
  18604. _cameraRotationMatrix: Matrix;
  18605. /** @hidden */
  18606. _referencePoint: Vector3;
  18607. /** @hidden */
  18608. _transformedReferencePoint: Vector3;
  18609. /** @hidden */
  18610. _reset: () => void;
  18611. private _defaultUp;
  18612. /**
  18613. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18614. * This is the base of the follow, arc rotate cameras and Free camera
  18615. * @see https://doc.babylonjs.com/features/cameras
  18616. * @param name Defines the name of the camera in the scene
  18617. * @param position Defines the start position of the camera in the scene
  18618. * @param scene Defines the scene the camera belongs to
  18619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18620. */
  18621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18622. /**
  18623. * Gets the position in front of the camera at a given distance.
  18624. * @param distance The distance from the camera we want the position to be
  18625. * @returns the position
  18626. */
  18627. getFrontPosition(distance: number): Vector3;
  18628. /** @hidden */
  18629. _getLockedTargetPosition(): Nullable<Vector3>;
  18630. private _storedPosition;
  18631. private _storedRotation;
  18632. private _storedRotationQuaternion;
  18633. /**
  18634. * Store current camera state of the camera (fov, position, rotation, etc..)
  18635. * @returns the camera
  18636. */
  18637. storeState(): Camera;
  18638. /**
  18639. * Restored camera state. You must call storeState() first
  18640. * @returns whether it was successful or not
  18641. * @hidden
  18642. */
  18643. _restoreStateValues(): boolean;
  18644. /** @hidden */
  18645. _initCache(): void;
  18646. /** @hidden */
  18647. _updateCache(ignoreParentClass?: boolean): void;
  18648. /** @hidden */
  18649. _isSynchronizedViewMatrix(): boolean;
  18650. /** @hidden */
  18651. _computeLocalCameraSpeed(): number;
  18652. /**
  18653. * Defines the target the camera should look at.
  18654. * @param target Defines the new target as a Vector or a mesh
  18655. */
  18656. setTarget(target: Vector3): void;
  18657. /**
  18658. * Defines the target point of the camera.
  18659. * The camera looks towards it form the radius distance.
  18660. */
  18661. get target(): Vector3;
  18662. set target(value: Vector3);
  18663. /**
  18664. * Return the current target position of the camera. This value is expressed in local space.
  18665. * @returns the target position
  18666. */
  18667. getTarget(): Vector3;
  18668. /** @hidden */
  18669. _decideIfNeedsToMove(): boolean;
  18670. /** @hidden */
  18671. _updatePosition(): void;
  18672. /** @hidden */
  18673. _checkInputs(): void;
  18674. protected _updateCameraRotationMatrix(): void;
  18675. /**
  18676. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18677. * @returns the current camera
  18678. */
  18679. private _rotateUpVectorWithCameraRotationMatrix;
  18680. private _cachedRotationZ;
  18681. private _cachedQuaternionRotationZ;
  18682. /** @hidden */
  18683. _getViewMatrix(): Matrix;
  18684. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18685. /**
  18686. * @hidden
  18687. */
  18688. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18689. /**
  18690. * @hidden
  18691. */
  18692. _updateRigCameras(): void;
  18693. private _getRigCamPositionAndTarget;
  18694. /**
  18695. * Gets the current object class name.
  18696. * @return the class name
  18697. */
  18698. getClassName(): string;
  18699. }
  18700. }
  18701. declare module BABYLON {
  18702. /**
  18703. * Gather the list of keyboard event types as constants.
  18704. */
  18705. export class KeyboardEventTypes {
  18706. /**
  18707. * The keydown event is fired when a key becomes active (pressed).
  18708. */
  18709. static readonly KEYDOWN: number;
  18710. /**
  18711. * The keyup event is fired when a key has been released.
  18712. */
  18713. static readonly KEYUP: number;
  18714. }
  18715. /**
  18716. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18717. */
  18718. export class KeyboardInfo {
  18719. /**
  18720. * Defines the type of event (KeyboardEventTypes)
  18721. */
  18722. type: number;
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: KeyboardEvent;
  18727. /**
  18728. * Instantiates a new keyboard info.
  18729. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18730. * @param type Defines the type of event (KeyboardEventTypes)
  18731. * @param event Defines the related dom event
  18732. */
  18733. constructor(
  18734. /**
  18735. * Defines the type of event (KeyboardEventTypes)
  18736. */
  18737. type: number,
  18738. /**
  18739. * Defines the related dom event
  18740. */
  18741. event: KeyboardEvent);
  18742. }
  18743. /**
  18744. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18745. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18746. */
  18747. export class KeyboardInfoPre extends KeyboardInfo {
  18748. /**
  18749. * Defines the type of event (KeyboardEventTypes)
  18750. */
  18751. type: number;
  18752. /**
  18753. * Defines the related dom event
  18754. */
  18755. event: KeyboardEvent;
  18756. /**
  18757. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18758. */
  18759. skipOnPointerObservable: boolean;
  18760. /**
  18761. * Instantiates a new keyboard pre info.
  18762. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18763. * @param type Defines the type of event (KeyboardEventTypes)
  18764. * @param event Defines the related dom event
  18765. */
  18766. constructor(
  18767. /**
  18768. * Defines the type of event (KeyboardEventTypes)
  18769. */
  18770. type: number,
  18771. /**
  18772. * Defines the related dom event
  18773. */
  18774. event: KeyboardEvent);
  18775. }
  18776. }
  18777. declare module BABYLON {
  18778. /**
  18779. * Manage the keyboard inputs to control the movement of a free camera.
  18780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18781. */
  18782. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18783. /**
  18784. * Defines the camera the input is attached to.
  18785. */
  18786. camera: FreeCamera;
  18787. /**
  18788. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18789. */
  18790. keysUp: number[];
  18791. /**
  18792. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18793. */
  18794. keysUpward: number[];
  18795. /**
  18796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18797. */
  18798. keysDown: number[];
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18801. */
  18802. keysDownward: number[];
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18805. */
  18806. keysLeft: number[];
  18807. /**
  18808. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18809. */
  18810. keysRight: number[];
  18811. private _keys;
  18812. private _onCanvasBlurObserver;
  18813. private _onKeyboardObserver;
  18814. private _engine;
  18815. private _scene;
  18816. /**
  18817. * Attach the input controls to a specific dom element to get the input from.
  18818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18819. */
  18820. attachControl(noPreventDefault?: boolean): void;
  18821. /**
  18822. * Detach the current controls from the specified dom element.
  18823. */
  18824. detachControl(): void;
  18825. /**
  18826. * Update the current camera state depending on the inputs that have been used this frame.
  18827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18828. */
  18829. checkInputs(): void;
  18830. /**
  18831. * Gets the class name of the current intput.
  18832. * @returns the class name
  18833. */
  18834. getClassName(): string;
  18835. /** @hidden */
  18836. _onLostFocus(): void;
  18837. /**
  18838. * Get the friendly name associated with the input class.
  18839. * @returns the input friendly name
  18840. */
  18841. getSimpleName(): string;
  18842. }
  18843. }
  18844. declare module BABYLON {
  18845. /**
  18846. * Gather the list of pointer event types as constants.
  18847. */
  18848. export class PointerEventTypes {
  18849. /**
  18850. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18851. */
  18852. static readonly POINTERDOWN: number;
  18853. /**
  18854. * The pointerup event is fired when a pointer is no longer active.
  18855. */
  18856. static readonly POINTERUP: number;
  18857. /**
  18858. * The pointermove event is fired when a pointer changes coordinates.
  18859. */
  18860. static readonly POINTERMOVE: number;
  18861. /**
  18862. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18863. */
  18864. static readonly POINTERWHEEL: number;
  18865. /**
  18866. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18867. */
  18868. static readonly POINTERPICK: number;
  18869. /**
  18870. * The pointertap event is fired when a the object has been touched and released without drag.
  18871. */
  18872. static readonly POINTERTAP: number;
  18873. /**
  18874. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18875. */
  18876. static readonly POINTERDOUBLETAP: number;
  18877. }
  18878. /**
  18879. * Base class of pointer info types.
  18880. */
  18881. export class PointerInfoBase {
  18882. /**
  18883. * Defines the type of event (PointerEventTypes)
  18884. */
  18885. type: number;
  18886. /**
  18887. * Defines the related dom event
  18888. */
  18889. event: PointerEvent | MouseWheelEvent;
  18890. /**
  18891. * Instantiates the base class of pointers info.
  18892. * @param type Defines the type of event (PointerEventTypes)
  18893. * @param event Defines the related dom event
  18894. */
  18895. constructor(
  18896. /**
  18897. * Defines the type of event (PointerEventTypes)
  18898. */
  18899. type: number,
  18900. /**
  18901. * Defines the related dom event
  18902. */
  18903. event: PointerEvent | MouseWheelEvent);
  18904. }
  18905. /**
  18906. * This class is used to store pointer related info for the onPrePointerObservable event.
  18907. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18908. */
  18909. export class PointerInfoPre extends PointerInfoBase {
  18910. /**
  18911. * Ray from a pointer if availible (eg. 6dof controller)
  18912. */
  18913. ray: Nullable<Ray>;
  18914. /**
  18915. * Defines the local position of the pointer on the canvas.
  18916. */
  18917. localPosition: Vector2;
  18918. /**
  18919. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18920. */
  18921. skipOnPointerObservable: boolean;
  18922. /**
  18923. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18924. * @param type Defines the type of event (PointerEventTypes)
  18925. * @param event Defines the related dom event
  18926. * @param localX Defines the local x coordinates of the pointer when the event occured
  18927. * @param localY Defines the local y coordinates of the pointer when the event occured
  18928. */
  18929. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18930. }
  18931. /**
  18932. * This type contains all the data related to a pointer event in Babylon.js.
  18933. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18934. */
  18935. export class PointerInfo extends PointerInfoBase {
  18936. /**
  18937. * Defines the picking info associated to the info (if any)\
  18938. */
  18939. pickInfo: Nullable<PickingInfo>;
  18940. /**
  18941. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18942. * @param type Defines the type of event (PointerEventTypes)
  18943. * @param event Defines the related dom event
  18944. * @param pickInfo Defines the picking info associated to the info (if any)\
  18945. */
  18946. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18947. /**
  18948. * Defines the picking info associated to the info (if any)\
  18949. */
  18950. pickInfo: Nullable<PickingInfo>);
  18951. }
  18952. /**
  18953. * Data relating to a touch event on the screen.
  18954. */
  18955. export interface PointerTouch {
  18956. /**
  18957. * X coordinate of touch.
  18958. */
  18959. x: number;
  18960. /**
  18961. * Y coordinate of touch.
  18962. */
  18963. y: number;
  18964. /**
  18965. * Id of touch. Unique for each finger.
  18966. */
  18967. pointerId: number;
  18968. /**
  18969. * Event type passed from DOM.
  18970. */
  18971. type: any;
  18972. }
  18973. }
  18974. declare module BABYLON {
  18975. /**
  18976. * Manage the mouse inputs to control the movement of a free camera.
  18977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18978. */
  18979. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18980. /**
  18981. * Define if touch is enabled in the mouse input
  18982. */
  18983. touchEnabled: boolean;
  18984. /**
  18985. * Defines the camera the input is attached to.
  18986. */
  18987. camera: FreeCamera;
  18988. /**
  18989. * Defines the buttons associated with the input to handle camera move.
  18990. */
  18991. buttons: number[];
  18992. /**
  18993. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18994. */
  18995. angularSensibility: number;
  18996. private _pointerInput;
  18997. private _onMouseMove;
  18998. private _observer;
  18999. private previousPosition;
  19000. /**
  19001. * Observable for when a pointer move event occurs containing the move offset
  19002. */
  19003. onPointerMovedObservable: Observable<{
  19004. offsetX: number;
  19005. offsetY: number;
  19006. }>;
  19007. /**
  19008. * @hidden
  19009. * If the camera should be rotated automatically based on pointer movement
  19010. */
  19011. _allowCameraRotation: boolean;
  19012. /**
  19013. * Manage the mouse inputs to control the movement of a free camera.
  19014. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19015. * @param touchEnabled Defines if touch is enabled or not
  19016. */
  19017. constructor(
  19018. /**
  19019. * Define if touch is enabled in the mouse input
  19020. */
  19021. touchEnabled?: boolean);
  19022. /**
  19023. * Attach the input controls to a specific dom element to get the input from.
  19024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19025. */
  19026. attachControl(noPreventDefault?: boolean): void;
  19027. /**
  19028. * Called on JS contextmenu event.
  19029. * Override this method to provide functionality.
  19030. */
  19031. protected onContextMenu(evt: PointerEvent): void;
  19032. /**
  19033. * Detach the current controls from the specified dom element.
  19034. */
  19035. detachControl(): void;
  19036. /**
  19037. * Gets the class name of the current intput.
  19038. * @returns the class name
  19039. */
  19040. getClassName(): string;
  19041. /**
  19042. * Get the friendly name associated with the input class.
  19043. * @returns the input friendly name
  19044. */
  19045. getSimpleName(): string;
  19046. }
  19047. }
  19048. declare module BABYLON {
  19049. /**
  19050. * Base class for mouse wheel input..
  19051. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19052. * for example usage.
  19053. */
  19054. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19055. /**
  19056. * Defines the camera the input is attached to.
  19057. */
  19058. abstract camera: Camera;
  19059. /**
  19060. * How fast is the camera moves in relation to X axis mouseWheel events.
  19061. * Use negative value to reverse direction.
  19062. */
  19063. wheelPrecisionX: number;
  19064. /**
  19065. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19066. * Use negative value to reverse direction.
  19067. */
  19068. wheelPrecisionY: number;
  19069. /**
  19070. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19071. * Use negative value to reverse direction.
  19072. */
  19073. wheelPrecisionZ: number;
  19074. /**
  19075. * Observable for when a mouse wheel move event occurs.
  19076. */
  19077. onChangedObservable: Observable<{
  19078. wheelDeltaX: number;
  19079. wheelDeltaY: number;
  19080. wheelDeltaZ: number;
  19081. }>;
  19082. private _wheel;
  19083. private _observer;
  19084. /**
  19085. * Attach the input controls to a specific dom element to get the input from.
  19086. * @param noPreventDefault Defines whether event caught by the controls
  19087. * should call preventdefault().
  19088. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19089. */
  19090. attachControl(noPreventDefault?: boolean): void;
  19091. /**
  19092. * Detach the current controls from the specified dom element.
  19093. */
  19094. detachControl(): void;
  19095. /**
  19096. * Called for each rendered frame.
  19097. */
  19098. checkInputs(): void;
  19099. /**
  19100. * Gets the class name of the current intput.
  19101. * @returns the class name
  19102. */
  19103. getClassName(): string;
  19104. /**
  19105. * Get the friendly name associated with the input class.
  19106. * @returns the input friendly name
  19107. */
  19108. getSimpleName(): string;
  19109. /**
  19110. * Incremental value of multiple mouse wheel movements of the X axis.
  19111. * Should be zero-ed when read.
  19112. */
  19113. protected _wheelDeltaX: number;
  19114. /**
  19115. * Incremental value of multiple mouse wheel movements of the Y axis.
  19116. * Should be zero-ed when read.
  19117. */
  19118. protected _wheelDeltaY: number;
  19119. /**
  19120. * Incremental value of multiple mouse wheel movements of the Z axis.
  19121. * Should be zero-ed when read.
  19122. */
  19123. protected _wheelDeltaZ: number;
  19124. /**
  19125. * Firefox uses a different scheme to report scroll distances to other
  19126. * browsers. Rather than use complicated methods to calculate the exact
  19127. * multiple we need to apply, let's just cheat and use a constant.
  19128. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19129. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19130. */
  19131. private readonly _ffMultiplier;
  19132. /**
  19133. * Different event attributes for wheel data fall into a few set ranges.
  19134. * Some relevant but dated date here:
  19135. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19136. */
  19137. private readonly _normalize;
  19138. }
  19139. }
  19140. declare module BABYLON {
  19141. /**
  19142. * Manage the mouse wheel inputs to control a free camera.
  19143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19144. */
  19145. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19146. /**
  19147. * Defines the camera the input is attached to.
  19148. */
  19149. camera: FreeCamera;
  19150. /**
  19151. * Gets the class name of the current input.
  19152. * @returns the class name
  19153. */
  19154. getClassName(): string;
  19155. /**
  19156. * Set which movement axis (relative to camera's orientation) the mouse
  19157. * wheel's X axis controls.
  19158. * @param axis The axis to be moved. Set null to clear.
  19159. */
  19160. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19161. /**
  19162. * Get the configured movement axis (relative to camera's orientation) the
  19163. * mouse wheel's X axis controls.
  19164. * @returns The configured axis or null if none.
  19165. */
  19166. get wheelXMoveRelative(): Nullable<Coordinate>;
  19167. /**
  19168. * Set which movement axis (relative to camera's orientation) the mouse
  19169. * wheel's Y axis controls.
  19170. * @param axis The axis to be moved. Set null to clear.
  19171. */
  19172. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19173. /**
  19174. * Get the configured movement axis (relative to camera's orientation) the
  19175. * mouse wheel's Y axis controls.
  19176. * @returns The configured axis or null if none.
  19177. */
  19178. get wheelYMoveRelative(): Nullable<Coordinate>;
  19179. /**
  19180. * Set which movement axis (relative to camera's orientation) the mouse
  19181. * wheel's Z axis controls.
  19182. * @param axis The axis to be moved. Set null to clear.
  19183. */
  19184. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19185. /**
  19186. * Get the configured movement axis (relative to camera's orientation) the
  19187. * mouse wheel's Z axis controls.
  19188. * @returns The configured axis or null if none.
  19189. */
  19190. get wheelZMoveRelative(): Nullable<Coordinate>;
  19191. /**
  19192. * Set which rotation axis (relative to camera's orientation) the mouse
  19193. * wheel's X axis controls.
  19194. * @param axis The axis to be moved. Set null to clear.
  19195. */
  19196. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19197. /**
  19198. * Get the configured rotation axis (relative to camera's orientation) the
  19199. * mouse wheel's X axis controls.
  19200. * @returns The configured axis or null if none.
  19201. */
  19202. get wheelXRotateRelative(): Nullable<Coordinate>;
  19203. /**
  19204. * Set which rotation axis (relative to camera's orientation) the mouse
  19205. * wheel's Y axis controls.
  19206. * @param axis The axis to be moved. Set null to clear.
  19207. */
  19208. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19209. /**
  19210. * Get the configured rotation axis (relative to camera's orientation) the
  19211. * mouse wheel's Y axis controls.
  19212. * @returns The configured axis or null if none.
  19213. */
  19214. get wheelYRotateRelative(): Nullable<Coordinate>;
  19215. /**
  19216. * Set which rotation axis (relative to camera's orientation) the mouse
  19217. * wheel's Z axis controls.
  19218. * @param axis The axis to be moved. Set null to clear.
  19219. */
  19220. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19221. /**
  19222. * Get the configured rotation axis (relative to camera's orientation) the
  19223. * mouse wheel's Z axis controls.
  19224. * @returns The configured axis or null if none.
  19225. */
  19226. get wheelZRotateRelative(): Nullable<Coordinate>;
  19227. /**
  19228. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19229. * controls.
  19230. * @param axis The axis to be moved. Set null to clear.
  19231. */
  19232. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19233. /**
  19234. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19235. * X axis controls.
  19236. * @returns The configured axis or null if none.
  19237. */
  19238. get wheelXMoveScene(): Nullable<Coordinate>;
  19239. /**
  19240. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19241. * controls.
  19242. * @param axis The axis to be moved. Set null to clear.
  19243. */
  19244. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19245. /**
  19246. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19247. * Y axis controls.
  19248. * @returns The configured axis or null if none.
  19249. */
  19250. get wheelYMoveScene(): Nullable<Coordinate>;
  19251. /**
  19252. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19253. * controls.
  19254. * @param axis The axis to be moved. Set null to clear.
  19255. */
  19256. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19257. /**
  19258. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19259. * Z axis controls.
  19260. * @returns The configured axis or null if none.
  19261. */
  19262. get wheelZMoveScene(): Nullable<Coordinate>;
  19263. /**
  19264. * Called for each rendered frame.
  19265. */
  19266. checkInputs(): void;
  19267. private _moveRelative;
  19268. private _rotateRelative;
  19269. private _moveScene;
  19270. /**
  19271. * These are set to the desired default behaviour.
  19272. */
  19273. private _wheelXAction;
  19274. private _wheelXActionCoordinate;
  19275. private _wheelYAction;
  19276. private _wheelYActionCoordinate;
  19277. private _wheelZAction;
  19278. private _wheelZActionCoordinate;
  19279. /**
  19280. * Update the camera according to any configured properties for the 3
  19281. * mouse-wheel axis.
  19282. */
  19283. private _updateCamera;
  19284. }
  19285. }
  19286. declare module BABYLON {
  19287. /**
  19288. * Manage the touch inputs to control the movement of a free camera.
  19289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19290. */
  19291. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19292. /**
  19293. * Define if mouse events can be treated as touch events
  19294. */
  19295. allowMouse: boolean;
  19296. /**
  19297. * Defines the camera the input is attached to.
  19298. */
  19299. camera: FreeCamera;
  19300. /**
  19301. * Defines the touch sensibility for rotation.
  19302. * The higher the faster.
  19303. */
  19304. touchAngularSensibility: number;
  19305. /**
  19306. * Defines the touch sensibility for move.
  19307. * The higher the faster.
  19308. */
  19309. touchMoveSensibility: number;
  19310. private _offsetX;
  19311. private _offsetY;
  19312. private _pointerPressed;
  19313. private _pointerInput?;
  19314. private _observer;
  19315. private _onLostFocus;
  19316. /**
  19317. * Manage the touch inputs to control the movement of a free camera.
  19318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19319. * @param allowMouse Defines if mouse events can be treated as touch events
  19320. */
  19321. constructor(
  19322. /**
  19323. * Define if mouse events can be treated as touch events
  19324. */
  19325. allowMouse?: boolean);
  19326. /**
  19327. * Attach the input controls to a specific dom element to get the input from.
  19328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19329. */
  19330. attachControl(noPreventDefault?: boolean): void;
  19331. /**
  19332. * Detach the current controls from the specified dom element.
  19333. */
  19334. detachControl(): void;
  19335. /**
  19336. * Update the current camera state depending on the inputs that have been used this frame.
  19337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19338. */
  19339. checkInputs(): void;
  19340. /**
  19341. * Gets the class name of the current intput.
  19342. * @returns the class name
  19343. */
  19344. getClassName(): string;
  19345. /**
  19346. * Get the friendly name associated with the input class.
  19347. * @returns the input friendly name
  19348. */
  19349. getSimpleName(): string;
  19350. }
  19351. }
  19352. declare module BABYLON {
  19353. /**
  19354. * Default Inputs manager for the FreeCamera.
  19355. * It groups all the default supported inputs for ease of use.
  19356. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19357. */
  19358. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19359. /**
  19360. * @hidden
  19361. */
  19362. _mouseInput: Nullable<FreeCameraMouseInput>;
  19363. /**
  19364. * @hidden
  19365. */
  19366. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19367. /**
  19368. * Instantiates a new FreeCameraInputsManager.
  19369. * @param camera Defines the camera the inputs belong to
  19370. */
  19371. constructor(camera: FreeCamera);
  19372. /**
  19373. * Add keyboard input support to the input manager.
  19374. * @returns the current input manager
  19375. */
  19376. addKeyboard(): FreeCameraInputsManager;
  19377. /**
  19378. * Add mouse input support to the input manager.
  19379. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19380. * @returns the current input manager
  19381. */
  19382. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19383. /**
  19384. * Removes the mouse input support from the manager
  19385. * @returns the current input manager
  19386. */
  19387. removeMouse(): FreeCameraInputsManager;
  19388. /**
  19389. * Add mouse wheel input support to the input manager.
  19390. * @returns the current input manager
  19391. */
  19392. addMouseWheel(): FreeCameraInputsManager;
  19393. /**
  19394. * Removes the mouse wheel input support from the manager
  19395. * @returns the current input manager
  19396. */
  19397. removeMouseWheel(): FreeCameraInputsManager;
  19398. /**
  19399. * Add touch input support to the input manager.
  19400. * @returns the current input manager
  19401. */
  19402. addTouch(): FreeCameraInputsManager;
  19403. /**
  19404. * Remove all attached input methods from a camera
  19405. */
  19406. clear(): void;
  19407. }
  19408. }
  19409. declare module BABYLON {
  19410. /**
  19411. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19412. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19413. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19414. */
  19415. export class FreeCamera extends TargetCamera {
  19416. /**
  19417. * Define the collision ellipsoid of the camera.
  19418. * This is helpful to simulate a camera body like the player body around the camera
  19419. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19420. */
  19421. ellipsoid: Vector3;
  19422. /**
  19423. * Define an offset for the position of the ellipsoid around the camera.
  19424. * This can be helpful to determine the center of the body near the gravity center of the body
  19425. * instead of its head.
  19426. */
  19427. ellipsoidOffset: Vector3;
  19428. /**
  19429. * Enable or disable collisions of the camera with the rest of the scene objects.
  19430. */
  19431. checkCollisions: boolean;
  19432. /**
  19433. * Enable or disable gravity on the camera.
  19434. */
  19435. applyGravity: boolean;
  19436. /**
  19437. * Define the input manager associated to the camera.
  19438. */
  19439. inputs: FreeCameraInputsManager;
  19440. /**
  19441. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19442. * Higher values reduce sensitivity.
  19443. */
  19444. get angularSensibility(): number;
  19445. /**
  19446. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19447. * Higher values reduce sensitivity.
  19448. */
  19449. set angularSensibility(value: number);
  19450. /**
  19451. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19452. */
  19453. get keysUp(): number[];
  19454. set keysUp(value: number[]);
  19455. /**
  19456. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19457. */
  19458. get keysUpward(): number[];
  19459. set keysUpward(value: number[]);
  19460. /**
  19461. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19462. */
  19463. get keysDown(): number[];
  19464. set keysDown(value: number[]);
  19465. /**
  19466. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19467. */
  19468. get keysDownward(): number[];
  19469. set keysDownward(value: number[]);
  19470. /**
  19471. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19472. */
  19473. get keysLeft(): number[];
  19474. set keysLeft(value: number[]);
  19475. /**
  19476. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19477. */
  19478. get keysRight(): number[];
  19479. set keysRight(value: number[]);
  19480. /**
  19481. * Event raised when the camera collide with a mesh in the scene.
  19482. */
  19483. onCollide: (collidedMesh: AbstractMesh) => void;
  19484. private _collider;
  19485. private _needMoveForGravity;
  19486. private _oldPosition;
  19487. private _diffPosition;
  19488. private _newPosition;
  19489. /** @hidden */
  19490. _localDirection: Vector3;
  19491. /** @hidden */
  19492. _transformedDirection: Vector3;
  19493. /**
  19494. * Instantiates a Free Camera.
  19495. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19496. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19497. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19498. * @param name Define the name of the camera in the scene
  19499. * @param position Define the start position of the camera in the scene
  19500. * @param scene Define the scene the camera belongs to
  19501. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19502. */
  19503. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19504. /**
  19505. * Attach the input controls to a specific dom element to get the input from.
  19506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19507. */
  19508. attachControl(noPreventDefault?: boolean): void;
  19509. /**
  19510. * Detach the current controls from the specified dom element.
  19511. */
  19512. detachControl(): void;
  19513. private _collisionMask;
  19514. /**
  19515. * Define a collision mask to limit the list of object the camera can collide with
  19516. */
  19517. get collisionMask(): number;
  19518. set collisionMask(mask: number);
  19519. /** @hidden */
  19520. _collideWithWorld(displacement: Vector3): void;
  19521. private _onCollisionPositionChange;
  19522. /** @hidden */
  19523. _checkInputs(): void;
  19524. /** @hidden */
  19525. _decideIfNeedsToMove(): boolean;
  19526. /** @hidden */
  19527. _updatePosition(): void;
  19528. /**
  19529. * Destroy the camera and release the current resources hold by it.
  19530. */
  19531. dispose(): void;
  19532. /**
  19533. * Gets the current object class name.
  19534. * @return the class name
  19535. */
  19536. getClassName(): string;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. /**
  19541. * Represents a gamepad control stick position
  19542. */
  19543. export class StickValues {
  19544. /**
  19545. * The x component of the control stick
  19546. */
  19547. x: number;
  19548. /**
  19549. * The y component of the control stick
  19550. */
  19551. y: number;
  19552. /**
  19553. * Initializes the gamepad x and y control stick values
  19554. * @param x The x component of the gamepad control stick value
  19555. * @param y The y component of the gamepad control stick value
  19556. */
  19557. constructor(
  19558. /**
  19559. * The x component of the control stick
  19560. */
  19561. x: number,
  19562. /**
  19563. * The y component of the control stick
  19564. */
  19565. y: number);
  19566. }
  19567. /**
  19568. * An interface which manages callbacks for gamepad button changes
  19569. */
  19570. export interface GamepadButtonChanges {
  19571. /**
  19572. * Called when a gamepad has been changed
  19573. */
  19574. changed: boolean;
  19575. /**
  19576. * Called when a gamepad press event has been triggered
  19577. */
  19578. pressChanged: boolean;
  19579. /**
  19580. * Called when a touch event has been triggered
  19581. */
  19582. touchChanged: boolean;
  19583. /**
  19584. * Called when a value has changed
  19585. */
  19586. valueChanged: boolean;
  19587. }
  19588. /**
  19589. * Represents a gamepad
  19590. */
  19591. export class Gamepad {
  19592. /**
  19593. * The id of the gamepad
  19594. */
  19595. id: string;
  19596. /**
  19597. * The index of the gamepad
  19598. */
  19599. index: number;
  19600. /**
  19601. * The browser gamepad
  19602. */
  19603. browserGamepad: any;
  19604. /**
  19605. * Specifies what type of gamepad this represents
  19606. */
  19607. type: number;
  19608. private _leftStick;
  19609. private _rightStick;
  19610. /** @hidden */
  19611. _isConnected: boolean;
  19612. private _leftStickAxisX;
  19613. private _leftStickAxisY;
  19614. private _rightStickAxisX;
  19615. private _rightStickAxisY;
  19616. /**
  19617. * Triggered when the left control stick has been changed
  19618. */
  19619. private _onleftstickchanged;
  19620. /**
  19621. * Triggered when the right control stick has been changed
  19622. */
  19623. private _onrightstickchanged;
  19624. /**
  19625. * Represents a gamepad controller
  19626. */
  19627. static GAMEPAD: number;
  19628. /**
  19629. * Represents a generic controller
  19630. */
  19631. static GENERIC: number;
  19632. /**
  19633. * Represents an XBox controller
  19634. */
  19635. static XBOX: number;
  19636. /**
  19637. * Represents a pose-enabled controller
  19638. */
  19639. static POSE_ENABLED: number;
  19640. /**
  19641. * Represents an Dual Shock controller
  19642. */
  19643. static DUALSHOCK: number;
  19644. /**
  19645. * Specifies whether the left control stick should be Y-inverted
  19646. */
  19647. protected _invertLeftStickY: boolean;
  19648. /**
  19649. * Specifies if the gamepad has been connected
  19650. */
  19651. get isConnected(): boolean;
  19652. /**
  19653. * Initializes the gamepad
  19654. * @param id The id of the gamepad
  19655. * @param index The index of the gamepad
  19656. * @param browserGamepad The browser gamepad
  19657. * @param leftStickX The x component of the left joystick
  19658. * @param leftStickY The y component of the left joystick
  19659. * @param rightStickX The x component of the right joystick
  19660. * @param rightStickY The y component of the right joystick
  19661. */
  19662. constructor(
  19663. /**
  19664. * The id of the gamepad
  19665. */
  19666. id: string,
  19667. /**
  19668. * The index of the gamepad
  19669. */
  19670. index: number,
  19671. /**
  19672. * The browser gamepad
  19673. */
  19674. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19675. /**
  19676. * Callback triggered when the left joystick has changed
  19677. * @param callback
  19678. */
  19679. onleftstickchanged(callback: (values: StickValues) => void): void;
  19680. /**
  19681. * Callback triggered when the right joystick has changed
  19682. * @param callback
  19683. */
  19684. onrightstickchanged(callback: (values: StickValues) => void): void;
  19685. /**
  19686. * Gets the left joystick
  19687. */
  19688. get leftStick(): StickValues;
  19689. /**
  19690. * Sets the left joystick values
  19691. */
  19692. set leftStick(newValues: StickValues);
  19693. /**
  19694. * Gets the right joystick
  19695. */
  19696. get rightStick(): StickValues;
  19697. /**
  19698. * Sets the right joystick value
  19699. */
  19700. set rightStick(newValues: StickValues);
  19701. /**
  19702. * Updates the gamepad joystick positions
  19703. */
  19704. update(): void;
  19705. /**
  19706. * Disposes the gamepad
  19707. */
  19708. dispose(): void;
  19709. }
  19710. /**
  19711. * Represents a generic gamepad
  19712. */
  19713. export class GenericPad extends Gamepad {
  19714. private _buttons;
  19715. private _onbuttondown;
  19716. private _onbuttonup;
  19717. /**
  19718. * Observable triggered when a button has been pressed
  19719. */
  19720. onButtonDownObservable: Observable<number>;
  19721. /**
  19722. * Observable triggered when a button has been released
  19723. */
  19724. onButtonUpObservable: Observable<number>;
  19725. /**
  19726. * Callback triggered when a button has been pressed
  19727. * @param callback Called when a button has been pressed
  19728. */
  19729. onbuttondown(callback: (buttonPressed: number) => void): void;
  19730. /**
  19731. * Callback triggered when a button has been released
  19732. * @param callback Called when a button has been released
  19733. */
  19734. onbuttonup(callback: (buttonReleased: number) => void): void;
  19735. /**
  19736. * Initializes the generic gamepad
  19737. * @param id The id of the generic gamepad
  19738. * @param index The index of the generic gamepad
  19739. * @param browserGamepad The browser gamepad
  19740. */
  19741. constructor(id: string, index: number, browserGamepad: any);
  19742. private _setButtonValue;
  19743. /**
  19744. * Updates the generic gamepad
  19745. */
  19746. update(): void;
  19747. /**
  19748. * Disposes the generic gamepad
  19749. */
  19750. dispose(): void;
  19751. }
  19752. }
  19753. declare module BABYLON {
  19754. /**
  19755. * Defines the types of pose enabled controllers that are supported
  19756. */
  19757. export enum PoseEnabledControllerType {
  19758. /**
  19759. * HTC Vive
  19760. */
  19761. VIVE = 0,
  19762. /**
  19763. * Oculus Rift
  19764. */
  19765. OCULUS = 1,
  19766. /**
  19767. * Windows mixed reality
  19768. */
  19769. WINDOWS = 2,
  19770. /**
  19771. * Samsung gear VR
  19772. */
  19773. GEAR_VR = 3,
  19774. /**
  19775. * Google Daydream
  19776. */
  19777. DAYDREAM = 4,
  19778. /**
  19779. * Generic
  19780. */
  19781. GENERIC = 5
  19782. }
  19783. /**
  19784. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19785. */
  19786. export interface MutableGamepadButton {
  19787. /**
  19788. * Value of the button/trigger
  19789. */
  19790. value: number;
  19791. /**
  19792. * If the button/trigger is currently touched
  19793. */
  19794. touched: boolean;
  19795. /**
  19796. * If the button/trigger is currently pressed
  19797. */
  19798. pressed: boolean;
  19799. }
  19800. /**
  19801. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19802. * @hidden
  19803. */
  19804. export interface ExtendedGamepadButton extends GamepadButton {
  19805. /**
  19806. * If the button/trigger is currently pressed
  19807. */
  19808. readonly pressed: boolean;
  19809. /**
  19810. * If the button/trigger is currently touched
  19811. */
  19812. readonly touched: boolean;
  19813. /**
  19814. * Value of the button/trigger
  19815. */
  19816. readonly value: number;
  19817. }
  19818. /** @hidden */
  19819. export interface _GamePadFactory {
  19820. /**
  19821. * Returns whether or not the current gamepad can be created for this type of controller.
  19822. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19823. * @returns true if it can be created, otherwise false
  19824. */
  19825. canCreate(gamepadInfo: any): boolean;
  19826. /**
  19827. * Creates a new instance of the Gamepad.
  19828. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19829. * @returns the new gamepad instance
  19830. */
  19831. create(gamepadInfo: any): Gamepad;
  19832. }
  19833. /**
  19834. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19835. */
  19836. export class PoseEnabledControllerHelper {
  19837. /** @hidden */
  19838. static _ControllerFactories: _GamePadFactory[];
  19839. /** @hidden */
  19840. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19841. /**
  19842. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19843. * @param vrGamepad the gamepad to initialized
  19844. * @returns a vr controller of the type the gamepad identified as
  19845. */
  19846. static InitiateController(vrGamepad: any): Gamepad;
  19847. }
  19848. /**
  19849. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19850. */
  19851. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19852. /**
  19853. * If the controller is used in a webXR session
  19854. */
  19855. isXR: boolean;
  19856. private _deviceRoomPosition;
  19857. private _deviceRoomRotationQuaternion;
  19858. /**
  19859. * The device position in babylon space
  19860. */
  19861. devicePosition: Vector3;
  19862. /**
  19863. * The device rotation in babylon space
  19864. */
  19865. deviceRotationQuaternion: Quaternion;
  19866. /**
  19867. * The scale factor of the device in babylon space
  19868. */
  19869. deviceScaleFactor: number;
  19870. /**
  19871. * (Likely devicePosition should be used instead) The device position in its room space
  19872. */
  19873. position: Vector3;
  19874. /**
  19875. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19876. */
  19877. rotationQuaternion: Quaternion;
  19878. /**
  19879. * The type of controller (Eg. Windows mixed reality)
  19880. */
  19881. controllerType: PoseEnabledControllerType;
  19882. protected _calculatedPosition: Vector3;
  19883. private _calculatedRotation;
  19884. /**
  19885. * The raw pose from the device
  19886. */
  19887. rawPose: DevicePose;
  19888. private _trackPosition;
  19889. private _maxRotationDistFromHeadset;
  19890. private _draggedRoomRotation;
  19891. /**
  19892. * @hidden
  19893. */
  19894. _disableTrackPosition(fixedPosition: Vector3): void;
  19895. /**
  19896. * Internal, the mesh attached to the controller
  19897. * @hidden
  19898. */
  19899. _mesh: Nullable<AbstractMesh>;
  19900. private _poseControlledCamera;
  19901. private _leftHandSystemQuaternion;
  19902. /**
  19903. * Internal, matrix used to convert room space to babylon space
  19904. * @hidden
  19905. */
  19906. _deviceToWorld: Matrix;
  19907. /**
  19908. * Node to be used when casting a ray from the controller
  19909. * @hidden
  19910. */
  19911. _pointingPoseNode: Nullable<TransformNode>;
  19912. /**
  19913. * Name of the child mesh that can be used to cast a ray from the controller
  19914. */
  19915. static readonly POINTING_POSE: string;
  19916. /**
  19917. * Creates a new PoseEnabledController from a gamepad
  19918. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19919. */
  19920. constructor(browserGamepad: any);
  19921. private _workingMatrix;
  19922. /**
  19923. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19924. */
  19925. update(): void;
  19926. /**
  19927. * Updates only the pose device and mesh without doing any button event checking
  19928. */
  19929. protected _updatePoseAndMesh(): void;
  19930. /**
  19931. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19932. * @param poseData raw pose fromthe device
  19933. */
  19934. updateFromDevice(poseData: DevicePose): void;
  19935. /**
  19936. * @hidden
  19937. */
  19938. _meshAttachedObservable: Observable<AbstractMesh>;
  19939. /**
  19940. * Attaches a mesh to the controller
  19941. * @param mesh the mesh to be attached
  19942. */
  19943. attachToMesh(mesh: AbstractMesh): void;
  19944. /**
  19945. * Attaches the controllers mesh to a camera
  19946. * @param camera the camera the mesh should be attached to
  19947. */
  19948. attachToPoseControlledCamera(camera: TargetCamera): void;
  19949. /**
  19950. * Disposes of the controller
  19951. */
  19952. dispose(): void;
  19953. /**
  19954. * The mesh that is attached to the controller
  19955. */
  19956. get mesh(): Nullable<AbstractMesh>;
  19957. /**
  19958. * Gets the ray of the controller in the direction the controller is pointing
  19959. * @param length the length the resulting ray should be
  19960. * @returns a ray in the direction the controller is pointing
  19961. */
  19962. getForwardRay(length?: number): Ray;
  19963. }
  19964. }
  19965. declare module BABYLON {
  19966. /**
  19967. * Defines the WebVRController object that represents controllers tracked in 3D space
  19968. */
  19969. export abstract class WebVRController extends PoseEnabledController {
  19970. /**
  19971. * Internal, the default controller model for the controller
  19972. */
  19973. protected _defaultModel: Nullable<AbstractMesh>;
  19974. /**
  19975. * Fired when the trigger state has changed
  19976. */
  19977. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19978. /**
  19979. * Fired when the main button state has changed
  19980. */
  19981. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19982. /**
  19983. * Fired when the secondary button state has changed
  19984. */
  19985. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19986. /**
  19987. * Fired when the pad state has changed
  19988. */
  19989. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19990. /**
  19991. * Fired when controllers stick values have changed
  19992. */
  19993. onPadValuesChangedObservable: Observable<StickValues>;
  19994. /**
  19995. * Array of button availible on the controller
  19996. */
  19997. protected _buttons: Array<MutableGamepadButton>;
  19998. private _onButtonStateChange;
  19999. /**
  20000. * Fired when a controller button's state has changed
  20001. * @param callback the callback containing the button that was modified
  20002. */
  20003. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20004. /**
  20005. * X and Y axis corresponding to the controllers joystick
  20006. */
  20007. pad: StickValues;
  20008. /**
  20009. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20010. */
  20011. hand: string;
  20012. /**
  20013. * The default controller model for the controller
  20014. */
  20015. get defaultModel(): Nullable<AbstractMesh>;
  20016. /**
  20017. * Creates a new WebVRController from a gamepad
  20018. * @param vrGamepad the gamepad that the WebVRController should be created from
  20019. */
  20020. constructor(vrGamepad: any);
  20021. /**
  20022. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20023. */
  20024. update(): void;
  20025. /**
  20026. * Function to be called when a button is modified
  20027. */
  20028. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20029. /**
  20030. * Loads a mesh and attaches it to the controller
  20031. * @param scene the scene the mesh should be added to
  20032. * @param meshLoaded callback for when the mesh has been loaded
  20033. */
  20034. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20035. private _setButtonValue;
  20036. private _changes;
  20037. private _checkChanges;
  20038. /**
  20039. * Disposes of th webVRCOntroller
  20040. */
  20041. dispose(): void;
  20042. }
  20043. }
  20044. declare module BABYLON {
  20045. /**
  20046. * The HemisphericLight simulates the ambient environment light,
  20047. * so the passed direction is the light reflection direction, not the incoming direction.
  20048. */
  20049. export class HemisphericLight extends Light {
  20050. /**
  20051. * The groundColor is the light in the opposite direction to the one specified during creation.
  20052. * 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.
  20053. */
  20054. groundColor: Color3;
  20055. /**
  20056. * The light reflection direction, not the incoming direction.
  20057. */
  20058. direction: Vector3;
  20059. /**
  20060. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20061. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20062. * The HemisphericLight can't cast shadows.
  20063. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20064. * @param name The friendly name of the light
  20065. * @param direction The direction of the light reflection
  20066. * @param scene The scene the light belongs to
  20067. */
  20068. constructor(name: string, direction: Vector3, scene: Scene);
  20069. protected _buildUniformLayout(): void;
  20070. /**
  20071. * Returns the string "HemisphericLight".
  20072. * @return The class name
  20073. */
  20074. getClassName(): string;
  20075. /**
  20076. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20077. * Returns the updated direction.
  20078. * @param target The target the direction should point to
  20079. * @return The computed direction
  20080. */
  20081. setDirectionToTarget(target: Vector3): Vector3;
  20082. /**
  20083. * Returns the shadow generator associated to the light.
  20084. * @returns Always null for hemispheric lights because it does not support shadows.
  20085. */
  20086. getShadowGenerator(): Nullable<IShadowGenerator>;
  20087. /**
  20088. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20089. * @param effect The effect to update
  20090. * @param lightIndex The index of the light in the effect to update
  20091. * @returns The hemispheric light
  20092. */
  20093. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20094. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20095. /**
  20096. * Computes the world matrix of the node
  20097. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20098. * @param useWasUpdatedFlag defines a reserved property
  20099. * @returns the world matrix
  20100. */
  20101. computeWorldMatrix(): Matrix;
  20102. /**
  20103. * Returns the integer 3.
  20104. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20105. */
  20106. getTypeID(): number;
  20107. /**
  20108. * Prepares the list of defines specific to the light type.
  20109. * @param defines the list of defines
  20110. * @param lightIndex defines the index of the light for the effect
  20111. */
  20112. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20113. }
  20114. }
  20115. declare module BABYLON {
  20116. /** @hidden */
  20117. export var vrMultiviewToSingleviewPixelShader: {
  20118. name: string;
  20119. shader: string;
  20120. };
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * Renders to multiple views with a single draw call
  20125. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20126. */
  20127. export class MultiviewRenderTarget extends RenderTargetTexture {
  20128. /**
  20129. * Creates a multiview render target
  20130. * @param scene scene used with the render target
  20131. * @param size the size of the render target (used for each view)
  20132. */
  20133. constructor(scene: Scene, size?: number | {
  20134. width: number;
  20135. height: number;
  20136. } | {
  20137. ratio: number;
  20138. });
  20139. /**
  20140. * @hidden
  20141. * @param faceIndex the face index, if its a cube texture
  20142. */
  20143. _bindFrameBuffer(faceIndex?: number): void;
  20144. /**
  20145. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20146. * @returns the view count
  20147. */
  20148. getViewCount(): number;
  20149. }
  20150. }
  20151. declare module BABYLON {
  20152. interface Engine {
  20153. /**
  20154. * Creates a new multiview render target
  20155. * @param width defines the width of the texture
  20156. * @param height defines the height of the texture
  20157. * @returns the created multiview texture
  20158. */
  20159. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20160. /**
  20161. * Binds a multiview framebuffer to be drawn to
  20162. * @param multiviewTexture texture to bind
  20163. */
  20164. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20165. }
  20166. interface Camera {
  20167. /**
  20168. * @hidden
  20169. * 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)
  20170. */
  20171. _useMultiviewToSingleView: boolean;
  20172. /**
  20173. * @hidden
  20174. * 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)
  20175. */
  20176. _multiviewTexture: Nullable<RenderTargetTexture>;
  20177. /**
  20178. * @hidden
  20179. * ensures the multiview texture of the camera exists and has the specified width/height
  20180. * @param width height to set on the multiview texture
  20181. * @param height width to set on the multiview texture
  20182. */
  20183. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20184. }
  20185. interface Scene {
  20186. /** @hidden */
  20187. _transformMatrixR: Matrix;
  20188. /** @hidden */
  20189. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20190. /** @hidden */
  20191. _createMultiviewUbo(): void;
  20192. /** @hidden */
  20193. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20194. /** @hidden */
  20195. _renderMultiviewToSingleView(camera: Camera): void;
  20196. }
  20197. }
  20198. declare module BABYLON {
  20199. /**
  20200. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20201. * This will not be used for webXR as it supports displaying texture arrays directly
  20202. */
  20203. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20204. /**
  20205. * Gets a string identifying the name of the class
  20206. * @returns "VRMultiviewToSingleviewPostProcess" string
  20207. */
  20208. getClassName(): string;
  20209. /**
  20210. * Initializes a VRMultiviewToSingleview
  20211. * @param name name of the post process
  20212. * @param camera camera to be applied to
  20213. * @param scaleFactor scaling factor to the size of the output texture
  20214. */
  20215. constructor(name: string, camera: Camera, scaleFactor: number);
  20216. }
  20217. }
  20218. declare module BABYLON {
  20219. /**
  20220. * Interface used to define additional presentation attributes
  20221. */
  20222. export interface IVRPresentationAttributes {
  20223. /**
  20224. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20225. */
  20226. highRefreshRate: boolean;
  20227. /**
  20228. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20229. */
  20230. foveationLevel: number;
  20231. }
  20232. interface Engine {
  20233. /** @hidden */
  20234. _vrDisplay: any;
  20235. /** @hidden */
  20236. _vrSupported: boolean;
  20237. /** @hidden */
  20238. _oldSize: Size;
  20239. /** @hidden */
  20240. _oldHardwareScaleFactor: number;
  20241. /** @hidden */
  20242. _vrExclusivePointerMode: boolean;
  20243. /** @hidden */
  20244. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20245. /** @hidden */
  20246. _onVRDisplayPointerRestricted: () => void;
  20247. /** @hidden */
  20248. _onVRDisplayPointerUnrestricted: () => void;
  20249. /** @hidden */
  20250. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20251. /** @hidden */
  20252. _onVrDisplayDisconnect: Nullable<() => void>;
  20253. /** @hidden */
  20254. _onVrDisplayPresentChange: Nullable<() => void>;
  20255. /**
  20256. * Observable signaled when VR display mode changes
  20257. */
  20258. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20259. /**
  20260. * Observable signaled when VR request present is complete
  20261. */
  20262. onVRRequestPresentComplete: Observable<boolean>;
  20263. /**
  20264. * Observable signaled when VR request present starts
  20265. */
  20266. onVRRequestPresentStart: Observable<Engine>;
  20267. /**
  20268. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20269. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20270. */
  20271. isInVRExclusivePointerMode: boolean;
  20272. /**
  20273. * Gets a boolean indicating if a webVR device was detected
  20274. * @returns true if a webVR device was detected
  20275. */
  20276. isVRDevicePresent(): boolean;
  20277. /**
  20278. * Gets the current webVR device
  20279. * @returns the current webVR device (or null)
  20280. */
  20281. getVRDevice(): any;
  20282. /**
  20283. * Initializes a webVR display and starts listening to display change events
  20284. * The onVRDisplayChangedObservable will be notified upon these changes
  20285. * @returns A promise containing a VRDisplay and if vr is supported
  20286. */
  20287. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20288. /** @hidden */
  20289. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20290. /**
  20291. * Gets or sets the presentation attributes used to configure VR rendering
  20292. */
  20293. vrPresentationAttributes?: IVRPresentationAttributes;
  20294. /**
  20295. * Call this function to switch to webVR mode
  20296. * Will do nothing if webVR is not supported or if there is no webVR device
  20297. * @param options the webvr options provided to the camera. mainly used for multiview
  20298. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20299. */
  20300. enableVR(options: WebVROptions): void;
  20301. /** @hidden */
  20302. _onVRFullScreenTriggered(): void;
  20303. }
  20304. }
  20305. declare module BABYLON {
  20306. /**
  20307. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20308. * IMPORTANT!! The data is right-hand data.
  20309. * @export
  20310. * @interface DevicePose
  20311. */
  20312. export interface DevicePose {
  20313. /**
  20314. * The position of the device, values in array are [x,y,z].
  20315. */
  20316. readonly position: Nullable<Float32Array>;
  20317. /**
  20318. * The linearVelocity of the device, values in array are [x,y,z].
  20319. */
  20320. readonly linearVelocity: Nullable<Float32Array>;
  20321. /**
  20322. * The linearAcceleration of the device, values in array are [x,y,z].
  20323. */
  20324. readonly linearAcceleration: Nullable<Float32Array>;
  20325. /**
  20326. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20327. */
  20328. readonly orientation: Nullable<Float32Array>;
  20329. /**
  20330. * The angularVelocity of the device, values in array are [x,y,z].
  20331. */
  20332. readonly angularVelocity: Nullable<Float32Array>;
  20333. /**
  20334. * The angularAcceleration of the device, values in array are [x,y,z].
  20335. */
  20336. readonly angularAcceleration: Nullable<Float32Array>;
  20337. }
  20338. /**
  20339. * Interface representing a pose controlled object in Babylon.
  20340. * A pose controlled object has both regular pose values as well as pose values
  20341. * from an external device such as a VR head mounted display
  20342. */
  20343. export interface PoseControlled {
  20344. /**
  20345. * The position of the object in babylon space.
  20346. */
  20347. position: Vector3;
  20348. /**
  20349. * The rotation quaternion of the object in babylon space.
  20350. */
  20351. rotationQuaternion: Quaternion;
  20352. /**
  20353. * The position of the device in babylon space.
  20354. */
  20355. devicePosition?: Vector3;
  20356. /**
  20357. * The rotation quaternion of the device in babylon space.
  20358. */
  20359. deviceRotationQuaternion: Quaternion;
  20360. /**
  20361. * The raw pose coming from the device.
  20362. */
  20363. rawPose: Nullable<DevicePose>;
  20364. /**
  20365. * The scale of the device to be used when translating from device space to babylon space.
  20366. */
  20367. deviceScaleFactor: number;
  20368. /**
  20369. * Updates the poseControlled values based on the input device pose.
  20370. * @param poseData the pose data to update the object with
  20371. */
  20372. updateFromDevice(poseData: DevicePose): void;
  20373. }
  20374. /**
  20375. * Set of options to customize the webVRCamera
  20376. */
  20377. export interface WebVROptions {
  20378. /**
  20379. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20380. */
  20381. trackPosition?: boolean;
  20382. /**
  20383. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20384. */
  20385. positionScale?: number;
  20386. /**
  20387. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20388. */
  20389. displayName?: string;
  20390. /**
  20391. * Should the native controller meshes be initialized. (default: true)
  20392. */
  20393. controllerMeshes?: boolean;
  20394. /**
  20395. * Creating a default HemiLight only on controllers. (default: true)
  20396. */
  20397. defaultLightingOnControllers?: boolean;
  20398. /**
  20399. * If you don't want to use the default VR button of the helper. (default: false)
  20400. */
  20401. useCustomVRButton?: boolean;
  20402. /**
  20403. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20404. */
  20405. customVRButton?: HTMLButtonElement;
  20406. /**
  20407. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20408. */
  20409. rayLength?: number;
  20410. /**
  20411. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20412. */
  20413. defaultHeight?: number;
  20414. /**
  20415. * If multiview should be used if availible (default: false)
  20416. */
  20417. useMultiview?: boolean;
  20418. }
  20419. /**
  20420. * This represents a WebVR camera.
  20421. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20422. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20423. */
  20424. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20425. private webVROptions;
  20426. /**
  20427. * @hidden
  20428. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20429. */
  20430. _vrDevice: any;
  20431. /**
  20432. * The rawPose of the vrDevice.
  20433. */
  20434. rawPose: Nullable<DevicePose>;
  20435. private _onVREnabled;
  20436. private _specsVersion;
  20437. private _attached;
  20438. private _frameData;
  20439. protected _descendants: Array<Node>;
  20440. private _deviceRoomPosition;
  20441. /** @hidden */
  20442. _deviceRoomRotationQuaternion: Quaternion;
  20443. private _standingMatrix;
  20444. /**
  20445. * Represents device position in babylon space.
  20446. */
  20447. devicePosition: Vector3;
  20448. /**
  20449. * Represents device rotation in babylon space.
  20450. */
  20451. deviceRotationQuaternion: Quaternion;
  20452. /**
  20453. * The scale of the device to be used when translating from device space to babylon space.
  20454. */
  20455. deviceScaleFactor: number;
  20456. private _deviceToWorld;
  20457. private _worldToDevice;
  20458. /**
  20459. * References to the webVR controllers for the vrDevice.
  20460. */
  20461. controllers: Array<WebVRController>;
  20462. /**
  20463. * Emits an event when a controller is attached.
  20464. */
  20465. onControllersAttachedObservable: Observable<WebVRController[]>;
  20466. /**
  20467. * Emits an event when a controller's mesh has been loaded;
  20468. */
  20469. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20470. /**
  20471. * Emits an event when the HMD's pose has been updated.
  20472. */
  20473. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20474. private _poseSet;
  20475. /**
  20476. * If the rig cameras be used as parent instead of this camera.
  20477. */
  20478. rigParenting: boolean;
  20479. private _lightOnControllers;
  20480. private _defaultHeight?;
  20481. /**
  20482. * Instantiates a WebVRFreeCamera.
  20483. * @param name The name of the WebVRFreeCamera
  20484. * @param position The starting anchor position for the camera
  20485. * @param scene The scene the camera belongs to
  20486. * @param webVROptions a set of customizable options for the webVRCamera
  20487. */
  20488. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20489. /**
  20490. * Gets the device distance from the ground in meters.
  20491. * @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.
  20492. */
  20493. deviceDistanceToRoomGround(): number;
  20494. /**
  20495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20496. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20497. */
  20498. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20499. /**
  20500. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20501. * @returns A promise with a boolean set to if the standing matrix is supported.
  20502. */
  20503. useStandingMatrixAsync(): Promise<boolean>;
  20504. /**
  20505. * Disposes the camera
  20506. */
  20507. dispose(): void;
  20508. /**
  20509. * Gets a vrController by name.
  20510. * @param name The name of the controller to retreive
  20511. * @returns the controller matching the name specified or null if not found
  20512. */
  20513. getControllerByName(name: string): Nullable<WebVRController>;
  20514. private _leftController;
  20515. /**
  20516. * The controller corresponding to the users left hand.
  20517. */
  20518. get leftController(): Nullable<WebVRController>;
  20519. private _rightController;
  20520. /**
  20521. * The controller corresponding to the users right hand.
  20522. */
  20523. get rightController(): Nullable<WebVRController>;
  20524. /**
  20525. * Casts a ray forward from the vrCamera's gaze.
  20526. * @param length Length of the ray (default: 100)
  20527. * @returns the ray corresponding to the gaze
  20528. */
  20529. getForwardRay(length?: number): Ray;
  20530. /**
  20531. * @hidden
  20532. * Updates the camera based on device's frame data
  20533. */
  20534. _checkInputs(): void;
  20535. /**
  20536. * Updates the poseControlled values based on the input device pose.
  20537. * @param poseData Pose coming from the device
  20538. */
  20539. updateFromDevice(poseData: DevicePose): void;
  20540. private _detachIfAttached;
  20541. /**
  20542. * WebVR's attach control will start broadcasting frames to the device.
  20543. * Note that in certain browsers (chrome for example) this function must be called
  20544. * within a user-interaction callback. Example:
  20545. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20546. *
  20547. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20548. */
  20549. attachControl(noPreventDefault?: boolean): void;
  20550. /**
  20551. * Detach the current controls from the specified dom element.
  20552. */
  20553. detachControl(): void;
  20554. /**
  20555. * @returns the name of this class
  20556. */
  20557. getClassName(): string;
  20558. /**
  20559. * Calls resetPose on the vrDisplay
  20560. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20561. */
  20562. resetToCurrentRotation(): void;
  20563. /**
  20564. * @hidden
  20565. * Updates the rig cameras (left and right eye)
  20566. */
  20567. _updateRigCameras(): void;
  20568. private _workingVector;
  20569. private _oneVector;
  20570. private _workingMatrix;
  20571. private updateCacheCalled;
  20572. private _correctPositionIfNotTrackPosition;
  20573. /**
  20574. * @hidden
  20575. * Updates the cached values of the camera
  20576. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20577. */
  20578. _updateCache(ignoreParentClass?: boolean): void;
  20579. /**
  20580. * @hidden
  20581. * Get current device position in babylon world
  20582. */
  20583. _computeDevicePosition(): void;
  20584. /**
  20585. * Updates the current device position and rotation in the babylon world
  20586. */
  20587. update(): void;
  20588. /**
  20589. * @hidden
  20590. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20591. * @returns an identity matrix
  20592. */
  20593. _getViewMatrix(): Matrix;
  20594. private _tmpMatrix;
  20595. /**
  20596. * This function is called by the two RIG cameras.
  20597. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20598. * @hidden
  20599. */
  20600. _getWebVRViewMatrix(): Matrix;
  20601. /** @hidden */
  20602. _getWebVRProjectionMatrix(): Matrix;
  20603. private _onGamepadConnectedObserver;
  20604. private _onGamepadDisconnectedObserver;
  20605. private _updateCacheWhenTrackingDisabledObserver;
  20606. /**
  20607. * Initializes the controllers and their meshes
  20608. */
  20609. initControllers(): void;
  20610. }
  20611. }
  20612. declare module BABYLON {
  20613. /**
  20614. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20615. *
  20616. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20617. *
  20618. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20619. */
  20620. export class MaterialHelper {
  20621. /**
  20622. * Bind the current view position to an effect.
  20623. * @param effect The effect to be bound
  20624. * @param scene The scene the eyes position is used from
  20625. * @param variableName name of the shader variable that will hold the eye position
  20626. */
  20627. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20628. /**
  20629. * Helps preparing the defines values about the UVs in used in the effect.
  20630. * UVs are shared as much as we can accross channels in the shaders.
  20631. * @param texture The texture we are preparing the UVs for
  20632. * @param defines The defines to update
  20633. * @param key The channel key "diffuse", "specular"... used in the shader
  20634. */
  20635. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20636. /**
  20637. * Binds a texture matrix value to its corrsponding uniform
  20638. * @param texture The texture to bind the matrix for
  20639. * @param uniformBuffer The uniform buffer receivin the data
  20640. * @param key The channel key "diffuse", "specular"... used in the shader
  20641. */
  20642. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20643. /**
  20644. * Gets the current status of the fog (should it be enabled?)
  20645. * @param mesh defines the mesh to evaluate for fog support
  20646. * @param scene defines the hosting scene
  20647. * @returns true if fog must be enabled
  20648. */
  20649. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20650. /**
  20651. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20652. * @param mesh defines the current mesh
  20653. * @param scene defines the current scene
  20654. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20655. * @param pointsCloud defines if point cloud rendering has to be turned on
  20656. * @param fogEnabled defines if fog has to be turned on
  20657. * @param alphaTest defines if alpha testing has to be turned on
  20658. * @param defines defines the current list of defines
  20659. */
  20660. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20661. /**
  20662. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20663. * @param scene defines the current scene
  20664. * @param engine defines the current engine
  20665. * @param defines specifies the list of active defines
  20666. * @param useInstances defines if instances have to be turned on
  20667. * @param useClipPlane defines if clip plane have to be turned on
  20668. * @param useInstances defines if instances have to be turned on
  20669. * @param useThinInstances defines if thin instances have to be turned on
  20670. */
  20671. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20672. /**
  20673. * Prepares the defines for bones
  20674. * @param mesh The mesh containing the geometry data we will draw
  20675. * @param defines The defines to update
  20676. */
  20677. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20678. /**
  20679. * Prepares the defines for morph targets
  20680. * @param mesh The mesh containing the geometry data we will draw
  20681. * @param defines The defines to update
  20682. */
  20683. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20684. /**
  20685. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20686. * @param mesh The mesh containing the geometry data we will draw
  20687. * @param defines The defines to update
  20688. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20689. * @param useBones Precise whether bones should be used or not (override mesh info)
  20690. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20691. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20692. * @returns false if defines are considered not dirty and have not been checked
  20693. */
  20694. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20695. /**
  20696. * Prepares the defines related to multiview
  20697. * @param scene The scene we are intending to draw
  20698. * @param defines The defines to update
  20699. */
  20700. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20701. /**
  20702. * Prepares the defines related to the prepass
  20703. * @param scene The scene we are intending to draw
  20704. * @param defines The defines to update
  20705. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20706. */
  20707. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20708. /**
  20709. * Prepares the defines related to the light information passed in parameter
  20710. * @param scene The scene we are intending to draw
  20711. * @param mesh The mesh the effect is compiling for
  20712. * @param light The light the effect is compiling for
  20713. * @param lightIndex The index of the light
  20714. * @param defines The defines to update
  20715. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20716. * @param state Defines the current state regarding what is needed (normals, etc...)
  20717. */
  20718. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20719. needNormals: boolean;
  20720. needRebuild: boolean;
  20721. shadowEnabled: boolean;
  20722. specularEnabled: boolean;
  20723. lightmapMode: boolean;
  20724. }): void;
  20725. /**
  20726. * Prepares the defines related to the light information passed in parameter
  20727. * @param scene The scene we are intending to draw
  20728. * @param mesh The mesh the effect is compiling for
  20729. * @param defines The defines to update
  20730. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20731. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20732. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20733. * @returns true if normals will be required for the rest of the effect
  20734. */
  20735. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20736. /**
  20737. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20738. * @param lightIndex defines the light index
  20739. * @param uniformsList The uniform list
  20740. * @param samplersList The sampler list
  20741. * @param projectedLightTexture defines if projected texture must be used
  20742. * @param uniformBuffersList defines an optional list of uniform buffers
  20743. */
  20744. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20745. /**
  20746. * Prepares the uniforms and samplers list to be used in the effect
  20747. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20748. * @param samplersList The sampler list
  20749. * @param defines The defines helping in the list generation
  20750. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20751. */
  20752. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20753. /**
  20754. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20755. * @param defines The defines to update while falling back
  20756. * @param fallbacks The authorized effect fallbacks
  20757. * @param maxSimultaneousLights The maximum number of lights allowed
  20758. * @param rank the current rank of the Effect
  20759. * @returns The newly affected rank
  20760. */
  20761. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20762. private static _TmpMorphInfluencers;
  20763. /**
  20764. * Prepares the list of attributes required for morph targets according to the effect defines.
  20765. * @param attribs The current list of supported attribs
  20766. * @param mesh The mesh to prepare the morph targets attributes for
  20767. * @param influencers The number of influencers
  20768. */
  20769. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20770. /**
  20771. * Prepares the list of attributes required for morph targets according to the effect defines.
  20772. * @param attribs The current list of supported attribs
  20773. * @param mesh The mesh to prepare the morph targets attributes for
  20774. * @param defines The current Defines of the effect
  20775. */
  20776. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20777. /**
  20778. * Prepares the list of attributes required for bones according to the effect defines.
  20779. * @param attribs The current list of supported attribs
  20780. * @param mesh The mesh to prepare the bones attributes for
  20781. * @param defines The current Defines of the effect
  20782. * @param fallbacks The current efffect fallback strategy
  20783. */
  20784. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20785. /**
  20786. * Check and prepare the list of attributes required for instances according to the effect defines.
  20787. * @param attribs The current list of supported attribs
  20788. * @param defines The current MaterialDefines of the effect
  20789. */
  20790. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20791. /**
  20792. * Add the list of attributes required for instances to the attribs array.
  20793. * @param attribs The current list of supported attribs
  20794. */
  20795. static PushAttributesForInstances(attribs: string[]): void;
  20796. /**
  20797. * Binds the light information to the effect.
  20798. * @param light The light containing the generator
  20799. * @param effect The effect we are binding the data to
  20800. * @param lightIndex The light index in the effect used to render
  20801. */
  20802. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20803. /**
  20804. * Binds the lights information from the scene to the effect for the given mesh.
  20805. * @param light Light to bind
  20806. * @param lightIndex Light index
  20807. * @param scene The scene where the light belongs to
  20808. * @param effect The effect we are binding the data to
  20809. * @param useSpecular Defines if specular is supported
  20810. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20811. */
  20812. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20813. /**
  20814. * Binds the lights information from the scene to the effect for the given mesh.
  20815. * @param scene The scene the lights belongs to
  20816. * @param mesh The mesh we are binding the information to render
  20817. * @param effect The effect we are binding the data to
  20818. * @param defines The generated defines for the effect
  20819. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20820. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20821. */
  20822. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20823. private static _tempFogColor;
  20824. /**
  20825. * Binds the fog information from the scene to the effect for the given mesh.
  20826. * @param scene The scene the lights belongs to
  20827. * @param mesh The mesh we are binding the information to render
  20828. * @param effect The effect we are binding the data to
  20829. * @param linearSpace Defines if the fog effect is applied in linear space
  20830. */
  20831. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20832. /**
  20833. * Binds the bones information from the mesh to the effect.
  20834. * @param mesh The mesh we are binding the information to render
  20835. * @param effect The effect we are binding the data to
  20836. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20837. */
  20838. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20839. private static _CopyBonesTransformationMatrices;
  20840. /**
  20841. * Binds the morph targets information from the mesh to the effect.
  20842. * @param abstractMesh The mesh we are binding the information to render
  20843. * @param effect The effect we are binding the data to
  20844. */
  20845. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20846. /**
  20847. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20848. * @param defines The generated defines used in the effect
  20849. * @param effect The effect we are binding the data to
  20850. * @param scene The scene we are willing to render with logarithmic scale for
  20851. */
  20852. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20853. /**
  20854. * Binds the clip plane information from the scene to the effect.
  20855. * @param scene The scene the clip plane information are extracted from
  20856. * @param effect The effect we are binding the data to
  20857. */
  20858. static BindClipPlane(effect: Effect, scene: Scene): void;
  20859. }
  20860. }
  20861. declare module BABYLON {
  20862. /**
  20863. * Block used to expose an input value
  20864. */
  20865. export class InputBlock extends NodeMaterialBlock {
  20866. private _mode;
  20867. private _associatedVariableName;
  20868. private _storedValue;
  20869. private _valueCallback;
  20870. private _type;
  20871. private _animationType;
  20872. /** Gets or set a value used to limit the range of float values */
  20873. min: number;
  20874. /** Gets or set a value used to limit the range of float values */
  20875. max: number;
  20876. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20877. isBoolean: boolean;
  20878. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20879. matrixMode: number;
  20880. /** @hidden */
  20881. _systemValue: Nullable<NodeMaterialSystemValues>;
  20882. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20883. isConstant: boolean;
  20884. /** Gets or sets the group to use to display this block in the Inspector */
  20885. groupInInspector: string;
  20886. /** Gets an observable raised when the value is changed */
  20887. onValueChangedObservable: Observable<InputBlock>;
  20888. /**
  20889. * Gets or sets the connection point type (default is float)
  20890. */
  20891. get type(): NodeMaterialBlockConnectionPointTypes;
  20892. /**
  20893. * Creates a new InputBlock
  20894. * @param name defines the block name
  20895. * @param target defines the target of that block (Vertex by default)
  20896. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20897. */
  20898. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20899. /**
  20900. * Validates if a name is a reserve word.
  20901. * @param newName the new name to be given to the node.
  20902. * @returns false if the name is a reserve word, else true.
  20903. */
  20904. validateBlockName(newName: string): boolean;
  20905. /**
  20906. * Gets the output component
  20907. */
  20908. get output(): NodeMaterialConnectionPoint;
  20909. /**
  20910. * Set the source of this connection point to a vertex attribute
  20911. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20912. * @returns the current connection point
  20913. */
  20914. setAsAttribute(attributeName?: string): InputBlock;
  20915. /**
  20916. * Set the source of this connection point to a system value
  20917. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20918. * @returns the current connection point
  20919. */
  20920. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20921. /**
  20922. * Gets or sets the value of that point.
  20923. * Please note that this value will be ignored if valueCallback is defined
  20924. */
  20925. get value(): any;
  20926. set value(value: any);
  20927. /**
  20928. * Gets or sets a callback used to get the value of that point.
  20929. * Please note that setting this value will force the connection point to ignore the value property
  20930. */
  20931. get valueCallback(): () => any;
  20932. set valueCallback(value: () => any);
  20933. /**
  20934. * Gets or sets the associated variable name in the shader
  20935. */
  20936. get associatedVariableName(): string;
  20937. set associatedVariableName(value: string);
  20938. /** Gets or sets the type of animation applied to the input */
  20939. get animationType(): AnimatedInputBlockTypes;
  20940. set animationType(value: AnimatedInputBlockTypes);
  20941. /**
  20942. * Gets a boolean indicating that this connection point not defined yet
  20943. */
  20944. get isUndefined(): boolean;
  20945. /**
  20946. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20947. * In this case the connection point name must be the name of the uniform to use.
  20948. * Can only be set on inputs
  20949. */
  20950. get isUniform(): boolean;
  20951. set isUniform(value: boolean);
  20952. /**
  20953. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20954. * In this case the connection point name must be the name of the attribute to use
  20955. * Can only be set on inputs
  20956. */
  20957. get isAttribute(): boolean;
  20958. set isAttribute(value: boolean);
  20959. /**
  20960. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20961. * Can only be set on exit points
  20962. */
  20963. get isVarying(): boolean;
  20964. set isVarying(value: boolean);
  20965. /**
  20966. * Gets a boolean indicating that the current connection point is a system value
  20967. */
  20968. get isSystemValue(): boolean;
  20969. /**
  20970. * Gets or sets the current well known value or null if not defined as a system value
  20971. */
  20972. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20973. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20974. /**
  20975. * Gets the current class name
  20976. * @returns the class name
  20977. */
  20978. getClassName(): string;
  20979. /**
  20980. * Animate the input if animationType !== None
  20981. * @param scene defines the rendering scene
  20982. */
  20983. animate(scene: Scene): void;
  20984. private _emitDefine;
  20985. initialize(state: NodeMaterialBuildState): void;
  20986. /**
  20987. * Set the input block to its default value (based on its type)
  20988. */
  20989. setDefaultValue(): void;
  20990. private _emitConstant;
  20991. /** @hidden */
  20992. get _noContextSwitch(): boolean;
  20993. private _emit;
  20994. /** @hidden */
  20995. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20996. /** @hidden */
  20997. _transmit(effect: Effect, scene: Scene): void;
  20998. protected _buildBlock(state: NodeMaterialBuildState): void;
  20999. protected _dumpPropertiesCode(): string;
  21000. dispose(): void;
  21001. serialize(): any;
  21002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21003. }
  21004. }
  21005. declare module BABYLON {
  21006. /**
  21007. * Enum used to define the compatibility state between two connection points
  21008. */
  21009. export enum NodeMaterialConnectionPointCompatibilityStates {
  21010. /** Points are compatibles */
  21011. Compatible = 0,
  21012. /** Points are incompatible because of their types */
  21013. TypeIncompatible = 1,
  21014. /** Points are incompatible because of their targets (vertex vs fragment) */
  21015. TargetIncompatible = 2
  21016. }
  21017. /**
  21018. * Defines the direction of a connection point
  21019. */
  21020. export enum NodeMaterialConnectionPointDirection {
  21021. /** Input */
  21022. Input = 0,
  21023. /** Output */
  21024. Output = 1
  21025. }
  21026. /**
  21027. * Defines a connection point for a block
  21028. */
  21029. export class NodeMaterialConnectionPoint {
  21030. /**
  21031. * Checks if two types are equivalent
  21032. * @param type1 type 1 to check
  21033. * @param type2 type 2 to check
  21034. * @returns true if both types are equivalent, else false
  21035. */
  21036. static AreEquivalentTypes(type1: number, type2: number): boolean;
  21037. /** @hidden */
  21038. _ownerBlock: NodeMaterialBlock;
  21039. /** @hidden */
  21040. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21041. private _endpoints;
  21042. private _associatedVariableName;
  21043. private _direction;
  21044. /** @hidden */
  21045. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21046. /** @hidden */
  21047. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21048. /** @hidden */
  21049. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  21050. private _type;
  21051. /** @hidden */
  21052. _enforceAssociatedVariableName: boolean;
  21053. /** Gets the direction of the point */
  21054. get direction(): NodeMaterialConnectionPointDirection;
  21055. /** Indicates that this connection point needs dual validation before being connected to another point */
  21056. needDualDirectionValidation: boolean;
  21057. /**
  21058. * Gets or sets the additional types supported by this connection point
  21059. */
  21060. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21061. /**
  21062. * Gets or sets the additional types excluded by this connection point
  21063. */
  21064. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21065. /**
  21066. * Observable triggered when this point is connected
  21067. */
  21068. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21069. /**
  21070. * Gets or sets the associated variable name in the shader
  21071. */
  21072. get associatedVariableName(): string;
  21073. set associatedVariableName(value: string);
  21074. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21075. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21076. /**
  21077. * Gets or sets the connection point type (default is float)
  21078. */
  21079. get type(): NodeMaterialBlockConnectionPointTypes;
  21080. set type(value: NodeMaterialBlockConnectionPointTypes);
  21081. /**
  21082. * Gets or sets the connection point name
  21083. */
  21084. name: string;
  21085. /**
  21086. * Gets or sets the connection point name
  21087. */
  21088. displayName: string;
  21089. /**
  21090. * Gets or sets a boolean indicating that this connection point can be omitted
  21091. */
  21092. isOptional: boolean;
  21093. /**
  21094. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21095. */
  21096. isExposedOnFrame: boolean;
  21097. /**
  21098. * Gets or sets number indicating the position that the port is exposed to on a frame
  21099. */
  21100. exposedPortPosition: number;
  21101. /**
  21102. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21103. */
  21104. define: string;
  21105. /** @hidden */
  21106. _prioritizeVertex: boolean;
  21107. private _target;
  21108. /** Gets or sets the target of that connection point */
  21109. get target(): NodeMaterialBlockTargets;
  21110. set target(value: NodeMaterialBlockTargets);
  21111. /**
  21112. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21113. */
  21114. get isConnected(): boolean;
  21115. /**
  21116. * Gets a boolean indicating that the current point is connected to an input block
  21117. */
  21118. get isConnectedToInputBlock(): boolean;
  21119. /**
  21120. * Gets a the connected input block (if any)
  21121. */
  21122. get connectInputBlock(): Nullable<InputBlock>;
  21123. /** Get the other side of the connection (if any) */
  21124. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21125. /** Get the block that owns this connection point */
  21126. get ownerBlock(): NodeMaterialBlock;
  21127. /** Get the block connected on the other side of this connection (if any) */
  21128. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21129. /** Get the block connected on the endpoints of this connection (if any) */
  21130. get connectedBlocks(): Array<NodeMaterialBlock>;
  21131. /** Gets the list of connected endpoints */
  21132. get endpoints(): NodeMaterialConnectionPoint[];
  21133. /** Gets a boolean indicating if that output point is connected to at least one input */
  21134. get hasEndpoints(): boolean;
  21135. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21136. get isConnectedInVertexShader(): boolean;
  21137. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21138. get isConnectedInFragmentShader(): boolean;
  21139. /**
  21140. * Creates a block suitable to be used as an input for this input point.
  21141. * If null is returned, a block based on the point type will be created.
  21142. * @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
  21143. */
  21144. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21145. /**
  21146. * Creates a new connection point
  21147. * @param name defines the connection point name
  21148. * @param ownerBlock defines the block hosting this connection point
  21149. * @param direction defines the direction of the connection point
  21150. */
  21151. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21152. /**
  21153. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21154. * @returns the class name
  21155. */
  21156. getClassName(): string;
  21157. /**
  21158. * Gets a boolean indicating if the current point can be connected to another point
  21159. * @param connectionPoint defines the other connection point
  21160. * @returns a boolean
  21161. */
  21162. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21163. /**
  21164. * Gets a number indicating if the current point can be connected to another point
  21165. * @param connectionPoint defines the other connection point
  21166. * @returns a number defining the compatibility state
  21167. */
  21168. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21169. /**
  21170. * Connect this point to another connection point
  21171. * @param connectionPoint defines the other connection point
  21172. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21173. * @returns the current connection point
  21174. */
  21175. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21176. /**
  21177. * Disconnect this point from one of his endpoint
  21178. * @param endpoint defines the other connection point
  21179. * @returns the current connection point
  21180. */
  21181. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21182. /**
  21183. * Serializes this point in a JSON representation
  21184. * @param isInput defines if the connection point is an input (default is true)
  21185. * @returns the serialized point object
  21186. */
  21187. serialize(isInput?: boolean): any;
  21188. /**
  21189. * Release resources
  21190. */
  21191. dispose(): void;
  21192. }
  21193. }
  21194. declare module BABYLON {
  21195. /**
  21196. * Enum used to define the material modes
  21197. */
  21198. export enum NodeMaterialModes {
  21199. /** Regular material */
  21200. Material = 0,
  21201. /** For post process */
  21202. PostProcess = 1,
  21203. /** For particle system */
  21204. Particle = 2,
  21205. /** For procedural texture */
  21206. ProceduralTexture = 3
  21207. }
  21208. }
  21209. declare module BABYLON {
  21210. /**
  21211. * Block used to read a texture from a sampler
  21212. */
  21213. export class TextureBlock extends NodeMaterialBlock {
  21214. private _defineName;
  21215. private _linearDefineName;
  21216. private _gammaDefineName;
  21217. private _tempTextureRead;
  21218. private _samplerName;
  21219. private _transformedUVName;
  21220. private _textureTransformName;
  21221. private _textureInfoName;
  21222. private _mainUVName;
  21223. private _mainUVDefineName;
  21224. private _fragmentOnly;
  21225. /**
  21226. * Gets or sets the texture associated with the node
  21227. */
  21228. texture: Nullable<Texture>;
  21229. /**
  21230. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21231. */
  21232. convertToGammaSpace: boolean;
  21233. /**
  21234. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21235. */
  21236. convertToLinearSpace: boolean;
  21237. /**
  21238. * Create a new TextureBlock
  21239. * @param name defines the block name
  21240. */
  21241. constructor(name: string, fragmentOnly?: boolean);
  21242. /**
  21243. * Gets the current class name
  21244. * @returns the class name
  21245. */
  21246. getClassName(): string;
  21247. /**
  21248. * Gets the uv input component
  21249. */
  21250. get uv(): NodeMaterialConnectionPoint;
  21251. /**
  21252. * Gets the rgba output component
  21253. */
  21254. get rgba(): NodeMaterialConnectionPoint;
  21255. /**
  21256. * Gets the rgb output component
  21257. */
  21258. get rgb(): NodeMaterialConnectionPoint;
  21259. /**
  21260. * Gets the r output component
  21261. */
  21262. get r(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the g output component
  21265. */
  21266. get g(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the b output component
  21269. */
  21270. get b(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the a output component
  21273. */
  21274. get a(): NodeMaterialConnectionPoint;
  21275. get target(): NodeMaterialBlockTargets;
  21276. autoConfigure(material: NodeMaterial): void;
  21277. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21279. isReady(): boolean;
  21280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21281. private get _isMixed();
  21282. private _injectVertexCode;
  21283. private _writeTextureRead;
  21284. private _writeOutput;
  21285. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21286. protected _dumpPropertiesCode(): string;
  21287. serialize(): any;
  21288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21289. }
  21290. }
  21291. declare module BABYLON {
  21292. /** @hidden */
  21293. export var reflectionFunction: {
  21294. name: string;
  21295. shader: string;
  21296. };
  21297. }
  21298. declare module BABYLON {
  21299. /**
  21300. * Base block used to read a reflection texture from a sampler
  21301. */
  21302. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21303. /** @hidden */
  21304. _define3DName: string;
  21305. /** @hidden */
  21306. _defineCubicName: string;
  21307. /** @hidden */
  21308. _defineExplicitName: string;
  21309. /** @hidden */
  21310. _defineProjectionName: string;
  21311. /** @hidden */
  21312. _defineLocalCubicName: string;
  21313. /** @hidden */
  21314. _defineSphericalName: string;
  21315. /** @hidden */
  21316. _definePlanarName: string;
  21317. /** @hidden */
  21318. _defineEquirectangularName: string;
  21319. /** @hidden */
  21320. _defineMirroredEquirectangularFixedName: string;
  21321. /** @hidden */
  21322. _defineEquirectangularFixedName: string;
  21323. /** @hidden */
  21324. _defineSkyboxName: string;
  21325. /** @hidden */
  21326. _defineOppositeZ: string;
  21327. /** @hidden */
  21328. _cubeSamplerName: string;
  21329. /** @hidden */
  21330. _2DSamplerName: string;
  21331. protected _positionUVWName: string;
  21332. protected _directionWName: string;
  21333. protected _reflectionVectorName: string;
  21334. /** @hidden */
  21335. _reflectionCoordsName: string;
  21336. /** @hidden */
  21337. _reflectionMatrixName: string;
  21338. protected _reflectionColorName: string;
  21339. /**
  21340. * Gets or sets the texture associated with the node
  21341. */
  21342. texture: Nullable<BaseTexture>;
  21343. /**
  21344. * Create a new ReflectionTextureBaseBlock
  21345. * @param name defines the block name
  21346. */
  21347. constructor(name: string);
  21348. /**
  21349. * Gets the current class name
  21350. * @returns the class name
  21351. */
  21352. getClassName(): string;
  21353. /**
  21354. * Gets the world position input component
  21355. */
  21356. abstract get position(): NodeMaterialConnectionPoint;
  21357. /**
  21358. * Gets the world position input component
  21359. */
  21360. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21361. /**
  21362. * Gets the world normal input component
  21363. */
  21364. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21365. /**
  21366. * Gets the world input component
  21367. */
  21368. abstract get world(): NodeMaterialConnectionPoint;
  21369. /**
  21370. * Gets the camera (or eye) position component
  21371. */
  21372. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21373. /**
  21374. * Gets the view input component
  21375. */
  21376. abstract get view(): NodeMaterialConnectionPoint;
  21377. protected _getTexture(): Nullable<BaseTexture>;
  21378. autoConfigure(material: NodeMaterial): void;
  21379. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21380. isReady(): boolean;
  21381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21382. /**
  21383. * Gets the code to inject in the vertex shader
  21384. * @param state current state of the node material building
  21385. * @returns the shader code
  21386. */
  21387. handleVertexSide(state: NodeMaterialBuildState): string;
  21388. /**
  21389. * Handles the inits for the fragment code path
  21390. * @param state node material build state
  21391. */
  21392. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21393. /**
  21394. * Generates the reflection coords code for the fragment code path
  21395. * @param worldNormalVarName name of the world normal variable
  21396. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21397. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21398. * @returns the shader code
  21399. */
  21400. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21401. /**
  21402. * Generates the reflection color code for the fragment code path
  21403. * @param lodVarName name of the lod variable
  21404. * @param swizzleLookupTexture swizzle to use for the final color variable
  21405. * @returns the shader code
  21406. */
  21407. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21408. /**
  21409. * Generates the code corresponding to the connected output points
  21410. * @param state node material build state
  21411. * @param varName name of the variable to output
  21412. * @returns the shader code
  21413. */
  21414. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21415. protected _buildBlock(state: NodeMaterialBuildState): this;
  21416. protected _dumpPropertiesCode(): string;
  21417. serialize(): any;
  21418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21419. }
  21420. }
  21421. declare module BABYLON {
  21422. /**
  21423. * Defines a connection point to be used for points with a custom object type
  21424. */
  21425. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21426. private _blockType;
  21427. private _blockName;
  21428. private _nameForCheking?;
  21429. /**
  21430. * Creates a new connection point
  21431. * @param name defines the connection point name
  21432. * @param ownerBlock defines the block hosting this connection point
  21433. * @param direction defines the direction of the connection point
  21434. */
  21435. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21436. /**
  21437. * Gets a number indicating if the current point can be connected to another point
  21438. * @param connectionPoint defines the other connection point
  21439. * @returns a number defining the compatibility state
  21440. */
  21441. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21442. /**
  21443. * Creates a block suitable to be used as an input for this input point.
  21444. * If null is returned, a block based on the point type will be created.
  21445. * @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
  21446. */
  21447. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21448. }
  21449. }
  21450. declare module BABYLON {
  21451. /**
  21452. * Enum defining the type of properties that can be edited in the property pages in the NME
  21453. */
  21454. export enum PropertyTypeForEdition {
  21455. /** property is a boolean */
  21456. Boolean = 0,
  21457. /** property is a float */
  21458. Float = 1,
  21459. /** property is a Vector2 */
  21460. Vector2 = 2,
  21461. /** property is a list of values */
  21462. List = 3
  21463. }
  21464. /**
  21465. * Interface that defines an option in a variable of type list
  21466. */
  21467. export interface IEditablePropertyListOption {
  21468. /** label of the option */
  21469. "label": string;
  21470. /** value of the option */
  21471. "value": number;
  21472. }
  21473. /**
  21474. * Interface that defines the options available for an editable property
  21475. */
  21476. export interface IEditablePropertyOption {
  21477. /** min value */
  21478. "min"?: number;
  21479. /** max value */
  21480. "max"?: number;
  21481. /** notifiers: indicates which actions to take when the property is changed */
  21482. "notifiers"?: {
  21483. /** the material should be rebuilt */
  21484. "rebuild"?: boolean;
  21485. /** the preview should be updated */
  21486. "update"?: boolean;
  21487. };
  21488. /** list of the options for a variable of type list */
  21489. "options"?: IEditablePropertyListOption[];
  21490. }
  21491. /**
  21492. * Interface that describes an editable property
  21493. */
  21494. export interface IPropertyDescriptionForEdition {
  21495. /** name of the property */
  21496. "propertyName": string;
  21497. /** display name of the property */
  21498. "displayName": string;
  21499. /** type of the property */
  21500. "type": PropertyTypeForEdition;
  21501. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21502. "groupName": string;
  21503. /** options for the property */
  21504. "options": IEditablePropertyOption;
  21505. }
  21506. /**
  21507. * Decorator that flags a property in a node material block as being editable
  21508. */
  21509. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21510. }
  21511. declare module BABYLON {
  21512. /**
  21513. * Block used to implement the refraction part of the sub surface module of the PBR material
  21514. */
  21515. export class RefractionBlock extends NodeMaterialBlock {
  21516. /** @hidden */
  21517. _define3DName: string;
  21518. /** @hidden */
  21519. _refractionMatrixName: string;
  21520. /** @hidden */
  21521. _defineLODRefractionAlpha: string;
  21522. /** @hidden */
  21523. _defineLinearSpecularRefraction: string;
  21524. /** @hidden */
  21525. _defineOppositeZ: string;
  21526. /** @hidden */
  21527. _cubeSamplerName: string;
  21528. /** @hidden */
  21529. _2DSamplerName: string;
  21530. /** @hidden */
  21531. _vRefractionMicrosurfaceInfosName: string;
  21532. /** @hidden */
  21533. _vRefractionInfosName: string;
  21534. private _scene;
  21535. /**
  21536. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21537. * Materials half opaque for instance using refraction could benefit from this control.
  21538. */
  21539. linkRefractionWithTransparency: boolean;
  21540. /**
  21541. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21542. */
  21543. invertRefractionY: boolean;
  21544. /**
  21545. * Gets or sets the texture associated with the node
  21546. */
  21547. texture: Nullable<BaseTexture>;
  21548. /**
  21549. * Create a new RefractionBlock
  21550. * @param name defines the block name
  21551. */
  21552. constructor(name: string);
  21553. /**
  21554. * Gets the current class name
  21555. * @returns the class name
  21556. */
  21557. getClassName(): string;
  21558. /**
  21559. * Gets the intensity input component
  21560. */
  21561. get intensity(): NodeMaterialConnectionPoint;
  21562. /**
  21563. * Gets the index of refraction input component
  21564. */
  21565. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21566. /**
  21567. * Gets the tint at distance input component
  21568. */
  21569. get tintAtDistance(): NodeMaterialConnectionPoint;
  21570. /**
  21571. * Gets the view input component
  21572. */
  21573. get view(): NodeMaterialConnectionPoint;
  21574. /**
  21575. * Gets the refraction object output component
  21576. */
  21577. get refraction(): NodeMaterialConnectionPoint;
  21578. /**
  21579. * Returns true if the block has a texture
  21580. */
  21581. get hasTexture(): boolean;
  21582. protected _getTexture(): Nullable<BaseTexture>;
  21583. autoConfigure(material: NodeMaterial): void;
  21584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21585. isReady(): boolean;
  21586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21587. /**
  21588. * Gets the main code of the block (fragment side)
  21589. * @param state current state of the node material building
  21590. * @returns the shader code
  21591. */
  21592. getCode(state: NodeMaterialBuildState): string;
  21593. protected _buildBlock(state: NodeMaterialBuildState): this;
  21594. protected _dumpPropertiesCode(): string;
  21595. serialize(): any;
  21596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21597. }
  21598. }
  21599. declare module BABYLON {
  21600. /**
  21601. * Base block used as input for post process
  21602. */
  21603. export class CurrentScreenBlock extends NodeMaterialBlock {
  21604. private _samplerName;
  21605. private _linearDefineName;
  21606. private _gammaDefineName;
  21607. private _mainUVName;
  21608. private _tempTextureRead;
  21609. /**
  21610. * Gets or sets the texture associated with the node
  21611. */
  21612. texture: Nullable<BaseTexture>;
  21613. /**
  21614. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21615. */
  21616. convertToGammaSpace: boolean;
  21617. /**
  21618. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21619. */
  21620. convertToLinearSpace: boolean;
  21621. /**
  21622. * Create a new CurrentScreenBlock
  21623. * @param name defines the block name
  21624. */
  21625. constructor(name: string);
  21626. /**
  21627. * Gets the current class name
  21628. * @returns the class name
  21629. */
  21630. getClassName(): string;
  21631. /**
  21632. * Gets the uv input component
  21633. */
  21634. get uv(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Gets the rgba output component
  21637. */
  21638. get rgba(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Gets the rgb output component
  21641. */
  21642. get rgb(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the r output component
  21645. */
  21646. get r(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the g output component
  21649. */
  21650. get g(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the b output component
  21653. */
  21654. get b(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the a output component
  21657. */
  21658. get a(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Initialize the block and prepare the context for build
  21661. * @param state defines the state that will be used for the build
  21662. */
  21663. initialize(state: NodeMaterialBuildState): void;
  21664. get target(): NodeMaterialBlockTargets;
  21665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21666. isReady(): boolean;
  21667. private _injectVertexCode;
  21668. private _writeTextureRead;
  21669. private _writeOutput;
  21670. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21671. serialize(): any;
  21672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21673. }
  21674. }
  21675. declare module BABYLON {
  21676. /**
  21677. * Base block used for the particle texture
  21678. */
  21679. export class ParticleTextureBlock extends NodeMaterialBlock {
  21680. private _samplerName;
  21681. private _linearDefineName;
  21682. private _gammaDefineName;
  21683. private _tempTextureRead;
  21684. /**
  21685. * Gets or sets the texture associated with the node
  21686. */
  21687. texture: Nullable<BaseTexture>;
  21688. /**
  21689. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21690. */
  21691. convertToGammaSpace: boolean;
  21692. /**
  21693. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21694. */
  21695. convertToLinearSpace: boolean;
  21696. /**
  21697. * Create a new ParticleTextureBlock
  21698. * @param name defines the block name
  21699. */
  21700. constructor(name: string);
  21701. /**
  21702. * Gets the current class name
  21703. * @returns the class name
  21704. */
  21705. getClassName(): string;
  21706. /**
  21707. * Gets the uv input component
  21708. */
  21709. get uv(): NodeMaterialConnectionPoint;
  21710. /**
  21711. * Gets the rgba output component
  21712. */
  21713. get rgba(): NodeMaterialConnectionPoint;
  21714. /**
  21715. * Gets the rgb output component
  21716. */
  21717. get rgb(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the r output component
  21720. */
  21721. get r(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the g output component
  21724. */
  21725. get g(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the b output component
  21728. */
  21729. get b(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the a output component
  21732. */
  21733. get a(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Initialize the block and prepare the context for build
  21736. * @param state defines the state that will be used for the build
  21737. */
  21738. initialize(state: NodeMaterialBuildState): void;
  21739. autoConfigure(material: NodeMaterial): void;
  21740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21741. isReady(): boolean;
  21742. private _writeOutput;
  21743. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21744. serialize(): any;
  21745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21746. }
  21747. }
  21748. declare module BABYLON {
  21749. /**
  21750. * Class used to store shared data between 2 NodeMaterialBuildState
  21751. */
  21752. export class NodeMaterialBuildStateSharedData {
  21753. /**
  21754. * Gets the list of emitted varyings
  21755. */
  21756. temps: string[];
  21757. /**
  21758. * Gets the list of emitted varyings
  21759. */
  21760. varyings: string[];
  21761. /**
  21762. * Gets the varying declaration string
  21763. */
  21764. varyingDeclaration: string;
  21765. /**
  21766. * Input blocks
  21767. */
  21768. inputBlocks: InputBlock[];
  21769. /**
  21770. * Input blocks
  21771. */
  21772. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21773. /**
  21774. * Bindable blocks (Blocks that need to set data to the effect)
  21775. */
  21776. bindableBlocks: NodeMaterialBlock[];
  21777. /**
  21778. * List of blocks that can provide a compilation fallback
  21779. */
  21780. blocksWithFallbacks: NodeMaterialBlock[];
  21781. /**
  21782. * List of blocks that can provide a define update
  21783. */
  21784. blocksWithDefines: NodeMaterialBlock[];
  21785. /**
  21786. * List of blocks that can provide a repeatable content
  21787. */
  21788. repeatableContentBlocks: NodeMaterialBlock[];
  21789. /**
  21790. * List of blocks that can provide a dynamic list of uniforms
  21791. */
  21792. dynamicUniformBlocks: NodeMaterialBlock[];
  21793. /**
  21794. * List of blocks that can block the isReady function for the material
  21795. */
  21796. blockingBlocks: NodeMaterialBlock[];
  21797. /**
  21798. * Gets the list of animated inputs
  21799. */
  21800. animatedInputs: InputBlock[];
  21801. /**
  21802. * Build Id used to avoid multiple recompilations
  21803. */
  21804. buildId: number;
  21805. /** List of emitted variables */
  21806. variableNames: {
  21807. [key: string]: number;
  21808. };
  21809. /** List of emitted defines */
  21810. defineNames: {
  21811. [key: string]: number;
  21812. };
  21813. /** Should emit comments? */
  21814. emitComments: boolean;
  21815. /** Emit build activity */
  21816. verbose: boolean;
  21817. /** Gets or sets the hosting scene */
  21818. scene: Scene;
  21819. /**
  21820. * Gets the compilation hints emitted at compilation time
  21821. */
  21822. hints: {
  21823. needWorldViewMatrix: boolean;
  21824. needWorldViewProjectionMatrix: boolean;
  21825. needAlphaBlending: boolean;
  21826. needAlphaTesting: boolean;
  21827. };
  21828. /**
  21829. * List of compilation checks
  21830. */
  21831. checks: {
  21832. emitVertex: boolean;
  21833. emitFragment: boolean;
  21834. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21835. };
  21836. /**
  21837. * Is vertex program allowed to be empty?
  21838. */
  21839. allowEmptyVertexProgram: boolean;
  21840. /** Creates a new shared data */
  21841. constructor();
  21842. /**
  21843. * Emits console errors and exceptions if there is a failing check
  21844. */
  21845. emitErrors(): void;
  21846. }
  21847. }
  21848. declare module BABYLON {
  21849. /**
  21850. * Class used to store node based material build state
  21851. */
  21852. export class NodeMaterialBuildState {
  21853. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21854. supportUniformBuffers: boolean;
  21855. /**
  21856. * Gets the list of emitted attributes
  21857. */
  21858. attributes: string[];
  21859. /**
  21860. * Gets the list of emitted uniforms
  21861. */
  21862. uniforms: string[];
  21863. /**
  21864. * Gets the list of emitted constants
  21865. */
  21866. constants: string[];
  21867. /**
  21868. * Gets the list of emitted samplers
  21869. */
  21870. samplers: string[];
  21871. /**
  21872. * Gets the list of emitted functions
  21873. */
  21874. functions: {
  21875. [key: string]: string;
  21876. };
  21877. /**
  21878. * Gets the list of emitted extensions
  21879. */
  21880. extensions: {
  21881. [key: string]: string;
  21882. };
  21883. /**
  21884. * Gets the target of the compilation state
  21885. */
  21886. target: NodeMaterialBlockTargets;
  21887. /**
  21888. * Gets the list of emitted counters
  21889. */
  21890. counters: {
  21891. [key: string]: number;
  21892. };
  21893. /**
  21894. * Shared data between multiple NodeMaterialBuildState instances
  21895. */
  21896. sharedData: NodeMaterialBuildStateSharedData;
  21897. /** @hidden */
  21898. _vertexState: NodeMaterialBuildState;
  21899. /** @hidden */
  21900. _attributeDeclaration: string;
  21901. /** @hidden */
  21902. _uniformDeclaration: string;
  21903. /** @hidden */
  21904. _constantDeclaration: string;
  21905. /** @hidden */
  21906. _samplerDeclaration: string;
  21907. /** @hidden */
  21908. _varyingTransfer: string;
  21909. /** @hidden */
  21910. _injectAtEnd: string;
  21911. private _repeatableContentAnchorIndex;
  21912. /** @hidden */
  21913. _builtCompilationString: string;
  21914. /**
  21915. * Gets the emitted compilation strings
  21916. */
  21917. compilationString: string;
  21918. /**
  21919. * Finalize the compilation strings
  21920. * @param state defines the current compilation state
  21921. */
  21922. finalize(state: NodeMaterialBuildState): void;
  21923. /** @hidden */
  21924. get _repeatableContentAnchor(): string;
  21925. /** @hidden */
  21926. _getFreeVariableName(prefix: string): string;
  21927. /** @hidden */
  21928. _getFreeDefineName(prefix: string): string;
  21929. /** @hidden */
  21930. _excludeVariableName(name: string): void;
  21931. /** @hidden */
  21932. _emit2DSampler(name: string): void;
  21933. /** @hidden */
  21934. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21935. /** @hidden */
  21936. _emitExtension(name: string, extension: string, define?: string): void;
  21937. /** @hidden */
  21938. _emitFunction(name: string, code: string, comments: string): void;
  21939. /** @hidden */
  21940. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21941. replaceStrings?: {
  21942. search: RegExp;
  21943. replace: string;
  21944. }[];
  21945. repeatKey?: string;
  21946. }): string;
  21947. /** @hidden */
  21948. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21949. repeatKey?: string;
  21950. removeAttributes?: boolean;
  21951. removeUniforms?: boolean;
  21952. removeVaryings?: boolean;
  21953. removeIfDef?: boolean;
  21954. replaceStrings?: {
  21955. search: RegExp;
  21956. replace: string;
  21957. }[];
  21958. }, storeKey?: string): void;
  21959. /** @hidden */
  21960. _registerTempVariable(name: string): boolean;
  21961. /** @hidden */
  21962. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21963. /** @hidden */
  21964. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21965. /** @hidden */
  21966. _emitFloat(value: number): string;
  21967. }
  21968. }
  21969. declare module BABYLON {
  21970. /**
  21971. * Helper class used to generate session unique ID
  21972. */
  21973. export class UniqueIdGenerator {
  21974. private static _UniqueIdCounter;
  21975. /**
  21976. * Gets an unique (relatively to the current scene) Id
  21977. */
  21978. static get UniqueId(): number;
  21979. }
  21980. }
  21981. declare module BABYLON {
  21982. /**
  21983. * Defines a block that can be used inside a node based material
  21984. */
  21985. export class NodeMaterialBlock {
  21986. private _buildId;
  21987. private _buildTarget;
  21988. private _target;
  21989. private _isFinalMerger;
  21990. private _isInput;
  21991. private _name;
  21992. protected _isUnique: boolean;
  21993. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21994. inputsAreExclusive: boolean;
  21995. /** @hidden */
  21996. _codeVariableName: string;
  21997. /** @hidden */
  21998. _inputs: NodeMaterialConnectionPoint[];
  21999. /** @hidden */
  22000. _outputs: NodeMaterialConnectionPoint[];
  22001. /** @hidden */
  22002. _preparationId: number;
  22003. /**
  22004. * Gets the name of the block
  22005. */
  22006. get name(): string;
  22007. /**
  22008. * Sets the name of the block. Will check if the name is valid.
  22009. */
  22010. set name(newName: string);
  22011. /**
  22012. * Gets or sets the unique id of the node
  22013. */
  22014. uniqueId: number;
  22015. /**
  22016. * Gets or sets the comments associated with this block
  22017. */
  22018. comments: string;
  22019. /**
  22020. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22021. */
  22022. get isUnique(): boolean;
  22023. /**
  22024. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22025. */
  22026. get isFinalMerger(): boolean;
  22027. /**
  22028. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22029. */
  22030. get isInput(): boolean;
  22031. /**
  22032. * Gets or sets the build Id
  22033. */
  22034. get buildId(): number;
  22035. set buildId(value: number);
  22036. /**
  22037. * Gets or sets the target of the block
  22038. */
  22039. get target(): NodeMaterialBlockTargets;
  22040. set target(value: NodeMaterialBlockTargets);
  22041. /**
  22042. * Gets the list of input points
  22043. */
  22044. get inputs(): NodeMaterialConnectionPoint[];
  22045. /** Gets the list of output points */
  22046. get outputs(): NodeMaterialConnectionPoint[];
  22047. /**
  22048. * Find an input by its name
  22049. * @param name defines the name of the input to look for
  22050. * @returns the input or null if not found
  22051. */
  22052. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22053. /**
  22054. * Find an output by its name
  22055. * @param name defines the name of the outputto look for
  22056. * @returns the output or null if not found
  22057. */
  22058. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22059. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22060. visibleInInspector: boolean;
  22061. /**
  22062. * Creates a new NodeMaterialBlock
  22063. * @param name defines the block name
  22064. * @param target defines the target of that block (Vertex by default)
  22065. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22066. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22067. */
  22068. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22069. /**
  22070. * Initialize the block and prepare the context for build
  22071. * @param state defines the state that will be used for the build
  22072. */
  22073. initialize(state: NodeMaterialBuildState): void;
  22074. /**
  22075. * Bind data to effect. Will only be called for blocks with isBindable === true
  22076. * @param effect defines the effect to bind data to
  22077. * @param nodeMaterial defines the hosting NodeMaterial
  22078. * @param mesh defines the mesh that will be rendered
  22079. * @param subMesh defines the submesh that will be rendered
  22080. */
  22081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22082. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22083. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22084. protected _writeFloat(value: number): string;
  22085. /**
  22086. * Gets the current class name e.g. "NodeMaterialBlock"
  22087. * @returns the class name
  22088. */
  22089. getClassName(): string;
  22090. /**
  22091. * Register a new input. Must be called inside a block constructor
  22092. * @param name defines the connection point name
  22093. * @param type defines the connection point type
  22094. * @param isOptional defines a boolean indicating that this input can be omitted
  22095. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22096. * @param point an already created connection point. If not provided, create a new one
  22097. * @returns the current block
  22098. */
  22099. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22100. /**
  22101. * Register a new output. Must be called inside a block constructor
  22102. * @param name defines the connection point name
  22103. * @param type defines the connection point type
  22104. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22105. * @param point an already created connection point. If not provided, create a new one
  22106. * @returns the current block
  22107. */
  22108. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22109. /**
  22110. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22111. * @param forOutput defines an optional connection point to check compatibility with
  22112. * @returns the first available input or null
  22113. */
  22114. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22115. /**
  22116. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22117. * @param forBlock defines an optional block to check compatibility with
  22118. * @returns the first available input or null
  22119. */
  22120. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22121. /**
  22122. * Gets the sibling of the given output
  22123. * @param current defines the current output
  22124. * @returns the next output in the list or null
  22125. */
  22126. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22127. /**
  22128. * Connect current block with another block
  22129. * @param other defines the block to connect with
  22130. * @param options define the various options to help pick the right connections
  22131. * @returns the current block
  22132. */
  22133. connectTo(other: NodeMaterialBlock, options?: {
  22134. input?: string;
  22135. output?: string;
  22136. outputSwizzle?: string;
  22137. }): this | undefined;
  22138. protected _buildBlock(state: NodeMaterialBuildState): void;
  22139. /**
  22140. * Add uniforms, samplers and uniform buffers at compilation time
  22141. * @param state defines the state to update
  22142. * @param nodeMaterial defines the node material requesting the update
  22143. * @param defines defines the material defines to update
  22144. * @param uniformBuffers defines the list of uniform buffer names
  22145. */
  22146. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22147. /**
  22148. * Add potential fallbacks if shader compilation fails
  22149. * @param mesh defines the mesh to be rendered
  22150. * @param fallbacks defines the current prioritized list of fallbacks
  22151. */
  22152. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22153. /**
  22154. * Initialize defines for shader compilation
  22155. * @param mesh defines the mesh to be rendered
  22156. * @param nodeMaterial defines the node material requesting the update
  22157. * @param defines defines the material defines to update
  22158. * @param useInstances specifies that instances should be used
  22159. */
  22160. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22161. /**
  22162. * Update defines for shader compilation
  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. * @param subMesh defines which submesh to render
  22168. */
  22169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22170. /**
  22171. * Lets the block try to connect some inputs automatically
  22172. * @param material defines the hosting NodeMaterial
  22173. */
  22174. autoConfigure(material: NodeMaterial): void;
  22175. /**
  22176. * Function called when a block is declared as repeatable content generator
  22177. * @param vertexShaderState defines the current compilation state for the vertex shader
  22178. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22179. * @param mesh defines the mesh to be rendered
  22180. * @param defines defines the material defines to update
  22181. */
  22182. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22183. /**
  22184. * Checks if the block is ready
  22185. * @param mesh defines the mesh to be rendered
  22186. * @param nodeMaterial defines the node material requesting the update
  22187. * @param defines defines the material defines to update
  22188. * @param useInstances specifies that instances should be used
  22189. * @returns true if the block is ready
  22190. */
  22191. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22192. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  22193. private _processBuild;
  22194. /**
  22195. * Validates the new name for the block node.
  22196. * @param newName the new name to be given to the node.
  22197. * @returns false if the name is a reserve word, else true.
  22198. */
  22199. validateBlockName(newName: string): boolean;
  22200. /**
  22201. * Compile the current node and generate the shader code
  22202. * @param state defines the current compilation state (uniforms, samplers, current string)
  22203. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22204. * @returns true if already built
  22205. */
  22206. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22207. protected _inputRename(name: string): string;
  22208. protected _outputRename(name: string): string;
  22209. protected _dumpPropertiesCode(): string;
  22210. /** @hidden */
  22211. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22212. /** @hidden */
  22213. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22214. /**
  22215. * Clone the current block to a new identical block
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22218. * @returns a copy of the current block
  22219. */
  22220. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22221. /**
  22222. * Serializes this block in a JSON representation
  22223. * @returns the serialized block object
  22224. */
  22225. serialize(): any;
  22226. /** @hidden */
  22227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22228. private _deserializePortDisplayNamesAndExposedOnFrame;
  22229. /**
  22230. * Release resources
  22231. */
  22232. dispose(): void;
  22233. }
  22234. }
  22235. declare module BABYLON {
  22236. /**
  22237. * Base class of materials working in push mode in babylon JS
  22238. * @hidden
  22239. */
  22240. export class PushMaterial extends Material {
  22241. protected _activeEffect: Effect;
  22242. protected _normalMatrix: Matrix;
  22243. constructor(name: string, scene: Scene);
  22244. getEffect(): Effect;
  22245. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22246. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22247. /**
  22248. * Binds the given world matrix to the active effect
  22249. *
  22250. * @param world the matrix to bind
  22251. */
  22252. bindOnlyWorldMatrix(world: Matrix): void;
  22253. /**
  22254. * Binds the given normal matrix to the active effect
  22255. *
  22256. * @param normalMatrix the matrix to bind
  22257. */
  22258. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22259. bind(world: Matrix, mesh?: Mesh): void;
  22260. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22261. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22262. }
  22263. }
  22264. declare module BABYLON {
  22265. /**
  22266. * Root class for all node material optimizers
  22267. */
  22268. export class NodeMaterialOptimizer {
  22269. /**
  22270. * Function used to optimize a NodeMaterial graph
  22271. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22272. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22273. */
  22274. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22275. }
  22276. }
  22277. declare module BABYLON {
  22278. /**
  22279. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22280. */
  22281. export class TransformBlock extends NodeMaterialBlock {
  22282. /**
  22283. * Defines the value to use to complement W value to transform it to a Vector4
  22284. */
  22285. complementW: number;
  22286. /**
  22287. * Defines the value to use to complement z value to transform it to a Vector4
  22288. */
  22289. complementZ: number;
  22290. /**
  22291. * Creates a new TransformBlock
  22292. * @param name defines the block name
  22293. */
  22294. constructor(name: string);
  22295. /**
  22296. * Gets the current class name
  22297. * @returns the class name
  22298. */
  22299. getClassName(): string;
  22300. /**
  22301. * Gets the vector input
  22302. */
  22303. get vector(): NodeMaterialConnectionPoint;
  22304. /**
  22305. * Gets the output component
  22306. */
  22307. get output(): NodeMaterialConnectionPoint;
  22308. /**
  22309. * Gets the xyz output component
  22310. */
  22311. get xyz(): NodeMaterialConnectionPoint;
  22312. /**
  22313. * Gets the matrix transform input
  22314. */
  22315. get transform(): NodeMaterialConnectionPoint;
  22316. protected _buildBlock(state: NodeMaterialBuildState): this;
  22317. /**
  22318. * Update defines for shader compilation
  22319. * @param mesh defines the mesh to be rendered
  22320. * @param nodeMaterial defines the node material requesting the update
  22321. * @param defines defines the material defines to update
  22322. * @param useInstances specifies that instances should be used
  22323. * @param subMesh defines which submesh to render
  22324. */
  22325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22326. serialize(): any;
  22327. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22328. protected _dumpPropertiesCode(): string;
  22329. }
  22330. }
  22331. declare module BABYLON {
  22332. /**
  22333. * Block used to output the vertex position
  22334. */
  22335. export class VertexOutputBlock extends NodeMaterialBlock {
  22336. /**
  22337. * Creates a new VertexOutputBlock
  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 vector input component
  22348. */
  22349. get vector(): NodeMaterialConnectionPoint;
  22350. protected _buildBlock(state: NodeMaterialBuildState): this;
  22351. }
  22352. }
  22353. declare module BABYLON {
  22354. /**
  22355. * Block used to output the final color
  22356. */
  22357. export class FragmentOutputBlock extends NodeMaterialBlock {
  22358. /**
  22359. * Create a new FragmentOutputBlock
  22360. * @param name defines the block name
  22361. */
  22362. constructor(name: string);
  22363. /**
  22364. * Gets the current class name
  22365. * @returns the class name
  22366. */
  22367. getClassName(): string;
  22368. /**
  22369. * Gets the rgba input component
  22370. */
  22371. get rgba(): NodeMaterialConnectionPoint;
  22372. /**
  22373. * Gets the rgb input component
  22374. */
  22375. get rgb(): NodeMaterialConnectionPoint;
  22376. /**
  22377. * Gets the a input component
  22378. */
  22379. get a(): NodeMaterialConnectionPoint;
  22380. protected _buildBlock(state: NodeMaterialBuildState): this;
  22381. }
  22382. }
  22383. declare module BABYLON {
  22384. /**
  22385. * Block used for the particle ramp gradient section
  22386. */
  22387. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22388. /**
  22389. * Create a new ParticleRampGradientBlock
  22390. * @param name defines the block name
  22391. */
  22392. constructor(name: string);
  22393. /**
  22394. * Gets the current class name
  22395. * @returns the class name
  22396. */
  22397. getClassName(): string;
  22398. /**
  22399. * Gets the color input component
  22400. */
  22401. get color(): NodeMaterialConnectionPoint;
  22402. /**
  22403. * Gets the rampColor output component
  22404. */
  22405. get rampColor(): NodeMaterialConnectionPoint;
  22406. /**
  22407. * Initialize the block and prepare the context for build
  22408. * @param state defines the state that will be used for the build
  22409. */
  22410. initialize(state: NodeMaterialBuildState): void;
  22411. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22412. }
  22413. }
  22414. declare module BABYLON {
  22415. /**
  22416. * Block used for the particle blend multiply section
  22417. */
  22418. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22419. /**
  22420. * Create a new ParticleBlendMultiplyBlock
  22421. * @param name defines the block name
  22422. */
  22423. constructor(name: string);
  22424. /**
  22425. * Gets the current class name
  22426. * @returns the class name
  22427. */
  22428. getClassName(): string;
  22429. /**
  22430. * Gets the color input component
  22431. */
  22432. get color(): NodeMaterialConnectionPoint;
  22433. /**
  22434. * Gets the alphaTexture input component
  22435. */
  22436. get alphaTexture(): NodeMaterialConnectionPoint;
  22437. /**
  22438. * Gets the alphaColor input component
  22439. */
  22440. get alphaColor(): NodeMaterialConnectionPoint;
  22441. /**
  22442. * Gets the blendColor output component
  22443. */
  22444. get blendColor(): NodeMaterialConnectionPoint;
  22445. /**
  22446. * Initialize the block and prepare the context for build
  22447. * @param state defines the state that will be used for the build
  22448. */
  22449. initialize(state: NodeMaterialBuildState): void;
  22450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22451. }
  22452. }
  22453. declare module BABYLON {
  22454. /**
  22455. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22456. */
  22457. export class VectorMergerBlock extends NodeMaterialBlock {
  22458. /**
  22459. * Create a new VectorMergerBlock
  22460. * @param name defines the block name
  22461. */
  22462. constructor(name: string);
  22463. /**
  22464. * Gets the current class name
  22465. * @returns the class name
  22466. */
  22467. getClassName(): string;
  22468. /**
  22469. * Gets the xyz component (input)
  22470. */
  22471. get xyzIn(): NodeMaterialConnectionPoint;
  22472. /**
  22473. * Gets the xy component (input)
  22474. */
  22475. get xyIn(): NodeMaterialConnectionPoint;
  22476. /**
  22477. * Gets the x component (input)
  22478. */
  22479. get x(): NodeMaterialConnectionPoint;
  22480. /**
  22481. * Gets the y component (input)
  22482. */
  22483. get y(): NodeMaterialConnectionPoint;
  22484. /**
  22485. * Gets the z component (input)
  22486. */
  22487. get z(): NodeMaterialConnectionPoint;
  22488. /**
  22489. * Gets the w component (input)
  22490. */
  22491. get w(): NodeMaterialConnectionPoint;
  22492. /**
  22493. * Gets the xyzw component (output)
  22494. */
  22495. get xyzw(): NodeMaterialConnectionPoint;
  22496. /**
  22497. * Gets the xyz component (output)
  22498. */
  22499. get xyzOut(): NodeMaterialConnectionPoint;
  22500. /**
  22501. * Gets the xy component (output)
  22502. */
  22503. get xyOut(): NodeMaterialConnectionPoint;
  22504. /**
  22505. * Gets the xy component (output)
  22506. * @deprecated Please use xyOut instead.
  22507. */
  22508. get xy(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the xyz component (output)
  22511. * @deprecated Please use xyzOut instead.
  22512. */
  22513. get xyz(): NodeMaterialConnectionPoint;
  22514. protected _buildBlock(state: NodeMaterialBuildState): this;
  22515. }
  22516. }
  22517. declare module BABYLON {
  22518. /**
  22519. * Block used to remap a float from a range to a new one
  22520. */
  22521. export class RemapBlock extends NodeMaterialBlock {
  22522. /**
  22523. * Gets or sets the source range
  22524. */
  22525. sourceRange: Vector2;
  22526. /**
  22527. * Gets or sets the target range
  22528. */
  22529. targetRange: Vector2;
  22530. /**
  22531. * Creates a new RemapBlock
  22532. * @param name defines the block name
  22533. */
  22534. constructor(name: string);
  22535. /**
  22536. * Gets the current class name
  22537. * @returns the class name
  22538. */
  22539. getClassName(): string;
  22540. /**
  22541. * Gets the input component
  22542. */
  22543. get input(): NodeMaterialConnectionPoint;
  22544. /**
  22545. * Gets the source min input component
  22546. */
  22547. get sourceMin(): NodeMaterialConnectionPoint;
  22548. /**
  22549. * Gets the source max input component
  22550. */
  22551. get sourceMax(): NodeMaterialConnectionPoint;
  22552. /**
  22553. * Gets the target min input component
  22554. */
  22555. get targetMin(): NodeMaterialConnectionPoint;
  22556. /**
  22557. * Gets the target max input component
  22558. */
  22559. get targetMax(): NodeMaterialConnectionPoint;
  22560. /**
  22561. * Gets the output component
  22562. */
  22563. get output(): NodeMaterialConnectionPoint;
  22564. protected _buildBlock(state: NodeMaterialBuildState): this;
  22565. protected _dumpPropertiesCode(): string;
  22566. serialize(): any;
  22567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22568. }
  22569. }
  22570. declare module BABYLON {
  22571. /**
  22572. * Block used to multiply 2 values
  22573. */
  22574. export class MultiplyBlock extends NodeMaterialBlock {
  22575. /**
  22576. * Creates a new MultiplyBlock
  22577. * @param name defines the block name
  22578. */
  22579. constructor(name: string);
  22580. /**
  22581. * Gets the current class name
  22582. * @returns the class name
  22583. */
  22584. getClassName(): string;
  22585. /**
  22586. * Gets the left operand input component
  22587. */
  22588. get left(): NodeMaterialConnectionPoint;
  22589. /**
  22590. * Gets the right operand input component
  22591. */
  22592. get right(): NodeMaterialConnectionPoint;
  22593. /**
  22594. * Gets the output component
  22595. */
  22596. get output(): NodeMaterialConnectionPoint;
  22597. protected _buildBlock(state: NodeMaterialBuildState): this;
  22598. }
  22599. }
  22600. declare module BABYLON {
  22601. /**
  22602. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22603. */
  22604. export class ColorSplitterBlock extends NodeMaterialBlock {
  22605. /**
  22606. * Create a new ColorSplitterBlock
  22607. * @param name defines the block name
  22608. */
  22609. constructor(name: string);
  22610. /**
  22611. * Gets the current class name
  22612. * @returns the class name
  22613. */
  22614. getClassName(): string;
  22615. /**
  22616. * Gets the rgba component (input)
  22617. */
  22618. get rgba(): NodeMaterialConnectionPoint;
  22619. /**
  22620. * Gets the rgb component (input)
  22621. */
  22622. get rgbIn(): NodeMaterialConnectionPoint;
  22623. /**
  22624. * Gets the rgb component (output)
  22625. */
  22626. get rgbOut(): NodeMaterialConnectionPoint;
  22627. /**
  22628. * Gets the r component (output)
  22629. */
  22630. get r(): NodeMaterialConnectionPoint;
  22631. /**
  22632. * Gets the g component (output)
  22633. */
  22634. get g(): NodeMaterialConnectionPoint;
  22635. /**
  22636. * Gets the b component (output)
  22637. */
  22638. get b(): NodeMaterialConnectionPoint;
  22639. /**
  22640. * Gets the a component (output)
  22641. */
  22642. get a(): NodeMaterialConnectionPoint;
  22643. protected _inputRename(name: string): string;
  22644. protected _outputRename(name: string): string;
  22645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22646. }
  22647. }
  22648. declare module BABYLON {
  22649. /**
  22650. * Operations supported by the Trigonometry block
  22651. */
  22652. export enum TrigonometryBlockOperations {
  22653. /** Cos */
  22654. Cos = 0,
  22655. /** Sin */
  22656. Sin = 1,
  22657. /** Abs */
  22658. Abs = 2,
  22659. /** Exp */
  22660. Exp = 3,
  22661. /** Exp2 */
  22662. Exp2 = 4,
  22663. /** Round */
  22664. Round = 5,
  22665. /** Floor */
  22666. Floor = 6,
  22667. /** Ceiling */
  22668. Ceiling = 7,
  22669. /** Square root */
  22670. Sqrt = 8,
  22671. /** Log */
  22672. Log = 9,
  22673. /** Tangent */
  22674. Tan = 10,
  22675. /** Arc tangent */
  22676. ArcTan = 11,
  22677. /** Arc cosinus */
  22678. ArcCos = 12,
  22679. /** Arc sinus */
  22680. ArcSin = 13,
  22681. /** Fraction */
  22682. Fract = 14,
  22683. /** Sign */
  22684. Sign = 15,
  22685. /** To radians (from degrees) */
  22686. Radians = 16,
  22687. /** To degrees (from radians) */
  22688. Degrees = 17
  22689. }
  22690. /**
  22691. * Block used to apply trigonometry operation to floats
  22692. */
  22693. export class TrigonometryBlock extends NodeMaterialBlock {
  22694. /**
  22695. * Gets or sets the operation applied by the block
  22696. */
  22697. operation: TrigonometryBlockOperations;
  22698. /**
  22699. * Creates a new TrigonometryBlock
  22700. * @param name defines the block name
  22701. */
  22702. constructor(name: string);
  22703. /**
  22704. * Gets the current class name
  22705. * @returns the class name
  22706. */
  22707. getClassName(): string;
  22708. /**
  22709. * Gets the input component
  22710. */
  22711. get input(): NodeMaterialConnectionPoint;
  22712. /**
  22713. * Gets the output component
  22714. */
  22715. get output(): NodeMaterialConnectionPoint;
  22716. protected _buildBlock(state: NodeMaterialBuildState): this;
  22717. serialize(): any;
  22718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22719. protected _dumpPropertiesCode(): string;
  22720. }
  22721. }
  22722. declare module BABYLON {
  22723. /**
  22724. * Interface used to configure the node material editor
  22725. */
  22726. export interface INodeMaterialEditorOptions {
  22727. /** Define the URl to load node editor script */
  22728. editorURL?: string;
  22729. }
  22730. /** @hidden */
  22731. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22732. NORMAL: boolean;
  22733. TANGENT: boolean;
  22734. UV1: boolean;
  22735. /** BONES */
  22736. NUM_BONE_INFLUENCERS: number;
  22737. BonesPerMesh: number;
  22738. BONETEXTURE: boolean;
  22739. /** MORPH TARGETS */
  22740. MORPHTARGETS: boolean;
  22741. MORPHTARGETS_NORMAL: boolean;
  22742. MORPHTARGETS_TANGENT: boolean;
  22743. MORPHTARGETS_UV: boolean;
  22744. NUM_MORPH_INFLUENCERS: number;
  22745. /** IMAGE PROCESSING */
  22746. IMAGEPROCESSING: boolean;
  22747. VIGNETTE: boolean;
  22748. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22749. VIGNETTEBLENDMODEOPAQUE: boolean;
  22750. TONEMAPPING: boolean;
  22751. TONEMAPPING_ACES: boolean;
  22752. CONTRAST: boolean;
  22753. EXPOSURE: boolean;
  22754. COLORCURVES: boolean;
  22755. COLORGRADING: boolean;
  22756. COLORGRADING3D: boolean;
  22757. SAMPLER3DGREENDEPTH: boolean;
  22758. SAMPLER3DBGRMAP: boolean;
  22759. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22760. /** MISC. */
  22761. BUMPDIRECTUV: number;
  22762. constructor();
  22763. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22764. }
  22765. /**
  22766. * Class used to configure NodeMaterial
  22767. */
  22768. export interface INodeMaterialOptions {
  22769. /**
  22770. * Defines if blocks should emit comments
  22771. */
  22772. emitComments: boolean;
  22773. }
  22774. /**
  22775. * Class used to create a node based material built by assembling shader blocks
  22776. */
  22777. export class NodeMaterial extends PushMaterial {
  22778. private static _BuildIdGenerator;
  22779. private _options;
  22780. private _vertexCompilationState;
  22781. private _fragmentCompilationState;
  22782. private _sharedData;
  22783. private _buildId;
  22784. private _buildWasSuccessful;
  22785. private _cachedWorldViewMatrix;
  22786. private _cachedWorldViewProjectionMatrix;
  22787. private _optimizers;
  22788. private _animationFrame;
  22789. /** Define the Url to load node editor script */
  22790. static EditorURL: string;
  22791. /** Define the Url to load snippets */
  22792. static SnippetUrl: string;
  22793. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22794. static IgnoreTexturesAtLoadTime: boolean;
  22795. private BJSNODEMATERIALEDITOR;
  22796. /** Get the inspector from bundle or global */
  22797. private _getGlobalNodeMaterialEditor;
  22798. /**
  22799. * Snippet ID if the material was created from the snippet server
  22800. */
  22801. snippetId: string;
  22802. /**
  22803. * Gets or sets data used by visual editor
  22804. * @see https://nme.babylonjs.com
  22805. */
  22806. editorData: any;
  22807. /**
  22808. * 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)
  22809. */
  22810. ignoreAlpha: boolean;
  22811. /**
  22812. * Defines the maximum number of lights that can be used in the material
  22813. */
  22814. maxSimultaneousLights: number;
  22815. /**
  22816. * Observable raised when the material is built
  22817. */
  22818. onBuildObservable: Observable<NodeMaterial>;
  22819. /**
  22820. * Gets or sets the root nodes of the material vertex shader
  22821. */
  22822. _vertexOutputNodes: NodeMaterialBlock[];
  22823. /**
  22824. * Gets or sets the root nodes of the material fragment (pixel) shader
  22825. */
  22826. _fragmentOutputNodes: NodeMaterialBlock[];
  22827. /** Gets or sets options to control the node material overall behavior */
  22828. get options(): INodeMaterialOptions;
  22829. set options(options: INodeMaterialOptions);
  22830. /**
  22831. * Default configuration related to image processing available in the standard Material.
  22832. */
  22833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22834. /**
  22835. * Gets the image processing configuration used either in this material.
  22836. */
  22837. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22838. /**
  22839. * Sets the Default image processing configuration used either in the this material.
  22840. *
  22841. * If sets to null, the scene one is in use.
  22842. */
  22843. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22844. /**
  22845. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22846. */
  22847. attachedBlocks: NodeMaterialBlock[];
  22848. /**
  22849. * Specifies the mode of the node material
  22850. * @hidden
  22851. */
  22852. _mode: NodeMaterialModes;
  22853. /**
  22854. * Gets the mode property
  22855. */
  22856. get mode(): NodeMaterialModes;
  22857. /**
  22858. * A free comment about the material
  22859. */
  22860. comment: string;
  22861. /**
  22862. * Create a new node based material
  22863. * @param name defines the material name
  22864. * @param scene defines the hosting scene
  22865. * @param options defines creation option
  22866. */
  22867. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22868. /**
  22869. * Gets the current class name of the material e.g. "NodeMaterial"
  22870. * @returns the class name
  22871. */
  22872. getClassName(): string;
  22873. /**
  22874. * Keep track of the image processing observer to allow dispose and replace.
  22875. */
  22876. private _imageProcessingObserver;
  22877. /**
  22878. * Attaches a new image processing configuration to the Standard Material.
  22879. * @param configuration
  22880. */
  22881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22882. /**
  22883. * Get a block by its name
  22884. * @param name defines the name of the block to retrieve
  22885. * @returns the required block or null if not found
  22886. */
  22887. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22888. /**
  22889. * Get a block by its name
  22890. * @param predicate defines the predicate used to find the good candidate
  22891. * @returns the required block or null if not found
  22892. */
  22893. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22894. /**
  22895. * Get an input block by its name
  22896. * @param predicate defines the predicate used to find the good candidate
  22897. * @returns the required input block or null if not found
  22898. */
  22899. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22900. /**
  22901. * Gets the list of input blocks attached to this material
  22902. * @returns an array of InputBlocks
  22903. */
  22904. getInputBlocks(): InputBlock[];
  22905. /**
  22906. * Adds a new optimizer to the list of optimizers
  22907. * @param optimizer defines the optimizers to add
  22908. * @returns the current material
  22909. */
  22910. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22911. /**
  22912. * Remove an optimizer from the list of optimizers
  22913. * @param optimizer defines the optimizers to remove
  22914. * @returns the current material
  22915. */
  22916. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22917. /**
  22918. * Add a new block to the list of output nodes
  22919. * @param node defines the node to add
  22920. * @returns the current material
  22921. */
  22922. addOutputNode(node: NodeMaterialBlock): this;
  22923. /**
  22924. * Remove a block from the list of root nodes
  22925. * @param node defines the node to remove
  22926. * @returns the current material
  22927. */
  22928. removeOutputNode(node: NodeMaterialBlock): this;
  22929. private _addVertexOutputNode;
  22930. private _removeVertexOutputNode;
  22931. private _addFragmentOutputNode;
  22932. private _removeFragmentOutputNode;
  22933. /**
  22934. * Specifies if the material will require alpha blending
  22935. * @returns a boolean specifying if alpha blending is needed
  22936. */
  22937. needAlphaBlending(): boolean;
  22938. /**
  22939. * Specifies if this material should be rendered in alpha test mode
  22940. * @returns a boolean specifying if an alpha test is needed.
  22941. */
  22942. needAlphaTesting(): boolean;
  22943. private _initializeBlock;
  22944. private _resetDualBlocks;
  22945. /**
  22946. * Remove a block from the current node material
  22947. * @param block defines the block to remove
  22948. */
  22949. removeBlock(block: NodeMaterialBlock): void;
  22950. /**
  22951. * Build the material and generates the inner effect
  22952. * @param verbose defines if the build should log activity
  22953. */
  22954. build(verbose?: boolean): void;
  22955. /**
  22956. * Runs an otpimization phase to try to improve the shader code
  22957. */
  22958. optimize(): void;
  22959. private _prepareDefinesForAttributes;
  22960. /**
  22961. * Create a post process from the material
  22962. * @param camera The camera to apply the render pass to.
  22963. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22965. * @param engine The engine which the post process will be applied. (default: current engine)
  22966. * @param reusable If the post process can be reused on the same frame. (default: false)
  22967. * @param textureType Type of textures used when performing the post process. (default: 0)
  22968. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22969. * @returns the post process created
  22970. */
  22971. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22972. /**
  22973. * Create the post process effect from the material
  22974. * @param postProcess The post process to create the effect for
  22975. */
  22976. createEffectForPostProcess(postProcess: PostProcess): void;
  22977. private _createEffectForPostProcess;
  22978. /**
  22979. * Create a new procedural texture based on this node material
  22980. * @param size defines the size of the texture
  22981. * @param scene defines the hosting scene
  22982. * @returns the new procedural texture attached to this node material
  22983. */
  22984. createProceduralTexture(size: number | {
  22985. width: number;
  22986. height: number;
  22987. layers?: number;
  22988. }, scene: Scene): Nullable<ProceduralTexture>;
  22989. private _createEffectForParticles;
  22990. private _checkInternals;
  22991. /**
  22992. * Create the effect to be used as the custom effect for a particle system
  22993. * @param particleSystem Particle system to create the effect for
  22994. * @param onCompiled defines a function to call when the effect creation is successful
  22995. * @param onError defines a function to call when the effect creation has failed
  22996. */
  22997. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22998. private _processDefines;
  22999. /**
  23000. * Get if the submesh is ready to be used and all its information available.
  23001. * Child classes can use it to update shaders
  23002. * @param mesh defines the mesh to check
  23003. * @param subMesh defines which submesh to check
  23004. * @param useInstances specifies that instances should be used
  23005. * @returns a boolean indicating that the submesh is ready or not
  23006. */
  23007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23008. /**
  23009. * Get a string representing the shaders built by the current node graph
  23010. */
  23011. get compiledShaders(): string;
  23012. /**
  23013. * Binds the world matrix to the material
  23014. * @param world defines the world transformation matrix
  23015. */
  23016. bindOnlyWorldMatrix(world: Matrix): void;
  23017. /**
  23018. * Binds the submesh to this material by preparing the effect and shader to draw
  23019. * @param world defines the world transformation matrix
  23020. * @param mesh defines the mesh containing the submesh
  23021. * @param subMesh defines the submesh to bind the material to
  23022. */
  23023. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23024. /**
  23025. * Gets the active textures from the material
  23026. * @returns an array of textures
  23027. */
  23028. getActiveTextures(): BaseTexture[];
  23029. /**
  23030. * Gets the list of texture blocks
  23031. * @returns an array of texture blocks
  23032. */
  23033. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23034. /**
  23035. * Specifies if the material uses a texture
  23036. * @param texture defines the texture to check against the material
  23037. * @returns a boolean specifying if the material uses the texture
  23038. */
  23039. hasTexture(texture: BaseTexture): boolean;
  23040. /**
  23041. * Disposes the material
  23042. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23043. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23044. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23045. */
  23046. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23047. /** Creates the node editor window. */
  23048. private _createNodeEditor;
  23049. /**
  23050. * Launch the node material editor
  23051. * @param config Define the configuration of the editor
  23052. * @return a promise fulfilled when the node editor is visible
  23053. */
  23054. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23055. /**
  23056. * Clear the current material
  23057. */
  23058. clear(): void;
  23059. /**
  23060. * Clear the current material and set it to a default state
  23061. */
  23062. setToDefault(): void;
  23063. /**
  23064. * Clear the current material and set it to a default state for post process
  23065. */
  23066. setToDefaultPostProcess(): void;
  23067. /**
  23068. * Clear the current material and set it to a default state for procedural texture
  23069. */
  23070. setToDefaultProceduralTexture(): void;
  23071. /**
  23072. * Clear the current material and set it to a default state for particle
  23073. */
  23074. setToDefaultParticle(): void;
  23075. /**
  23076. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23077. * @param url defines the url to load from
  23078. * @returns a promise that will fullfil when the material is fully loaded
  23079. */
  23080. loadAsync(url: string): Promise<void>;
  23081. private _gatherBlocks;
  23082. /**
  23083. * Generate a string containing the code declaration required to create an equivalent of this material
  23084. * @returns a string
  23085. */
  23086. generateCode(): string;
  23087. /**
  23088. * Serializes this material in a JSON representation
  23089. * @returns the serialized material object
  23090. */
  23091. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23092. private _restoreConnections;
  23093. /**
  23094. * Clear the current graph and load a new one from a serialization object
  23095. * @param source defines the JSON representation of the material
  23096. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23097. * @param merge defines whether or not the source must be merged or replace the current content
  23098. */
  23099. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23100. /**
  23101. * Makes a duplicate of the current material.
  23102. * @param name - name to use for the new material.
  23103. */
  23104. clone(name: string): NodeMaterial;
  23105. /**
  23106. * Creates a node material from parsed material data
  23107. * @param source defines the JSON representation of the material
  23108. * @param scene defines the hosting scene
  23109. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23110. * @returns a new node material
  23111. */
  23112. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23113. /**
  23114. * Creates a node material from a snippet saved in a remote file
  23115. * @param name defines the name of the material to create
  23116. * @param url defines the url to load from
  23117. * @param scene defines the hosting scene
  23118. * @returns a promise that will resolve to the new node material
  23119. */
  23120. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23121. /**
  23122. * Creates a node material from a snippet saved by the node material editor
  23123. * @param snippetId defines the snippet to load
  23124. * @param scene defines the hosting scene
  23125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23126. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23127. * @returns a promise that will resolve to the new node material
  23128. */
  23129. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23130. /**
  23131. * Creates a new node material set to default basic configuration
  23132. * @param name defines the name of the material
  23133. * @param scene defines the hosting scene
  23134. * @returns a new NodeMaterial
  23135. */
  23136. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23137. }
  23138. }
  23139. declare module BABYLON {
  23140. interface ThinEngine {
  23141. /**
  23142. * Unbind a list of render target textures from the webGL context
  23143. * This is used only when drawBuffer extension or webGL2 are active
  23144. * @param textures defines the render target textures to unbind
  23145. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23146. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23147. */
  23148. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23149. /**
  23150. * Create a multi render target texture
  23151. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23152. * @param size defines the size of the texture
  23153. * @param options defines the creation options
  23154. * @returns the cube texture as an InternalTexture
  23155. */
  23156. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23157. /**
  23158. * Update the sample count for a given multiple render target texture
  23159. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23160. * @param textures defines the textures to update
  23161. * @param samples defines the sample count to set
  23162. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23163. */
  23164. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23165. /**
  23166. * Select a subsets of attachments to draw to.
  23167. * @param attachments gl attachments
  23168. */
  23169. bindAttachments(attachments: number[]): void;
  23170. /**
  23171. * Creates a layout object to draw/clear on specific textures in a MRT
  23172. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23173. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23174. */
  23175. buildTextureLayout(textureStatus: boolean[]): number[];
  23176. /**
  23177. * Restores the webgl state to only draw on the main color attachment
  23178. */
  23179. restoreSingleAttachment(): void;
  23180. }
  23181. }
  23182. declare module BABYLON {
  23183. /**
  23184. * Creation options of the multi render target texture.
  23185. */
  23186. export interface IMultiRenderTargetOptions {
  23187. /**
  23188. * Define if the texture needs to create mip maps after render.
  23189. */
  23190. generateMipMaps?: boolean;
  23191. /**
  23192. * Define the types of all the draw buffers we want to create
  23193. */
  23194. types?: number[];
  23195. /**
  23196. * Define the sampling modes of all the draw buffers we want to create
  23197. */
  23198. samplingModes?: number[];
  23199. /**
  23200. * Define if a depth buffer is required
  23201. */
  23202. generateDepthBuffer?: boolean;
  23203. /**
  23204. * Define if a stencil buffer is required
  23205. */
  23206. generateStencilBuffer?: boolean;
  23207. /**
  23208. * Define if a depth texture is required instead of a depth buffer
  23209. */
  23210. generateDepthTexture?: boolean;
  23211. /**
  23212. * Define the number of desired draw buffers
  23213. */
  23214. textureCount?: number;
  23215. /**
  23216. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23217. */
  23218. doNotChangeAspectRatio?: boolean;
  23219. /**
  23220. * Define the default type of the buffers we are creating
  23221. */
  23222. defaultType?: number;
  23223. }
  23224. /**
  23225. * A multi render target, like a render target provides the ability to render to a texture.
  23226. * Unlike the render target, it can render to several draw buffers in one draw.
  23227. * This is specially interesting in deferred rendering or for any effects requiring more than
  23228. * just one color from a single pass.
  23229. */
  23230. export class MultiRenderTarget extends RenderTargetTexture {
  23231. private _internalTextures;
  23232. private _textures;
  23233. private _multiRenderTargetOptions;
  23234. private _count;
  23235. /**
  23236. * Get if draw buffers are currently supported by the used hardware and browser.
  23237. */
  23238. get isSupported(): boolean;
  23239. /**
  23240. * Get the list of textures generated by the multi render target.
  23241. */
  23242. get textures(): Texture[];
  23243. /**
  23244. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23245. */
  23246. get count(): number;
  23247. /**
  23248. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23249. */
  23250. get depthTexture(): Texture;
  23251. /**
  23252. * Set the wrapping mode on U of all the textures we are rendering to.
  23253. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23254. */
  23255. set wrapU(wrap: number);
  23256. /**
  23257. * Set the wrapping mode on V of all the textures we are rendering to.
  23258. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23259. */
  23260. set wrapV(wrap: number);
  23261. /**
  23262. * Instantiate a new multi render target texture.
  23263. * A multi render target, like a render target provides the ability to render to a texture.
  23264. * Unlike the render target, it can render to several draw buffers in one draw.
  23265. * This is specially interesting in deferred rendering or for any effects requiring more than
  23266. * just one color from a single pass.
  23267. * @param name Define the name of the texture
  23268. * @param size Define the size of the buffers to render to
  23269. * @param count Define the number of target we are rendering into
  23270. * @param scene Define the scene the texture belongs to
  23271. * @param options Define the options used to create the multi render target
  23272. */
  23273. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23274. private _initTypes;
  23275. /** @hidden */
  23276. _rebuild(forceFullRebuild?: boolean): void;
  23277. private _createInternalTextures;
  23278. private _createTextures;
  23279. /**
  23280. * Replaces a texture within the MRT.
  23281. * @param texture The new texture to insert in the MRT
  23282. * @param index The index of the texture to replace
  23283. */
  23284. replaceTexture(texture: Texture, index: number): void;
  23285. /**
  23286. * Define the number of samples used if MSAA is enabled.
  23287. */
  23288. get samples(): number;
  23289. set samples(value: number);
  23290. /**
  23291. * Resize all the textures in the multi render target.
  23292. * Be careful as it will recreate all the data in the new texture.
  23293. * @param size Define the new size
  23294. */
  23295. resize(size: any): void;
  23296. /**
  23297. * Changes the number of render targets in this MRT
  23298. * Be careful as it will recreate all the data in the new texture.
  23299. * @param count new texture count
  23300. * @param options Specifies texture types and sampling modes for new textures
  23301. */
  23302. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23303. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23304. /**
  23305. * Dispose the render targets and their associated resources
  23306. */
  23307. dispose(): void;
  23308. /**
  23309. * Release all the underlying texture used as draw buffers.
  23310. */
  23311. releaseInternalTextures(): void;
  23312. }
  23313. }
  23314. declare module BABYLON {
  23315. /** @hidden */
  23316. export var imageProcessingPixelShader: {
  23317. name: string;
  23318. shader: string;
  23319. };
  23320. }
  23321. declare module BABYLON {
  23322. /**
  23323. * ImageProcessingPostProcess
  23324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23325. */
  23326. export class ImageProcessingPostProcess extends PostProcess {
  23327. /**
  23328. * Default configuration related to image processing available in the PBR Material.
  23329. */
  23330. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23331. /**
  23332. * Gets the image processing configuration used either in this material.
  23333. */
  23334. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23335. /**
  23336. * Sets the Default image processing configuration used either in the this material.
  23337. *
  23338. * If sets to null, the scene one is in use.
  23339. */
  23340. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23341. /**
  23342. * Keep track of the image processing observer to allow dispose and replace.
  23343. */
  23344. private _imageProcessingObserver;
  23345. /**
  23346. * Attaches a new image processing configuration to the PBR Material.
  23347. * @param configuration
  23348. */
  23349. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23350. /**
  23351. * If the post process is supported.
  23352. */
  23353. get isSupported(): boolean;
  23354. /**
  23355. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23356. */
  23357. get colorCurves(): Nullable<ColorCurves>;
  23358. /**
  23359. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23360. */
  23361. set colorCurves(value: Nullable<ColorCurves>);
  23362. /**
  23363. * Gets wether the color curves effect is enabled.
  23364. */
  23365. get colorCurvesEnabled(): boolean;
  23366. /**
  23367. * Sets wether the color curves effect is enabled.
  23368. */
  23369. set colorCurvesEnabled(value: boolean);
  23370. /**
  23371. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23372. */
  23373. get colorGradingTexture(): Nullable<BaseTexture>;
  23374. /**
  23375. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23376. */
  23377. set colorGradingTexture(value: Nullable<BaseTexture>);
  23378. /**
  23379. * Gets wether the color grading effect is enabled.
  23380. */
  23381. get colorGradingEnabled(): boolean;
  23382. /**
  23383. * Gets wether the color grading effect is enabled.
  23384. */
  23385. set colorGradingEnabled(value: boolean);
  23386. /**
  23387. * Gets exposure used in the effect.
  23388. */
  23389. get exposure(): number;
  23390. /**
  23391. * Sets exposure used in the effect.
  23392. */
  23393. set exposure(value: number);
  23394. /**
  23395. * Gets wether tonemapping is enabled or not.
  23396. */
  23397. get toneMappingEnabled(): boolean;
  23398. /**
  23399. * Sets wether tonemapping is enabled or not
  23400. */
  23401. set toneMappingEnabled(value: boolean);
  23402. /**
  23403. * Gets the type of tone mapping effect.
  23404. */
  23405. get toneMappingType(): number;
  23406. /**
  23407. * Sets the type of tone mapping effect.
  23408. */
  23409. set toneMappingType(value: number);
  23410. /**
  23411. * Gets contrast used in the effect.
  23412. */
  23413. get contrast(): number;
  23414. /**
  23415. * Sets contrast used in the effect.
  23416. */
  23417. set contrast(value: number);
  23418. /**
  23419. * Gets Vignette stretch size.
  23420. */
  23421. get vignetteStretch(): number;
  23422. /**
  23423. * Sets Vignette stretch size.
  23424. */
  23425. set vignetteStretch(value: number);
  23426. /**
  23427. * Gets Vignette centre X Offset.
  23428. */
  23429. get vignetteCentreX(): number;
  23430. /**
  23431. * Sets Vignette centre X Offset.
  23432. */
  23433. set vignetteCentreX(value: number);
  23434. /**
  23435. * Gets Vignette centre Y Offset.
  23436. */
  23437. get vignetteCentreY(): number;
  23438. /**
  23439. * Sets Vignette centre Y Offset.
  23440. */
  23441. set vignetteCentreY(value: number);
  23442. /**
  23443. * Gets Vignette weight or intensity of the vignette effect.
  23444. */
  23445. get vignetteWeight(): number;
  23446. /**
  23447. * Sets Vignette weight or intensity of the vignette effect.
  23448. */
  23449. set vignetteWeight(value: number);
  23450. /**
  23451. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23452. * if vignetteEnabled is set to true.
  23453. */
  23454. get vignetteColor(): Color4;
  23455. /**
  23456. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23457. * if vignetteEnabled is set to true.
  23458. */
  23459. set vignetteColor(value: Color4);
  23460. /**
  23461. * Gets Camera field of view used by the Vignette effect.
  23462. */
  23463. get vignetteCameraFov(): number;
  23464. /**
  23465. * Sets Camera field of view used by the Vignette effect.
  23466. */
  23467. set vignetteCameraFov(value: number);
  23468. /**
  23469. * Gets the vignette blend mode allowing different kind of effect.
  23470. */
  23471. get vignetteBlendMode(): number;
  23472. /**
  23473. * Sets the vignette blend mode allowing different kind of effect.
  23474. */
  23475. set vignetteBlendMode(value: number);
  23476. /**
  23477. * Gets wether the vignette effect is enabled.
  23478. */
  23479. get vignetteEnabled(): boolean;
  23480. /**
  23481. * Sets wether the vignette effect is enabled.
  23482. */
  23483. set vignetteEnabled(value: boolean);
  23484. private _fromLinearSpace;
  23485. /**
  23486. * Gets wether the input of the processing is in Gamma or Linear Space.
  23487. */
  23488. get fromLinearSpace(): boolean;
  23489. /**
  23490. * Sets wether the input of the processing is in Gamma or Linear Space.
  23491. */
  23492. set fromLinearSpace(value: boolean);
  23493. /**
  23494. * Defines cache preventing GC.
  23495. */
  23496. private _defines;
  23497. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23498. /**
  23499. * "ImageProcessingPostProcess"
  23500. * @returns "ImageProcessingPostProcess"
  23501. */
  23502. getClassName(): string;
  23503. /**
  23504. * @hidden
  23505. */
  23506. _updateParameters(): void;
  23507. dispose(camera?: Camera): void;
  23508. }
  23509. }
  23510. declare module BABYLON {
  23511. /**
  23512. * Interface for defining prepass effects in the prepass post-process pipeline
  23513. */
  23514. export interface PrePassEffectConfiguration {
  23515. /**
  23516. * Name of the effect
  23517. */
  23518. name: string;
  23519. /**
  23520. * Post process to attach for this effect
  23521. */
  23522. postProcess?: PostProcess;
  23523. /**
  23524. * Textures required in the MRT
  23525. */
  23526. texturesRequired: number[];
  23527. /**
  23528. * Is the effect enabled
  23529. */
  23530. enabled: boolean;
  23531. /**
  23532. * Disposes the effect configuration
  23533. */
  23534. dispose?: () => void;
  23535. /**
  23536. * Creates the associated post process
  23537. */
  23538. createPostProcess?: () => PostProcess;
  23539. }
  23540. }
  23541. declare module BABYLON {
  23542. /**
  23543. * Options to be used when creating a FresnelParameters.
  23544. */
  23545. export type IFresnelParametersCreationOptions = {
  23546. /**
  23547. * Define the color used on edges (grazing angle)
  23548. */
  23549. leftColor?: Color3;
  23550. /**
  23551. * Define the color used on center
  23552. */
  23553. rightColor?: Color3;
  23554. /**
  23555. * Define bias applied to computed fresnel term
  23556. */
  23557. bias?: number;
  23558. /**
  23559. * Defined the power exponent applied to fresnel term
  23560. */
  23561. power?: number;
  23562. /**
  23563. * Define if the fresnel effect is enable or not.
  23564. */
  23565. isEnabled?: boolean;
  23566. };
  23567. /**
  23568. * Serialized format for FresnelParameters.
  23569. */
  23570. export type IFresnelParametersSerialized = {
  23571. /**
  23572. * Define the color used on edges (grazing angle) [as an array]
  23573. */
  23574. leftColor: number[];
  23575. /**
  23576. * Define the color used on center [as an array]
  23577. */
  23578. rightColor: number[];
  23579. /**
  23580. * Define bias applied to computed fresnel term
  23581. */
  23582. bias: number;
  23583. /**
  23584. * Defined the power exponent applied to fresnel term
  23585. */
  23586. power?: number;
  23587. /**
  23588. * Define if the fresnel effect is enable or not.
  23589. */
  23590. isEnabled: boolean;
  23591. };
  23592. /**
  23593. * This represents all the required information to add a fresnel effect on a material:
  23594. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23595. */
  23596. export class FresnelParameters {
  23597. private _isEnabled;
  23598. /**
  23599. * Define if the fresnel effect is enable or not.
  23600. */
  23601. get isEnabled(): boolean;
  23602. set isEnabled(value: boolean);
  23603. /**
  23604. * Define the color used on edges (grazing angle)
  23605. */
  23606. leftColor: Color3;
  23607. /**
  23608. * Define the color used on center
  23609. */
  23610. rightColor: Color3;
  23611. /**
  23612. * Define bias applied to computed fresnel term
  23613. */
  23614. bias: number;
  23615. /**
  23616. * Defined the power exponent applied to fresnel term
  23617. */
  23618. power: number;
  23619. /**
  23620. * Creates a new FresnelParameters object.
  23621. *
  23622. * @param options provide your own settings to optionally to override defaults
  23623. */
  23624. constructor(options?: IFresnelParametersCreationOptions);
  23625. /**
  23626. * Clones the current fresnel and its valuues
  23627. * @returns a clone fresnel configuration
  23628. */
  23629. clone(): FresnelParameters;
  23630. /**
  23631. * Determines equality between FresnelParameters objects
  23632. * @param otherFresnelParameters defines the second operand
  23633. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23634. */
  23635. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23636. /**
  23637. * Serializes the current fresnel parameters to a JSON representation.
  23638. * @return the JSON serialization
  23639. */
  23640. serialize(): IFresnelParametersSerialized;
  23641. /**
  23642. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23643. * @param parsedFresnelParameters Define the JSON representation
  23644. * @returns the parsed parameters
  23645. */
  23646. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23647. }
  23648. }
  23649. declare module BABYLON {
  23650. /**
  23651. * This groups all the flags used to control the materials channel.
  23652. */
  23653. export class MaterialFlags {
  23654. private static _DiffuseTextureEnabled;
  23655. /**
  23656. * Are diffuse textures enabled in the application.
  23657. */
  23658. static get DiffuseTextureEnabled(): boolean;
  23659. static set DiffuseTextureEnabled(value: boolean);
  23660. private static _DetailTextureEnabled;
  23661. /**
  23662. * Are detail textures enabled in the application.
  23663. */
  23664. static get DetailTextureEnabled(): boolean;
  23665. static set DetailTextureEnabled(value: boolean);
  23666. private static _AmbientTextureEnabled;
  23667. /**
  23668. * Are ambient textures enabled in the application.
  23669. */
  23670. static get AmbientTextureEnabled(): boolean;
  23671. static set AmbientTextureEnabled(value: boolean);
  23672. private static _OpacityTextureEnabled;
  23673. /**
  23674. * Are opacity textures enabled in the application.
  23675. */
  23676. static get OpacityTextureEnabled(): boolean;
  23677. static set OpacityTextureEnabled(value: boolean);
  23678. private static _ReflectionTextureEnabled;
  23679. /**
  23680. * Are reflection textures enabled in the application.
  23681. */
  23682. static get ReflectionTextureEnabled(): boolean;
  23683. static set ReflectionTextureEnabled(value: boolean);
  23684. private static _EmissiveTextureEnabled;
  23685. /**
  23686. * Are emissive textures enabled in the application.
  23687. */
  23688. static get EmissiveTextureEnabled(): boolean;
  23689. static set EmissiveTextureEnabled(value: boolean);
  23690. private static _SpecularTextureEnabled;
  23691. /**
  23692. * Are specular textures enabled in the application.
  23693. */
  23694. static get SpecularTextureEnabled(): boolean;
  23695. static set SpecularTextureEnabled(value: boolean);
  23696. private static _BumpTextureEnabled;
  23697. /**
  23698. * Are bump textures enabled in the application.
  23699. */
  23700. static get BumpTextureEnabled(): boolean;
  23701. static set BumpTextureEnabled(value: boolean);
  23702. private static _LightmapTextureEnabled;
  23703. /**
  23704. * Are lightmap textures enabled in the application.
  23705. */
  23706. static get LightmapTextureEnabled(): boolean;
  23707. static set LightmapTextureEnabled(value: boolean);
  23708. private static _RefractionTextureEnabled;
  23709. /**
  23710. * Are refraction textures enabled in the application.
  23711. */
  23712. static get RefractionTextureEnabled(): boolean;
  23713. static set RefractionTextureEnabled(value: boolean);
  23714. private static _ColorGradingTextureEnabled;
  23715. /**
  23716. * Are color grading textures enabled in the application.
  23717. */
  23718. static get ColorGradingTextureEnabled(): boolean;
  23719. static set ColorGradingTextureEnabled(value: boolean);
  23720. private static _FresnelEnabled;
  23721. /**
  23722. * Are fresnels enabled in the application.
  23723. */
  23724. static get FresnelEnabled(): boolean;
  23725. static set FresnelEnabled(value: boolean);
  23726. private static _ClearCoatTextureEnabled;
  23727. /**
  23728. * Are clear coat textures enabled in the application.
  23729. */
  23730. static get ClearCoatTextureEnabled(): boolean;
  23731. static set ClearCoatTextureEnabled(value: boolean);
  23732. private static _ClearCoatBumpTextureEnabled;
  23733. /**
  23734. * Are clear coat bump textures enabled in the application.
  23735. */
  23736. static get ClearCoatBumpTextureEnabled(): boolean;
  23737. static set ClearCoatBumpTextureEnabled(value: boolean);
  23738. private static _ClearCoatTintTextureEnabled;
  23739. /**
  23740. * Are clear coat tint textures enabled in the application.
  23741. */
  23742. static get ClearCoatTintTextureEnabled(): boolean;
  23743. static set ClearCoatTintTextureEnabled(value: boolean);
  23744. private static _SheenTextureEnabled;
  23745. /**
  23746. * Are sheen textures enabled in the application.
  23747. */
  23748. static get SheenTextureEnabled(): boolean;
  23749. static set SheenTextureEnabled(value: boolean);
  23750. private static _AnisotropicTextureEnabled;
  23751. /**
  23752. * Are anisotropic textures enabled in the application.
  23753. */
  23754. static get AnisotropicTextureEnabled(): boolean;
  23755. static set AnisotropicTextureEnabled(value: boolean);
  23756. private static _ThicknessTextureEnabled;
  23757. /**
  23758. * Are thickness textures enabled in the application.
  23759. */
  23760. static get ThicknessTextureEnabled(): boolean;
  23761. static set ThicknessTextureEnabled(value: boolean);
  23762. }
  23763. }
  23764. declare module BABYLON {
  23765. /** @hidden */
  23766. export var defaultFragmentDeclaration: {
  23767. name: string;
  23768. shader: string;
  23769. };
  23770. }
  23771. declare module BABYLON {
  23772. /** @hidden */
  23773. export var defaultUboDeclaration: {
  23774. name: string;
  23775. shader: string;
  23776. };
  23777. }
  23778. declare module BABYLON {
  23779. /** @hidden */
  23780. export var prePassDeclaration: {
  23781. name: string;
  23782. shader: string;
  23783. };
  23784. }
  23785. declare module BABYLON {
  23786. /** @hidden */
  23787. export var lightFragmentDeclaration: {
  23788. name: string;
  23789. shader: string;
  23790. };
  23791. }
  23792. declare module BABYLON {
  23793. /** @hidden */
  23794. export var lightUboDeclaration: {
  23795. name: string;
  23796. shader: string;
  23797. };
  23798. }
  23799. declare module BABYLON {
  23800. /** @hidden */
  23801. export var lightsFragmentFunctions: {
  23802. name: string;
  23803. shader: string;
  23804. };
  23805. }
  23806. declare module BABYLON {
  23807. /** @hidden */
  23808. export var shadowsFragmentFunctions: {
  23809. name: string;
  23810. shader: string;
  23811. };
  23812. }
  23813. declare module BABYLON {
  23814. /** @hidden */
  23815. export var fresnelFunction: {
  23816. name: string;
  23817. shader: string;
  23818. };
  23819. }
  23820. declare module BABYLON {
  23821. /** @hidden */
  23822. export var bumpFragmentMainFunctions: {
  23823. name: string;
  23824. shader: string;
  23825. };
  23826. }
  23827. declare module BABYLON {
  23828. /** @hidden */
  23829. export var bumpFragmentFunctions: {
  23830. name: string;
  23831. shader: string;
  23832. };
  23833. }
  23834. declare module BABYLON {
  23835. /** @hidden */
  23836. export var logDepthDeclaration: {
  23837. name: string;
  23838. shader: string;
  23839. };
  23840. }
  23841. declare module BABYLON {
  23842. /** @hidden */
  23843. export var bumpFragment: {
  23844. name: string;
  23845. shader: string;
  23846. };
  23847. }
  23848. declare module BABYLON {
  23849. /** @hidden */
  23850. export var depthPrePass: {
  23851. name: string;
  23852. shader: string;
  23853. };
  23854. }
  23855. declare module BABYLON {
  23856. /** @hidden */
  23857. export var lightFragment: {
  23858. name: string;
  23859. shader: string;
  23860. };
  23861. }
  23862. declare module BABYLON {
  23863. /** @hidden */
  23864. export var logDepthFragment: {
  23865. name: string;
  23866. shader: string;
  23867. };
  23868. }
  23869. declare module BABYLON {
  23870. /** @hidden */
  23871. export var defaultPixelShader: {
  23872. name: string;
  23873. shader: string;
  23874. };
  23875. }
  23876. declare module BABYLON {
  23877. /** @hidden */
  23878. export var defaultVertexDeclaration: {
  23879. name: string;
  23880. shader: string;
  23881. };
  23882. }
  23883. declare module BABYLON {
  23884. /** @hidden */
  23885. export var prePassVertexDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module BABYLON {
  23891. /** @hidden */
  23892. export var bumpVertexDeclaration: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module BABYLON {
  23898. /** @hidden */
  23899. export var prePassVertex: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module BABYLON {
  23905. /** @hidden */
  23906. export var bumpVertex: {
  23907. name: string;
  23908. shader: string;
  23909. };
  23910. }
  23911. declare module BABYLON {
  23912. /** @hidden */
  23913. export var fogVertex: {
  23914. name: string;
  23915. shader: string;
  23916. };
  23917. }
  23918. declare module BABYLON {
  23919. /** @hidden */
  23920. export var shadowsVertex: {
  23921. name: string;
  23922. shader: string;
  23923. };
  23924. }
  23925. declare module BABYLON {
  23926. /** @hidden */
  23927. export var pointCloudVertex: {
  23928. name: string;
  23929. shader: string;
  23930. };
  23931. }
  23932. declare module BABYLON {
  23933. /** @hidden */
  23934. export var logDepthVertex: {
  23935. name: string;
  23936. shader: string;
  23937. };
  23938. }
  23939. declare module BABYLON {
  23940. /** @hidden */
  23941. export var defaultVertexShader: {
  23942. name: string;
  23943. shader: string;
  23944. };
  23945. }
  23946. declare module BABYLON {
  23947. /**
  23948. * @hidden
  23949. */
  23950. export interface IMaterialDetailMapDefines {
  23951. DETAIL: boolean;
  23952. DETAILDIRECTUV: number;
  23953. DETAIL_NORMALBLENDMETHOD: number;
  23954. /** @hidden */
  23955. _areTexturesDirty: boolean;
  23956. }
  23957. /**
  23958. * Define the code related to the detail map parameters of a material
  23959. *
  23960. * Inspired from:
  23961. * 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
  23962. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23963. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23964. */
  23965. export class DetailMapConfiguration {
  23966. private _texture;
  23967. /**
  23968. * The detail texture of the material.
  23969. */
  23970. texture: Nullable<BaseTexture>;
  23971. /**
  23972. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23973. * Bigger values mean stronger blending
  23974. */
  23975. diffuseBlendLevel: number;
  23976. /**
  23977. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23978. * Bigger values mean stronger blending. Only used with PBR materials
  23979. */
  23980. roughnessBlendLevel: number;
  23981. /**
  23982. * Defines how strong the bump effect from the detail map is
  23983. * Bigger values mean stronger effect
  23984. */
  23985. bumpLevel: number;
  23986. private _normalBlendMethod;
  23987. /**
  23988. * The method used to blend the bump and detail normals together
  23989. */
  23990. normalBlendMethod: number;
  23991. private _isEnabled;
  23992. /**
  23993. * Enable or disable the detail map on this material
  23994. */
  23995. isEnabled: boolean;
  23996. /** @hidden */
  23997. private _internalMarkAllSubMeshesAsTexturesDirty;
  23998. /** @hidden */
  23999. _markAllSubMeshesAsTexturesDirty(): void;
  24000. /**
  24001. * Instantiate a new detail map
  24002. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24003. */
  24004. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24005. /**
  24006. * Gets whether the submesh is ready to be used or not.
  24007. * @param defines the list of "defines" to update.
  24008. * @param scene defines the scene the material belongs to.
  24009. * @returns - boolean indicating that the submesh is ready or not.
  24010. */
  24011. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24012. /**
  24013. * Update the defines for detail map usage
  24014. * @param defines the list of "defines" to update.
  24015. * @param scene defines the scene the material belongs to.
  24016. */
  24017. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24018. /**
  24019. * Binds the material data.
  24020. * @param uniformBuffer defines the Uniform buffer to fill in.
  24021. * @param scene defines the scene the material belongs to.
  24022. * @param isFrozen defines whether the material is frozen or not.
  24023. */
  24024. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24025. /**
  24026. * Checks to see if a texture is used in the material.
  24027. * @param texture - Base texture to use.
  24028. * @returns - Boolean specifying if a texture is used in the material.
  24029. */
  24030. hasTexture(texture: BaseTexture): boolean;
  24031. /**
  24032. * Returns an array of the actively used textures.
  24033. * @param activeTextures Array of BaseTextures
  24034. */
  24035. getActiveTextures(activeTextures: BaseTexture[]): void;
  24036. /**
  24037. * Returns the animatable textures.
  24038. * @param animatables Array of animatable textures.
  24039. */
  24040. getAnimatables(animatables: IAnimatable[]): void;
  24041. /**
  24042. * Disposes the resources of the material.
  24043. * @param forceDisposeTextures - Forces the disposal of all textures.
  24044. */
  24045. dispose(forceDisposeTextures?: boolean): void;
  24046. /**
  24047. * Get the current class name useful for serialization or dynamic coding.
  24048. * @returns "DetailMap"
  24049. */
  24050. getClassName(): string;
  24051. /**
  24052. * Add the required uniforms to the current list.
  24053. * @param uniforms defines the current uniform list.
  24054. */
  24055. static AddUniforms(uniforms: string[]): void;
  24056. /**
  24057. * Add the required samplers to the current list.
  24058. * @param samplers defines the current sampler list.
  24059. */
  24060. static AddSamplers(samplers: string[]): void;
  24061. /**
  24062. * Add the required uniforms to the current buffer.
  24063. * @param uniformBuffer defines the current uniform buffer.
  24064. */
  24065. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24066. /**
  24067. * Makes a duplicate of the current instance into another one.
  24068. * @param detailMap define the instance where to copy the info
  24069. */
  24070. copyTo(detailMap: DetailMapConfiguration): void;
  24071. /**
  24072. * Serializes this detail map instance
  24073. * @returns - An object with the serialized instance.
  24074. */
  24075. serialize(): any;
  24076. /**
  24077. * Parses a detail map setting from a serialized object.
  24078. * @param source - Serialized object.
  24079. * @param scene Defines the scene we are parsing for
  24080. * @param rootUrl Defines the rootUrl to load from
  24081. */
  24082. parse(source: any, scene: Scene, rootUrl: string): void;
  24083. }
  24084. }
  24085. declare module BABYLON {
  24086. /** @hidden */
  24087. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24088. MAINUV1: boolean;
  24089. MAINUV2: boolean;
  24090. DIFFUSE: boolean;
  24091. DIFFUSEDIRECTUV: number;
  24092. DETAIL: boolean;
  24093. DETAILDIRECTUV: number;
  24094. DETAIL_NORMALBLENDMETHOD: number;
  24095. AMBIENT: boolean;
  24096. AMBIENTDIRECTUV: number;
  24097. OPACITY: boolean;
  24098. OPACITYDIRECTUV: number;
  24099. OPACITYRGB: boolean;
  24100. REFLECTION: boolean;
  24101. EMISSIVE: boolean;
  24102. EMISSIVEDIRECTUV: number;
  24103. SPECULAR: boolean;
  24104. SPECULARDIRECTUV: number;
  24105. BUMP: boolean;
  24106. BUMPDIRECTUV: number;
  24107. PARALLAX: boolean;
  24108. PARALLAXOCCLUSION: boolean;
  24109. SPECULAROVERALPHA: boolean;
  24110. CLIPPLANE: boolean;
  24111. CLIPPLANE2: boolean;
  24112. CLIPPLANE3: boolean;
  24113. CLIPPLANE4: boolean;
  24114. CLIPPLANE5: boolean;
  24115. CLIPPLANE6: boolean;
  24116. ALPHATEST: boolean;
  24117. DEPTHPREPASS: boolean;
  24118. ALPHAFROMDIFFUSE: boolean;
  24119. POINTSIZE: boolean;
  24120. FOG: boolean;
  24121. SPECULARTERM: boolean;
  24122. DIFFUSEFRESNEL: boolean;
  24123. OPACITYFRESNEL: boolean;
  24124. REFLECTIONFRESNEL: boolean;
  24125. REFRACTIONFRESNEL: boolean;
  24126. EMISSIVEFRESNEL: boolean;
  24127. FRESNEL: boolean;
  24128. NORMAL: boolean;
  24129. UV1: boolean;
  24130. UV2: boolean;
  24131. VERTEXCOLOR: boolean;
  24132. VERTEXALPHA: boolean;
  24133. NUM_BONE_INFLUENCERS: number;
  24134. BonesPerMesh: number;
  24135. BONETEXTURE: boolean;
  24136. BONES_VELOCITY_ENABLED: boolean;
  24137. INSTANCES: boolean;
  24138. THIN_INSTANCES: boolean;
  24139. GLOSSINESS: boolean;
  24140. ROUGHNESS: boolean;
  24141. EMISSIVEASILLUMINATION: boolean;
  24142. LINKEMISSIVEWITHDIFFUSE: boolean;
  24143. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24144. LIGHTMAP: boolean;
  24145. LIGHTMAPDIRECTUV: number;
  24146. OBJECTSPACE_NORMALMAP: boolean;
  24147. USELIGHTMAPASSHADOWMAP: boolean;
  24148. REFLECTIONMAP_3D: boolean;
  24149. REFLECTIONMAP_SPHERICAL: boolean;
  24150. REFLECTIONMAP_PLANAR: boolean;
  24151. REFLECTIONMAP_CUBIC: boolean;
  24152. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24153. REFLECTIONMAP_PROJECTION: boolean;
  24154. REFLECTIONMAP_SKYBOX: boolean;
  24155. REFLECTIONMAP_EXPLICIT: boolean;
  24156. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24157. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24158. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24159. INVERTCUBICMAP: boolean;
  24160. LOGARITHMICDEPTH: boolean;
  24161. REFRACTION: boolean;
  24162. REFRACTIONMAP_3D: boolean;
  24163. REFLECTIONOVERALPHA: boolean;
  24164. TWOSIDEDLIGHTING: boolean;
  24165. SHADOWFLOAT: boolean;
  24166. MORPHTARGETS: boolean;
  24167. MORPHTARGETS_NORMAL: boolean;
  24168. MORPHTARGETS_TANGENT: boolean;
  24169. MORPHTARGETS_UV: boolean;
  24170. NUM_MORPH_INFLUENCERS: number;
  24171. NONUNIFORMSCALING: boolean;
  24172. PREMULTIPLYALPHA: boolean;
  24173. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24174. ALPHABLEND: boolean;
  24175. PREPASS: boolean;
  24176. PREPASS_IRRADIANCE: boolean;
  24177. PREPASS_IRRADIANCE_INDEX: number;
  24178. PREPASS_ALBEDO: boolean;
  24179. PREPASS_ALBEDO_INDEX: number;
  24180. PREPASS_DEPTHNORMAL: boolean;
  24181. PREPASS_DEPTHNORMAL_INDEX: number;
  24182. PREPASS_POSITION: boolean;
  24183. PREPASS_POSITION_INDEX: number;
  24184. PREPASS_VELOCITY: boolean;
  24185. PREPASS_VELOCITY_INDEX: number;
  24186. PREPASS_REFLECTIVITY: boolean;
  24187. PREPASS_REFLECTIVITY_INDEX: number;
  24188. SCENE_MRT_COUNT: number;
  24189. RGBDLIGHTMAP: boolean;
  24190. RGBDREFLECTION: boolean;
  24191. RGBDREFRACTION: boolean;
  24192. IMAGEPROCESSING: boolean;
  24193. VIGNETTE: boolean;
  24194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24195. VIGNETTEBLENDMODEOPAQUE: boolean;
  24196. TONEMAPPING: boolean;
  24197. TONEMAPPING_ACES: boolean;
  24198. CONTRAST: boolean;
  24199. COLORCURVES: boolean;
  24200. COLORGRADING: boolean;
  24201. COLORGRADING3D: boolean;
  24202. SAMPLER3DGREENDEPTH: boolean;
  24203. SAMPLER3DBGRMAP: boolean;
  24204. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24205. MULTIVIEW: boolean;
  24206. /**
  24207. * If the reflection texture on this material is in linear color space
  24208. * @hidden
  24209. */
  24210. IS_REFLECTION_LINEAR: boolean;
  24211. /**
  24212. * If the refraction texture on this material is in linear color space
  24213. * @hidden
  24214. */
  24215. IS_REFRACTION_LINEAR: boolean;
  24216. EXPOSURE: boolean;
  24217. constructor();
  24218. setReflectionMode(modeToEnable: string): void;
  24219. }
  24220. /**
  24221. * This is the default material used in Babylon. It is the best trade off between quality
  24222. * and performances.
  24223. * @see https://doc.babylonjs.com/babylon101/materials
  24224. */
  24225. export class StandardMaterial extends PushMaterial {
  24226. private _diffuseTexture;
  24227. /**
  24228. * The basic texture of the material as viewed under a light.
  24229. */
  24230. diffuseTexture: Nullable<BaseTexture>;
  24231. private _ambientTexture;
  24232. /**
  24233. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24234. */
  24235. ambientTexture: Nullable<BaseTexture>;
  24236. private _opacityTexture;
  24237. /**
  24238. * Define the transparency of the material from a texture.
  24239. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24240. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24241. */
  24242. opacityTexture: Nullable<BaseTexture>;
  24243. private _reflectionTexture;
  24244. /**
  24245. * Define the texture used to display the reflection.
  24246. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24247. */
  24248. reflectionTexture: Nullable<BaseTexture>;
  24249. private _emissiveTexture;
  24250. /**
  24251. * Define texture of the material as if self lit.
  24252. * This will be mixed in the final result even in the absence of light.
  24253. */
  24254. emissiveTexture: Nullable<BaseTexture>;
  24255. private _specularTexture;
  24256. /**
  24257. * Define how the color and intensity of the highlight given by the light in the material.
  24258. */
  24259. specularTexture: Nullable<BaseTexture>;
  24260. private _bumpTexture;
  24261. /**
  24262. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24263. * 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.
  24264. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24265. */
  24266. bumpTexture: Nullable<BaseTexture>;
  24267. private _lightmapTexture;
  24268. /**
  24269. * Complex lighting can be computationally expensive to compute at runtime.
  24270. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24271. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24272. */
  24273. lightmapTexture: Nullable<BaseTexture>;
  24274. private _refractionTexture;
  24275. /**
  24276. * Define the texture used to display the refraction.
  24277. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24278. */
  24279. refractionTexture: Nullable<BaseTexture>;
  24280. /**
  24281. * The color of the material lit by the environmental background lighting.
  24282. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24283. */
  24284. ambientColor: Color3;
  24285. /**
  24286. * The basic color of the material as viewed under a light.
  24287. */
  24288. diffuseColor: Color3;
  24289. /**
  24290. * Define how the color and intensity of the highlight given by the light in the material.
  24291. */
  24292. specularColor: Color3;
  24293. /**
  24294. * Define the color of the material as if self lit.
  24295. * This will be mixed in the final result even in the absence of light.
  24296. */
  24297. emissiveColor: Color3;
  24298. /**
  24299. * Defines how sharp are the highlights in the material.
  24300. * The bigger the value the sharper giving a more glossy feeling to the result.
  24301. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24302. */
  24303. specularPower: number;
  24304. private _useAlphaFromDiffuseTexture;
  24305. /**
  24306. * Does the transparency come from the diffuse texture alpha channel.
  24307. */
  24308. useAlphaFromDiffuseTexture: boolean;
  24309. private _useEmissiveAsIllumination;
  24310. /**
  24311. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24312. */
  24313. useEmissiveAsIllumination: boolean;
  24314. private _linkEmissiveWithDiffuse;
  24315. /**
  24316. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24317. * the emissive level when the final color is close to one.
  24318. */
  24319. linkEmissiveWithDiffuse: boolean;
  24320. private _useSpecularOverAlpha;
  24321. /**
  24322. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24323. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24324. */
  24325. useSpecularOverAlpha: boolean;
  24326. private _useReflectionOverAlpha;
  24327. /**
  24328. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24329. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24330. */
  24331. useReflectionOverAlpha: boolean;
  24332. private _disableLighting;
  24333. /**
  24334. * Does lights from the scene impacts this material.
  24335. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24336. */
  24337. disableLighting: boolean;
  24338. private _useObjectSpaceNormalMap;
  24339. /**
  24340. * Allows using an object space normal map (instead of tangent space).
  24341. */
  24342. useObjectSpaceNormalMap: boolean;
  24343. private _useParallax;
  24344. /**
  24345. * Is parallax enabled or not.
  24346. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24347. */
  24348. useParallax: boolean;
  24349. private _useParallaxOcclusion;
  24350. /**
  24351. * Is parallax occlusion enabled or not.
  24352. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24353. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24354. */
  24355. useParallaxOcclusion: boolean;
  24356. /**
  24357. * 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.
  24358. */
  24359. parallaxScaleBias: number;
  24360. private _roughness;
  24361. /**
  24362. * Helps to define how blurry the reflections should appears in the material.
  24363. */
  24364. roughness: number;
  24365. /**
  24366. * In case of refraction, define the value of the index of refraction.
  24367. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24368. */
  24369. indexOfRefraction: number;
  24370. /**
  24371. * Invert the refraction texture alongside the y axis.
  24372. * It can be useful with procedural textures or probe for instance.
  24373. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24374. */
  24375. invertRefractionY: boolean;
  24376. /**
  24377. * Defines the alpha limits in alpha test mode.
  24378. */
  24379. alphaCutOff: number;
  24380. private _useLightmapAsShadowmap;
  24381. /**
  24382. * In case of light mapping, define whether the map contains light or shadow informations.
  24383. */
  24384. useLightmapAsShadowmap: boolean;
  24385. private _diffuseFresnelParameters;
  24386. /**
  24387. * Define the diffuse fresnel parameters of the material.
  24388. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24389. */
  24390. diffuseFresnelParameters: FresnelParameters;
  24391. private _opacityFresnelParameters;
  24392. /**
  24393. * Define the opacity fresnel parameters of the material.
  24394. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24395. */
  24396. opacityFresnelParameters: FresnelParameters;
  24397. private _reflectionFresnelParameters;
  24398. /**
  24399. * Define the reflection fresnel parameters of the material.
  24400. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24401. */
  24402. reflectionFresnelParameters: FresnelParameters;
  24403. private _refractionFresnelParameters;
  24404. /**
  24405. * Define the refraction fresnel parameters of the material.
  24406. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24407. */
  24408. refractionFresnelParameters: FresnelParameters;
  24409. private _emissiveFresnelParameters;
  24410. /**
  24411. * Define the emissive fresnel parameters of the material.
  24412. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24413. */
  24414. emissiveFresnelParameters: FresnelParameters;
  24415. private _useReflectionFresnelFromSpecular;
  24416. /**
  24417. * If true automatically deducts the fresnels values from the material specularity.
  24418. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24419. */
  24420. useReflectionFresnelFromSpecular: boolean;
  24421. private _useGlossinessFromSpecularMapAlpha;
  24422. /**
  24423. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24424. */
  24425. useGlossinessFromSpecularMapAlpha: boolean;
  24426. private _maxSimultaneousLights;
  24427. /**
  24428. * Defines the maximum number of lights that can be used in the material
  24429. */
  24430. maxSimultaneousLights: number;
  24431. private _invertNormalMapX;
  24432. /**
  24433. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24434. */
  24435. invertNormalMapX: boolean;
  24436. private _invertNormalMapY;
  24437. /**
  24438. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24439. */
  24440. invertNormalMapY: boolean;
  24441. private _twoSidedLighting;
  24442. /**
  24443. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24444. */
  24445. twoSidedLighting: boolean;
  24446. /**
  24447. * Default configuration related to image processing available in the standard Material.
  24448. */
  24449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24450. /**
  24451. * Gets the image processing configuration used either in this material.
  24452. */
  24453. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24454. /**
  24455. * Sets the Default image processing configuration used either in the this material.
  24456. *
  24457. * If sets to null, the scene one is in use.
  24458. */
  24459. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24460. /**
  24461. * Keep track of the image processing observer to allow dispose and replace.
  24462. */
  24463. private _imageProcessingObserver;
  24464. /**
  24465. * Attaches a new image processing configuration to the Standard Material.
  24466. * @param configuration
  24467. */
  24468. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24469. /**
  24470. * Defines additionnal PrePass parameters for the material.
  24471. */
  24472. readonly prePassConfiguration: PrePassConfiguration;
  24473. /**
  24474. * Gets wether the color curves effect is enabled.
  24475. */
  24476. get cameraColorCurvesEnabled(): boolean;
  24477. /**
  24478. * Sets wether the color curves effect is enabled.
  24479. */
  24480. set cameraColorCurvesEnabled(value: boolean);
  24481. /**
  24482. * Gets wether the color grading effect is enabled.
  24483. */
  24484. get cameraColorGradingEnabled(): boolean;
  24485. /**
  24486. * Gets wether the color grading effect is enabled.
  24487. */
  24488. set cameraColorGradingEnabled(value: boolean);
  24489. /**
  24490. * Gets wether tonemapping is enabled or not.
  24491. */
  24492. get cameraToneMappingEnabled(): boolean;
  24493. /**
  24494. * Sets wether tonemapping is enabled or not
  24495. */
  24496. set cameraToneMappingEnabled(value: boolean);
  24497. /**
  24498. * The camera exposure used on this material.
  24499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24500. * This corresponds to a photographic exposure.
  24501. */
  24502. get cameraExposure(): number;
  24503. /**
  24504. * The camera exposure used on this material.
  24505. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24506. * This corresponds to a photographic exposure.
  24507. */
  24508. set cameraExposure(value: number);
  24509. /**
  24510. * Gets The camera contrast used on this material.
  24511. */
  24512. get cameraContrast(): number;
  24513. /**
  24514. * Sets The camera contrast used on this material.
  24515. */
  24516. set cameraContrast(value: number);
  24517. /**
  24518. * Gets the Color Grading 2D Lookup Texture.
  24519. */
  24520. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24521. /**
  24522. * Sets the Color Grading 2D Lookup Texture.
  24523. */
  24524. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24525. /**
  24526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24528. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24530. */
  24531. get cameraColorCurves(): Nullable<ColorCurves>;
  24532. /**
  24533. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24534. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24535. * 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;
  24536. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24537. */
  24538. set cameraColorCurves(value: Nullable<ColorCurves>);
  24539. /**
  24540. * Can this material render to several textures at once
  24541. */
  24542. get canRenderToMRT(): boolean;
  24543. /**
  24544. * Defines the detail map parameters for the material.
  24545. */
  24546. readonly detailMap: DetailMapConfiguration;
  24547. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24548. protected _worldViewProjectionMatrix: Matrix;
  24549. protected _globalAmbientColor: Color3;
  24550. protected _useLogarithmicDepth: boolean;
  24551. protected _rebuildInParallel: boolean;
  24552. /**
  24553. * Instantiates a new standard material.
  24554. * This is the default material used in Babylon. It is the best trade off between quality
  24555. * and performances.
  24556. * @see https://doc.babylonjs.com/babylon101/materials
  24557. * @param name Define the name of the material in the scene
  24558. * @param scene Define the scene the material belong to
  24559. */
  24560. constructor(name: string, scene: Scene);
  24561. /**
  24562. * Gets a boolean indicating that current material needs to register RTT
  24563. */
  24564. get hasRenderTargetTextures(): boolean;
  24565. /**
  24566. * Gets the current class name of the material e.g. "StandardMaterial"
  24567. * Mainly use in serialization.
  24568. * @returns the class name
  24569. */
  24570. getClassName(): string;
  24571. /**
  24572. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24573. * You can try switching to logarithmic depth.
  24574. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24575. */
  24576. get useLogarithmicDepth(): boolean;
  24577. set useLogarithmicDepth(value: boolean);
  24578. /**
  24579. * Specifies if the material will require alpha blending
  24580. * @returns a boolean specifying if alpha blending is needed
  24581. */
  24582. needAlphaBlending(): boolean;
  24583. /**
  24584. * Specifies if this material should be rendered in alpha test mode
  24585. * @returns a boolean specifying if an alpha test is needed.
  24586. */
  24587. needAlphaTesting(): boolean;
  24588. /**
  24589. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24590. */
  24591. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24592. /**
  24593. * Specifies whether or not there is a usable alpha channel for transparency.
  24594. */
  24595. protected _hasAlphaChannel(): boolean;
  24596. /**
  24597. * Get the texture used for alpha test purpose.
  24598. * @returns the diffuse texture in case of the standard material.
  24599. */
  24600. getAlphaTestTexture(): Nullable<BaseTexture>;
  24601. /**
  24602. * Get if the submesh is ready to be used and all its information available.
  24603. * Child classes can use it to update shaders
  24604. * @param mesh defines the mesh to check
  24605. * @param subMesh defines which submesh to check
  24606. * @param useInstances specifies that instances should be used
  24607. * @returns a boolean indicating that the submesh is ready or not
  24608. */
  24609. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24610. /**
  24611. * Builds the material UBO layouts.
  24612. * Used internally during the effect preparation.
  24613. */
  24614. buildUniformLayout(): void;
  24615. /**
  24616. * Unbinds the material from the mesh
  24617. */
  24618. unbind(): void;
  24619. /**
  24620. * Binds the submesh to this material by preparing the effect and shader to draw
  24621. * @param world defines the world transformation matrix
  24622. * @param mesh defines the mesh containing the submesh
  24623. * @param subMesh defines the submesh to bind the material to
  24624. */
  24625. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24626. /**
  24627. * Get the list of animatables in the material.
  24628. * @returns the list of animatables object used in the material
  24629. */
  24630. getAnimatables(): IAnimatable[];
  24631. /**
  24632. * Gets the active textures from the material
  24633. * @returns an array of textures
  24634. */
  24635. getActiveTextures(): BaseTexture[];
  24636. /**
  24637. * Specifies if the material uses a texture
  24638. * @param texture defines the texture to check against the material
  24639. * @returns a boolean specifying if the material uses the texture
  24640. */
  24641. hasTexture(texture: BaseTexture): boolean;
  24642. /**
  24643. * Disposes the material
  24644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24646. */
  24647. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24648. /**
  24649. * Makes a duplicate of the material, and gives it a new name
  24650. * @param name defines the new name for the duplicated material
  24651. * @returns the cloned material
  24652. */
  24653. clone(name: string): StandardMaterial;
  24654. /**
  24655. * Serializes this material in a JSON representation
  24656. * @returns the serialized material object
  24657. */
  24658. serialize(): any;
  24659. /**
  24660. * Creates a standard material from parsed material data
  24661. * @param source defines the JSON representation of the material
  24662. * @param scene defines the hosting scene
  24663. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24664. * @returns a new standard material
  24665. */
  24666. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24667. /**
  24668. * Are diffuse textures enabled in the application.
  24669. */
  24670. static get DiffuseTextureEnabled(): boolean;
  24671. static set DiffuseTextureEnabled(value: boolean);
  24672. /**
  24673. * Are detail textures enabled in the application.
  24674. */
  24675. static get DetailTextureEnabled(): boolean;
  24676. static set DetailTextureEnabled(value: boolean);
  24677. /**
  24678. * Are ambient textures enabled in the application.
  24679. */
  24680. static get AmbientTextureEnabled(): boolean;
  24681. static set AmbientTextureEnabled(value: boolean);
  24682. /**
  24683. * Are opacity textures enabled in the application.
  24684. */
  24685. static get OpacityTextureEnabled(): boolean;
  24686. static set OpacityTextureEnabled(value: boolean);
  24687. /**
  24688. * Are reflection textures enabled in the application.
  24689. */
  24690. static get ReflectionTextureEnabled(): boolean;
  24691. static set ReflectionTextureEnabled(value: boolean);
  24692. /**
  24693. * Are emissive textures enabled in the application.
  24694. */
  24695. static get EmissiveTextureEnabled(): boolean;
  24696. static set EmissiveTextureEnabled(value: boolean);
  24697. /**
  24698. * Are specular textures enabled in the application.
  24699. */
  24700. static get SpecularTextureEnabled(): boolean;
  24701. static set SpecularTextureEnabled(value: boolean);
  24702. /**
  24703. * Are bump textures enabled in the application.
  24704. */
  24705. static get BumpTextureEnabled(): boolean;
  24706. static set BumpTextureEnabled(value: boolean);
  24707. /**
  24708. * Are lightmap textures enabled in the application.
  24709. */
  24710. static get LightmapTextureEnabled(): boolean;
  24711. static set LightmapTextureEnabled(value: boolean);
  24712. /**
  24713. * Are refraction textures enabled in the application.
  24714. */
  24715. static get RefractionTextureEnabled(): boolean;
  24716. static set RefractionTextureEnabled(value: boolean);
  24717. /**
  24718. * Are color grading textures enabled in the application.
  24719. */
  24720. static get ColorGradingTextureEnabled(): boolean;
  24721. static set ColorGradingTextureEnabled(value: boolean);
  24722. /**
  24723. * Are fresnels enabled in the application.
  24724. */
  24725. static get FresnelEnabled(): boolean;
  24726. static set FresnelEnabled(value: boolean);
  24727. }
  24728. }
  24729. declare module BABYLON {
  24730. /** @hidden */
  24731. export var rgbdDecodePixelShader: {
  24732. name: string;
  24733. shader: string;
  24734. };
  24735. }
  24736. declare module BABYLON {
  24737. /**
  24738. * Class used to host RGBD texture specific utilities
  24739. */
  24740. export class RGBDTextureTools {
  24741. /**
  24742. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24743. * @param texture the texture to expand.
  24744. */
  24745. static ExpandRGBDTexture(texture: Texture): void;
  24746. }
  24747. }
  24748. declare module BABYLON {
  24749. /**
  24750. * Class used to host texture specific utilities
  24751. */
  24752. export class BRDFTextureTools {
  24753. /**
  24754. * Prevents texture cache collision
  24755. */
  24756. private static _instanceNumber;
  24757. /**
  24758. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24759. * @param scene defines the hosting scene
  24760. * @returns the environment BRDF texture
  24761. */
  24762. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24763. private static _environmentBRDFBase64Texture;
  24764. }
  24765. }
  24766. declare module BABYLON {
  24767. /**
  24768. * @hidden
  24769. */
  24770. export interface IMaterialClearCoatDefines {
  24771. CLEARCOAT: boolean;
  24772. CLEARCOAT_DEFAULTIOR: boolean;
  24773. CLEARCOAT_TEXTURE: boolean;
  24774. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24775. CLEARCOAT_TEXTUREDIRECTUV: number;
  24776. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24777. CLEARCOAT_BUMP: boolean;
  24778. CLEARCOAT_BUMPDIRECTUV: number;
  24779. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24780. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24781. CLEARCOAT_REMAP_F0: boolean;
  24782. CLEARCOAT_TINT: boolean;
  24783. CLEARCOAT_TINT_TEXTURE: boolean;
  24784. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24785. /** @hidden */
  24786. _areTexturesDirty: boolean;
  24787. }
  24788. /**
  24789. * Define the code related to the clear coat parameters of the pbr material.
  24790. */
  24791. export class PBRClearCoatConfiguration {
  24792. /**
  24793. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24794. * The default fits with a polyurethane material.
  24795. */
  24796. private static readonly _DefaultIndexOfRefraction;
  24797. private _isEnabled;
  24798. /**
  24799. * Defines if the clear coat is enabled in the material.
  24800. */
  24801. isEnabled: boolean;
  24802. /**
  24803. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24804. */
  24805. intensity: number;
  24806. /**
  24807. * Defines the clear coat layer roughness.
  24808. */
  24809. roughness: number;
  24810. private _indexOfRefraction;
  24811. /**
  24812. * Defines the index of refraction of the clear coat.
  24813. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24814. * The default fits with a polyurethane material.
  24815. * Changing the default value is more performance intensive.
  24816. */
  24817. indexOfRefraction: number;
  24818. private _texture;
  24819. /**
  24820. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24821. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24822. * if textureRoughness is not empty, else no texture roughness is used
  24823. */
  24824. texture: Nullable<BaseTexture>;
  24825. private _useRoughnessFromMainTexture;
  24826. /**
  24827. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24828. * If false, the green channel from textureRoughness is used for roughness
  24829. */
  24830. useRoughnessFromMainTexture: boolean;
  24831. private _textureRoughness;
  24832. /**
  24833. * Stores the clear coat roughness in a texture (green channel)
  24834. * Not used if useRoughnessFromMainTexture is true
  24835. */
  24836. textureRoughness: Nullable<BaseTexture>;
  24837. private _remapF0OnInterfaceChange;
  24838. /**
  24839. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24840. */
  24841. remapF0OnInterfaceChange: boolean;
  24842. private _bumpTexture;
  24843. /**
  24844. * Define the clear coat specific bump texture.
  24845. */
  24846. bumpTexture: Nullable<BaseTexture>;
  24847. private _isTintEnabled;
  24848. /**
  24849. * Defines if the clear coat tint is enabled in the material.
  24850. */
  24851. isTintEnabled: boolean;
  24852. /**
  24853. * Defines the clear coat tint of the material.
  24854. * This is only use if tint is enabled
  24855. */
  24856. tintColor: Color3;
  24857. /**
  24858. * Defines the distance at which the tint color should be found in the
  24859. * clear coat media.
  24860. * This is only use if tint is enabled
  24861. */
  24862. tintColorAtDistance: number;
  24863. /**
  24864. * Defines the clear coat layer thickness.
  24865. * This is only use if tint is enabled
  24866. */
  24867. tintThickness: number;
  24868. private _tintTexture;
  24869. /**
  24870. * Stores the clear tint values in a texture.
  24871. * rgb is tint
  24872. * a is a thickness factor
  24873. */
  24874. tintTexture: Nullable<BaseTexture>;
  24875. /** @hidden */
  24876. private _internalMarkAllSubMeshesAsTexturesDirty;
  24877. /** @hidden */
  24878. _markAllSubMeshesAsTexturesDirty(): void;
  24879. /**
  24880. * Instantiate a new istance of clear coat configuration.
  24881. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24882. */
  24883. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24884. /**
  24885. * Gets wehter the submesh is ready to be used or not.
  24886. * @param defines the list of "defines" to update.
  24887. * @param scene defines the scene the material belongs to.
  24888. * @param engine defines the engine the material belongs to.
  24889. * @param disableBumpMap defines wether the material disables bump or not.
  24890. * @returns - boolean indicating that the submesh is ready or not.
  24891. */
  24892. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24893. /**
  24894. * Checks to see if a texture is used in the material.
  24895. * @param defines the list of "defines" to update.
  24896. * @param scene defines the scene to the material belongs to.
  24897. */
  24898. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24899. /**
  24900. * Binds the material data.
  24901. * @param uniformBuffer defines the Uniform buffer to fill in.
  24902. * @param scene defines the scene the material belongs to.
  24903. * @param engine defines the engine the material belongs to.
  24904. * @param disableBumpMap defines wether the material disables bump or not.
  24905. * @param isFrozen defines wether the material is frozen or not.
  24906. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24907. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24908. * @param subMesh the submesh to bind data for
  24909. */
  24910. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24911. /**
  24912. * Checks to see if a texture is used in the material.
  24913. * @param texture - Base texture to use.
  24914. * @returns - Boolean specifying if a texture is used in the material.
  24915. */
  24916. hasTexture(texture: BaseTexture): boolean;
  24917. /**
  24918. * Returns an array of the actively used textures.
  24919. * @param activeTextures Array of BaseTextures
  24920. */
  24921. getActiveTextures(activeTextures: BaseTexture[]): void;
  24922. /**
  24923. * Returns the animatable textures.
  24924. * @param animatables Array of animatable textures.
  24925. */
  24926. getAnimatables(animatables: IAnimatable[]): void;
  24927. /**
  24928. * Disposes the resources of the material.
  24929. * @param forceDisposeTextures - Forces the disposal of all textures.
  24930. */
  24931. dispose(forceDisposeTextures?: boolean): void;
  24932. /**
  24933. * Get the current class name of the texture useful for serialization or dynamic coding.
  24934. * @returns "PBRClearCoatConfiguration"
  24935. */
  24936. getClassName(): string;
  24937. /**
  24938. * Add fallbacks to the effect fallbacks list.
  24939. * @param defines defines the Base texture to use.
  24940. * @param fallbacks defines the current fallback list.
  24941. * @param currentRank defines the current fallback rank.
  24942. * @returns the new fallback rank.
  24943. */
  24944. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24945. /**
  24946. * Add the required uniforms to the current list.
  24947. * @param uniforms defines the current uniform list.
  24948. */
  24949. static AddUniforms(uniforms: string[]): void;
  24950. /**
  24951. * Add the required samplers to the current list.
  24952. * @param samplers defines the current sampler list.
  24953. */
  24954. static AddSamplers(samplers: string[]): void;
  24955. /**
  24956. * Add the required uniforms to the current buffer.
  24957. * @param uniformBuffer defines the current uniform buffer.
  24958. */
  24959. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24960. /**
  24961. * Makes a duplicate of the current configuration into another one.
  24962. * @param clearCoatConfiguration define the config where to copy the info
  24963. */
  24964. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24965. /**
  24966. * Serializes this clear coat configuration.
  24967. * @returns - An object with the serialized config.
  24968. */
  24969. serialize(): any;
  24970. /**
  24971. * Parses a anisotropy Configuration from a serialized object.
  24972. * @param source - Serialized object.
  24973. * @param scene Defines the scene we are parsing for
  24974. * @param rootUrl Defines the rootUrl to load from
  24975. */
  24976. parse(source: any, scene: Scene, rootUrl: string): void;
  24977. }
  24978. }
  24979. declare module BABYLON {
  24980. /**
  24981. * @hidden
  24982. */
  24983. export interface IMaterialAnisotropicDefines {
  24984. ANISOTROPIC: boolean;
  24985. ANISOTROPIC_TEXTURE: boolean;
  24986. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24987. MAINUV1: boolean;
  24988. _areTexturesDirty: boolean;
  24989. _needUVs: boolean;
  24990. }
  24991. /**
  24992. * Define the code related to the anisotropic parameters of the pbr material.
  24993. */
  24994. export class PBRAnisotropicConfiguration {
  24995. private _isEnabled;
  24996. /**
  24997. * Defines if the anisotropy is enabled in the material.
  24998. */
  24999. isEnabled: boolean;
  25000. /**
  25001. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25002. */
  25003. intensity: number;
  25004. /**
  25005. * Defines if the effect is along the tangents, bitangents or in between.
  25006. * By default, the effect is "strectching" the highlights along the tangents.
  25007. */
  25008. direction: Vector2;
  25009. private _texture;
  25010. /**
  25011. * Stores the anisotropy values in a texture.
  25012. * rg is direction (like normal from -1 to 1)
  25013. * b is a intensity
  25014. */
  25015. texture: Nullable<BaseTexture>;
  25016. /** @hidden */
  25017. private _internalMarkAllSubMeshesAsTexturesDirty;
  25018. /** @hidden */
  25019. _markAllSubMeshesAsTexturesDirty(): void;
  25020. /**
  25021. * Instantiate a new istance of anisotropy configuration.
  25022. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25023. */
  25024. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25025. /**
  25026. * Specifies that the submesh is ready to be used.
  25027. * @param defines the list of "defines" to update.
  25028. * @param scene defines the scene the material belongs to.
  25029. * @returns - boolean indicating that the submesh is ready or not.
  25030. */
  25031. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25032. /**
  25033. * Checks to see if a texture is used in the material.
  25034. * @param defines the list of "defines" to update.
  25035. * @param mesh the mesh we are preparing the defines for.
  25036. * @param scene defines the scene the material belongs to.
  25037. */
  25038. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25039. /**
  25040. * Binds the material data.
  25041. * @param uniformBuffer defines the Uniform buffer to fill in.
  25042. * @param scene defines the scene the material belongs to.
  25043. * @param isFrozen defines wether the material is frozen or not.
  25044. */
  25045. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25046. /**
  25047. * Checks to see if a texture is used in the material.
  25048. * @param texture - Base texture to use.
  25049. * @returns - Boolean specifying if a texture is used in the material.
  25050. */
  25051. hasTexture(texture: BaseTexture): boolean;
  25052. /**
  25053. * Returns an array of the actively used textures.
  25054. * @param activeTextures Array of BaseTextures
  25055. */
  25056. getActiveTextures(activeTextures: BaseTexture[]): void;
  25057. /**
  25058. * Returns the animatable textures.
  25059. * @param animatables Array of animatable textures.
  25060. */
  25061. getAnimatables(animatables: IAnimatable[]): void;
  25062. /**
  25063. * Disposes the resources of the material.
  25064. * @param forceDisposeTextures - Forces the disposal of all textures.
  25065. */
  25066. dispose(forceDisposeTextures?: boolean): void;
  25067. /**
  25068. * Get the current class name of the texture useful for serialization or dynamic coding.
  25069. * @returns "PBRAnisotropicConfiguration"
  25070. */
  25071. getClassName(): string;
  25072. /**
  25073. * Add fallbacks to the effect fallbacks list.
  25074. * @param defines defines the Base texture to use.
  25075. * @param fallbacks defines the current fallback list.
  25076. * @param currentRank defines the current fallback rank.
  25077. * @returns the new fallback rank.
  25078. */
  25079. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25080. /**
  25081. * Add the required uniforms to the current list.
  25082. * @param uniforms defines the current uniform list.
  25083. */
  25084. static AddUniforms(uniforms: string[]): void;
  25085. /**
  25086. * Add the required uniforms to the current buffer.
  25087. * @param uniformBuffer defines the current uniform buffer.
  25088. */
  25089. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25090. /**
  25091. * Add the required samplers to the current list.
  25092. * @param samplers defines the current sampler list.
  25093. */
  25094. static AddSamplers(samplers: string[]): void;
  25095. /**
  25096. * Makes a duplicate of the current configuration into another one.
  25097. * @param anisotropicConfiguration define the config where to copy the info
  25098. */
  25099. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25100. /**
  25101. * Serializes this anisotropy configuration.
  25102. * @returns - An object with the serialized config.
  25103. */
  25104. serialize(): any;
  25105. /**
  25106. * Parses a anisotropy Configuration from a serialized object.
  25107. * @param source - Serialized object.
  25108. * @param scene Defines the scene we are parsing for
  25109. * @param rootUrl Defines the rootUrl to load from
  25110. */
  25111. parse(source: any, scene: Scene, rootUrl: string): void;
  25112. }
  25113. }
  25114. declare module BABYLON {
  25115. /**
  25116. * @hidden
  25117. */
  25118. export interface IMaterialBRDFDefines {
  25119. BRDF_V_HEIGHT_CORRELATED: boolean;
  25120. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25121. SPHERICAL_HARMONICS: boolean;
  25122. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25123. /** @hidden */
  25124. _areMiscDirty: boolean;
  25125. }
  25126. /**
  25127. * Define the code related to the BRDF parameters of the pbr material.
  25128. */
  25129. export class PBRBRDFConfiguration {
  25130. /**
  25131. * Default value used for the energy conservation.
  25132. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25133. */
  25134. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25135. /**
  25136. * Default value used for the Smith Visibility Height Correlated mode.
  25137. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25138. */
  25139. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25140. /**
  25141. * Default value used for the IBL diffuse part.
  25142. * This can help switching back to the polynomials mode globally which is a tiny bit
  25143. * less GPU intensive at the drawback of a lower quality.
  25144. */
  25145. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25146. /**
  25147. * Default value used for activating energy conservation for the specular workflow.
  25148. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25149. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25150. */
  25151. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25152. private _useEnergyConservation;
  25153. /**
  25154. * Defines if the material uses energy conservation.
  25155. */
  25156. useEnergyConservation: boolean;
  25157. private _useSmithVisibilityHeightCorrelated;
  25158. /**
  25159. * LEGACY Mode set to false
  25160. * Defines if the material uses height smith correlated visibility term.
  25161. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25162. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25163. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25164. * Not relying on height correlated will also disable energy conservation.
  25165. */
  25166. useSmithVisibilityHeightCorrelated: boolean;
  25167. private _useSphericalHarmonics;
  25168. /**
  25169. * LEGACY Mode set to false
  25170. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25171. * diffuse part of the IBL.
  25172. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25173. * to the ground truth.
  25174. */
  25175. useSphericalHarmonics: boolean;
  25176. private _useSpecularGlossinessInputEnergyConservation;
  25177. /**
  25178. * Defines if the material uses energy conservation, when the specular workflow is active.
  25179. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25180. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25181. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25182. */
  25183. useSpecularGlossinessInputEnergyConservation: boolean;
  25184. /** @hidden */
  25185. private _internalMarkAllSubMeshesAsMiscDirty;
  25186. /** @hidden */
  25187. _markAllSubMeshesAsMiscDirty(): void;
  25188. /**
  25189. * Instantiate a new istance of clear coat configuration.
  25190. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25191. */
  25192. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25193. /**
  25194. * Checks to see if a texture is used in the material.
  25195. * @param defines the list of "defines" to update.
  25196. */
  25197. prepareDefines(defines: IMaterialBRDFDefines): void;
  25198. /**
  25199. * Get the current class name of the texture useful for serialization or dynamic coding.
  25200. * @returns "PBRClearCoatConfiguration"
  25201. */
  25202. getClassName(): string;
  25203. /**
  25204. * Makes a duplicate of the current configuration into another one.
  25205. * @param brdfConfiguration define the config where to copy the info
  25206. */
  25207. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25208. /**
  25209. * Serializes this BRDF configuration.
  25210. * @returns - An object with the serialized config.
  25211. */
  25212. serialize(): any;
  25213. /**
  25214. * Parses a anisotropy Configuration from a serialized object.
  25215. * @param source - Serialized object.
  25216. * @param scene Defines the scene we are parsing for
  25217. * @param rootUrl Defines the rootUrl to load from
  25218. */
  25219. parse(source: any, scene: Scene, rootUrl: string): void;
  25220. }
  25221. }
  25222. declare module BABYLON {
  25223. /**
  25224. * @hidden
  25225. */
  25226. export interface IMaterialSheenDefines {
  25227. SHEEN: boolean;
  25228. SHEEN_TEXTURE: boolean;
  25229. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25230. SHEEN_TEXTUREDIRECTUV: number;
  25231. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25232. SHEEN_LINKWITHALBEDO: boolean;
  25233. SHEEN_ROUGHNESS: boolean;
  25234. SHEEN_ALBEDOSCALING: boolean;
  25235. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25236. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25237. /** @hidden */
  25238. _areTexturesDirty: boolean;
  25239. }
  25240. /**
  25241. * Define the code related to the Sheen parameters of the pbr material.
  25242. */
  25243. export class PBRSheenConfiguration {
  25244. private _isEnabled;
  25245. /**
  25246. * Defines if the material uses sheen.
  25247. */
  25248. isEnabled: boolean;
  25249. private _linkSheenWithAlbedo;
  25250. /**
  25251. * Defines if the sheen is linked to the sheen color.
  25252. */
  25253. linkSheenWithAlbedo: boolean;
  25254. /**
  25255. * Defines the sheen intensity.
  25256. */
  25257. intensity: number;
  25258. /**
  25259. * Defines the sheen color.
  25260. */
  25261. color: Color3;
  25262. private _texture;
  25263. /**
  25264. * Stores the sheen tint values in a texture.
  25265. * rgb is tint
  25266. * 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)
  25267. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25268. */
  25269. texture: Nullable<BaseTexture>;
  25270. private _useRoughnessFromMainTexture;
  25271. /**
  25272. * Indicates that the alpha channel of the texture property will be used for roughness.
  25273. * Has no effect if the roughness (and texture!) property is not defined
  25274. */
  25275. useRoughnessFromMainTexture: boolean;
  25276. private _roughness;
  25277. /**
  25278. * Defines the sheen roughness.
  25279. * It is not taken into account if linkSheenWithAlbedo is true.
  25280. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25281. */
  25282. roughness: Nullable<number>;
  25283. private _textureRoughness;
  25284. /**
  25285. * Stores the sheen roughness in a texture.
  25286. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25287. */
  25288. textureRoughness: Nullable<BaseTexture>;
  25289. private _albedoScaling;
  25290. /**
  25291. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25292. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25293. * making it easier to setup and tweak the effect
  25294. */
  25295. albedoScaling: boolean;
  25296. /** @hidden */
  25297. private _internalMarkAllSubMeshesAsTexturesDirty;
  25298. /** @hidden */
  25299. _markAllSubMeshesAsTexturesDirty(): void;
  25300. /**
  25301. * Instantiate a new istance of clear coat configuration.
  25302. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25303. */
  25304. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25305. /**
  25306. * Specifies that the submesh is ready to be used.
  25307. * @param defines the list of "defines" to update.
  25308. * @param scene defines the scene the material belongs to.
  25309. * @returns - boolean indicating that the submesh is ready or not.
  25310. */
  25311. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25312. /**
  25313. * Checks to see if a texture is used in the material.
  25314. * @param defines the list of "defines" to update.
  25315. * @param scene defines the scene the material belongs to.
  25316. */
  25317. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25318. /**
  25319. * Binds the material data.
  25320. * @param uniformBuffer defines the Uniform buffer to fill in.
  25321. * @param scene defines the scene the material belongs to.
  25322. * @param isFrozen defines wether the material is frozen or not.
  25323. * @param subMesh the submesh to bind data for
  25324. */
  25325. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25326. /**
  25327. * Checks to see if a texture is used in the material.
  25328. * @param texture - Base texture to use.
  25329. * @returns - Boolean specifying if a texture is used in the material.
  25330. */
  25331. hasTexture(texture: BaseTexture): boolean;
  25332. /**
  25333. * Returns an array of the actively used textures.
  25334. * @param activeTextures Array of BaseTextures
  25335. */
  25336. getActiveTextures(activeTextures: BaseTexture[]): void;
  25337. /**
  25338. * Returns the animatable textures.
  25339. * @param animatables Array of animatable textures.
  25340. */
  25341. getAnimatables(animatables: IAnimatable[]): void;
  25342. /**
  25343. * Disposes the resources of the material.
  25344. * @param forceDisposeTextures - Forces the disposal of all textures.
  25345. */
  25346. dispose(forceDisposeTextures?: boolean): void;
  25347. /**
  25348. * Get the current class name of the texture useful for serialization or dynamic coding.
  25349. * @returns "PBRSheenConfiguration"
  25350. */
  25351. getClassName(): string;
  25352. /**
  25353. * Add fallbacks to the effect fallbacks list.
  25354. * @param defines defines the Base texture to use.
  25355. * @param fallbacks defines the current fallback list.
  25356. * @param currentRank defines the current fallback rank.
  25357. * @returns the new fallback rank.
  25358. */
  25359. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25360. /**
  25361. * Add the required uniforms to the current list.
  25362. * @param uniforms defines the current uniform list.
  25363. */
  25364. static AddUniforms(uniforms: string[]): void;
  25365. /**
  25366. * Add the required uniforms to the current buffer.
  25367. * @param uniformBuffer defines the current uniform buffer.
  25368. */
  25369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25370. /**
  25371. * Add the required samplers to the current list.
  25372. * @param samplers defines the current sampler list.
  25373. */
  25374. static AddSamplers(samplers: string[]): void;
  25375. /**
  25376. * Makes a duplicate of the current configuration into another one.
  25377. * @param sheenConfiguration define the config where to copy the info
  25378. */
  25379. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25380. /**
  25381. * Serializes this BRDF configuration.
  25382. * @returns - An object with the serialized config.
  25383. */
  25384. serialize(): any;
  25385. /**
  25386. * Parses a anisotropy Configuration from a serialized object.
  25387. * @param source - Serialized object.
  25388. * @param scene Defines the scene we are parsing for
  25389. * @param rootUrl Defines the rootUrl to load from
  25390. */
  25391. parse(source: any, scene: Scene, rootUrl: string): void;
  25392. }
  25393. }
  25394. declare module BABYLON {
  25395. /**
  25396. * @hidden
  25397. */
  25398. export interface IMaterialSubSurfaceDefines {
  25399. SUBSURFACE: boolean;
  25400. SS_REFRACTION: boolean;
  25401. SS_TRANSLUCENCY: boolean;
  25402. SS_SCATTERING: boolean;
  25403. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25404. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25405. SS_REFRACTIONMAP_3D: boolean;
  25406. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25407. SS_LODINREFRACTIONALPHA: boolean;
  25408. SS_GAMMAREFRACTION: boolean;
  25409. SS_RGBDREFRACTION: boolean;
  25410. SS_LINEARSPECULARREFRACTION: boolean;
  25411. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25412. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25413. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25414. /** @hidden */
  25415. _areTexturesDirty: boolean;
  25416. }
  25417. /**
  25418. * Define the code related to the sub surface parameters of the pbr material.
  25419. */
  25420. export class PBRSubSurfaceConfiguration {
  25421. private _isRefractionEnabled;
  25422. /**
  25423. * Defines if the refraction is enabled in the material.
  25424. */
  25425. isRefractionEnabled: boolean;
  25426. private _isTranslucencyEnabled;
  25427. /**
  25428. * Defines if the translucency is enabled in the material.
  25429. */
  25430. isTranslucencyEnabled: boolean;
  25431. private _isScatteringEnabled;
  25432. /**
  25433. * Defines if the sub surface scattering is enabled in the material.
  25434. */
  25435. isScatteringEnabled: boolean;
  25436. private _scatteringDiffusionProfileIndex;
  25437. /**
  25438. * Diffusion profile for subsurface scattering.
  25439. * Useful for better scattering in the skins or foliages.
  25440. */
  25441. get scatteringDiffusionProfile(): Nullable<Color3>;
  25442. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25443. /**
  25444. * Defines the refraction intensity of the material.
  25445. * The refraction when enabled replaces the Diffuse part of the material.
  25446. * The intensity helps transitionning between diffuse and refraction.
  25447. */
  25448. refractionIntensity: number;
  25449. /**
  25450. * Defines the translucency intensity of the material.
  25451. * When translucency has been enabled, this defines how much of the "translucency"
  25452. * is addded to the diffuse part of the material.
  25453. */
  25454. translucencyIntensity: number;
  25455. /**
  25456. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25457. */
  25458. useAlbedoToTintRefraction: boolean;
  25459. private _thicknessTexture;
  25460. /**
  25461. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25462. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25463. * 0 would mean minimumThickness
  25464. * 1 would mean maximumThickness
  25465. * The other channels might be use as a mask to vary the different effects intensity.
  25466. */
  25467. thicknessTexture: Nullable<BaseTexture>;
  25468. private _refractionTexture;
  25469. /**
  25470. * Defines the texture to use for refraction.
  25471. */
  25472. refractionTexture: Nullable<BaseTexture>;
  25473. private _indexOfRefraction;
  25474. /**
  25475. * Index of refraction of the material base layer.
  25476. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25477. *
  25478. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25479. *
  25480. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25481. */
  25482. indexOfRefraction: number;
  25483. private _volumeIndexOfRefraction;
  25484. /**
  25485. * Index of refraction of the material's volume.
  25486. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25487. *
  25488. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25489. * the volume will use the same IOR as the surface.
  25490. */
  25491. get volumeIndexOfRefraction(): number;
  25492. set volumeIndexOfRefraction(value: number);
  25493. private _invertRefractionY;
  25494. /**
  25495. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25496. */
  25497. invertRefractionY: boolean;
  25498. private _linkRefractionWithTransparency;
  25499. /**
  25500. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25501. * Materials half opaque for instance using refraction could benefit from this control.
  25502. */
  25503. linkRefractionWithTransparency: boolean;
  25504. /**
  25505. * Defines the minimum thickness stored in the thickness map.
  25506. * If no thickness map is defined, this value will be used to simulate thickness.
  25507. */
  25508. minimumThickness: number;
  25509. /**
  25510. * Defines the maximum thickness stored in the thickness map.
  25511. */
  25512. maximumThickness: number;
  25513. /**
  25514. * Defines the volume tint of the material.
  25515. * This is used for both translucency and scattering.
  25516. */
  25517. tintColor: Color3;
  25518. /**
  25519. * Defines the distance at which the tint color should be found in the media.
  25520. * This is used for refraction only.
  25521. */
  25522. tintColorAtDistance: number;
  25523. /**
  25524. * Defines how far each channel transmit through the media.
  25525. * It is defined as a color to simplify it selection.
  25526. */
  25527. diffusionDistance: Color3;
  25528. private _useMaskFromThicknessTexture;
  25529. /**
  25530. * Stores the intensity of the different subsurface effects in the thickness texture.
  25531. * * the green channel is the translucency intensity.
  25532. * * the blue channel is the scattering intensity.
  25533. * * the alpha channel is the refraction intensity.
  25534. */
  25535. useMaskFromThicknessTexture: boolean;
  25536. private _scene;
  25537. /** @hidden */
  25538. private _internalMarkAllSubMeshesAsTexturesDirty;
  25539. private _internalMarkScenePrePassDirty;
  25540. /** @hidden */
  25541. _markAllSubMeshesAsTexturesDirty(): void;
  25542. /** @hidden */
  25543. _markScenePrePassDirty(): void;
  25544. /**
  25545. * Instantiate a new istance of sub surface configuration.
  25546. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25547. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25548. * @param scene The scene
  25549. */
  25550. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25551. /**
  25552. * Gets wehter the submesh is ready to be used or not.
  25553. * @param defines the list of "defines" to update.
  25554. * @param scene defines the scene the material belongs to.
  25555. * @returns - boolean indicating that the submesh is ready or not.
  25556. */
  25557. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25558. /**
  25559. * Checks to see if a texture is used in the material.
  25560. * @param defines the list of "defines" to update.
  25561. * @param scene defines the scene to the material belongs to.
  25562. */
  25563. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25564. /**
  25565. * Binds the material data.
  25566. * @param uniformBuffer defines the Uniform buffer to fill in.
  25567. * @param scene defines the scene the material belongs to.
  25568. * @param engine defines the engine the material belongs to.
  25569. * @param isFrozen defines whether the material is frozen or not.
  25570. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25571. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25572. */
  25573. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25574. /**
  25575. * Unbinds the material from the mesh.
  25576. * @param activeEffect defines the effect that should be unbound from.
  25577. * @returns true if unbound, otherwise false
  25578. */
  25579. unbind(activeEffect: Effect): boolean;
  25580. /**
  25581. * Returns the texture used for refraction or null if none is used.
  25582. * @param scene defines the scene the material belongs to.
  25583. * @returns - Refraction texture if present. If no refraction texture and refraction
  25584. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25585. */
  25586. private _getRefractionTexture;
  25587. /**
  25588. * Returns true if alpha blending should be disabled.
  25589. */
  25590. get disableAlphaBlending(): boolean;
  25591. /**
  25592. * Fills the list of render target textures.
  25593. * @param renderTargets the list of render targets to update
  25594. */
  25595. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25596. /**
  25597. * Checks to see if a texture is used in the material.
  25598. * @param texture - Base texture to use.
  25599. * @returns - Boolean specifying if a texture is used in the material.
  25600. */
  25601. hasTexture(texture: BaseTexture): boolean;
  25602. /**
  25603. * Gets a boolean indicating that current material needs to register RTT
  25604. * @returns true if this uses a render target otherwise false.
  25605. */
  25606. hasRenderTargetTextures(): boolean;
  25607. /**
  25608. * Returns an array of the actively used textures.
  25609. * @param activeTextures Array of BaseTextures
  25610. */
  25611. getActiveTextures(activeTextures: BaseTexture[]): void;
  25612. /**
  25613. * Returns the animatable textures.
  25614. * @param animatables Array of animatable textures.
  25615. */
  25616. getAnimatables(animatables: IAnimatable[]): void;
  25617. /**
  25618. * Disposes the resources of the material.
  25619. * @param forceDisposeTextures - Forces the disposal of all textures.
  25620. */
  25621. dispose(forceDisposeTextures?: boolean): void;
  25622. /**
  25623. * Get the current class name of the texture useful for serialization or dynamic coding.
  25624. * @returns "PBRSubSurfaceConfiguration"
  25625. */
  25626. getClassName(): string;
  25627. /**
  25628. * Add fallbacks to the effect fallbacks list.
  25629. * @param defines defines the Base texture to use.
  25630. * @param fallbacks defines the current fallback list.
  25631. * @param currentRank defines the current fallback rank.
  25632. * @returns the new fallback rank.
  25633. */
  25634. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25635. /**
  25636. * Add the required uniforms to the current list.
  25637. * @param uniforms defines the current uniform list.
  25638. */
  25639. static AddUniforms(uniforms: string[]): void;
  25640. /**
  25641. * Add the required samplers to the current list.
  25642. * @param samplers defines the current sampler list.
  25643. */
  25644. static AddSamplers(samplers: string[]): void;
  25645. /**
  25646. * Add the required uniforms to the current buffer.
  25647. * @param uniformBuffer defines the current uniform buffer.
  25648. */
  25649. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25650. /**
  25651. * Makes a duplicate of the current configuration into another one.
  25652. * @param configuration define the config where to copy the info
  25653. */
  25654. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25655. /**
  25656. * Serializes this Sub Surface configuration.
  25657. * @returns - An object with the serialized config.
  25658. */
  25659. serialize(): any;
  25660. /**
  25661. * Parses a anisotropy Configuration from a serialized object.
  25662. * @param source - Serialized object.
  25663. * @param scene Defines the scene we are parsing for
  25664. * @param rootUrl Defines the rootUrl to load from
  25665. */
  25666. parse(source: any, scene: Scene, rootUrl: string): void;
  25667. }
  25668. }
  25669. declare module BABYLON {
  25670. /**
  25671. * Class representing spherical harmonics coefficients to the 3rd degree
  25672. */
  25673. export class SphericalHarmonics {
  25674. /**
  25675. * Defines whether or not the harmonics have been prescaled for rendering.
  25676. */
  25677. preScaled: boolean;
  25678. /**
  25679. * The l0,0 coefficients of the spherical harmonics
  25680. */
  25681. l00: Vector3;
  25682. /**
  25683. * The l1,-1 coefficients of the spherical harmonics
  25684. */
  25685. l1_1: Vector3;
  25686. /**
  25687. * The l1,0 coefficients of the spherical harmonics
  25688. */
  25689. l10: Vector3;
  25690. /**
  25691. * The l1,1 coefficients of the spherical harmonics
  25692. */
  25693. l11: Vector3;
  25694. /**
  25695. * The l2,-2 coefficients of the spherical harmonics
  25696. */
  25697. l2_2: Vector3;
  25698. /**
  25699. * The l2,-1 coefficients of the spherical harmonics
  25700. */
  25701. l2_1: Vector3;
  25702. /**
  25703. * The l2,0 coefficients of the spherical harmonics
  25704. */
  25705. l20: Vector3;
  25706. /**
  25707. * The l2,1 coefficients of the spherical harmonics
  25708. */
  25709. l21: Vector3;
  25710. /**
  25711. * The l2,2 coefficients of the spherical harmonics
  25712. */
  25713. l22: Vector3;
  25714. /**
  25715. * Adds a light to the spherical harmonics
  25716. * @param direction the direction of the light
  25717. * @param color the color of the light
  25718. * @param deltaSolidAngle the delta solid angle of the light
  25719. */
  25720. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25721. /**
  25722. * Scales the spherical harmonics by the given amount
  25723. * @param scale the amount to scale
  25724. */
  25725. scaleInPlace(scale: number): void;
  25726. /**
  25727. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25728. *
  25729. * ```
  25730. * E_lm = A_l * L_lm
  25731. * ```
  25732. *
  25733. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25734. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25735. * the scaling factors are given in equation 9.
  25736. */
  25737. convertIncidentRadianceToIrradiance(): void;
  25738. /**
  25739. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25740. *
  25741. * ```
  25742. * L = (1/pi) * E * rho
  25743. * ```
  25744. *
  25745. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25746. */
  25747. convertIrradianceToLambertianRadiance(): void;
  25748. /**
  25749. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25750. * required operations at run time.
  25751. *
  25752. * This is simply done by scaling back the SH with Ylm constants parameter.
  25753. * The trigonometric part being applied by the shader at run time.
  25754. */
  25755. preScaleForRendering(): void;
  25756. /**
  25757. * Constructs a spherical harmonics from an array.
  25758. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25759. * @returns the spherical harmonics
  25760. */
  25761. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25762. /**
  25763. * Gets the spherical harmonics from polynomial
  25764. * @param polynomial the spherical polynomial
  25765. * @returns the spherical harmonics
  25766. */
  25767. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25768. }
  25769. /**
  25770. * Class representing spherical polynomial coefficients to the 3rd degree
  25771. */
  25772. export class SphericalPolynomial {
  25773. private _harmonics;
  25774. /**
  25775. * The spherical harmonics used to create the polynomials.
  25776. */
  25777. get preScaledHarmonics(): SphericalHarmonics;
  25778. /**
  25779. * The x coefficients of the spherical polynomial
  25780. */
  25781. x: Vector3;
  25782. /**
  25783. * The y coefficients of the spherical polynomial
  25784. */
  25785. y: Vector3;
  25786. /**
  25787. * The z coefficients of the spherical polynomial
  25788. */
  25789. z: Vector3;
  25790. /**
  25791. * The xx coefficients of the spherical polynomial
  25792. */
  25793. xx: Vector3;
  25794. /**
  25795. * The yy coefficients of the spherical polynomial
  25796. */
  25797. yy: Vector3;
  25798. /**
  25799. * The zz coefficients of the spherical polynomial
  25800. */
  25801. zz: Vector3;
  25802. /**
  25803. * The xy coefficients of the spherical polynomial
  25804. */
  25805. xy: Vector3;
  25806. /**
  25807. * The yz coefficients of the spherical polynomial
  25808. */
  25809. yz: Vector3;
  25810. /**
  25811. * The zx coefficients of the spherical polynomial
  25812. */
  25813. zx: Vector3;
  25814. /**
  25815. * Adds an ambient color to the spherical polynomial
  25816. * @param color the color to add
  25817. */
  25818. addAmbient(color: Color3): void;
  25819. /**
  25820. * Scales the spherical polynomial by the given amount
  25821. * @param scale the amount to scale
  25822. */
  25823. scaleInPlace(scale: number): void;
  25824. /**
  25825. * Gets the spherical polynomial from harmonics
  25826. * @param harmonics the spherical harmonics
  25827. * @returns the spherical polynomial
  25828. */
  25829. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25830. /**
  25831. * Constructs a spherical polynomial from an array.
  25832. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25833. * @returns the spherical polynomial
  25834. */
  25835. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25836. }
  25837. }
  25838. declare module BABYLON {
  25839. /**
  25840. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25841. */
  25842. export interface CubeMapInfo {
  25843. /**
  25844. * The pixel array for the front face.
  25845. * This is stored in format, left to right, up to down format.
  25846. */
  25847. front: Nullable<ArrayBufferView>;
  25848. /**
  25849. * The pixel array for the back face.
  25850. * This is stored in format, left to right, up to down format.
  25851. */
  25852. back: Nullable<ArrayBufferView>;
  25853. /**
  25854. * The pixel array for the left face.
  25855. * This is stored in format, left to right, up to down format.
  25856. */
  25857. left: Nullable<ArrayBufferView>;
  25858. /**
  25859. * The pixel array for the right face.
  25860. * This is stored in format, left to right, up to down format.
  25861. */
  25862. right: Nullable<ArrayBufferView>;
  25863. /**
  25864. * The pixel array for the up face.
  25865. * This is stored in format, left to right, up to down format.
  25866. */
  25867. up: Nullable<ArrayBufferView>;
  25868. /**
  25869. * The pixel array for the down face.
  25870. * This is stored in format, left to right, up to down format.
  25871. */
  25872. down: Nullable<ArrayBufferView>;
  25873. /**
  25874. * The size of the cubemap stored.
  25875. *
  25876. * Each faces will be size * size pixels.
  25877. */
  25878. size: number;
  25879. /**
  25880. * The format of the texture.
  25881. *
  25882. * RGBA, RGB.
  25883. */
  25884. format: number;
  25885. /**
  25886. * The type of the texture data.
  25887. *
  25888. * UNSIGNED_INT, FLOAT.
  25889. */
  25890. type: number;
  25891. /**
  25892. * Specifies whether the texture is in gamma space.
  25893. */
  25894. gammaSpace: boolean;
  25895. }
  25896. /**
  25897. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25898. */
  25899. export class PanoramaToCubeMapTools {
  25900. private static FACE_LEFT;
  25901. private static FACE_RIGHT;
  25902. private static FACE_FRONT;
  25903. private static FACE_BACK;
  25904. private static FACE_DOWN;
  25905. private static FACE_UP;
  25906. /**
  25907. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25908. *
  25909. * @param float32Array The source data.
  25910. * @param inputWidth The width of the input panorama.
  25911. * @param inputHeight The height of the input panorama.
  25912. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25913. * @return The cubemap data
  25914. */
  25915. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25916. private static CreateCubemapTexture;
  25917. private static CalcProjectionSpherical;
  25918. }
  25919. }
  25920. declare module BABYLON {
  25921. /**
  25922. * Helper class dealing with the extraction of spherical polynomial dataArray
  25923. * from a cube map.
  25924. */
  25925. export class CubeMapToSphericalPolynomialTools {
  25926. private static FileFaces;
  25927. /**
  25928. * Converts a texture to the according Spherical Polynomial data.
  25929. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25930. *
  25931. * @param texture The texture to extract the information from.
  25932. * @return The Spherical Polynomial data.
  25933. */
  25934. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25935. /**
  25936. * Converts a cubemap to the according Spherical Polynomial data.
  25937. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25938. *
  25939. * @param cubeInfo The Cube map to extract the information from.
  25940. * @return The Spherical Polynomial data.
  25941. */
  25942. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25943. }
  25944. }
  25945. declare module BABYLON {
  25946. interface BaseTexture {
  25947. /**
  25948. * Get the polynomial representation of the texture data.
  25949. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25950. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25951. */
  25952. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25953. }
  25954. }
  25955. declare module BABYLON {
  25956. /** @hidden */
  25957. export var pbrFragmentDeclaration: {
  25958. name: string;
  25959. shader: string;
  25960. };
  25961. }
  25962. declare module BABYLON {
  25963. /** @hidden */
  25964. export var pbrUboDeclaration: {
  25965. name: string;
  25966. shader: string;
  25967. };
  25968. }
  25969. declare module BABYLON {
  25970. /** @hidden */
  25971. export var pbrFragmentExtraDeclaration: {
  25972. name: string;
  25973. shader: string;
  25974. };
  25975. }
  25976. declare module BABYLON {
  25977. /** @hidden */
  25978. export var pbrFragmentSamplersDeclaration: {
  25979. name: string;
  25980. shader: string;
  25981. };
  25982. }
  25983. declare module BABYLON {
  25984. /** @hidden */
  25985. export var subSurfaceScatteringFunctions: {
  25986. name: string;
  25987. shader: string;
  25988. };
  25989. }
  25990. declare module BABYLON {
  25991. /** @hidden */
  25992. export var importanceSampling: {
  25993. name: string;
  25994. shader: string;
  25995. };
  25996. }
  25997. declare module BABYLON {
  25998. /** @hidden */
  25999. export var pbrHelperFunctions: {
  26000. name: string;
  26001. shader: string;
  26002. };
  26003. }
  26004. declare module BABYLON {
  26005. /** @hidden */
  26006. export var harmonicsFunctions: {
  26007. name: string;
  26008. shader: string;
  26009. };
  26010. }
  26011. declare module BABYLON {
  26012. /** @hidden */
  26013. export var pbrDirectLightingSetupFunctions: {
  26014. name: string;
  26015. shader: string;
  26016. };
  26017. }
  26018. declare module BABYLON {
  26019. /** @hidden */
  26020. export var pbrDirectLightingFalloffFunctions: {
  26021. name: string;
  26022. shader: string;
  26023. };
  26024. }
  26025. declare module BABYLON {
  26026. /** @hidden */
  26027. export var pbrBRDFFunctions: {
  26028. name: string;
  26029. shader: string;
  26030. };
  26031. }
  26032. declare module BABYLON {
  26033. /** @hidden */
  26034. export var hdrFilteringFunctions: {
  26035. name: string;
  26036. shader: string;
  26037. };
  26038. }
  26039. declare module BABYLON {
  26040. /** @hidden */
  26041. export var pbrDirectLightingFunctions: {
  26042. name: string;
  26043. shader: string;
  26044. };
  26045. }
  26046. declare module BABYLON {
  26047. /** @hidden */
  26048. export var pbrIBLFunctions: {
  26049. name: string;
  26050. shader: string;
  26051. };
  26052. }
  26053. declare module BABYLON {
  26054. /** @hidden */
  26055. export var pbrBlockAlbedoOpacity: {
  26056. name: string;
  26057. shader: string;
  26058. };
  26059. }
  26060. declare module BABYLON {
  26061. /** @hidden */
  26062. export var pbrBlockReflectivity: {
  26063. name: string;
  26064. shader: string;
  26065. };
  26066. }
  26067. declare module BABYLON {
  26068. /** @hidden */
  26069. export var pbrBlockAmbientOcclusion: {
  26070. name: string;
  26071. shader: string;
  26072. };
  26073. }
  26074. declare module BABYLON {
  26075. /** @hidden */
  26076. export var pbrBlockAlphaFresnel: {
  26077. name: string;
  26078. shader: string;
  26079. };
  26080. }
  26081. declare module BABYLON {
  26082. /** @hidden */
  26083. export var pbrBlockAnisotropic: {
  26084. name: string;
  26085. shader: string;
  26086. };
  26087. }
  26088. declare module BABYLON {
  26089. /** @hidden */
  26090. export var pbrBlockReflection: {
  26091. name: string;
  26092. shader: string;
  26093. };
  26094. }
  26095. declare module BABYLON {
  26096. /** @hidden */
  26097. export var pbrBlockSheen: {
  26098. name: string;
  26099. shader: string;
  26100. };
  26101. }
  26102. declare module BABYLON {
  26103. /** @hidden */
  26104. export var pbrBlockClearcoat: {
  26105. name: string;
  26106. shader: string;
  26107. };
  26108. }
  26109. declare module BABYLON {
  26110. /** @hidden */
  26111. export var pbrBlockSubSurface: {
  26112. name: string;
  26113. shader: string;
  26114. };
  26115. }
  26116. declare module BABYLON {
  26117. /** @hidden */
  26118. export var pbrBlockNormalGeometric: {
  26119. name: string;
  26120. shader: string;
  26121. };
  26122. }
  26123. declare module BABYLON {
  26124. /** @hidden */
  26125. export var pbrBlockNormalFinal: {
  26126. name: string;
  26127. shader: string;
  26128. };
  26129. }
  26130. declare module BABYLON {
  26131. /** @hidden */
  26132. export var pbrBlockLightmapInit: {
  26133. name: string;
  26134. shader: string;
  26135. };
  26136. }
  26137. declare module BABYLON {
  26138. /** @hidden */
  26139. export var pbrBlockGeometryInfo: {
  26140. name: string;
  26141. shader: string;
  26142. };
  26143. }
  26144. declare module BABYLON {
  26145. /** @hidden */
  26146. export var pbrBlockReflectance0: {
  26147. name: string;
  26148. shader: string;
  26149. };
  26150. }
  26151. declare module BABYLON {
  26152. /** @hidden */
  26153. export var pbrBlockReflectance: {
  26154. name: string;
  26155. shader: string;
  26156. };
  26157. }
  26158. declare module BABYLON {
  26159. /** @hidden */
  26160. export var pbrBlockDirectLighting: {
  26161. name: string;
  26162. shader: string;
  26163. };
  26164. }
  26165. declare module BABYLON {
  26166. /** @hidden */
  26167. export var pbrBlockFinalLitComponents: {
  26168. name: string;
  26169. shader: string;
  26170. };
  26171. }
  26172. declare module BABYLON {
  26173. /** @hidden */
  26174. export var pbrBlockFinalUnlitComponents: {
  26175. name: string;
  26176. shader: string;
  26177. };
  26178. }
  26179. declare module BABYLON {
  26180. /** @hidden */
  26181. export var pbrBlockFinalColorComposition: {
  26182. name: string;
  26183. shader: string;
  26184. };
  26185. }
  26186. declare module BABYLON {
  26187. /** @hidden */
  26188. export var pbrBlockImageProcessing: {
  26189. name: string;
  26190. shader: string;
  26191. };
  26192. }
  26193. declare module BABYLON {
  26194. /** @hidden */
  26195. export var pbrDebug: {
  26196. name: string;
  26197. shader: string;
  26198. };
  26199. }
  26200. declare module BABYLON {
  26201. /** @hidden */
  26202. export var pbrPixelShader: {
  26203. name: string;
  26204. shader: string;
  26205. };
  26206. }
  26207. declare module BABYLON {
  26208. /** @hidden */
  26209. export var pbrVertexDeclaration: {
  26210. name: string;
  26211. shader: string;
  26212. };
  26213. }
  26214. declare module BABYLON {
  26215. /** @hidden */
  26216. export var pbrVertexShader: {
  26217. name: string;
  26218. shader: string;
  26219. };
  26220. }
  26221. declare module BABYLON {
  26222. /**
  26223. * Manages the defines for the PBR Material.
  26224. * @hidden
  26225. */
  26226. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26227. PBR: boolean;
  26228. NUM_SAMPLES: string;
  26229. REALTIME_FILTERING: boolean;
  26230. MAINUV1: boolean;
  26231. MAINUV2: boolean;
  26232. UV1: boolean;
  26233. UV2: boolean;
  26234. ALBEDO: boolean;
  26235. GAMMAALBEDO: boolean;
  26236. ALBEDODIRECTUV: number;
  26237. VERTEXCOLOR: boolean;
  26238. DETAIL: boolean;
  26239. DETAILDIRECTUV: number;
  26240. DETAIL_NORMALBLENDMETHOD: number;
  26241. AMBIENT: boolean;
  26242. AMBIENTDIRECTUV: number;
  26243. AMBIENTINGRAYSCALE: boolean;
  26244. OPACITY: boolean;
  26245. VERTEXALPHA: boolean;
  26246. OPACITYDIRECTUV: number;
  26247. OPACITYRGB: boolean;
  26248. ALPHATEST: boolean;
  26249. DEPTHPREPASS: boolean;
  26250. ALPHABLEND: boolean;
  26251. ALPHAFROMALBEDO: boolean;
  26252. ALPHATESTVALUE: string;
  26253. SPECULAROVERALPHA: boolean;
  26254. RADIANCEOVERALPHA: boolean;
  26255. ALPHAFRESNEL: boolean;
  26256. LINEARALPHAFRESNEL: boolean;
  26257. PREMULTIPLYALPHA: boolean;
  26258. EMISSIVE: boolean;
  26259. EMISSIVEDIRECTUV: number;
  26260. REFLECTIVITY: boolean;
  26261. REFLECTIVITYDIRECTUV: number;
  26262. SPECULARTERM: boolean;
  26263. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26264. MICROSURFACEAUTOMATIC: boolean;
  26265. LODBASEDMICROSFURACE: boolean;
  26266. MICROSURFACEMAP: boolean;
  26267. MICROSURFACEMAPDIRECTUV: number;
  26268. METALLICWORKFLOW: boolean;
  26269. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26270. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26271. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26272. AOSTOREINMETALMAPRED: boolean;
  26273. METALLIC_REFLECTANCE: boolean;
  26274. METALLIC_REFLECTANCEDIRECTUV: number;
  26275. ENVIRONMENTBRDF: boolean;
  26276. ENVIRONMENTBRDF_RGBD: boolean;
  26277. NORMAL: boolean;
  26278. TANGENT: boolean;
  26279. BUMP: boolean;
  26280. BUMPDIRECTUV: number;
  26281. OBJECTSPACE_NORMALMAP: boolean;
  26282. PARALLAX: boolean;
  26283. PARALLAXOCCLUSION: boolean;
  26284. NORMALXYSCALE: boolean;
  26285. LIGHTMAP: boolean;
  26286. LIGHTMAPDIRECTUV: number;
  26287. USELIGHTMAPASSHADOWMAP: boolean;
  26288. GAMMALIGHTMAP: boolean;
  26289. RGBDLIGHTMAP: boolean;
  26290. REFLECTION: boolean;
  26291. REFLECTIONMAP_3D: boolean;
  26292. REFLECTIONMAP_SPHERICAL: boolean;
  26293. REFLECTIONMAP_PLANAR: boolean;
  26294. REFLECTIONMAP_CUBIC: boolean;
  26295. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26296. REFLECTIONMAP_PROJECTION: boolean;
  26297. REFLECTIONMAP_SKYBOX: boolean;
  26298. REFLECTIONMAP_EXPLICIT: boolean;
  26299. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26300. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26301. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26302. INVERTCUBICMAP: boolean;
  26303. USESPHERICALFROMREFLECTIONMAP: boolean;
  26304. USEIRRADIANCEMAP: boolean;
  26305. SPHERICAL_HARMONICS: boolean;
  26306. USESPHERICALINVERTEX: boolean;
  26307. REFLECTIONMAP_OPPOSITEZ: boolean;
  26308. LODINREFLECTIONALPHA: boolean;
  26309. GAMMAREFLECTION: boolean;
  26310. RGBDREFLECTION: boolean;
  26311. LINEARSPECULARREFLECTION: boolean;
  26312. RADIANCEOCCLUSION: boolean;
  26313. HORIZONOCCLUSION: boolean;
  26314. INSTANCES: boolean;
  26315. THIN_INSTANCES: boolean;
  26316. PREPASS: boolean;
  26317. PREPASS_IRRADIANCE: boolean;
  26318. PREPASS_IRRADIANCE_INDEX: number;
  26319. PREPASS_ALBEDO: boolean;
  26320. PREPASS_ALBEDO_INDEX: number;
  26321. PREPASS_DEPTHNORMAL: boolean;
  26322. PREPASS_DEPTHNORMAL_INDEX: number;
  26323. PREPASS_POSITION: boolean;
  26324. PREPASS_POSITION_INDEX: number;
  26325. PREPASS_VELOCITY: boolean;
  26326. PREPASS_VELOCITY_INDEX: number;
  26327. PREPASS_REFLECTIVITY: boolean;
  26328. PREPASS_REFLECTIVITY_INDEX: number;
  26329. SCENE_MRT_COUNT: number;
  26330. NUM_BONE_INFLUENCERS: number;
  26331. BonesPerMesh: number;
  26332. BONETEXTURE: boolean;
  26333. BONES_VELOCITY_ENABLED: boolean;
  26334. NONUNIFORMSCALING: boolean;
  26335. MORPHTARGETS: boolean;
  26336. MORPHTARGETS_NORMAL: boolean;
  26337. MORPHTARGETS_TANGENT: boolean;
  26338. MORPHTARGETS_UV: boolean;
  26339. NUM_MORPH_INFLUENCERS: number;
  26340. IMAGEPROCESSING: boolean;
  26341. VIGNETTE: boolean;
  26342. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26343. VIGNETTEBLENDMODEOPAQUE: boolean;
  26344. TONEMAPPING: boolean;
  26345. TONEMAPPING_ACES: boolean;
  26346. CONTRAST: boolean;
  26347. COLORCURVES: boolean;
  26348. COLORGRADING: boolean;
  26349. COLORGRADING3D: boolean;
  26350. SAMPLER3DGREENDEPTH: boolean;
  26351. SAMPLER3DBGRMAP: boolean;
  26352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26353. EXPOSURE: boolean;
  26354. MULTIVIEW: boolean;
  26355. USEPHYSICALLIGHTFALLOFF: boolean;
  26356. USEGLTFLIGHTFALLOFF: boolean;
  26357. TWOSIDEDLIGHTING: boolean;
  26358. SHADOWFLOAT: boolean;
  26359. CLIPPLANE: boolean;
  26360. CLIPPLANE2: boolean;
  26361. CLIPPLANE3: boolean;
  26362. CLIPPLANE4: boolean;
  26363. CLIPPLANE5: boolean;
  26364. CLIPPLANE6: boolean;
  26365. POINTSIZE: boolean;
  26366. FOG: boolean;
  26367. LOGARITHMICDEPTH: boolean;
  26368. FORCENORMALFORWARD: boolean;
  26369. SPECULARAA: boolean;
  26370. CLEARCOAT: boolean;
  26371. CLEARCOAT_DEFAULTIOR: boolean;
  26372. CLEARCOAT_TEXTURE: boolean;
  26373. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26374. CLEARCOAT_TEXTUREDIRECTUV: number;
  26375. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26376. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26377. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26378. CLEARCOAT_BUMP: boolean;
  26379. CLEARCOAT_BUMPDIRECTUV: number;
  26380. CLEARCOAT_REMAP_F0: boolean;
  26381. CLEARCOAT_TINT: boolean;
  26382. CLEARCOAT_TINT_TEXTURE: boolean;
  26383. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26384. ANISOTROPIC: boolean;
  26385. ANISOTROPIC_TEXTURE: boolean;
  26386. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26387. BRDF_V_HEIGHT_CORRELATED: boolean;
  26388. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26389. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26390. SHEEN: boolean;
  26391. SHEEN_TEXTURE: boolean;
  26392. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26393. SHEEN_TEXTUREDIRECTUV: number;
  26394. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26395. SHEEN_LINKWITHALBEDO: boolean;
  26396. SHEEN_ROUGHNESS: boolean;
  26397. SHEEN_ALBEDOSCALING: boolean;
  26398. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26399. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26400. SUBSURFACE: boolean;
  26401. SS_REFRACTION: boolean;
  26402. SS_TRANSLUCENCY: boolean;
  26403. SS_SCATTERING: boolean;
  26404. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26405. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26406. SS_REFRACTIONMAP_3D: boolean;
  26407. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26408. SS_LODINREFRACTIONALPHA: boolean;
  26409. SS_GAMMAREFRACTION: boolean;
  26410. SS_RGBDREFRACTION: boolean;
  26411. SS_LINEARSPECULARREFRACTION: boolean;
  26412. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26413. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26414. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26415. UNLIT: boolean;
  26416. DEBUGMODE: number;
  26417. /**
  26418. * Initializes the PBR Material defines.
  26419. */
  26420. constructor();
  26421. /**
  26422. * Resets the PBR Material defines.
  26423. */
  26424. reset(): void;
  26425. }
  26426. /**
  26427. * The Physically based material base class of BJS.
  26428. *
  26429. * This offers the main features of a standard PBR material.
  26430. * For more information, please refer to the documentation :
  26431. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26432. */
  26433. export abstract class PBRBaseMaterial extends PushMaterial {
  26434. /**
  26435. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26436. */
  26437. static readonly PBRMATERIAL_OPAQUE: number;
  26438. /**
  26439. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26440. */
  26441. static readonly PBRMATERIAL_ALPHATEST: number;
  26442. /**
  26443. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26444. */
  26445. static readonly PBRMATERIAL_ALPHABLEND: number;
  26446. /**
  26447. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26448. * They are also discarded below the alpha cutoff threshold to improve performances.
  26449. */
  26450. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26451. /**
  26452. * Defines the default value of how much AO map is occluding the analytical lights
  26453. * (point spot...).
  26454. */
  26455. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26456. /**
  26457. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26458. */
  26459. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26460. /**
  26461. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26462. * to enhance interoperability with other engines.
  26463. */
  26464. static readonly LIGHTFALLOFF_GLTF: number;
  26465. /**
  26466. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26467. * to enhance interoperability with other materials.
  26468. */
  26469. static readonly LIGHTFALLOFF_STANDARD: number;
  26470. /**
  26471. * Intensity of the direct lights e.g. the four lights available in your scene.
  26472. * This impacts both the direct diffuse and specular highlights.
  26473. */
  26474. protected _directIntensity: number;
  26475. /**
  26476. * Intensity of the emissive part of the material.
  26477. * This helps controlling the emissive effect without modifying the emissive color.
  26478. */
  26479. protected _emissiveIntensity: number;
  26480. /**
  26481. * Intensity of the environment e.g. how much the environment will light the object
  26482. * either through harmonics for rough material or through the refelction for shiny ones.
  26483. */
  26484. protected _environmentIntensity: number;
  26485. /**
  26486. * This is a special control allowing the reduction of the specular highlights coming from the
  26487. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26488. */
  26489. protected _specularIntensity: number;
  26490. /**
  26491. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26492. */
  26493. private _lightingInfos;
  26494. /**
  26495. * Debug Control allowing disabling the bump map on this material.
  26496. */
  26497. protected _disableBumpMap: boolean;
  26498. /**
  26499. * AKA Diffuse Texture in standard nomenclature.
  26500. */
  26501. protected _albedoTexture: Nullable<BaseTexture>;
  26502. /**
  26503. * AKA Occlusion Texture in other nomenclature.
  26504. */
  26505. protected _ambientTexture: Nullable<BaseTexture>;
  26506. /**
  26507. * AKA Occlusion Texture Intensity in other nomenclature.
  26508. */
  26509. protected _ambientTextureStrength: number;
  26510. /**
  26511. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26512. * 1 means it completely occludes it
  26513. * 0 mean it has no impact
  26514. */
  26515. protected _ambientTextureImpactOnAnalyticalLights: number;
  26516. /**
  26517. * Stores the alpha values in a texture.
  26518. */
  26519. protected _opacityTexture: Nullable<BaseTexture>;
  26520. /**
  26521. * Stores the reflection values in a texture.
  26522. */
  26523. protected _reflectionTexture: Nullable<BaseTexture>;
  26524. /**
  26525. * Stores the emissive values in a texture.
  26526. */
  26527. protected _emissiveTexture: Nullable<BaseTexture>;
  26528. /**
  26529. * AKA Specular texture in other nomenclature.
  26530. */
  26531. protected _reflectivityTexture: Nullable<BaseTexture>;
  26532. /**
  26533. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26534. */
  26535. protected _metallicTexture: Nullable<BaseTexture>;
  26536. /**
  26537. * Specifies the metallic scalar of the metallic/roughness workflow.
  26538. * Can also be used to scale the metalness values of the metallic texture.
  26539. */
  26540. protected _metallic: Nullable<number>;
  26541. /**
  26542. * Specifies the roughness scalar of the metallic/roughness workflow.
  26543. * Can also be used to scale the roughness values of the metallic texture.
  26544. */
  26545. protected _roughness: Nullable<number>;
  26546. /**
  26547. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26548. * By default the indexOfrefraction is used to compute F0;
  26549. *
  26550. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26551. *
  26552. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26553. * F90 = metallicReflectanceColor;
  26554. */
  26555. protected _metallicF0Factor: number;
  26556. /**
  26557. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26558. * By default the F90 is always 1;
  26559. *
  26560. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26561. *
  26562. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26563. * F90 = metallicReflectanceColor;
  26564. */
  26565. protected _metallicReflectanceColor: Color3;
  26566. /**
  26567. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26568. * This is multiply against the scalar values defined in the material.
  26569. */
  26570. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26571. /**
  26572. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26573. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26574. */
  26575. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26576. /**
  26577. * Stores surface normal data used to displace a mesh in a texture.
  26578. */
  26579. protected _bumpTexture: Nullable<BaseTexture>;
  26580. /**
  26581. * Stores the pre-calculated light information of a mesh in a texture.
  26582. */
  26583. protected _lightmapTexture: Nullable<BaseTexture>;
  26584. /**
  26585. * The color of a material in ambient lighting.
  26586. */
  26587. protected _ambientColor: Color3;
  26588. /**
  26589. * AKA Diffuse Color in other nomenclature.
  26590. */
  26591. protected _albedoColor: Color3;
  26592. /**
  26593. * AKA Specular Color in other nomenclature.
  26594. */
  26595. protected _reflectivityColor: Color3;
  26596. /**
  26597. * The color applied when light is reflected from a material.
  26598. */
  26599. protected _reflectionColor: Color3;
  26600. /**
  26601. * The color applied when light is emitted from a material.
  26602. */
  26603. protected _emissiveColor: Color3;
  26604. /**
  26605. * AKA Glossiness in other nomenclature.
  26606. */
  26607. protected _microSurface: number;
  26608. /**
  26609. * Specifies that the material will use the light map as a show map.
  26610. */
  26611. protected _useLightmapAsShadowmap: boolean;
  26612. /**
  26613. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26614. * makes the reflect vector face the model (under horizon).
  26615. */
  26616. protected _useHorizonOcclusion: boolean;
  26617. /**
  26618. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26619. * too much the area relying on ambient texture to define their ambient occlusion.
  26620. */
  26621. protected _useRadianceOcclusion: boolean;
  26622. /**
  26623. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26624. */
  26625. protected _useAlphaFromAlbedoTexture: boolean;
  26626. /**
  26627. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26628. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26629. */
  26630. protected _useSpecularOverAlpha: boolean;
  26631. /**
  26632. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26633. */
  26634. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26635. /**
  26636. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26637. */
  26638. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26639. /**
  26640. * Specifies if the metallic texture contains the roughness information in its green channel.
  26641. */
  26642. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26643. /**
  26644. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26645. */
  26646. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26647. /**
  26648. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26649. */
  26650. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26651. /**
  26652. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26653. */
  26654. protected _useAmbientInGrayScale: boolean;
  26655. /**
  26656. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26657. * The material will try to infer what glossiness each pixel should be.
  26658. */
  26659. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26660. /**
  26661. * Defines the falloff type used in this material.
  26662. * It by default is Physical.
  26663. */
  26664. protected _lightFalloff: number;
  26665. /**
  26666. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26667. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26668. */
  26669. protected _useRadianceOverAlpha: boolean;
  26670. /**
  26671. * Allows using an object space normal map (instead of tangent space).
  26672. */
  26673. protected _useObjectSpaceNormalMap: boolean;
  26674. /**
  26675. * Allows using the bump map in parallax mode.
  26676. */
  26677. protected _useParallax: boolean;
  26678. /**
  26679. * Allows using the bump map in parallax occlusion mode.
  26680. */
  26681. protected _useParallaxOcclusion: boolean;
  26682. /**
  26683. * Controls the scale bias of the parallax mode.
  26684. */
  26685. protected _parallaxScaleBias: number;
  26686. /**
  26687. * If sets to true, disables all the lights affecting the material.
  26688. */
  26689. protected _disableLighting: boolean;
  26690. /**
  26691. * Number of Simultaneous lights allowed on the material.
  26692. */
  26693. protected _maxSimultaneousLights: number;
  26694. /**
  26695. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26696. */
  26697. protected _invertNormalMapX: boolean;
  26698. /**
  26699. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26700. */
  26701. protected _invertNormalMapY: boolean;
  26702. /**
  26703. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26704. */
  26705. protected _twoSidedLighting: boolean;
  26706. /**
  26707. * Defines the alpha limits in alpha test mode.
  26708. */
  26709. protected _alphaCutOff: number;
  26710. /**
  26711. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26712. */
  26713. protected _forceAlphaTest: boolean;
  26714. /**
  26715. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26716. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26717. */
  26718. protected _useAlphaFresnel: boolean;
  26719. /**
  26720. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26721. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26722. */
  26723. protected _useLinearAlphaFresnel: boolean;
  26724. /**
  26725. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26726. * from cos thetav and roughness:
  26727. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26728. */
  26729. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26730. /**
  26731. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26732. */
  26733. protected _forceIrradianceInFragment: boolean;
  26734. private _realTimeFiltering;
  26735. /**
  26736. * Enables realtime filtering on the texture.
  26737. */
  26738. get realTimeFiltering(): boolean;
  26739. set realTimeFiltering(b: boolean);
  26740. private _realTimeFilteringQuality;
  26741. /**
  26742. * Quality switch for realtime filtering
  26743. */
  26744. get realTimeFilteringQuality(): number;
  26745. set realTimeFilteringQuality(n: number);
  26746. /**
  26747. * Can this material render to several textures at once
  26748. */
  26749. get canRenderToMRT(): boolean;
  26750. /**
  26751. * Force normal to face away from face.
  26752. */
  26753. protected _forceNormalForward: boolean;
  26754. /**
  26755. * Enables specular anti aliasing in the PBR shader.
  26756. * It will both interacts on the Geometry for analytical and IBL lighting.
  26757. * It also prefilter the roughness map based on the bump values.
  26758. */
  26759. protected _enableSpecularAntiAliasing: boolean;
  26760. /**
  26761. * Default configuration related to image processing available in the PBR Material.
  26762. */
  26763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26764. /**
  26765. * Keep track of the image processing observer to allow dispose and replace.
  26766. */
  26767. private _imageProcessingObserver;
  26768. /**
  26769. * Attaches a new image processing configuration to the PBR Material.
  26770. * @param configuration
  26771. */
  26772. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26773. /**
  26774. * Stores the available render targets.
  26775. */
  26776. private _renderTargets;
  26777. /**
  26778. * Sets the global ambient color for the material used in lighting calculations.
  26779. */
  26780. private _globalAmbientColor;
  26781. /**
  26782. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26783. */
  26784. private _useLogarithmicDepth;
  26785. /**
  26786. * If set to true, no lighting calculations will be applied.
  26787. */
  26788. private _unlit;
  26789. private _debugMode;
  26790. /**
  26791. * @hidden
  26792. * This is reserved for the inspector.
  26793. * Defines the material debug mode.
  26794. * It helps seeing only some components of the material while troubleshooting.
  26795. */
  26796. debugMode: number;
  26797. /**
  26798. * @hidden
  26799. * This is reserved for the inspector.
  26800. * Specify from where on screen the debug mode should start.
  26801. * The value goes from -1 (full screen) to 1 (not visible)
  26802. * It helps with side by side comparison against the final render
  26803. * This defaults to -1
  26804. */
  26805. private debugLimit;
  26806. /**
  26807. * @hidden
  26808. * This is reserved for the inspector.
  26809. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26810. * You can use the factor to better multiply the final value.
  26811. */
  26812. private debugFactor;
  26813. /**
  26814. * Defines the clear coat layer parameters for the material.
  26815. */
  26816. readonly clearCoat: PBRClearCoatConfiguration;
  26817. /**
  26818. * Defines the anisotropic parameters for the material.
  26819. */
  26820. readonly anisotropy: PBRAnisotropicConfiguration;
  26821. /**
  26822. * Defines the BRDF parameters for the material.
  26823. */
  26824. readonly brdf: PBRBRDFConfiguration;
  26825. /**
  26826. * Defines the Sheen parameters for the material.
  26827. */
  26828. readonly sheen: PBRSheenConfiguration;
  26829. /**
  26830. * Defines the SubSurface parameters for the material.
  26831. */
  26832. readonly subSurface: PBRSubSurfaceConfiguration;
  26833. /**
  26834. * Defines additionnal PrePass parameters for the material.
  26835. */
  26836. readonly prePassConfiguration: PrePassConfiguration;
  26837. /**
  26838. * Defines the detail map parameters for the material.
  26839. */
  26840. readonly detailMap: DetailMapConfiguration;
  26841. protected _rebuildInParallel: boolean;
  26842. /**
  26843. * Instantiates a new PBRMaterial instance.
  26844. *
  26845. * @param name The material name
  26846. * @param scene The scene the material will be use in.
  26847. */
  26848. constructor(name: string, scene: Scene);
  26849. /**
  26850. * Gets a boolean indicating that current material needs to register RTT
  26851. */
  26852. get hasRenderTargetTextures(): boolean;
  26853. /**
  26854. * Gets the name of the material class.
  26855. */
  26856. getClassName(): string;
  26857. /**
  26858. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26859. */
  26860. get useLogarithmicDepth(): boolean;
  26861. /**
  26862. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26863. */
  26864. set useLogarithmicDepth(value: boolean);
  26865. /**
  26866. * Returns true if alpha blending should be disabled.
  26867. */
  26868. protected get _disableAlphaBlending(): boolean;
  26869. /**
  26870. * Specifies whether or not this material should be rendered in alpha blend mode.
  26871. */
  26872. needAlphaBlending(): boolean;
  26873. /**
  26874. * Specifies whether or not this material should be rendered in alpha test mode.
  26875. */
  26876. needAlphaTesting(): boolean;
  26877. /**
  26878. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26879. */
  26880. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26881. /**
  26882. * Specifies whether or not there is a usable alpha channel for transparency.
  26883. */
  26884. protected _hasAlphaChannel(): boolean;
  26885. /**
  26886. * Gets the texture used for the alpha test.
  26887. */
  26888. getAlphaTestTexture(): Nullable<BaseTexture>;
  26889. /**
  26890. * Specifies that the submesh is ready to be used.
  26891. * @param mesh - BJS mesh.
  26892. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26893. * @param useInstances - Specifies that instances should be used.
  26894. * @returns - boolean indicating that the submesh is ready or not.
  26895. */
  26896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26897. /**
  26898. * Specifies if the material uses metallic roughness workflow.
  26899. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26900. */
  26901. isMetallicWorkflow(): boolean;
  26902. private _prepareEffect;
  26903. private _prepareDefines;
  26904. /**
  26905. * Force shader compilation
  26906. */
  26907. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26908. /**
  26909. * Initializes the uniform buffer layout for the shader.
  26910. */
  26911. buildUniformLayout(): void;
  26912. /**
  26913. * Unbinds the material from the mesh
  26914. */
  26915. unbind(): void;
  26916. /**
  26917. * Binds the submesh data.
  26918. * @param world - The world matrix.
  26919. * @param mesh - The BJS mesh.
  26920. * @param subMesh - A submesh of the BJS mesh.
  26921. */
  26922. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26923. /**
  26924. * Returns the animatable textures.
  26925. * @returns - Array of animatable textures.
  26926. */
  26927. getAnimatables(): IAnimatable[];
  26928. /**
  26929. * Returns the texture used for reflections.
  26930. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26931. */
  26932. private _getReflectionTexture;
  26933. /**
  26934. * Returns an array of the actively used textures.
  26935. * @returns - Array of BaseTextures
  26936. */
  26937. getActiveTextures(): BaseTexture[];
  26938. /**
  26939. * Checks to see if a texture is used in the material.
  26940. * @param texture - Base texture to use.
  26941. * @returns - Boolean specifying if a texture is used in the material.
  26942. */
  26943. hasTexture(texture: BaseTexture): boolean;
  26944. /**
  26945. * Sets the required values to the prepass renderer.
  26946. * @param prePassRenderer defines the prepass renderer to setup
  26947. */
  26948. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26949. /**
  26950. * Disposes the resources of the material.
  26951. * @param forceDisposeEffect - Forces the disposal of effects.
  26952. * @param forceDisposeTextures - Forces the disposal of all textures.
  26953. */
  26954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26955. }
  26956. }
  26957. declare module BABYLON {
  26958. /**
  26959. * The Physically based material of BJS.
  26960. *
  26961. * This offers the main features of a standard PBR material.
  26962. * For more information, please refer to the documentation :
  26963. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26964. */
  26965. export class PBRMaterial extends PBRBaseMaterial {
  26966. /**
  26967. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26968. */
  26969. static readonly PBRMATERIAL_OPAQUE: number;
  26970. /**
  26971. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26972. */
  26973. static readonly PBRMATERIAL_ALPHATEST: number;
  26974. /**
  26975. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26976. */
  26977. static readonly PBRMATERIAL_ALPHABLEND: number;
  26978. /**
  26979. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26980. * They are also discarded below the alpha cutoff threshold to improve performances.
  26981. */
  26982. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26983. /**
  26984. * Defines the default value of how much AO map is occluding the analytical lights
  26985. * (point spot...).
  26986. */
  26987. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26988. /**
  26989. * Intensity of the direct lights e.g. the four lights available in your scene.
  26990. * This impacts both the direct diffuse and specular highlights.
  26991. */
  26992. directIntensity: number;
  26993. /**
  26994. * Intensity of the emissive part of the material.
  26995. * This helps controlling the emissive effect without modifying the emissive color.
  26996. */
  26997. emissiveIntensity: number;
  26998. /**
  26999. * Intensity of the environment e.g. how much the environment will light the object
  27000. * either through harmonics for rough material or through the refelction for shiny ones.
  27001. */
  27002. environmentIntensity: number;
  27003. /**
  27004. * This is a special control allowing the reduction of the specular highlights coming from the
  27005. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27006. */
  27007. specularIntensity: number;
  27008. /**
  27009. * Debug Control allowing disabling the bump map on this material.
  27010. */
  27011. disableBumpMap: boolean;
  27012. /**
  27013. * AKA Diffuse Texture in standard nomenclature.
  27014. */
  27015. albedoTexture: BaseTexture;
  27016. /**
  27017. * AKA Occlusion Texture in other nomenclature.
  27018. */
  27019. ambientTexture: BaseTexture;
  27020. /**
  27021. * AKA Occlusion Texture Intensity in other nomenclature.
  27022. */
  27023. ambientTextureStrength: number;
  27024. /**
  27025. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27026. * 1 means it completely occludes it
  27027. * 0 mean it has no impact
  27028. */
  27029. ambientTextureImpactOnAnalyticalLights: number;
  27030. /**
  27031. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27032. */
  27033. opacityTexture: BaseTexture;
  27034. /**
  27035. * Stores the reflection values in a texture.
  27036. */
  27037. reflectionTexture: Nullable<BaseTexture>;
  27038. /**
  27039. * Stores the emissive values in a texture.
  27040. */
  27041. emissiveTexture: BaseTexture;
  27042. /**
  27043. * AKA Specular texture in other nomenclature.
  27044. */
  27045. reflectivityTexture: BaseTexture;
  27046. /**
  27047. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27048. */
  27049. metallicTexture: BaseTexture;
  27050. /**
  27051. * Specifies the metallic scalar of the metallic/roughness workflow.
  27052. * Can also be used to scale the metalness values of the metallic texture.
  27053. */
  27054. metallic: Nullable<number>;
  27055. /**
  27056. * Specifies the roughness scalar of the metallic/roughness workflow.
  27057. * Can also be used to scale the roughness values of the metallic texture.
  27058. */
  27059. roughness: Nullable<number>;
  27060. /**
  27061. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27062. * By default the indexOfrefraction is used to compute F0;
  27063. *
  27064. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27065. *
  27066. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27067. * F90 = metallicReflectanceColor;
  27068. */
  27069. metallicF0Factor: number;
  27070. /**
  27071. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27072. * By default the F90 is always 1;
  27073. *
  27074. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27075. *
  27076. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27077. * F90 = metallicReflectanceColor;
  27078. */
  27079. metallicReflectanceColor: Color3;
  27080. /**
  27081. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27082. * This is multiply against the scalar values defined in the material.
  27083. */
  27084. metallicReflectanceTexture: Nullable<BaseTexture>;
  27085. /**
  27086. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27087. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27088. */
  27089. microSurfaceTexture: BaseTexture;
  27090. /**
  27091. * Stores surface normal data used to displace a mesh in a texture.
  27092. */
  27093. bumpTexture: BaseTexture;
  27094. /**
  27095. * Stores the pre-calculated light information of a mesh in a texture.
  27096. */
  27097. lightmapTexture: BaseTexture;
  27098. /**
  27099. * Stores the refracted light information in a texture.
  27100. */
  27101. get refractionTexture(): Nullable<BaseTexture>;
  27102. set refractionTexture(value: Nullable<BaseTexture>);
  27103. /**
  27104. * The color of a material in ambient lighting.
  27105. */
  27106. ambientColor: Color3;
  27107. /**
  27108. * AKA Diffuse Color in other nomenclature.
  27109. */
  27110. albedoColor: Color3;
  27111. /**
  27112. * AKA Specular Color in other nomenclature.
  27113. */
  27114. reflectivityColor: Color3;
  27115. /**
  27116. * The color reflected from the material.
  27117. */
  27118. reflectionColor: Color3;
  27119. /**
  27120. * The color emitted from the material.
  27121. */
  27122. emissiveColor: Color3;
  27123. /**
  27124. * AKA Glossiness in other nomenclature.
  27125. */
  27126. microSurface: number;
  27127. /**
  27128. * Index of refraction of the material base layer.
  27129. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27130. *
  27131. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27132. *
  27133. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27134. */
  27135. get indexOfRefraction(): number;
  27136. set indexOfRefraction(value: number);
  27137. /**
  27138. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27139. */
  27140. get invertRefractionY(): boolean;
  27141. set invertRefractionY(value: boolean);
  27142. /**
  27143. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27144. * Materials half opaque for instance using refraction could benefit from this control.
  27145. */
  27146. get linkRefractionWithTransparency(): boolean;
  27147. set linkRefractionWithTransparency(value: boolean);
  27148. /**
  27149. * If true, the light map contains occlusion information instead of lighting info.
  27150. */
  27151. useLightmapAsShadowmap: boolean;
  27152. /**
  27153. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27154. */
  27155. useAlphaFromAlbedoTexture: boolean;
  27156. /**
  27157. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27158. */
  27159. forceAlphaTest: boolean;
  27160. /**
  27161. * Defines the alpha limits in alpha test mode.
  27162. */
  27163. alphaCutOff: number;
  27164. /**
  27165. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27166. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27167. */
  27168. useSpecularOverAlpha: boolean;
  27169. /**
  27170. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27171. */
  27172. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27173. /**
  27174. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27175. */
  27176. useRoughnessFromMetallicTextureAlpha: boolean;
  27177. /**
  27178. * Specifies if the metallic texture contains the roughness information in its green channel.
  27179. */
  27180. useRoughnessFromMetallicTextureGreen: boolean;
  27181. /**
  27182. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27183. */
  27184. useMetallnessFromMetallicTextureBlue: boolean;
  27185. /**
  27186. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27187. */
  27188. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27189. /**
  27190. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27191. */
  27192. useAmbientInGrayScale: boolean;
  27193. /**
  27194. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27195. * The material will try to infer what glossiness each pixel should be.
  27196. */
  27197. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27198. /**
  27199. * BJS is using an harcoded light falloff based on a manually sets up range.
  27200. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27201. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27202. */
  27203. get usePhysicalLightFalloff(): boolean;
  27204. /**
  27205. * BJS is using an harcoded light falloff based on a manually sets up range.
  27206. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27207. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27208. */
  27209. set usePhysicalLightFalloff(value: boolean);
  27210. /**
  27211. * In order to support the falloff compatibility with gltf, a special mode has been added
  27212. * to reproduce the gltf light falloff.
  27213. */
  27214. get useGLTFLightFalloff(): boolean;
  27215. /**
  27216. * In order to support the falloff compatibility with gltf, a special mode has been added
  27217. * to reproduce the gltf light falloff.
  27218. */
  27219. set useGLTFLightFalloff(value: boolean);
  27220. /**
  27221. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27222. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27223. */
  27224. useRadianceOverAlpha: boolean;
  27225. /**
  27226. * Allows using an object space normal map (instead of tangent space).
  27227. */
  27228. useObjectSpaceNormalMap: boolean;
  27229. /**
  27230. * Allows using the bump map in parallax mode.
  27231. */
  27232. useParallax: boolean;
  27233. /**
  27234. * Allows using the bump map in parallax occlusion mode.
  27235. */
  27236. useParallaxOcclusion: boolean;
  27237. /**
  27238. * Controls the scale bias of the parallax mode.
  27239. */
  27240. parallaxScaleBias: number;
  27241. /**
  27242. * If sets to true, disables all the lights affecting the material.
  27243. */
  27244. disableLighting: boolean;
  27245. /**
  27246. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27247. */
  27248. forceIrradianceInFragment: boolean;
  27249. /**
  27250. * Number of Simultaneous lights allowed on the material.
  27251. */
  27252. maxSimultaneousLights: number;
  27253. /**
  27254. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27255. */
  27256. invertNormalMapX: boolean;
  27257. /**
  27258. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27259. */
  27260. invertNormalMapY: boolean;
  27261. /**
  27262. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27263. */
  27264. twoSidedLighting: boolean;
  27265. /**
  27266. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27267. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27268. */
  27269. useAlphaFresnel: boolean;
  27270. /**
  27271. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27272. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27273. */
  27274. useLinearAlphaFresnel: boolean;
  27275. /**
  27276. * Let user defines the brdf lookup texture used for IBL.
  27277. * A default 8bit version is embedded but you could point at :
  27278. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27279. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27280. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27281. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27282. */
  27283. environmentBRDFTexture: Nullable<BaseTexture>;
  27284. /**
  27285. * Force normal to face away from face.
  27286. */
  27287. forceNormalForward: boolean;
  27288. /**
  27289. * Enables specular anti aliasing in the PBR shader.
  27290. * It will both interacts on the Geometry for analytical and IBL lighting.
  27291. * It also prefilter the roughness map based on the bump values.
  27292. */
  27293. enableSpecularAntiAliasing: boolean;
  27294. /**
  27295. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27296. * makes the reflect vector face the model (under horizon).
  27297. */
  27298. useHorizonOcclusion: boolean;
  27299. /**
  27300. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27301. * too much the area relying on ambient texture to define their ambient occlusion.
  27302. */
  27303. useRadianceOcclusion: boolean;
  27304. /**
  27305. * If set to true, no lighting calculations will be applied.
  27306. */
  27307. unlit: boolean;
  27308. /**
  27309. * Gets the image processing configuration used either in this material.
  27310. */
  27311. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27312. /**
  27313. * Sets the Default image processing configuration used either in the this material.
  27314. *
  27315. * If sets to null, the scene one is in use.
  27316. */
  27317. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27318. /**
  27319. * Gets wether the color curves effect is enabled.
  27320. */
  27321. get cameraColorCurvesEnabled(): boolean;
  27322. /**
  27323. * Sets wether the color curves effect is enabled.
  27324. */
  27325. set cameraColorCurvesEnabled(value: boolean);
  27326. /**
  27327. * Gets wether the color grading effect is enabled.
  27328. */
  27329. get cameraColorGradingEnabled(): boolean;
  27330. /**
  27331. * Gets wether the color grading effect is enabled.
  27332. */
  27333. set cameraColorGradingEnabled(value: boolean);
  27334. /**
  27335. * Gets wether tonemapping is enabled or not.
  27336. */
  27337. get cameraToneMappingEnabled(): boolean;
  27338. /**
  27339. * Sets wether tonemapping is enabled or not
  27340. */
  27341. set cameraToneMappingEnabled(value: boolean);
  27342. /**
  27343. * The camera exposure used on this material.
  27344. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27345. * This corresponds to a photographic exposure.
  27346. */
  27347. get cameraExposure(): number;
  27348. /**
  27349. * The camera exposure used on this material.
  27350. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27351. * This corresponds to a photographic exposure.
  27352. */
  27353. set cameraExposure(value: number);
  27354. /**
  27355. * Gets The camera contrast used on this material.
  27356. */
  27357. get cameraContrast(): number;
  27358. /**
  27359. * Sets The camera contrast used on this material.
  27360. */
  27361. set cameraContrast(value: number);
  27362. /**
  27363. * Gets the Color Grading 2D Lookup Texture.
  27364. */
  27365. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27366. /**
  27367. * Sets the Color Grading 2D Lookup Texture.
  27368. */
  27369. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27370. /**
  27371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27373. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27375. */
  27376. get cameraColorCurves(): Nullable<ColorCurves>;
  27377. /**
  27378. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27379. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27380. * 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;
  27381. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27382. */
  27383. set cameraColorCurves(value: Nullable<ColorCurves>);
  27384. /**
  27385. * Instantiates a new PBRMaterial instance.
  27386. *
  27387. * @param name The material name
  27388. * @param scene The scene the material will be use in.
  27389. */
  27390. constructor(name: string, scene: Scene);
  27391. /**
  27392. * Returns the name of this material class.
  27393. */
  27394. getClassName(): string;
  27395. /**
  27396. * Makes a duplicate of the current material.
  27397. * @param name - name to use for the new material.
  27398. */
  27399. clone(name: string): PBRMaterial;
  27400. /**
  27401. * Serializes this PBR Material.
  27402. * @returns - An object with the serialized material.
  27403. */
  27404. serialize(): any;
  27405. /**
  27406. * Parses a PBR Material from a serialized object.
  27407. * @param source - Serialized object.
  27408. * @param scene - BJS scene instance.
  27409. * @param rootUrl - url for the scene object
  27410. * @returns - PBRMaterial
  27411. */
  27412. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27413. }
  27414. }
  27415. declare module BABYLON {
  27416. /** @hidden */
  27417. export var mrtFragmentDeclaration: {
  27418. name: string;
  27419. shader: string;
  27420. };
  27421. }
  27422. declare module BABYLON {
  27423. /** @hidden */
  27424. export var geometryPixelShader: {
  27425. name: string;
  27426. shader: string;
  27427. };
  27428. }
  27429. declare module BABYLON {
  27430. /** @hidden */
  27431. export var geometryVertexShader: {
  27432. name: string;
  27433. shader: string;
  27434. };
  27435. }
  27436. declare module BABYLON {
  27437. /** @hidden */
  27438. interface ISavedTransformationMatrix {
  27439. world: Matrix;
  27440. viewProjection: Matrix;
  27441. }
  27442. /**
  27443. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27444. */
  27445. export class GeometryBufferRenderer {
  27446. /**
  27447. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27448. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27449. */
  27450. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27451. /**
  27452. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27453. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27454. */
  27455. static readonly POSITION_TEXTURE_TYPE: number;
  27456. /**
  27457. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27458. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27459. */
  27460. static readonly VELOCITY_TEXTURE_TYPE: number;
  27461. /**
  27462. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27463. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27464. */
  27465. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27466. /**
  27467. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27468. * in order to compute objects velocities when enableVelocity is set to "true"
  27469. * @hidden
  27470. */
  27471. _previousTransformationMatrices: {
  27472. [index: number]: ISavedTransformationMatrix;
  27473. };
  27474. /**
  27475. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27476. * in order to compute objects velocities when enableVelocity is set to "true"
  27477. * @hidden
  27478. */
  27479. _previousBonesTransformationMatrices: {
  27480. [index: number]: Float32Array;
  27481. };
  27482. /**
  27483. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27484. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27485. */
  27486. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27487. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27488. renderTransparentMeshes: boolean;
  27489. private _scene;
  27490. private _resizeObserver;
  27491. private _multiRenderTarget;
  27492. private _ratio;
  27493. private _enablePosition;
  27494. private _enableVelocity;
  27495. private _enableReflectivity;
  27496. private _positionIndex;
  27497. private _velocityIndex;
  27498. private _reflectivityIndex;
  27499. private _depthNormalIndex;
  27500. private _linkedWithPrePass;
  27501. private _prePassRenderer;
  27502. private _attachments;
  27503. protected _effect: Effect;
  27504. protected _cachedDefines: string;
  27505. /**
  27506. * @hidden
  27507. * Sets up internal structures to share outputs with PrePassRenderer
  27508. * This method should only be called by the PrePassRenderer itself
  27509. */
  27510. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27511. /**
  27512. * @hidden
  27513. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27514. * This method should only be called by the PrePassRenderer itself
  27515. */
  27516. _unlinkPrePassRenderer(): void;
  27517. /**
  27518. * @hidden
  27519. * Resets the geometry buffer layout
  27520. */
  27521. _resetLayout(): void;
  27522. /**
  27523. * @hidden
  27524. * Replaces a texture in the geometry buffer renderer
  27525. * Useful when linking textures of the prepass renderer
  27526. */
  27527. _forceTextureType(geometryBufferType: number, index: number): void;
  27528. /**
  27529. * @hidden
  27530. * Sets texture attachments
  27531. * Useful when linking textures of the prepass renderer
  27532. */
  27533. _setAttachments(attachments: number[]): void;
  27534. /**
  27535. * @hidden
  27536. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27537. * Useful when linking textures of the prepass renderer
  27538. */
  27539. _linkInternalTexture(internalTexture: InternalTexture): void;
  27540. /**
  27541. * Gets the render list (meshes to be rendered) used in the G buffer.
  27542. */
  27543. get renderList(): Nullable<AbstractMesh[]>;
  27544. /**
  27545. * Set the render list (meshes to be rendered) used in the G buffer.
  27546. */
  27547. set renderList(meshes: Nullable<AbstractMesh[]>);
  27548. /**
  27549. * Gets wether or not G buffer are supported by the running hardware.
  27550. * This requires draw buffer supports
  27551. */
  27552. get isSupported(): boolean;
  27553. /**
  27554. * Returns the index of the given texture type in the G-Buffer textures array
  27555. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27556. * @returns the index of the given texture type in the G-Buffer textures array
  27557. */
  27558. getTextureIndex(textureType: number): number;
  27559. /**
  27560. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27561. */
  27562. get enablePosition(): boolean;
  27563. /**
  27564. * Sets whether or not objects positions are enabled for the G buffer.
  27565. */
  27566. set enablePosition(enable: boolean);
  27567. /**
  27568. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27569. */
  27570. get enableVelocity(): boolean;
  27571. /**
  27572. * Sets wether or not objects velocities are enabled for the G buffer.
  27573. */
  27574. set enableVelocity(enable: boolean);
  27575. /**
  27576. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27577. */
  27578. get enableReflectivity(): boolean;
  27579. /**
  27580. * Sets wether or not objects roughness are enabled for the G buffer.
  27581. */
  27582. set enableReflectivity(enable: boolean);
  27583. /**
  27584. * Gets the scene associated with the buffer.
  27585. */
  27586. get scene(): Scene;
  27587. /**
  27588. * Gets the ratio used by the buffer during its creation.
  27589. * How big is the buffer related to the main canvas.
  27590. */
  27591. get ratio(): number;
  27592. /** @hidden */
  27593. static _SceneComponentInitialization: (scene: Scene) => void;
  27594. /**
  27595. * Creates a new G Buffer for the scene
  27596. * @param scene The scene the buffer belongs to
  27597. * @param ratio How big is the buffer related to the main canvas.
  27598. */
  27599. constructor(scene: Scene, ratio?: number);
  27600. /**
  27601. * Checks wether everything is ready to render a submesh to the G buffer.
  27602. * @param subMesh the submesh to check readiness for
  27603. * @param useInstances is the mesh drawn using instance or not
  27604. * @returns true if ready otherwise false
  27605. */
  27606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27607. /**
  27608. * Gets the current underlying G Buffer.
  27609. * @returns the buffer
  27610. */
  27611. getGBuffer(): MultiRenderTarget;
  27612. /**
  27613. * Gets the number of samples used to render the buffer (anti aliasing).
  27614. */
  27615. get samples(): number;
  27616. /**
  27617. * Sets the number of samples used to render the buffer (anti aliasing).
  27618. */
  27619. set samples(value: number);
  27620. /**
  27621. * Disposes the renderer and frees up associated resources.
  27622. */
  27623. dispose(): void;
  27624. private _assignRenderTargetIndices;
  27625. protected _createRenderTargets(): void;
  27626. private _copyBonesTransformationMatrices;
  27627. }
  27628. }
  27629. declare module BABYLON {
  27630. /**
  27631. * Renders a pre pass of the scene
  27632. * This means every mesh in the scene will be rendered to a render target texture
  27633. * And then this texture will be composited to the rendering canvas with post processes
  27634. * It is necessary for effects like subsurface scattering or deferred shading
  27635. */
  27636. export class PrePassRenderer {
  27637. /** @hidden */
  27638. static _SceneComponentInitialization: (scene: Scene) => void;
  27639. private _textureFormats;
  27640. /**
  27641. * To save performance, we can excluded skinned meshes from the prepass
  27642. */
  27643. excludedSkinnedMesh: AbstractMesh[];
  27644. /**
  27645. * Force material to be excluded from the prepass
  27646. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27647. * and you don't want a material to show in the effect.
  27648. */
  27649. excludedMaterials: Material[];
  27650. private _textureIndices;
  27651. private _scene;
  27652. private _engine;
  27653. private _isDirty;
  27654. /**
  27655. * Number of textures in the multi render target texture where the scene is directly rendered
  27656. */
  27657. mrtCount: number;
  27658. /**
  27659. * The render target where the scene is directly rendered
  27660. */
  27661. prePassRT: MultiRenderTarget;
  27662. private _multiRenderAttachments;
  27663. private _defaultAttachments;
  27664. private _clearAttachments;
  27665. private _postProcesses;
  27666. private readonly _clearColor;
  27667. /**
  27668. * Image processing post process for composition
  27669. */
  27670. imageProcessingPostProcess: ImageProcessingPostProcess;
  27671. /**
  27672. * Configuration for prepass effects
  27673. */
  27674. private _effectConfigurations;
  27675. private _mrtFormats;
  27676. private _mrtLayout;
  27677. private _enabled;
  27678. /**
  27679. * Indicates if the prepass is enabled
  27680. */
  27681. get enabled(): boolean;
  27682. /**
  27683. * How many samples are used for MSAA of the scene render target
  27684. */
  27685. get samples(): number;
  27686. set samples(n: number);
  27687. private _geometryBuffer;
  27688. private _useGeometryBufferFallback;
  27689. /**
  27690. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27691. */
  27692. get useGeometryBufferFallback(): boolean;
  27693. set useGeometryBufferFallback(value: boolean);
  27694. /**
  27695. * Instanciates a prepass renderer
  27696. * @param scene The scene
  27697. */
  27698. constructor(scene: Scene);
  27699. private _initializeAttachments;
  27700. private _createCompositionEffect;
  27701. /**
  27702. * Indicates if rendering a prepass is supported
  27703. */
  27704. get isSupported(): boolean;
  27705. /**
  27706. * Sets the proper output textures to draw in the engine.
  27707. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27708. * @param subMesh Submesh on which the effect is applied
  27709. */
  27710. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27711. /**
  27712. * @hidden
  27713. */
  27714. _beforeCameraDraw(): void;
  27715. /**
  27716. * @hidden
  27717. */
  27718. _afterCameraDraw(): void;
  27719. private _checkRTSize;
  27720. private _bindFrameBuffer;
  27721. /**
  27722. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27723. */
  27724. clear(): void;
  27725. private _setState;
  27726. private _updateGeometryBufferLayout;
  27727. /**
  27728. * Adds an effect configuration to the prepass.
  27729. * If an effect has already been added, it won't add it twice and will return the configuration
  27730. * already present.
  27731. * @param cfg the effect configuration
  27732. * @return the effect configuration now used by the prepass
  27733. */
  27734. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27735. /**
  27736. * Returns the index of a texture in the multi render target texture array.
  27737. * @param type Texture type
  27738. * @return The index
  27739. */
  27740. getIndex(type: number): number;
  27741. private _enable;
  27742. private _disable;
  27743. private _resetLayout;
  27744. private _resetPostProcessChain;
  27745. private _bindPostProcessChain;
  27746. /**
  27747. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27748. */
  27749. markAsDirty(): void;
  27750. /**
  27751. * Enables a texture on the MultiRenderTarget for prepass
  27752. */
  27753. private _enableTextures;
  27754. private _update;
  27755. private _markAllMaterialsAsPrePassDirty;
  27756. /**
  27757. * Disposes the prepass renderer.
  27758. */
  27759. dispose(): void;
  27760. }
  27761. }
  27762. declare module BABYLON {
  27763. /**
  27764. * Size options for a post process
  27765. */
  27766. export type PostProcessOptions = {
  27767. width: number;
  27768. height: number;
  27769. };
  27770. /**
  27771. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27772. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27773. */
  27774. export class PostProcess {
  27775. /**
  27776. * Gets or sets the unique id of the post process
  27777. */
  27778. uniqueId: number;
  27779. /** Name of the PostProcess. */
  27780. name: string;
  27781. /**
  27782. * Width of the texture to apply the post process on
  27783. */
  27784. width: number;
  27785. /**
  27786. * Height of the texture to apply the post process on
  27787. */
  27788. height: number;
  27789. /**
  27790. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27791. */
  27792. nodeMaterialSource: Nullable<NodeMaterial>;
  27793. /**
  27794. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27795. * @hidden
  27796. */
  27797. _outputTexture: Nullable<InternalTexture>;
  27798. /**
  27799. * Sampling mode used by the shader
  27800. * See https://doc.babylonjs.com/classes/3.1/texture
  27801. */
  27802. renderTargetSamplingMode: number;
  27803. /**
  27804. * Clear color to use when screen clearing
  27805. */
  27806. clearColor: Color4;
  27807. /**
  27808. * If the buffer needs to be cleared before applying the post process. (default: true)
  27809. * Should be set to false if shader will overwrite all previous pixels.
  27810. */
  27811. autoClear: boolean;
  27812. /**
  27813. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27814. */
  27815. alphaMode: number;
  27816. /**
  27817. * Sets the setAlphaBlendConstants of the babylon engine
  27818. */
  27819. alphaConstants: Color4;
  27820. /**
  27821. * Animations to be used for the post processing
  27822. */
  27823. animations: Animation[];
  27824. /**
  27825. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27826. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27827. */
  27828. enablePixelPerfectMode: boolean;
  27829. /**
  27830. * Force the postprocess to be applied without taking in account viewport
  27831. */
  27832. forceFullscreenViewport: boolean;
  27833. /**
  27834. * List of inspectable custom properties (used by the Inspector)
  27835. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27836. */
  27837. inspectableCustomProperties: IInspectable[];
  27838. /**
  27839. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27840. *
  27841. * | Value | Type | Description |
  27842. * | ----- | ----------------------------------- | ----------- |
  27843. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27844. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27845. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27846. *
  27847. */
  27848. scaleMode: number;
  27849. /**
  27850. * Force textures to be a power of two (default: false)
  27851. */
  27852. alwaysForcePOT: boolean;
  27853. private _samples;
  27854. /**
  27855. * Number of sample textures (default: 1)
  27856. */
  27857. get samples(): number;
  27858. set samples(n: number);
  27859. /**
  27860. * Modify the scale of the post process to be the same as the viewport (default: false)
  27861. */
  27862. adaptScaleToCurrentViewport: boolean;
  27863. private _camera;
  27864. protected _scene: Scene;
  27865. private _engine;
  27866. private _options;
  27867. private _reusable;
  27868. private _textureType;
  27869. private _textureFormat;
  27870. /**
  27871. * Smart array of input and output textures for the post process.
  27872. * @hidden
  27873. */
  27874. _textures: SmartArray<InternalTexture>;
  27875. /**
  27876. * The index in _textures that corresponds to the output texture.
  27877. * @hidden
  27878. */
  27879. _currentRenderTextureInd: number;
  27880. private _effect;
  27881. private _samplers;
  27882. private _fragmentUrl;
  27883. private _vertexUrl;
  27884. private _parameters;
  27885. private _scaleRatio;
  27886. protected _indexParameters: any;
  27887. private _shareOutputWithPostProcess;
  27888. private _texelSize;
  27889. private _forcedOutputTexture;
  27890. /**
  27891. * Prepass configuration in case this post process needs a texture from prepass
  27892. * @hidden
  27893. */
  27894. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27895. /**
  27896. * Returns the fragment url or shader name used in the post process.
  27897. * @returns the fragment url or name in the shader store.
  27898. */
  27899. getEffectName(): string;
  27900. /**
  27901. * An event triggered when the postprocess is activated.
  27902. */
  27903. onActivateObservable: Observable<Camera>;
  27904. private _onActivateObserver;
  27905. /**
  27906. * A function that is added to the onActivateObservable
  27907. */
  27908. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27909. /**
  27910. * An event triggered when the postprocess changes its size.
  27911. */
  27912. onSizeChangedObservable: Observable<PostProcess>;
  27913. private _onSizeChangedObserver;
  27914. /**
  27915. * A function that is added to the onSizeChangedObservable
  27916. */
  27917. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27918. /**
  27919. * An event triggered when the postprocess applies its effect.
  27920. */
  27921. onApplyObservable: Observable<Effect>;
  27922. private _onApplyObserver;
  27923. /**
  27924. * A function that is added to the onApplyObservable
  27925. */
  27926. set onApply(callback: (effect: Effect) => void);
  27927. /**
  27928. * An event triggered before rendering the postprocess
  27929. */
  27930. onBeforeRenderObservable: Observable<Effect>;
  27931. private _onBeforeRenderObserver;
  27932. /**
  27933. * A function that is added to the onBeforeRenderObservable
  27934. */
  27935. set onBeforeRender(callback: (effect: Effect) => void);
  27936. /**
  27937. * An event triggered after rendering the postprocess
  27938. */
  27939. onAfterRenderObservable: Observable<Effect>;
  27940. private _onAfterRenderObserver;
  27941. /**
  27942. * A function that is added to the onAfterRenderObservable
  27943. */
  27944. set onAfterRender(callback: (efect: Effect) => void);
  27945. /**
  27946. * 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
  27947. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27948. */
  27949. get inputTexture(): InternalTexture;
  27950. set inputTexture(value: InternalTexture);
  27951. /**
  27952. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27953. * the only way to unset it is to use this function to restore its internal state
  27954. */
  27955. restoreDefaultInputTexture(): void;
  27956. /**
  27957. * Gets the camera which post process is applied to.
  27958. * @returns The camera the post process is applied to.
  27959. */
  27960. getCamera(): Camera;
  27961. /**
  27962. * Gets the texel size of the postprocess.
  27963. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27964. */
  27965. get texelSize(): Vector2;
  27966. /**
  27967. * Creates a new instance PostProcess
  27968. * @param name The name of the PostProcess.
  27969. * @param fragmentUrl The url of the fragment shader to be used.
  27970. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27971. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27972. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27973. * @param camera The camera to apply the render pass to.
  27974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27975. * @param engine The engine which the post process will be applied. (default: current engine)
  27976. * @param reusable If the post process can be reused on the same frame. (default: false)
  27977. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27978. * @param textureType Type of textures used when performing the post process. (default: 0)
  27979. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27980. * @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
  27981. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27982. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27983. */
  27984. 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);
  27985. /**
  27986. * Gets a string identifying the name of the class
  27987. * @returns "PostProcess" string
  27988. */
  27989. getClassName(): string;
  27990. /**
  27991. * Gets the engine which this post process belongs to.
  27992. * @returns The engine the post process was enabled with.
  27993. */
  27994. getEngine(): Engine;
  27995. /**
  27996. * The effect that is created when initializing the post process.
  27997. * @returns The created effect corresponding the the postprocess.
  27998. */
  27999. getEffect(): Effect;
  28000. /**
  28001. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28002. * @param postProcess The post process to share the output with.
  28003. * @returns This post process.
  28004. */
  28005. shareOutputWith(postProcess: PostProcess): PostProcess;
  28006. /**
  28007. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28008. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28009. */
  28010. useOwnOutput(): void;
  28011. /**
  28012. * Updates the effect with the current post process compile time values and recompiles the shader.
  28013. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28014. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28015. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28016. * @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
  28017. * @param onCompiled Called when the shader has been compiled.
  28018. * @param onError Called if there is an error when compiling a shader.
  28019. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28020. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28021. */
  28022. 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;
  28023. /**
  28024. * The post process is reusable if it can be used multiple times within one frame.
  28025. * @returns If the post process is reusable
  28026. */
  28027. isReusable(): boolean;
  28028. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28029. markTextureDirty(): void;
  28030. /**
  28031. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28032. * 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.
  28033. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28034. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28035. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28036. * @returns The target texture that was bound to be written to.
  28037. */
  28038. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28039. /**
  28040. * If the post process is supported.
  28041. */
  28042. get isSupported(): boolean;
  28043. /**
  28044. * The aspect ratio of the output texture.
  28045. */
  28046. get aspectRatio(): number;
  28047. /**
  28048. * Get a value indicating if the post-process is ready to be used
  28049. * @returns true if the post-process is ready (shader is compiled)
  28050. */
  28051. isReady(): boolean;
  28052. /**
  28053. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28054. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28055. */
  28056. apply(): Nullable<Effect>;
  28057. private _disposeTextures;
  28058. /**
  28059. * Sets the required values to the prepass renderer.
  28060. * @param prePassRenderer defines the prepass renderer to setup.
  28061. * @returns true if the pre pass is needed.
  28062. */
  28063. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28064. /**
  28065. * Disposes the post process.
  28066. * @param camera The camera to dispose the post process on.
  28067. */
  28068. dispose(camera?: Camera): void;
  28069. /**
  28070. * Serializes the particle system to a JSON object
  28071. * @returns the JSON object
  28072. */
  28073. serialize(): any;
  28074. /**
  28075. * Creates a material from parsed material data
  28076. * @param parsedPostProcess defines parsed post process data
  28077. * @param scene defines the hosting scene
  28078. * @param rootUrl defines the root URL to use to load textures
  28079. * @returns a new post process
  28080. */
  28081. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28082. }
  28083. }
  28084. declare module BABYLON {
  28085. /** @hidden */
  28086. export var kernelBlurVaryingDeclaration: {
  28087. name: string;
  28088. shader: string;
  28089. };
  28090. }
  28091. declare module BABYLON {
  28092. /** @hidden */
  28093. export var kernelBlurFragment: {
  28094. name: string;
  28095. shader: string;
  28096. };
  28097. }
  28098. declare module BABYLON {
  28099. /** @hidden */
  28100. export var kernelBlurFragment2: {
  28101. name: string;
  28102. shader: string;
  28103. };
  28104. }
  28105. declare module BABYLON {
  28106. /** @hidden */
  28107. export var kernelBlurPixelShader: {
  28108. name: string;
  28109. shader: string;
  28110. };
  28111. }
  28112. declare module BABYLON {
  28113. /** @hidden */
  28114. export var kernelBlurVertex: {
  28115. name: string;
  28116. shader: string;
  28117. };
  28118. }
  28119. declare module BABYLON {
  28120. /** @hidden */
  28121. export var kernelBlurVertexShader: {
  28122. name: string;
  28123. shader: string;
  28124. };
  28125. }
  28126. declare module BABYLON {
  28127. /**
  28128. * The Blur Post Process which blurs an image based on a kernel and direction.
  28129. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28130. */
  28131. export class BlurPostProcess extends PostProcess {
  28132. private blockCompilation;
  28133. protected _kernel: number;
  28134. protected _idealKernel: number;
  28135. protected _packedFloat: boolean;
  28136. private _staticDefines;
  28137. /** The direction in which to blur the image. */
  28138. direction: Vector2;
  28139. /**
  28140. * Sets the length in pixels of the blur sample region
  28141. */
  28142. set kernel(v: number);
  28143. /**
  28144. * Gets the length in pixels of the blur sample region
  28145. */
  28146. get kernel(): number;
  28147. /**
  28148. * Sets wether or not the blur needs to unpack/repack floats
  28149. */
  28150. set packedFloat(v: boolean);
  28151. /**
  28152. * Gets wether or not the blur is unpacking/repacking floats
  28153. */
  28154. get packedFloat(): boolean;
  28155. /**
  28156. * Gets a string identifying the name of the class
  28157. * @returns "BlurPostProcess" string
  28158. */
  28159. getClassName(): string;
  28160. /**
  28161. * Creates a new instance BlurPostProcess
  28162. * @param name The name of the effect.
  28163. * @param direction The direction in which to blur the image.
  28164. * @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.
  28165. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28166. * @param camera The camera to apply the render pass to.
  28167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28168. * @param engine The engine which the post process will be applied. (default: current engine)
  28169. * @param reusable If the post process can be reused on the same frame. (default: false)
  28170. * @param textureType Type of textures used when performing the post process. (default: 0)
  28171. * @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)
  28172. */
  28173. 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);
  28174. /**
  28175. * Updates the effect with the current post process compile time values and recompiles the shader.
  28176. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28177. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28178. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28179. * @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
  28180. * @param onCompiled Called when the shader has been compiled.
  28181. * @param onError Called if there is an error when compiling a shader.
  28182. */
  28183. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28184. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28185. /**
  28186. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28187. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28188. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28189. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28190. * The gaps between physical kernels are compensated for in the weighting of the samples
  28191. * @param idealKernel Ideal blur kernel.
  28192. * @return Nearest best kernel.
  28193. */
  28194. protected _nearestBestKernel(idealKernel: number): number;
  28195. /**
  28196. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28197. * @param x The point on the Gaussian distribution to sample.
  28198. * @return the value of the Gaussian function at x.
  28199. */
  28200. protected _gaussianWeight(x: number): number;
  28201. /**
  28202. * Generates a string that can be used as a floating point number in GLSL.
  28203. * @param x Value to print.
  28204. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28205. * @return GLSL float string.
  28206. */
  28207. protected _glslFloat(x: number, decimalFigures?: number): string;
  28208. /** @hidden */
  28209. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28210. }
  28211. }
  28212. declare module BABYLON {
  28213. /**
  28214. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28215. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28216. * You can then easily use it as a reflectionTexture on a flat surface.
  28217. * In case the surface is not a plane, please consider relying on reflection probes.
  28218. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28219. */
  28220. export class MirrorTexture extends RenderTargetTexture {
  28221. private scene;
  28222. /**
  28223. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28224. * 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.
  28225. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28226. */
  28227. mirrorPlane: Plane;
  28228. /**
  28229. * Define the blur ratio used to blur the reflection if needed.
  28230. */
  28231. set blurRatio(value: number);
  28232. get blurRatio(): number;
  28233. /**
  28234. * Define the adaptive blur kernel used to blur the reflection if needed.
  28235. * This will autocompute the closest best match for the `blurKernel`
  28236. */
  28237. set adaptiveBlurKernel(value: number);
  28238. /**
  28239. * Define the blur kernel used to blur the reflection if needed.
  28240. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28241. */
  28242. set blurKernel(value: number);
  28243. /**
  28244. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28245. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28246. */
  28247. set blurKernelX(value: number);
  28248. get blurKernelX(): number;
  28249. /**
  28250. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28251. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28252. */
  28253. set blurKernelY(value: number);
  28254. get blurKernelY(): number;
  28255. private _autoComputeBlurKernel;
  28256. protected _onRatioRescale(): void;
  28257. private _updateGammaSpace;
  28258. private _imageProcessingConfigChangeObserver;
  28259. private _transformMatrix;
  28260. private _mirrorMatrix;
  28261. private _savedViewMatrix;
  28262. private _blurX;
  28263. private _blurY;
  28264. private _adaptiveBlurKernel;
  28265. private _blurKernelX;
  28266. private _blurKernelY;
  28267. private _blurRatio;
  28268. /**
  28269. * Instantiates a Mirror Texture.
  28270. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28271. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28272. * You can then easily use it as a reflectionTexture on a flat surface.
  28273. * In case the surface is not a plane, please consider relying on reflection probes.
  28274. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28275. * @param name
  28276. * @param size
  28277. * @param scene
  28278. * @param generateMipMaps
  28279. * @param type
  28280. * @param samplingMode
  28281. * @param generateDepthBuffer
  28282. */
  28283. constructor(name: string, size: number | {
  28284. width: number;
  28285. height: number;
  28286. } | {
  28287. ratio: number;
  28288. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28289. private _preparePostProcesses;
  28290. /**
  28291. * Clone the mirror texture.
  28292. * @returns the cloned texture
  28293. */
  28294. clone(): MirrorTexture;
  28295. /**
  28296. * Serialize the texture to a JSON representation you could use in Parse later on
  28297. * @returns the serialized JSON representation
  28298. */
  28299. serialize(): any;
  28300. /**
  28301. * Dispose the texture and release its associated resources.
  28302. */
  28303. dispose(): void;
  28304. }
  28305. }
  28306. declare module BABYLON {
  28307. /**
  28308. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28309. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28310. */
  28311. export class Texture extends BaseTexture {
  28312. /**
  28313. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28314. */
  28315. static SerializeBuffers: boolean;
  28316. /**
  28317. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  28318. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  28319. */
  28320. static ForceSerializeBuffers: boolean;
  28321. /** @hidden */
  28322. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28323. /** @hidden */
  28324. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28325. /** @hidden */
  28326. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28327. /** nearest is mag = nearest and min = nearest and mip = linear */
  28328. static readonly NEAREST_SAMPLINGMODE: number;
  28329. /** nearest is mag = nearest and min = nearest and mip = linear */
  28330. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28331. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28332. static readonly BILINEAR_SAMPLINGMODE: number;
  28333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28334. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28335. /** Trilinear is mag = linear and min = linear and mip = linear */
  28336. static readonly TRILINEAR_SAMPLINGMODE: number;
  28337. /** Trilinear is mag = linear and min = linear and mip = linear */
  28338. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28339. /** mag = nearest and min = nearest and mip = nearest */
  28340. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28341. /** mag = nearest and min = linear and mip = nearest */
  28342. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28343. /** mag = nearest and min = linear and mip = linear */
  28344. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28345. /** mag = nearest and min = linear and mip = none */
  28346. static readonly NEAREST_LINEAR: number;
  28347. /** mag = nearest and min = nearest and mip = none */
  28348. static readonly NEAREST_NEAREST: number;
  28349. /** mag = linear and min = nearest and mip = nearest */
  28350. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28351. /** mag = linear and min = nearest and mip = linear */
  28352. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28353. /** mag = linear and min = linear and mip = none */
  28354. static readonly LINEAR_LINEAR: number;
  28355. /** mag = linear and min = nearest and mip = none */
  28356. static readonly LINEAR_NEAREST: number;
  28357. /** Explicit coordinates mode */
  28358. static readonly EXPLICIT_MODE: number;
  28359. /** Spherical coordinates mode */
  28360. static readonly SPHERICAL_MODE: number;
  28361. /** Planar coordinates mode */
  28362. static readonly PLANAR_MODE: number;
  28363. /** Cubic coordinates mode */
  28364. static readonly CUBIC_MODE: number;
  28365. /** Projection coordinates mode */
  28366. static readonly PROJECTION_MODE: number;
  28367. /** Inverse Cubic coordinates mode */
  28368. static readonly SKYBOX_MODE: number;
  28369. /** Inverse Cubic coordinates mode */
  28370. static readonly INVCUBIC_MODE: number;
  28371. /** Equirectangular coordinates mode */
  28372. static readonly EQUIRECTANGULAR_MODE: number;
  28373. /** Equirectangular Fixed coordinates mode */
  28374. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28375. /** Equirectangular Fixed Mirrored coordinates mode */
  28376. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28377. /** Texture is not repeating outside of 0..1 UVs */
  28378. static readonly CLAMP_ADDRESSMODE: number;
  28379. /** Texture is repeating outside of 0..1 UVs */
  28380. static readonly WRAP_ADDRESSMODE: number;
  28381. /** Texture is repeating and mirrored */
  28382. static readonly MIRROR_ADDRESSMODE: number;
  28383. /**
  28384. * 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
  28385. */
  28386. static UseSerializedUrlIfAny: boolean;
  28387. /**
  28388. * Define the url of the texture.
  28389. */
  28390. url: Nullable<string>;
  28391. /**
  28392. * Define an offset on the texture to offset the u coordinates of the UVs
  28393. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28394. */
  28395. uOffset: number;
  28396. /**
  28397. * Define an offset on the texture to offset the v coordinates of the UVs
  28398. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28399. */
  28400. vOffset: number;
  28401. /**
  28402. * Define an offset on the texture to scale the u coordinates of the UVs
  28403. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28404. */
  28405. uScale: number;
  28406. /**
  28407. * Define an offset on the texture to scale the v coordinates of the UVs
  28408. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28409. */
  28410. vScale: number;
  28411. /**
  28412. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28413. * @see https://doc.babylonjs.com/how_to/more_materials
  28414. */
  28415. uAng: number;
  28416. /**
  28417. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28418. * @see https://doc.babylonjs.com/how_to/more_materials
  28419. */
  28420. vAng: number;
  28421. /**
  28422. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28423. * @see https://doc.babylonjs.com/how_to/more_materials
  28424. */
  28425. wAng: number;
  28426. /**
  28427. * Defines the center of rotation (U)
  28428. */
  28429. uRotationCenter: number;
  28430. /**
  28431. * Defines the center of rotation (V)
  28432. */
  28433. vRotationCenter: number;
  28434. /**
  28435. * Defines the center of rotation (W)
  28436. */
  28437. wRotationCenter: number;
  28438. /**
  28439. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28440. */
  28441. homogeneousRotationInUVTransform: boolean;
  28442. /**
  28443. * Are mip maps generated for this texture or not.
  28444. */
  28445. get noMipmap(): boolean;
  28446. /**
  28447. * List of inspectable custom properties (used by the Inspector)
  28448. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28449. */
  28450. inspectableCustomProperties: Nullable<IInspectable[]>;
  28451. private _noMipmap;
  28452. /** @hidden */
  28453. _invertY: boolean;
  28454. private _rowGenerationMatrix;
  28455. private _cachedTextureMatrix;
  28456. private _projectionModeMatrix;
  28457. private _t0;
  28458. private _t1;
  28459. private _t2;
  28460. private _cachedUOffset;
  28461. private _cachedVOffset;
  28462. private _cachedUScale;
  28463. private _cachedVScale;
  28464. private _cachedUAng;
  28465. private _cachedVAng;
  28466. private _cachedWAng;
  28467. private _cachedProjectionMatrixId;
  28468. private _cachedURotationCenter;
  28469. private _cachedVRotationCenter;
  28470. private _cachedWRotationCenter;
  28471. private _cachedHomogeneousRotationInUVTransform;
  28472. private _cachedCoordinatesMode;
  28473. /** @hidden */
  28474. protected _initialSamplingMode: number;
  28475. /** @hidden */
  28476. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28477. private _deleteBuffer;
  28478. protected _format: Nullable<number>;
  28479. private _delayedOnLoad;
  28480. private _delayedOnError;
  28481. private _mimeType?;
  28482. private _loaderOptions?;
  28483. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28484. get mimeType(): string | undefined;
  28485. /**
  28486. * Observable triggered once the texture has been loaded.
  28487. */
  28488. onLoadObservable: Observable<Texture>;
  28489. protected _isBlocking: boolean;
  28490. /**
  28491. * Is the texture preventing material to render while loading.
  28492. * If false, a default texture will be used instead of the loading one during the preparation step.
  28493. */
  28494. set isBlocking(value: boolean);
  28495. get isBlocking(): boolean;
  28496. /**
  28497. * Get the current sampling mode associated with the texture.
  28498. */
  28499. get samplingMode(): number;
  28500. /**
  28501. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28502. */
  28503. get invertY(): boolean;
  28504. /**
  28505. * Instantiates a new texture.
  28506. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28507. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28508. * @param url defines the url of the picture to load as a texture
  28509. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28510. * @param noMipmap defines if the texture will require mip maps or not
  28511. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28512. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28513. * @param onLoad defines a callback triggered when the texture has been loaded
  28514. * @param onError defines a callback triggered when an error occurred during the loading session
  28515. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28516. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28517. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28518. * @param mimeType defines an optional mime type information
  28519. * @param loaderOptions options to be passed to the loader
  28520. */
  28521. 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);
  28522. /**
  28523. * Update the url (and optional buffer) of this texture if url was null during construction.
  28524. * @param url the url of the texture
  28525. * @param buffer the buffer of the texture (defaults to null)
  28526. * @param onLoad callback called when the texture is loaded (defaults to null)
  28527. */
  28528. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28529. /**
  28530. * Finish the loading sequence of a texture flagged as delayed load.
  28531. * @hidden
  28532. */
  28533. delayLoad(): void;
  28534. private _prepareRowForTextureGeneration;
  28535. /**
  28536. * Checks if the texture has the same transform matrix than another texture
  28537. * @param texture texture to check against
  28538. * @returns true if the transforms are the same, else false
  28539. */
  28540. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28541. /**
  28542. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28543. * @returns the transform matrix of the texture.
  28544. */
  28545. getTextureMatrix(uBase?: number): Matrix;
  28546. /**
  28547. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28548. * @returns The reflection texture transform
  28549. */
  28550. getReflectionTextureMatrix(): Matrix;
  28551. /**
  28552. * Clones the texture.
  28553. * @returns the cloned texture
  28554. */
  28555. clone(): Texture;
  28556. /**
  28557. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28558. * @returns The JSON representation of the texture
  28559. */
  28560. serialize(): any;
  28561. /**
  28562. * Get the current class name of the texture useful for serialization or dynamic coding.
  28563. * @returns "Texture"
  28564. */
  28565. getClassName(): string;
  28566. /**
  28567. * Dispose the texture and release its associated resources.
  28568. */
  28569. dispose(): void;
  28570. /**
  28571. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28572. * @param parsedTexture Define the JSON representation of the texture
  28573. * @param scene Define the scene the parsed texture should be instantiated in
  28574. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28575. * @returns The parsed texture if successful
  28576. */
  28577. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28578. /**
  28579. * Creates a texture from its base 64 representation.
  28580. * @param data Define the base64 payload without the data: prefix
  28581. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28582. * @param scene Define the scene the texture should belong to
  28583. * @param noMipmap Forces the texture to not create mip map information if true
  28584. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28585. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28586. * @param onLoad define a callback triggered when the texture has been loaded
  28587. * @param onError define a callback triggered when an error occurred during the loading session
  28588. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28589. * @returns the created texture
  28590. */
  28591. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28592. /**
  28593. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28594. * @param data Define the base64 payload without the data: prefix
  28595. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28596. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28597. * @param scene Define the scene the texture should belong to
  28598. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28599. * @param noMipmap Forces the texture to not create mip map information if true
  28600. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28601. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28602. * @param onLoad define a callback triggered when the texture has been loaded
  28603. * @param onError define a callback triggered when an error occurred during the loading session
  28604. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28605. * @returns the created texture
  28606. */
  28607. 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;
  28608. }
  28609. }
  28610. declare module BABYLON {
  28611. /**
  28612. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28613. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28614. */
  28615. export class PostProcessManager {
  28616. private _scene;
  28617. private _indexBuffer;
  28618. private _vertexBuffers;
  28619. /**
  28620. * Creates a new instance PostProcess
  28621. * @param scene The scene that the post process is associated with.
  28622. */
  28623. constructor(scene: Scene);
  28624. private _prepareBuffers;
  28625. private _buildIndexBuffer;
  28626. /**
  28627. * Rebuilds the vertex buffers of the manager.
  28628. * @hidden
  28629. */
  28630. _rebuild(): void;
  28631. /**
  28632. * Prepares a frame to be run through a post process.
  28633. * @param sourceTexture The input texture to the post procesess. (default: null)
  28634. * @param postProcesses An array of post processes to be run. (default: null)
  28635. * @returns True if the post processes were able to be run.
  28636. * @hidden
  28637. */
  28638. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28639. /**
  28640. * Manually render a set of post processes to a texture.
  28641. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28642. * @param postProcesses An array of post processes to be run.
  28643. * @param targetTexture The target texture to render to.
  28644. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28645. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28646. * @param lodLevel defines which lod of the texture to render to
  28647. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28648. */
  28649. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28650. /**
  28651. * Finalize the result of the output of the postprocesses.
  28652. * @param doNotPresent If true the result will not be displayed to the screen.
  28653. * @param targetTexture The target texture to render to.
  28654. * @param faceIndex The index of the face to bind the target texture to.
  28655. * @param postProcesses The array of post processes to render.
  28656. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28657. * @hidden
  28658. */
  28659. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28660. /**
  28661. * Disposes of the post process manager.
  28662. */
  28663. dispose(): void;
  28664. }
  28665. }
  28666. declare module BABYLON {
  28667. /**
  28668. * This Helps creating a texture that will be created from a camera in your scene.
  28669. * It is basically a dynamic texture that could be used to create special effects for instance.
  28670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28671. */
  28672. export class RenderTargetTexture extends Texture {
  28673. /**
  28674. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28675. */
  28676. static readonly REFRESHRATE_RENDER_ONCE: number;
  28677. /**
  28678. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28679. */
  28680. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28681. /**
  28682. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28683. * the central point of your effect and can save a lot of performances.
  28684. */
  28685. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28686. /**
  28687. * Use this predicate to dynamically define the list of mesh you want to render.
  28688. * If set, the renderList property will be overwritten.
  28689. */
  28690. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28691. private _renderList;
  28692. /**
  28693. * Use this list to define the list of mesh you want to render.
  28694. */
  28695. get renderList(): Nullable<Array<AbstractMesh>>;
  28696. set renderList(value: Nullable<Array<AbstractMesh>>);
  28697. /**
  28698. * Use this function to overload the renderList array at rendering time.
  28699. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28700. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28701. * the cube (if the RTT is a cube, else layerOrFace=0).
  28702. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28703. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28704. * hold dummy elements!
  28705. */
  28706. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28707. private _hookArray;
  28708. /**
  28709. * Define if particles should be rendered in your texture.
  28710. */
  28711. renderParticles: boolean;
  28712. /**
  28713. * Define if sprites should be rendered in your texture.
  28714. */
  28715. renderSprites: boolean;
  28716. /**
  28717. * Define the camera used to render the texture.
  28718. */
  28719. activeCamera: Nullable<Camera>;
  28720. /**
  28721. * Override the mesh isReady function with your own one.
  28722. */
  28723. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28724. /**
  28725. * Override the render function of the texture with your own one.
  28726. */
  28727. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28728. /**
  28729. * Define if camera post processes should be use while rendering the texture.
  28730. */
  28731. useCameraPostProcesses: boolean;
  28732. /**
  28733. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28734. */
  28735. ignoreCameraViewport: boolean;
  28736. private _postProcessManager;
  28737. private _postProcesses;
  28738. private _resizeObserver;
  28739. /**
  28740. * An event triggered when the texture is unbind.
  28741. */
  28742. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28743. /**
  28744. * An event triggered when the texture is unbind.
  28745. */
  28746. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28747. private _onAfterUnbindObserver;
  28748. /**
  28749. * Set a after unbind callback in the texture.
  28750. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28751. */
  28752. set onAfterUnbind(callback: () => void);
  28753. /**
  28754. * An event triggered before rendering the texture
  28755. */
  28756. onBeforeRenderObservable: Observable<number>;
  28757. private _onBeforeRenderObserver;
  28758. /**
  28759. * Set a before render callback in the texture.
  28760. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28761. */
  28762. set onBeforeRender(callback: (faceIndex: number) => void);
  28763. /**
  28764. * An event triggered after rendering the texture
  28765. */
  28766. onAfterRenderObservable: Observable<number>;
  28767. private _onAfterRenderObserver;
  28768. /**
  28769. * Set a after render callback in the texture.
  28770. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28771. */
  28772. set onAfterRender(callback: (faceIndex: number) => void);
  28773. /**
  28774. * An event triggered after the texture clear
  28775. */
  28776. onClearObservable: Observable<Engine>;
  28777. private _onClearObserver;
  28778. /**
  28779. * Set a clear callback in the texture.
  28780. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28781. */
  28782. set onClear(callback: (Engine: Engine) => void);
  28783. /**
  28784. * An event triggered when the texture is resized.
  28785. */
  28786. onResizeObservable: Observable<RenderTargetTexture>;
  28787. /**
  28788. * Define the clear color of the Render Target if it should be different from the scene.
  28789. */
  28790. clearColor: Color4;
  28791. protected _size: number | {
  28792. width: number;
  28793. height: number;
  28794. layers?: number;
  28795. };
  28796. protected _initialSizeParameter: number | {
  28797. width: number;
  28798. height: number;
  28799. } | {
  28800. ratio: number;
  28801. };
  28802. protected _sizeRatio: Nullable<number>;
  28803. /** @hidden */
  28804. _generateMipMaps: boolean;
  28805. protected _renderingManager: RenderingManager;
  28806. /** @hidden */
  28807. _waitingRenderList?: string[];
  28808. protected _doNotChangeAspectRatio: boolean;
  28809. protected _currentRefreshId: number;
  28810. protected _refreshRate: number;
  28811. protected _textureMatrix: Matrix;
  28812. protected _samples: number;
  28813. protected _renderTargetOptions: RenderTargetCreationOptions;
  28814. /**
  28815. * Gets render target creation options that were used.
  28816. */
  28817. get renderTargetOptions(): RenderTargetCreationOptions;
  28818. protected _onRatioRescale(): void;
  28819. /**
  28820. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28821. * It must define where the camera used to render the texture is set
  28822. */
  28823. boundingBoxPosition: Vector3;
  28824. private _boundingBoxSize;
  28825. /**
  28826. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28827. * When defined, the cubemap will switch to local mode
  28828. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28829. * @example https://www.babylonjs-playground.com/#RNASML
  28830. */
  28831. set boundingBoxSize(value: Vector3);
  28832. get boundingBoxSize(): Vector3;
  28833. /**
  28834. * In case the RTT has been created with a depth texture, get the associated
  28835. * depth texture.
  28836. * Otherwise, return null.
  28837. */
  28838. get depthStencilTexture(): Nullable<InternalTexture>;
  28839. /**
  28840. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28841. * or used a shadow, depth texture...
  28842. * @param name The friendly name of the texture
  28843. * @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)
  28844. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28845. * @param generateMipMaps True if mip maps need to be generated after render.
  28846. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28847. * @param type The type of the buffer in the RTT (int, half float, float...)
  28848. * @param isCube True if a cube texture needs to be created
  28849. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28850. * @param generateDepthBuffer True to generate a depth buffer
  28851. * @param generateStencilBuffer True to generate a stencil buffer
  28852. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28853. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28854. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28855. */
  28856. constructor(name: string, size: number | {
  28857. width: number;
  28858. height: number;
  28859. layers?: number;
  28860. } | {
  28861. ratio: number;
  28862. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28863. /**
  28864. * Creates a depth stencil texture.
  28865. * This is only available in WebGL 2 or with the depth texture extension available.
  28866. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28867. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28868. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28869. */
  28870. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28871. private _processSizeParameter;
  28872. /**
  28873. * Define the number of samples to use in case of MSAA.
  28874. * It defaults to one meaning no MSAA has been enabled.
  28875. */
  28876. get samples(): number;
  28877. set samples(value: number);
  28878. /**
  28879. * Resets the refresh counter of the texture and start bak from scratch.
  28880. * Could be useful to regenerate the texture if it is setup to render only once.
  28881. */
  28882. resetRefreshCounter(): void;
  28883. /**
  28884. * Define the refresh rate of the texture or the rendering frequency.
  28885. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28886. */
  28887. get refreshRate(): number;
  28888. set refreshRate(value: number);
  28889. /**
  28890. * Adds a post process to the render target rendering passes.
  28891. * @param postProcess define the post process to add
  28892. */
  28893. addPostProcess(postProcess: PostProcess): void;
  28894. /**
  28895. * Clear all the post processes attached to the render target
  28896. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28897. */
  28898. clearPostProcesses(dispose?: boolean): void;
  28899. /**
  28900. * Remove one of the post process from the list of attached post processes to the texture
  28901. * @param postProcess define the post process to remove from the list
  28902. */
  28903. removePostProcess(postProcess: PostProcess): void;
  28904. /** @hidden */
  28905. _shouldRender(): boolean;
  28906. /**
  28907. * Gets the actual render size of the texture.
  28908. * @returns the width of the render size
  28909. */
  28910. getRenderSize(): number;
  28911. /**
  28912. * Gets the actual render width of the texture.
  28913. * @returns the width of the render size
  28914. */
  28915. getRenderWidth(): number;
  28916. /**
  28917. * Gets the actual render height of the texture.
  28918. * @returns the height of the render size
  28919. */
  28920. getRenderHeight(): number;
  28921. /**
  28922. * Gets the actual number of layers of the texture.
  28923. * @returns the number of layers
  28924. */
  28925. getRenderLayers(): number;
  28926. /**
  28927. * Get if the texture can be rescaled or not.
  28928. */
  28929. get canRescale(): boolean;
  28930. /**
  28931. * Resize the texture using a ratio.
  28932. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28933. */
  28934. scale(ratio: number): void;
  28935. /**
  28936. * Get the texture reflection matrix used to rotate/transform the reflection.
  28937. * @returns the reflection matrix
  28938. */
  28939. getReflectionTextureMatrix(): Matrix;
  28940. /**
  28941. * Resize the texture to a new desired size.
  28942. * Be carrefull as it will recreate all the data in the new texture.
  28943. * @param size Define the new size. It can be:
  28944. * - a number for squared texture,
  28945. * - an object containing { width: number, height: number }
  28946. * - or an object containing a ratio { ratio: number }
  28947. */
  28948. resize(size: number | {
  28949. width: number;
  28950. height: number;
  28951. } | {
  28952. ratio: number;
  28953. }): void;
  28954. private _defaultRenderListPrepared;
  28955. /**
  28956. * Renders all the objects from the render list into the texture.
  28957. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28958. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28959. */
  28960. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28961. private _bestReflectionRenderTargetDimension;
  28962. private _prepareRenderingManager;
  28963. /**
  28964. * @hidden
  28965. * @param faceIndex face index to bind to if this is a cubetexture
  28966. * @param layer defines the index of the texture to bind in the array
  28967. */
  28968. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28969. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28970. private renderToTarget;
  28971. /**
  28972. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28973. * This allowed control for front to back rendering or reversly depending of the special needs.
  28974. *
  28975. * @param renderingGroupId The rendering group id corresponding to its index
  28976. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28977. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28978. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28979. */
  28980. 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;
  28981. /**
  28982. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28983. *
  28984. * @param renderingGroupId The rendering group id corresponding to its index
  28985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28986. */
  28987. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28988. /**
  28989. * Clones the texture.
  28990. * @returns the cloned texture
  28991. */
  28992. clone(): RenderTargetTexture;
  28993. /**
  28994. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28995. * @returns The JSON representation of the texture
  28996. */
  28997. serialize(): any;
  28998. /**
  28999. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29000. */
  29001. disposeFramebufferObjects(): void;
  29002. /**
  29003. * Dispose the texture and release its associated resources.
  29004. */
  29005. dispose(): void;
  29006. /** @hidden */
  29007. _rebuild(): void;
  29008. /**
  29009. * Clear the info related to rendering groups preventing retention point in material dispose.
  29010. */
  29011. freeRenderingGroups(): void;
  29012. /**
  29013. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29014. * @returns the view count
  29015. */
  29016. getViewCount(): number;
  29017. }
  29018. }
  29019. declare module BABYLON {
  29020. /**
  29021. * Class used to manipulate GUIDs
  29022. */
  29023. export class GUID {
  29024. /**
  29025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29026. * Be aware Math.random() could cause collisions, but:
  29027. * "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"
  29028. * @returns a pseudo random id
  29029. */
  29030. static RandomId(): string;
  29031. }
  29032. }
  29033. declare module BABYLON {
  29034. /**
  29035. * Options to be used when creating a shadow depth material
  29036. */
  29037. export interface IIOptionShadowDepthMaterial {
  29038. /** Variables in the vertex shader code that need to have their names remapped.
  29039. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29040. * "var_name" should be either: worldPos or vNormalW
  29041. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29042. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29043. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29044. */
  29045. remappedVariables?: string[];
  29046. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29047. standalone?: boolean;
  29048. }
  29049. /**
  29050. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29051. */
  29052. export class ShadowDepthWrapper {
  29053. private _scene;
  29054. private _options?;
  29055. private _baseMaterial;
  29056. private _onEffectCreatedObserver;
  29057. private _subMeshToEffect;
  29058. private _subMeshToDepthEffect;
  29059. private _meshes;
  29060. /** @hidden */
  29061. _matriceNames: any;
  29062. /** Gets the standalone status of the wrapper */
  29063. get standalone(): boolean;
  29064. /** Gets the base material the wrapper is built upon */
  29065. get baseMaterial(): Material;
  29066. /**
  29067. * Instantiate a new shadow depth wrapper.
  29068. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29069. * generate the shadow depth map. For more information, please refer to the documentation:
  29070. * https://doc.babylonjs.com/babylon101/shadows
  29071. * @param baseMaterial Material to wrap
  29072. * @param scene Define the scene the material belongs to
  29073. * @param options Options used to create the wrapper
  29074. */
  29075. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29076. /**
  29077. * Gets the effect to use to generate the depth map
  29078. * @param subMesh subMesh to get the effect for
  29079. * @param shadowGenerator shadow generator to get the effect for
  29080. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29081. */
  29082. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29083. /**
  29084. * Specifies that the submesh is ready to be used for depth rendering
  29085. * @param subMesh submesh to check
  29086. * @param defines the list of defines to take into account when checking the effect
  29087. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29088. * @param useInstances specifies that instances should be used
  29089. * @returns a boolean indicating that the submesh is ready or not
  29090. */
  29091. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29092. /**
  29093. * Disposes the resources
  29094. */
  29095. dispose(): void;
  29096. private _makeEffect;
  29097. }
  29098. }
  29099. declare module BABYLON {
  29100. /**
  29101. * Options for compiling materials.
  29102. */
  29103. export interface IMaterialCompilationOptions {
  29104. /**
  29105. * Defines whether clip planes are enabled.
  29106. */
  29107. clipPlane: boolean;
  29108. /**
  29109. * Defines whether instances are enabled.
  29110. */
  29111. useInstances: boolean;
  29112. }
  29113. /**
  29114. * Options passed when calling customShaderNameResolve
  29115. */
  29116. export interface ICustomShaderNameResolveOptions {
  29117. /**
  29118. * 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
  29119. */
  29120. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29121. }
  29122. /**
  29123. * Base class for the main features of a material in Babylon.js
  29124. */
  29125. export class Material implements IAnimatable {
  29126. /**
  29127. * Returns the triangle fill mode
  29128. */
  29129. static readonly TriangleFillMode: number;
  29130. /**
  29131. * Returns the wireframe mode
  29132. */
  29133. static readonly WireFrameFillMode: number;
  29134. /**
  29135. * Returns the point fill mode
  29136. */
  29137. static readonly PointFillMode: number;
  29138. /**
  29139. * Returns the point list draw mode
  29140. */
  29141. static readonly PointListDrawMode: number;
  29142. /**
  29143. * Returns the line list draw mode
  29144. */
  29145. static readonly LineListDrawMode: number;
  29146. /**
  29147. * Returns the line loop draw mode
  29148. */
  29149. static readonly LineLoopDrawMode: number;
  29150. /**
  29151. * Returns the line strip draw mode
  29152. */
  29153. static readonly LineStripDrawMode: number;
  29154. /**
  29155. * Returns the triangle strip draw mode
  29156. */
  29157. static readonly TriangleStripDrawMode: number;
  29158. /**
  29159. * Returns the triangle fan draw mode
  29160. */
  29161. static readonly TriangleFanDrawMode: number;
  29162. /**
  29163. * Stores the clock-wise side orientation
  29164. */
  29165. static readonly ClockWiseSideOrientation: number;
  29166. /**
  29167. * Stores the counter clock-wise side orientation
  29168. */
  29169. static readonly CounterClockWiseSideOrientation: number;
  29170. /**
  29171. * The dirty texture flag value
  29172. */
  29173. static readonly TextureDirtyFlag: number;
  29174. /**
  29175. * The dirty light flag value
  29176. */
  29177. static readonly LightDirtyFlag: number;
  29178. /**
  29179. * The dirty fresnel flag value
  29180. */
  29181. static readonly FresnelDirtyFlag: number;
  29182. /**
  29183. * The dirty attribute flag value
  29184. */
  29185. static readonly AttributesDirtyFlag: number;
  29186. /**
  29187. * The dirty misc flag value
  29188. */
  29189. static readonly MiscDirtyFlag: number;
  29190. /**
  29191. * The dirty prepass flag value
  29192. */
  29193. static readonly PrePassDirtyFlag: number;
  29194. /**
  29195. * The all dirty flag value
  29196. */
  29197. static readonly AllDirtyFlag: number;
  29198. /**
  29199. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29200. */
  29201. static readonly MATERIAL_OPAQUE: number;
  29202. /**
  29203. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29204. */
  29205. static readonly MATERIAL_ALPHATEST: number;
  29206. /**
  29207. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29208. */
  29209. static readonly MATERIAL_ALPHABLEND: number;
  29210. /**
  29211. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29212. * They are also discarded below the alpha cutoff threshold to improve performances.
  29213. */
  29214. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29215. /**
  29216. * The Whiteout method is used to blend normals.
  29217. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29218. */
  29219. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29220. /**
  29221. * The Reoriented Normal Mapping method is used to blend normals.
  29222. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29223. */
  29224. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29225. /**
  29226. * Custom callback helping to override the default shader used in the material.
  29227. */
  29228. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29229. /**
  29230. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29231. */
  29232. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29233. /**
  29234. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29235. * This means that the material can keep using a previous shader while a new one is being compiled.
  29236. * This is mostly used when shader parallel compilation is supported (true by default)
  29237. */
  29238. allowShaderHotSwapping: boolean;
  29239. /**
  29240. * The ID of the material
  29241. */
  29242. id: string;
  29243. /**
  29244. * Gets or sets the unique id of the material
  29245. */
  29246. uniqueId: number;
  29247. /**
  29248. * The name of the material
  29249. */
  29250. name: string;
  29251. /**
  29252. * Gets or sets user defined metadata
  29253. */
  29254. metadata: any;
  29255. /**
  29256. * For internal use only. Please do not use.
  29257. */
  29258. reservedDataStore: any;
  29259. /**
  29260. * Specifies if the ready state should be checked on each call
  29261. */
  29262. checkReadyOnEveryCall: boolean;
  29263. /**
  29264. * Specifies if the ready state should be checked once
  29265. */
  29266. checkReadyOnlyOnce: boolean;
  29267. /**
  29268. * The state of the material
  29269. */
  29270. state: string;
  29271. /**
  29272. * If the material can be rendered to several textures with MRT extension
  29273. */
  29274. get canRenderToMRT(): boolean;
  29275. /**
  29276. * The alpha value of the material
  29277. */
  29278. protected _alpha: number;
  29279. /**
  29280. * List of inspectable custom properties (used by the Inspector)
  29281. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29282. */
  29283. inspectableCustomProperties: IInspectable[];
  29284. /**
  29285. * Sets the alpha value of the material
  29286. */
  29287. set alpha(value: number);
  29288. /**
  29289. * Gets the alpha value of the material
  29290. */
  29291. get alpha(): number;
  29292. /**
  29293. * Specifies if back face culling is enabled
  29294. */
  29295. protected _backFaceCulling: boolean;
  29296. /**
  29297. * Sets the back-face culling state
  29298. */
  29299. set backFaceCulling(value: boolean);
  29300. /**
  29301. * Gets the back-face culling state
  29302. */
  29303. get backFaceCulling(): boolean;
  29304. /**
  29305. * Stores the value for side orientation
  29306. */
  29307. sideOrientation: number;
  29308. /**
  29309. * Callback triggered when the material is compiled
  29310. */
  29311. onCompiled: Nullable<(effect: Effect) => void>;
  29312. /**
  29313. * Callback triggered when an error occurs
  29314. */
  29315. onError: Nullable<(effect: Effect, errors: string) => void>;
  29316. /**
  29317. * Callback triggered to get the render target textures
  29318. */
  29319. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29320. /**
  29321. * Gets a boolean indicating that current material needs to register RTT
  29322. */
  29323. get hasRenderTargetTextures(): boolean;
  29324. /**
  29325. * Specifies if the material should be serialized
  29326. */
  29327. doNotSerialize: boolean;
  29328. /**
  29329. * @hidden
  29330. */
  29331. _storeEffectOnSubMeshes: boolean;
  29332. /**
  29333. * Stores the animations for the material
  29334. */
  29335. animations: Nullable<Array<Animation>>;
  29336. /**
  29337. * An event triggered when the material is disposed
  29338. */
  29339. onDisposeObservable: Observable<Material>;
  29340. /**
  29341. * An observer which watches for dispose events
  29342. */
  29343. private _onDisposeObserver;
  29344. private _onUnBindObservable;
  29345. /**
  29346. * Called during a dispose event
  29347. */
  29348. set onDispose(callback: () => void);
  29349. private _onBindObservable;
  29350. /**
  29351. * An event triggered when the material is bound
  29352. */
  29353. get onBindObservable(): Observable<AbstractMesh>;
  29354. /**
  29355. * An observer which watches for bind events
  29356. */
  29357. private _onBindObserver;
  29358. /**
  29359. * Called during a bind event
  29360. */
  29361. set onBind(callback: (Mesh: AbstractMesh) => void);
  29362. /**
  29363. * An event triggered when the material is unbound
  29364. */
  29365. get onUnBindObservable(): Observable<Material>;
  29366. protected _onEffectCreatedObservable: Nullable<Observable<{
  29367. effect: Effect;
  29368. subMesh: Nullable<SubMesh>;
  29369. }>>;
  29370. /**
  29371. * An event triggered when the effect is (re)created
  29372. */
  29373. get onEffectCreatedObservable(): Observable<{
  29374. effect: Effect;
  29375. subMesh: Nullable<SubMesh>;
  29376. }>;
  29377. /**
  29378. * Stores the value of the alpha mode
  29379. */
  29380. private _alphaMode;
  29381. /**
  29382. * Sets the value of the alpha mode.
  29383. *
  29384. * | Value | Type | Description |
  29385. * | --- | --- | --- |
  29386. * | 0 | ALPHA_DISABLE | |
  29387. * | 1 | ALPHA_ADD | |
  29388. * | 2 | ALPHA_COMBINE | |
  29389. * | 3 | ALPHA_SUBTRACT | |
  29390. * | 4 | ALPHA_MULTIPLY | |
  29391. * | 5 | ALPHA_MAXIMIZED | |
  29392. * | 6 | ALPHA_ONEONE | |
  29393. * | 7 | ALPHA_PREMULTIPLIED | |
  29394. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29395. * | 9 | ALPHA_INTERPOLATE | |
  29396. * | 10 | ALPHA_SCREENMODE | |
  29397. *
  29398. */
  29399. set alphaMode(value: number);
  29400. /**
  29401. * Gets the value of the alpha mode
  29402. */
  29403. get alphaMode(): number;
  29404. /**
  29405. * Stores the state of the need depth pre-pass value
  29406. */
  29407. private _needDepthPrePass;
  29408. /**
  29409. * Sets the need depth pre-pass value
  29410. */
  29411. set needDepthPrePass(value: boolean);
  29412. /**
  29413. * Gets the depth pre-pass value
  29414. */
  29415. get needDepthPrePass(): boolean;
  29416. /**
  29417. * Specifies if depth writing should be disabled
  29418. */
  29419. disableDepthWrite: boolean;
  29420. /**
  29421. * Specifies if color writing should be disabled
  29422. */
  29423. disableColorWrite: boolean;
  29424. /**
  29425. * Specifies if depth writing should be forced
  29426. */
  29427. forceDepthWrite: boolean;
  29428. /**
  29429. * Specifies the depth function that should be used. 0 means the default engine function
  29430. */
  29431. depthFunction: number;
  29432. /**
  29433. * Specifies if there should be a separate pass for culling
  29434. */
  29435. separateCullingPass: boolean;
  29436. /**
  29437. * Stores the state specifing if fog should be enabled
  29438. */
  29439. private _fogEnabled;
  29440. /**
  29441. * Sets the state for enabling fog
  29442. */
  29443. set fogEnabled(value: boolean);
  29444. /**
  29445. * Gets the value of the fog enabled state
  29446. */
  29447. get fogEnabled(): boolean;
  29448. /**
  29449. * Stores the size of points
  29450. */
  29451. pointSize: number;
  29452. /**
  29453. * Stores the z offset value
  29454. */
  29455. zOffset: number;
  29456. get wireframe(): boolean;
  29457. /**
  29458. * Sets the state of wireframe mode
  29459. */
  29460. set wireframe(value: boolean);
  29461. /**
  29462. * Gets the value specifying if point clouds are enabled
  29463. */
  29464. get pointsCloud(): boolean;
  29465. /**
  29466. * Sets the state of point cloud mode
  29467. */
  29468. set pointsCloud(value: boolean);
  29469. /**
  29470. * Gets the material fill mode
  29471. */
  29472. get fillMode(): number;
  29473. /**
  29474. * Sets the material fill mode
  29475. */
  29476. set fillMode(value: number);
  29477. /**
  29478. * @hidden
  29479. * Stores the effects for the material
  29480. */
  29481. _effect: Nullable<Effect>;
  29482. /**
  29483. * Specifies if uniform buffers should be used
  29484. */
  29485. private _useUBO;
  29486. /**
  29487. * Stores a reference to the scene
  29488. */
  29489. private _scene;
  29490. /**
  29491. * Stores the fill mode state
  29492. */
  29493. private _fillMode;
  29494. /**
  29495. * Specifies if the depth write state should be cached
  29496. */
  29497. private _cachedDepthWriteState;
  29498. /**
  29499. * Specifies if the color write state should be cached
  29500. */
  29501. private _cachedColorWriteState;
  29502. /**
  29503. * Specifies if the depth function state should be cached
  29504. */
  29505. private _cachedDepthFunctionState;
  29506. /**
  29507. * Stores the uniform buffer
  29508. */
  29509. protected _uniformBuffer: UniformBuffer;
  29510. /** @hidden */
  29511. _indexInSceneMaterialArray: number;
  29512. /** @hidden */
  29513. meshMap: Nullable<{
  29514. [id: string]: AbstractMesh | undefined;
  29515. }>;
  29516. /**
  29517. * Creates a material instance
  29518. * @param name defines the name of the material
  29519. * @param scene defines the scene to reference
  29520. * @param doNotAdd specifies if the material should be added to the scene
  29521. */
  29522. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29523. /**
  29524. * Returns a string representation of the current material
  29525. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29526. * @returns a string with material information
  29527. */
  29528. toString(fullDetails?: boolean): string;
  29529. /**
  29530. * Gets the class name of the material
  29531. * @returns a string with the class name of the material
  29532. */
  29533. getClassName(): string;
  29534. /**
  29535. * Specifies if updates for the material been locked
  29536. */
  29537. get isFrozen(): boolean;
  29538. /**
  29539. * Locks updates for the material
  29540. */
  29541. freeze(): void;
  29542. /**
  29543. * Unlocks updates for the material
  29544. */
  29545. unfreeze(): void;
  29546. /**
  29547. * Specifies if the material is ready to be used
  29548. * @param mesh defines the mesh to check
  29549. * @param useInstances specifies if instances should be used
  29550. * @returns a boolean indicating if the material is ready to be used
  29551. */
  29552. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29553. /**
  29554. * Specifies that the submesh is ready to be used
  29555. * @param mesh defines the mesh to check
  29556. * @param subMesh defines which submesh to check
  29557. * @param useInstances specifies that instances should be used
  29558. * @returns a boolean indicating that the submesh is ready or not
  29559. */
  29560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29561. /**
  29562. * Returns the material effect
  29563. * @returns the effect associated with the material
  29564. */
  29565. getEffect(): Nullable<Effect>;
  29566. /**
  29567. * Returns the current scene
  29568. * @returns a Scene
  29569. */
  29570. getScene(): Scene;
  29571. /**
  29572. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29573. */
  29574. protected _forceAlphaTest: boolean;
  29575. /**
  29576. * The transparency mode of the material.
  29577. */
  29578. protected _transparencyMode: Nullable<number>;
  29579. /**
  29580. * Gets the current transparency mode.
  29581. */
  29582. get transparencyMode(): Nullable<number>;
  29583. /**
  29584. * Sets the transparency mode of the material.
  29585. *
  29586. * | Value | Type | Description |
  29587. * | ----- | ----------------------------------- | ----------- |
  29588. * | 0 | OPAQUE | |
  29589. * | 1 | ALPHATEST | |
  29590. * | 2 | ALPHABLEND | |
  29591. * | 3 | ALPHATESTANDBLEND | |
  29592. *
  29593. */
  29594. set transparencyMode(value: Nullable<number>);
  29595. /**
  29596. * Returns true if alpha blending should be disabled.
  29597. */
  29598. protected get _disableAlphaBlending(): boolean;
  29599. /**
  29600. * Specifies whether or not this material should be rendered in alpha blend mode.
  29601. * @returns a boolean specifying if alpha blending is needed
  29602. */
  29603. needAlphaBlending(): boolean;
  29604. /**
  29605. * Specifies if the mesh will require alpha blending
  29606. * @param mesh defines the mesh to check
  29607. * @returns a boolean specifying if alpha blending is needed for the mesh
  29608. */
  29609. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29610. /**
  29611. * Specifies whether or not this material should be rendered in alpha test mode.
  29612. * @returns a boolean specifying if an alpha test is needed.
  29613. */
  29614. needAlphaTesting(): boolean;
  29615. /**
  29616. * Specifies if material alpha testing should be turned on for the mesh
  29617. * @param mesh defines the mesh to check
  29618. */
  29619. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29620. /**
  29621. * Gets the texture used for the alpha test
  29622. * @returns the texture to use for alpha testing
  29623. */
  29624. getAlphaTestTexture(): Nullable<BaseTexture>;
  29625. /**
  29626. * Marks the material to indicate that it needs to be re-calculated
  29627. */
  29628. markDirty(): void;
  29629. /** @hidden */
  29630. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29631. /**
  29632. * Binds the material to the mesh
  29633. * @param world defines the world transformation matrix
  29634. * @param mesh defines the mesh to bind the material to
  29635. */
  29636. bind(world: Matrix, mesh?: Mesh): void;
  29637. /**
  29638. * Binds the submesh to the material
  29639. * @param world defines the world transformation matrix
  29640. * @param mesh defines the mesh containing the submesh
  29641. * @param subMesh defines the submesh to bind the material to
  29642. */
  29643. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29644. /**
  29645. * Binds the world matrix to the material
  29646. * @param world defines the world transformation matrix
  29647. */
  29648. bindOnlyWorldMatrix(world: Matrix): void;
  29649. /**
  29650. * Binds the scene's uniform buffer to the effect.
  29651. * @param effect defines the effect to bind to the scene uniform buffer
  29652. * @param sceneUbo defines the uniform buffer storing scene data
  29653. */
  29654. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29655. /**
  29656. * Binds the view matrix to the effect
  29657. * @param effect defines the effect to bind the view matrix to
  29658. */
  29659. bindView(effect: Effect): void;
  29660. /**
  29661. * Binds the view projection matrix to the effect
  29662. * @param effect defines the effect to bind the view projection matrix to
  29663. */
  29664. bindViewProjection(effect: Effect): void;
  29665. /**
  29666. * Processes to execute after binding the material to a mesh
  29667. * @param mesh defines the rendered mesh
  29668. */
  29669. protected _afterBind(mesh?: Mesh): void;
  29670. /**
  29671. * Unbinds the material from the mesh
  29672. */
  29673. unbind(): void;
  29674. /**
  29675. * Gets the active textures from the material
  29676. * @returns an array of textures
  29677. */
  29678. getActiveTextures(): BaseTexture[];
  29679. /**
  29680. * Specifies if the material uses a texture
  29681. * @param texture defines the texture to check against the material
  29682. * @returns a boolean specifying if the material uses the texture
  29683. */
  29684. hasTexture(texture: BaseTexture): boolean;
  29685. /**
  29686. * Makes a duplicate of the material, and gives it a new name
  29687. * @param name defines the new name for the duplicated material
  29688. * @returns the cloned material
  29689. */
  29690. clone(name: string): Nullable<Material>;
  29691. /**
  29692. * Gets the meshes bound to the material
  29693. * @returns an array of meshes bound to the material
  29694. */
  29695. getBindedMeshes(): AbstractMesh[];
  29696. /**
  29697. * Force shader compilation
  29698. * @param mesh defines the mesh associated with this material
  29699. * @param onCompiled defines a function to execute once the material is compiled
  29700. * @param options defines the options to configure the compilation
  29701. * @param onError defines a function to execute if the material fails compiling
  29702. */
  29703. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29704. /**
  29705. * Force shader compilation
  29706. * @param mesh defines the mesh that will use this material
  29707. * @param options defines additional options for compiling the shaders
  29708. * @returns a promise that resolves when the compilation completes
  29709. */
  29710. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29711. private static readonly _AllDirtyCallBack;
  29712. private static readonly _ImageProcessingDirtyCallBack;
  29713. private static readonly _TextureDirtyCallBack;
  29714. private static readonly _FresnelDirtyCallBack;
  29715. private static readonly _MiscDirtyCallBack;
  29716. private static readonly _PrePassDirtyCallBack;
  29717. private static readonly _LightsDirtyCallBack;
  29718. private static readonly _AttributeDirtyCallBack;
  29719. private static _FresnelAndMiscDirtyCallBack;
  29720. private static _TextureAndMiscDirtyCallBack;
  29721. private static readonly _DirtyCallbackArray;
  29722. private static readonly _RunDirtyCallBacks;
  29723. /**
  29724. * Marks a define in the material to indicate that it needs to be re-computed
  29725. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29726. */
  29727. markAsDirty(flag: number): void;
  29728. /**
  29729. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29730. * @param func defines a function which checks material defines against the submeshes
  29731. */
  29732. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29733. /**
  29734. * Indicates that the scene should check if the rendering now needs a prepass
  29735. */
  29736. protected _markScenePrePassDirty(): void;
  29737. /**
  29738. * Indicates that we need to re-calculated for all submeshes
  29739. */
  29740. protected _markAllSubMeshesAsAllDirty(): void;
  29741. /**
  29742. * Indicates that image processing needs to be re-calculated for all submeshes
  29743. */
  29744. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29745. /**
  29746. * Indicates that textures need to be re-calculated for all submeshes
  29747. */
  29748. protected _markAllSubMeshesAsTexturesDirty(): void;
  29749. /**
  29750. * Indicates that fresnel needs to be re-calculated for all submeshes
  29751. */
  29752. protected _markAllSubMeshesAsFresnelDirty(): void;
  29753. /**
  29754. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29755. */
  29756. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29757. /**
  29758. * Indicates that lights need to be re-calculated for all submeshes
  29759. */
  29760. protected _markAllSubMeshesAsLightsDirty(): void;
  29761. /**
  29762. * Indicates that attributes need to be re-calculated for all submeshes
  29763. */
  29764. protected _markAllSubMeshesAsAttributesDirty(): void;
  29765. /**
  29766. * Indicates that misc needs to be re-calculated for all submeshes
  29767. */
  29768. protected _markAllSubMeshesAsMiscDirty(): void;
  29769. /**
  29770. * Indicates that prepass needs to be re-calculated for all submeshes
  29771. */
  29772. protected _markAllSubMeshesAsPrePassDirty(): void;
  29773. /**
  29774. * Indicates that textures and misc need to be re-calculated for all submeshes
  29775. */
  29776. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29777. /**
  29778. * Sets the required values to the prepass renderer.
  29779. * @param prePassRenderer defines the prepass renderer to setup.
  29780. * @returns true if the pre pass is needed.
  29781. */
  29782. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29783. /**
  29784. * Disposes the material
  29785. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29786. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29787. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29788. */
  29789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29790. /** @hidden */
  29791. private releaseVertexArrayObject;
  29792. /**
  29793. * Serializes this material
  29794. * @returns the serialized material object
  29795. */
  29796. serialize(): any;
  29797. /**
  29798. * Creates a material from parsed material data
  29799. * @param parsedMaterial defines parsed material data
  29800. * @param scene defines the hosting scene
  29801. * @param rootUrl defines the root URL to use to load textures
  29802. * @returns a new material
  29803. */
  29804. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29805. }
  29806. }
  29807. declare module BABYLON {
  29808. /**
  29809. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29810. * separate meshes. This can be use to improve performances.
  29811. * @see https://doc.babylonjs.com/how_to/multi_materials
  29812. */
  29813. export class MultiMaterial extends Material {
  29814. private _subMaterials;
  29815. /**
  29816. * Gets or Sets the list of Materials used within the multi material.
  29817. * They need to be ordered according to the submeshes order in the associated mesh
  29818. */
  29819. get subMaterials(): Nullable<Material>[];
  29820. set subMaterials(value: Nullable<Material>[]);
  29821. /**
  29822. * Function used to align with Node.getChildren()
  29823. * @returns the list of Materials used within the multi material
  29824. */
  29825. getChildren(): Nullable<Material>[];
  29826. /**
  29827. * Instantiates a new Multi Material
  29828. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29829. * separate meshes. This can be use to improve performances.
  29830. * @see https://doc.babylonjs.com/how_to/multi_materials
  29831. * @param name Define the name in the scene
  29832. * @param scene Define the scene the material belongs to
  29833. */
  29834. constructor(name: string, scene: Scene);
  29835. private _hookArray;
  29836. /**
  29837. * Get one of the submaterial by its index in the submaterials array
  29838. * @param index The index to look the sub material at
  29839. * @returns The Material if the index has been defined
  29840. */
  29841. getSubMaterial(index: number): Nullable<Material>;
  29842. /**
  29843. * Get the list of active textures for the whole sub materials list.
  29844. * @returns All the textures that will be used during the rendering
  29845. */
  29846. getActiveTextures(): BaseTexture[];
  29847. /**
  29848. * Gets the current class name of the material e.g. "MultiMaterial"
  29849. * Mainly use in serialization.
  29850. * @returns the class name
  29851. */
  29852. getClassName(): string;
  29853. /**
  29854. * Checks if the material is ready to render the requested sub mesh
  29855. * @param mesh Define the mesh the submesh belongs to
  29856. * @param subMesh Define the sub mesh to look readyness for
  29857. * @param useInstances Define whether or not the material is used with instances
  29858. * @returns true if ready, otherwise false
  29859. */
  29860. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29861. /**
  29862. * Clones the current material and its related sub materials
  29863. * @param name Define the name of the newly cloned material
  29864. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29865. * @returns the cloned material
  29866. */
  29867. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29868. /**
  29869. * Serializes the materials into a JSON representation.
  29870. * @returns the JSON representation
  29871. */
  29872. serialize(): any;
  29873. /**
  29874. * Dispose the material and release its associated resources
  29875. * @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)
  29876. * @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)
  29877. * @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)
  29878. */
  29879. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29880. /**
  29881. * Creates a MultiMaterial from parsed MultiMaterial data.
  29882. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29883. * @param scene defines the hosting scene
  29884. * @returns a new MultiMaterial
  29885. */
  29886. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29887. }
  29888. }
  29889. declare module BABYLON {
  29890. /**
  29891. * Defines a subdivision inside a mesh
  29892. */
  29893. export class SubMesh implements ICullable {
  29894. /** the material index to use */
  29895. materialIndex: number;
  29896. /** vertex index start */
  29897. verticesStart: number;
  29898. /** vertices count */
  29899. verticesCount: number;
  29900. /** index start */
  29901. indexStart: number;
  29902. /** indices count */
  29903. indexCount: number;
  29904. /** @hidden */
  29905. _materialDefines: Nullable<MaterialDefines>;
  29906. /** @hidden */
  29907. _materialEffect: Nullable<Effect>;
  29908. /** @hidden */
  29909. _effectOverride: Nullable<Effect>;
  29910. /**
  29911. * Gets material defines used by the effect associated to the sub mesh
  29912. */
  29913. get materialDefines(): Nullable<MaterialDefines>;
  29914. /**
  29915. * Sets material defines used by the effect associated to the sub mesh
  29916. */
  29917. set materialDefines(defines: Nullable<MaterialDefines>);
  29918. /**
  29919. * Gets associated effect
  29920. */
  29921. get effect(): Nullable<Effect>;
  29922. /**
  29923. * Sets associated effect (effect used to render this submesh)
  29924. * @param effect defines the effect to associate with
  29925. * @param defines defines the set of defines used to compile this effect
  29926. */
  29927. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29928. /** @hidden */
  29929. _linesIndexCount: number;
  29930. private _mesh;
  29931. private _renderingMesh;
  29932. private _boundingInfo;
  29933. private _linesIndexBuffer;
  29934. /** @hidden */
  29935. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29936. /** @hidden */
  29937. _trianglePlanes: Plane[];
  29938. /** @hidden */
  29939. _lastColliderTransformMatrix: Nullable<Matrix>;
  29940. /** @hidden */
  29941. _renderId: number;
  29942. /** @hidden */
  29943. _alphaIndex: number;
  29944. /** @hidden */
  29945. _distanceToCamera: number;
  29946. /** @hidden */
  29947. _id: number;
  29948. private _currentMaterial;
  29949. /**
  29950. * Add a new submesh to a mesh
  29951. * @param materialIndex defines the material index to use
  29952. * @param verticesStart defines vertex index start
  29953. * @param verticesCount defines vertices count
  29954. * @param indexStart defines index start
  29955. * @param indexCount defines indices count
  29956. * @param mesh defines the parent mesh
  29957. * @param renderingMesh defines an optional rendering mesh
  29958. * @param createBoundingBox defines if bounding box should be created for this submesh
  29959. * @returns the new submesh
  29960. */
  29961. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29962. /**
  29963. * Creates a new submesh
  29964. * @param materialIndex defines the material index to use
  29965. * @param verticesStart defines vertex index start
  29966. * @param verticesCount defines vertices count
  29967. * @param indexStart defines index start
  29968. * @param indexCount defines indices count
  29969. * @param mesh defines the parent mesh
  29970. * @param renderingMesh defines an optional rendering mesh
  29971. * @param createBoundingBox defines if bounding box should be created for this submesh
  29972. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29973. */
  29974. constructor(
  29975. /** the material index to use */
  29976. materialIndex: number,
  29977. /** vertex index start */
  29978. verticesStart: number,
  29979. /** vertices count */
  29980. verticesCount: number,
  29981. /** index start */
  29982. indexStart: number,
  29983. /** indices count */
  29984. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29985. /**
  29986. * Returns true if this submesh covers the entire parent mesh
  29987. * @ignorenaming
  29988. */
  29989. get IsGlobal(): boolean;
  29990. /**
  29991. * Returns the submesh BoudingInfo object
  29992. * @returns current bounding info (or mesh's one if the submesh is global)
  29993. */
  29994. getBoundingInfo(): BoundingInfo;
  29995. /**
  29996. * Sets the submesh BoundingInfo
  29997. * @param boundingInfo defines the new bounding info to use
  29998. * @returns the SubMesh
  29999. */
  30000. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30001. /**
  30002. * Returns the mesh of the current submesh
  30003. * @return the parent mesh
  30004. */
  30005. getMesh(): AbstractMesh;
  30006. /**
  30007. * Returns the rendering mesh of the submesh
  30008. * @returns the rendering mesh (could be different from parent mesh)
  30009. */
  30010. getRenderingMesh(): Mesh;
  30011. /**
  30012. * Returns the replacement mesh of the submesh
  30013. * @returns the replacement mesh (could be different from parent mesh)
  30014. */
  30015. getReplacementMesh(): Nullable<AbstractMesh>;
  30016. /**
  30017. * Returns the effective mesh of the submesh
  30018. * @returns the effective mesh (could be different from parent mesh)
  30019. */
  30020. getEffectiveMesh(): AbstractMesh;
  30021. /**
  30022. * Returns the submesh material
  30023. * @returns null or the current material
  30024. */
  30025. getMaterial(): Nullable<Material>;
  30026. private _IsMultiMaterial;
  30027. /**
  30028. * Sets a new updated BoundingInfo object to the submesh
  30029. * @param data defines an optional position array to use to determine the bounding info
  30030. * @returns the SubMesh
  30031. */
  30032. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30033. /** @hidden */
  30034. _checkCollision(collider: Collider): boolean;
  30035. /**
  30036. * Updates the submesh BoundingInfo
  30037. * @param world defines the world matrix to use to update the bounding info
  30038. * @returns the submesh
  30039. */
  30040. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30041. /**
  30042. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30043. * @param frustumPlanes defines the frustum planes
  30044. * @returns true if the submesh is intersecting with the frustum
  30045. */
  30046. isInFrustum(frustumPlanes: Plane[]): boolean;
  30047. /**
  30048. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30049. * @param frustumPlanes defines the frustum planes
  30050. * @returns true if the submesh is inside the frustum
  30051. */
  30052. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30053. /**
  30054. * Renders the submesh
  30055. * @param enableAlphaMode defines if alpha needs to be used
  30056. * @returns the submesh
  30057. */
  30058. render(enableAlphaMode: boolean): SubMesh;
  30059. /**
  30060. * @hidden
  30061. */
  30062. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30063. /**
  30064. * Checks if the submesh intersects with a ray
  30065. * @param ray defines the ray to test
  30066. * @returns true is the passed ray intersects the submesh bounding box
  30067. */
  30068. canIntersects(ray: Ray): boolean;
  30069. /**
  30070. * Intersects current submesh with a ray
  30071. * @param ray defines the ray to test
  30072. * @param positions defines mesh's positions array
  30073. * @param indices defines mesh's indices array
  30074. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30075. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30076. * @returns intersection info or null if no intersection
  30077. */
  30078. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30079. /** @hidden */
  30080. private _intersectLines;
  30081. /** @hidden */
  30082. private _intersectUnIndexedLines;
  30083. /** @hidden */
  30084. private _intersectTriangles;
  30085. /** @hidden */
  30086. private _intersectUnIndexedTriangles;
  30087. /** @hidden */
  30088. _rebuild(): void;
  30089. /**
  30090. * Creates a new submesh from the passed mesh
  30091. * @param newMesh defines the new hosting mesh
  30092. * @param newRenderingMesh defines an optional rendering mesh
  30093. * @returns the new submesh
  30094. */
  30095. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30096. /**
  30097. * Release associated resources
  30098. */
  30099. dispose(): void;
  30100. /**
  30101. * Gets the class name
  30102. * @returns the string "SubMesh".
  30103. */
  30104. getClassName(): string;
  30105. /**
  30106. * Creates a new submesh from indices data
  30107. * @param materialIndex the index of the main mesh material
  30108. * @param startIndex the index where to start the copy in the mesh indices array
  30109. * @param indexCount the number of indices to copy then from the startIndex
  30110. * @param mesh the main mesh to create the submesh from
  30111. * @param renderingMesh the optional rendering mesh
  30112. * @returns a new submesh
  30113. */
  30114. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30115. }
  30116. }
  30117. declare module BABYLON {
  30118. /**
  30119. * Class used to represent data loading progression
  30120. */
  30121. export class SceneLoaderFlags {
  30122. private static _ForceFullSceneLoadingForIncremental;
  30123. private static _ShowLoadingScreen;
  30124. private static _CleanBoneMatrixWeights;
  30125. private static _loggingLevel;
  30126. /**
  30127. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30128. */
  30129. static get ForceFullSceneLoadingForIncremental(): boolean;
  30130. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30131. /**
  30132. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30133. */
  30134. static get ShowLoadingScreen(): boolean;
  30135. static set ShowLoadingScreen(value: boolean);
  30136. /**
  30137. * Defines the current logging level (while loading the scene)
  30138. * @ignorenaming
  30139. */
  30140. static get loggingLevel(): number;
  30141. static set loggingLevel(value: number);
  30142. /**
  30143. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30144. */
  30145. static get CleanBoneMatrixWeights(): boolean;
  30146. static set CleanBoneMatrixWeights(value: boolean);
  30147. }
  30148. }
  30149. declare module BABYLON {
  30150. /**
  30151. * Class used to store geometry data (vertex buffers + index buffer)
  30152. */
  30153. export class Geometry implements IGetSetVerticesData {
  30154. /**
  30155. * Gets or sets the ID of the geometry
  30156. */
  30157. id: string;
  30158. /**
  30159. * Gets or sets the unique ID of the geometry
  30160. */
  30161. uniqueId: number;
  30162. /**
  30163. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30164. */
  30165. delayLoadState: number;
  30166. /**
  30167. * Gets the file containing the data to load when running in delay load state
  30168. */
  30169. delayLoadingFile: Nullable<string>;
  30170. /**
  30171. * Callback called when the geometry is updated
  30172. */
  30173. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30174. private _scene;
  30175. private _engine;
  30176. private _meshes;
  30177. private _totalVertices;
  30178. /** @hidden */
  30179. _indices: IndicesArray;
  30180. /** @hidden */
  30181. _vertexBuffers: {
  30182. [key: string]: VertexBuffer;
  30183. };
  30184. private _isDisposed;
  30185. private _extend;
  30186. private _boundingBias;
  30187. /** @hidden */
  30188. _delayInfo: Array<string>;
  30189. private _indexBuffer;
  30190. private _indexBufferIsUpdatable;
  30191. /** @hidden */
  30192. _boundingInfo: Nullable<BoundingInfo>;
  30193. /** @hidden */
  30194. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30195. /** @hidden */
  30196. _softwareSkinningFrameId: number;
  30197. private _vertexArrayObjects;
  30198. private _updatable;
  30199. /** @hidden */
  30200. _positions: Nullable<Vector3[]>;
  30201. private _positionsCache;
  30202. /**
  30203. * 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
  30204. */
  30205. get boundingBias(): Vector2;
  30206. /**
  30207. * 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
  30208. */
  30209. set boundingBias(value: Vector2);
  30210. /**
  30211. * Static function used to attach a new empty geometry to a mesh
  30212. * @param mesh defines the mesh to attach the geometry to
  30213. * @returns the new Geometry
  30214. */
  30215. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30216. /** Get the list of meshes using this geometry */
  30217. get meshes(): Mesh[];
  30218. /**
  30219. * 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
  30220. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30221. */
  30222. useBoundingInfoFromGeometry: boolean;
  30223. /**
  30224. * Creates a new geometry
  30225. * @param id defines the unique ID
  30226. * @param scene defines the hosting scene
  30227. * @param vertexData defines the VertexData used to get geometry data
  30228. * @param updatable defines if geometry must be updatable (false by default)
  30229. * @param mesh defines the mesh that will be associated with the geometry
  30230. */
  30231. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30232. /**
  30233. * Gets the current extend of the geometry
  30234. */
  30235. get extend(): {
  30236. minimum: Vector3;
  30237. maximum: Vector3;
  30238. };
  30239. /**
  30240. * Gets the hosting scene
  30241. * @returns the hosting Scene
  30242. */
  30243. getScene(): Scene;
  30244. /**
  30245. * Gets the hosting engine
  30246. * @returns the hosting Engine
  30247. */
  30248. getEngine(): Engine;
  30249. /**
  30250. * Defines if the geometry is ready to use
  30251. * @returns true if the geometry is ready to be used
  30252. */
  30253. isReady(): boolean;
  30254. /**
  30255. * Gets a value indicating that the geometry should not be serialized
  30256. */
  30257. get doNotSerialize(): boolean;
  30258. /** @hidden */
  30259. _rebuild(): void;
  30260. /**
  30261. * Affects all geometry data in one call
  30262. * @param vertexData defines the geometry data
  30263. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30264. */
  30265. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30266. /**
  30267. * Set specific vertex data
  30268. * @param kind defines the data kind (Position, normal, etc...)
  30269. * @param data defines the vertex data to use
  30270. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30271. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30272. */
  30273. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30274. /**
  30275. * Removes a specific vertex data
  30276. * @param kind defines the data kind (Position, normal, etc...)
  30277. */
  30278. removeVerticesData(kind: string): void;
  30279. /**
  30280. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30281. * @param buffer defines the vertex buffer to use
  30282. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30283. */
  30284. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30285. /**
  30286. * Update a specific vertex buffer
  30287. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30288. * It will do nothing if the buffer is not updatable
  30289. * @param kind defines the data kind (Position, normal, etc...)
  30290. * @param data defines the data to use
  30291. * @param offset defines the offset in the target buffer where to store the data
  30292. * @param useBytes set to true if the offset is in bytes
  30293. */
  30294. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30295. /**
  30296. * Update a specific vertex buffer
  30297. * This function will create a new buffer if the current one is not updatable
  30298. * @param kind defines the data kind (Position, normal, etc...)
  30299. * @param data defines the data to use
  30300. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30301. */
  30302. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30303. private _updateBoundingInfo;
  30304. /** @hidden */
  30305. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30306. /**
  30307. * Gets total number of vertices
  30308. * @returns the total number of vertices
  30309. */
  30310. getTotalVertices(): number;
  30311. /**
  30312. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30313. * @param kind defines the data kind (Position, normal, etc...)
  30314. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30315. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30316. * @returns a float array containing vertex data
  30317. */
  30318. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30319. /**
  30320. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30321. * @param kind defines the data kind (Position, normal, etc...)
  30322. * @returns true if the vertex buffer with the specified kind is updatable
  30323. */
  30324. isVertexBufferUpdatable(kind: string): boolean;
  30325. /**
  30326. * Gets a specific vertex buffer
  30327. * @param kind defines the data kind (Position, normal, etc...)
  30328. * @returns a VertexBuffer
  30329. */
  30330. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30331. /**
  30332. * Returns all vertex buffers
  30333. * @return an object holding all vertex buffers indexed by kind
  30334. */
  30335. getVertexBuffers(): Nullable<{
  30336. [key: string]: VertexBuffer;
  30337. }>;
  30338. /**
  30339. * Gets a boolean indicating if specific vertex buffer is present
  30340. * @param kind defines the data kind (Position, normal, etc...)
  30341. * @returns true if data is present
  30342. */
  30343. isVerticesDataPresent(kind: string): boolean;
  30344. /**
  30345. * Gets a list of all attached data kinds (Position, normal, etc...)
  30346. * @returns a list of string containing all kinds
  30347. */
  30348. getVerticesDataKinds(): string[];
  30349. /**
  30350. * Update index buffer
  30351. * @param indices defines the indices to store in the index buffer
  30352. * @param offset defines the offset in the target buffer where to store the data
  30353. * @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)
  30354. */
  30355. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30356. /**
  30357. * Creates a new index buffer
  30358. * @param indices defines the indices to store in the index buffer
  30359. * @param totalVertices defines the total number of vertices (could be null)
  30360. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30361. */
  30362. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30363. /**
  30364. * Return the total number of indices
  30365. * @returns the total number of indices
  30366. */
  30367. getTotalIndices(): number;
  30368. /**
  30369. * Gets the index buffer array
  30370. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30371. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30372. * @returns the index buffer array
  30373. */
  30374. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30375. /**
  30376. * Gets the index buffer
  30377. * @return the index buffer
  30378. */
  30379. getIndexBuffer(): Nullable<DataBuffer>;
  30380. /** @hidden */
  30381. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30382. /**
  30383. * Release the associated resources for a specific mesh
  30384. * @param mesh defines the source mesh
  30385. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30386. */
  30387. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30388. /**
  30389. * Apply current geometry to a given mesh
  30390. * @param mesh defines the mesh to apply geometry to
  30391. */
  30392. applyToMesh(mesh: Mesh): void;
  30393. private _updateExtend;
  30394. private _applyToMesh;
  30395. private notifyUpdate;
  30396. /**
  30397. * Load the geometry if it was flagged as delay loaded
  30398. * @param scene defines the hosting scene
  30399. * @param onLoaded defines a callback called when the geometry is loaded
  30400. */
  30401. load(scene: Scene, onLoaded?: () => void): void;
  30402. private _queueLoad;
  30403. /**
  30404. * Invert the geometry to move from a right handed system to a left handed one.
  30405. */
  30406. toLeftHanded(): void;
  30407. /** @hidden */
  30408. _resetPointsArrayCache(): void;
  30409. /** @hidden */
  30410. _generatePointsArray(): boolean;
  30411. /**
  30412. * Gets a value indicating if the geometry is disposed
  30413. * @returns true if the geometry was disposed
  30414. */
  30415. isDisposed(): boolean;
  30416. private _disposeVertexArrayObjects;
  30417. /**
  30418. * Free all associated resources
  30419. */
  30420. dispose(): void;
  30421. /**
  30422. * Clone the current geometry into a new geometry
  30423. * @param id defines the unique ID of the new geometry
  30424. * @returns a new geometry object
  30425. */
  30426. copy(id: string): Geometry;
  30427. /**
  30428. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30429. * @return a JSON representation of the current geometry data (without the vertices data)
  30430. */
  30431. serialize(): any;
  30432. private toNumberArray;
  30433. /**
  30434. * Serialize all vertices data into a JSON oject
  30435. * @returns a JSON representation of the current geometry data
  30436. */
  30437. serializeVerticeData(): any;
  30438. /**
  30439. * Extracts a clone of a mesh geometry
  30440. * @param mesh defines the source mesh
  30441. * @param id defines the unique ID of the new geometry object
  30442. * @returns the new geometry object
  30443. */
  30444. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30445. /**
  30446. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30447. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30448. * Be aware Math.random() could cause collisions, but:
  30449. * "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"
  30450. * @returns a string containing a new GUID
  30451. */
  30452. static RandomId(): string;
  30453. /** @hidden */
  30454. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30455. private static _CleanMatricesWeights;
  30456. /**
  30457. * Create a new geometry from persisted data (Using .babylon file format)
  30458. * @param parsedVertexData defines the persisted data
  30459. * @param scene defines the hosting scene
  30460. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30461. * @returns the new geometry object
  30462. */
  30463. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30464. }
  30465. }
  30466. declare module BABYLON {
  30467. /**
  30468. * Define an interface for all classes that will get and set the data on vertices
  30469. */
  30470. export interface IGetSetVerticesData {
  30471. /**
  30472. * Gets a boolean indicating if specific vertex data is present
  30473. * @param kind defines the vertex data kind to use
  30474. * @returns true is data kind is present
  30475. */
  30476. isVerticesDataPresent(kind: string): boolean;
  30477. /**
  30478. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30479. * @param kind defines the data kind (Position, normal, etc...)
  30480. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30481. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30482. * @returns a float array containing vertex data
  30483. */
  30484. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30485. /**
  30486. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30487. * @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.
  30488. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30489. * @returns the indices array or an empty array if the mesh has no geometry
  30490. */
  30491. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30492. /**
  30493. * Set specific vertex data
  30494. * @param kind defines the data kind (Position, normal, etc...)
  30495. * @param data defines the vertex data to use
  30496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30498. */
  30499. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30500. /**
  30501. * Update a specific associated vertex buffer
  30502. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30503. * - VertexBuffer.PositionKind
  30504. * - VertexBuffer.UVKind
  30505. * - VertexBuffer.UV2Kind
  30506. * - VertexBuffer.UV3Kind
  30507. * - VertexBuffer.UV4Kind
  30508. * - VertexBuffer.UV5Kind
  30509. * - VertexBuffer.UV6Kind
  30510. * - VertexBuffer.ColorKind
  30511. * - VertexBuffer.MatricesIndicesKind
  30512. * - VertexBuffer.MatricesIndicesExtraKind
  30513. * - VertexBuffer.MatricesWeightsKind
  30514. * - VertexBuffer.MatricesWeightsExtraKind
  30515. * @param data defines the data source
  30516. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30517. * @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)
  30518. */
  30519. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30520. /**
  30521. * Creates a new index buffer
  30522. * @param indices defines the indices to store in the index buffer
  30523. * @param totalVertices defines the total number of vertices (could be null)
  30524. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30525. */
  30526. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30527. }
  30528. /**
  30529. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30530. */
  30531. export class VertexData {
  30532. /**
  30533. * Mesh side orientation : usually the external or front surface
  30534. */
  30535. static readonly FRONTSIDE: number;
  30536. /**
  30537. * Mesh side orientation : usually the internal or back surface
  30538. */
  30539. static readonly BACKSIDE: number;
  30540. /**
  30541. * Mesh side orientation : both internal and external or front and back surfaces
  30542. */
  30543. static readonly DOUBLESIDE: number;
  30544. /**
  30545. * Mesh side orientation : by default, `FRONTSIDE`
  30546. */
  30547. static readonly DEFAULTSIDE: number;
  30548. /**
  30549. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30550. */
  30551. positions: Nullable<FloatArray>;
  30552. /**
  30553. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30554. */
  30555. normals: Nullable<FloatArray>;
  30556. /**
  30557. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30558. */
  30559. tangents: Nullable<FloatArray>;
  30560. /**
  30561. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30562. */
  30563. uvs: Nullable<FloatArray>;
  30564. /**
  30565. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30566. */
  30567. uvs2: Nullable<FloatArray>;
  30568. /**
  30569. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30570. */
  30571. uvs3: Nullable<FloatArray>;
  30572. /**
  30573. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30574. */
  30575. uvs4: Nullable<FloatArray>;
  30576. /**
  30577. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30578. */
  30579. uvs5: Nullable<FloatArray>;
  30580. /**
  30581. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30582. */
  30583. uvs6: Nullable<FloatArray>;
  30584. /**
  30585. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30586. */
  30587. colors: Nullable<FloatArray>;
  30588. /**
  30589. * 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).
  30590. */
  30591. matricesIndices: Nullable<FloatArray>;
  30592. /**
  30593. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30594. */
  30595. matricesWeights: Nullable<FloatArray>;
  30596. /**
  30597. * An array extending the number of possible indices
  30598. */
  30599. matricesIndicesExtra: Nullable<FloatArray>;
  30600. /**
  30601. * An array extending the number of possible weights when the number of indices is extended
  30602. */
  30603. matricesWeightsExtra: Nullable<FloatArray>;
  30604. /**
  30605. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30606. */
  30607. indices: Nullable<IndicesArray>;
  30608. /**
  30609. * Uses the passed data array to set the set the values for the specified kind of data
  30610. * @param data a linear array of floating numbers
  30611. * @param kind the type of data that is being set, eg positions, colors etc
  30612. */
  30613. set(data: FloatArray, kind: string): void;
  30614. /**
  30615. * Associates the vertexData to the passed Mesh.
  30616. * Sets it as updatable or not (default `false`)
  30617. * @param mesh the mesh the vertexData is applied to
  30618. * @param updatable when used and having the value true allows new data to update the vertexData
  30619. * @returns the VertexData
  30620. */
  30621. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30622. /**
  30623. * Associates the vertexData to the passed Geometry.
  30624. * Sets it as updatable or not (default `false`)
  30625. * @param geometry the geometry the vertexData is applied to
  30626. * @param updatable when used and having the value true allows new data to update the vertexData
  30627. * @returns VertexData
  30628. */
  30629. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30630. /**
  30631. * Updates the associated mesh
  30632. * @param mesh the mesh to be updated
  30633. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30634. * @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
  30635. * @returns VertexData
  30636. */
  30637. updateMesh(mesh: Mesh): VertexData;
  30638. /**
  30639. * Updates the associated geometry
  30640. * @param geometry the geometry to be updated
  30641. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30642. * @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
  30643. * @returns VertexData.
  30644. */
  30645. updateGeometry(geometry: Geometry): VertexData;
  30646. private _applyTo;
  30647. private _update;
  30648. /**
  30649. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30650. * @param matrix the transforming matrix
  30651. * @returns the VertexData
  30652. */
  30653. transform(matrix: Matrix): VertexData;
  30654. /**
  30655. * Merges the passed VertexData into the current one
  30656. * @param other the VertexData to be merged into the current one
  30657. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30658. * @returns the modified VertexData
  30659. */
  30660. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30661. private _mergeElement;
  30662. private _validate;
  30663. /**
  30664. * Serializes the VertexData
  30665. * @returns a serialized object
  30666. */
  30667. serialize(): any;
  30668. /**
  30669. * Extracts the vertexData from a mesh
  30670. * @param mesh the mesh from which to extract the VertexData
  30671. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30672. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30673. * @returns the object VertexData associated to the passed mesh
  30674. */
  30675. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30676. /**
  30677. * Extracts the vertexData from the geometry
  30678. * @param geometry the geometry from which to extract the VertexData
  30679. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30680. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30681. * @returns the object VertexData associated to the passed mesh
  30682. */
  30683. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30684. private static _ExtractFrom;
  30685. /**
  30686. * Creates the VertexData for a Ribbon
  30687. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30688. * * pathArray array of paths, each of which an array of successive Vector3
  30689. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30690. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30691. * * 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
  30692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30693. * * 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)
  30694. * * 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)
  30695. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30696. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30697. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30698. * @returns the VertexData of the ribbon
  30699. */
  30700. static CreateRibbon(options: {
  30701. pathArray: Vector3[][];
  30702. closeArray?: boolean;
  30703. closePath?: boolean;
  30704. offset?: number;
  30705. sideOrientation?: number;
  30706. frontUVs?: Vector4;
  30707. backUVs?: Vector4;
  30708. invertUV?: boolean;
  30709. uvs?: Vector2[];
  30710. colors?: Color4[];
  30711. }): VertexData;
  30712. /**
  30713. * Creates the VertexData for a box
  30714. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30715. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30716. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30717. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30718. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30719. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30720. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30721. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30722. * * 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)
  30723. * * 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)
  30724. * @returns the VertexData of the box
  30725. */
  30726. static CreateBox(options: {
  30727. size?: number;
  30728. width?: number;
  30729. height?: number;
  30730. depth?: number;
  30731. faceUV?: Vector4[];
  30732. faceColors?: Color4[];
  30733. sideOrientation?: number;
  30734. frontUVs?: Vector4;
  30735. backUVs?: Vector4;
  30736. }): VertexData;
  30737. /**
  30738. * Creates the VertexData for a tiled box
  30739. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30740. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30741. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30742. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30744. * @returns the VertexData of the box
  30745. */
  30746. static CreateTiledBox(options: {
  30747. pattern?: number;
  30748. width?: number;
  30749. height?: number;
  30750. depth?: number;
  30751. tileSize?: number;
  30752. tileWidth?: number;
  30753. tileHeight?: number;
  30754. alignHorizontal?: number;
  30755. alignVertical?: number;
  30756. faceUV?: Vector4[];
  30757. faceColors?: Color4[];
  30758. sideOrientation?: number;
  30759. }): VertexData;
  30760. /**
  30761. * Creates the VertexData for a tiled plane
  30762. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30763. * * pattern a limited pattern arrangement depending on the number
  30764. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30765. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30766. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30768. * * 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)
  30769. * * 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)
  30770. * @returns the VertexData of the tiled plane
  30771. */
  30772. static CreateTiledPlane(options: {
  30773. pattern?: number;
  30774. tileSize?: number;
  30775. tileWidth?: number;
  30776. tileHeight?: number;
  30777. size?: number;
  30778. width?: number;
  30779. height?: number;
  30780. alignHorizontal?: number;
  30781. alignVertical?: number;
  30782. sideOrientation?: number;
  30783. frontUVs?: Vector4;
  30784. backUVs?: Vector4;
  30785. }): VertexData;
  30786. /**
  30787. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30789. * * segments sets the number of horizontal strips optional, default 32
  30790. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30791. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30792. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30793. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30794. * * 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
  30795. * * 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
  30796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30797. * * 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)
  30798. * * 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)
  30799. * @returns the VertexData of the ellipsoid
  30800. */
  30801. static CreateSphere(options: {
  30802. segments?: number;
  30803. diameter?: number;
  30804. diameterX?: number;
  30805. diameterY?: number;
  30806. diameterZ?: number;
  30807. arc?: number;
  30808. slice?: number;
  30809. sideOrientation?: number;
  30810. frontUVs?: Vector4;
  30811. backUVs?: Vector4;
  30812. }): VertexData;
  30813. /**
  30814. * Creates the VertexData for a cylinder, cone or prism
  30815. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30816. * * height sets the height (y direction) of the cylinder, optional, default 2
  30817. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30818. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30819. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30820. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30821. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30822. * * 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
  30823. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30824. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30825. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30826. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  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 cylinder, cone or prism
  30831. */
  30832. static CreateCylinder(options: {
  30833. height?: number;
  30834. diameterTop?: number;
  30835. diameterBottom?: number;
  30836. diameter?: number;
  30837. tessellation?: number;
  30838. subdivisions?: number;
  30839. arc?: number;
  30840. faceColors?: Color4[];
  30841. faceUV?: Vector4[];
  30842. hasRings?: boolean;
  30843. enclose?: boolean;
  30844. sideOrientation?: number;
  30845. frontUVs?: Vector4;
  30846. backUVs?: Vector4;
  30847. }): VertexData;
  30848. /**
  30849. * Creates the VertexData for a torus
  30850. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30851. * * diameter the diameter of the torus, optional default 1
  30852. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30853. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30854. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30855. * * 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)
  30856. * * 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)
  30857. * @returns the VertexData of the torus
  30858. */
  30859. static CreateTorus(options: {
  30860. diameter?: number;
  30861. thickness?: number;
  30862. tessellation?: number;
  30863. sideOrientation?: number;
  30864. frontUVs?: Vector4;
  30865. backUVs?: Vector4;
  30866. }): VertexData;
  30867. /**
  30868. * Creates the VertexData of the LineSystem
  30869. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30870. * - lines an array of lines, each line being an array of successive Vector3
  30871. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30872. * @returns the VertexData of the LineSystem
  30873. */
  30874. static CreateLineSystem(options: {
  30875. lines: Vector3[][];
  30876. colors?: Nullable<Color4[][]>;
  30877. }): VertexData;
  30878. /**
  30879. * Create the VertexData for a DashedLines
  30880. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30881. * - points an array successive Vector3
  30882. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30883. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30884. * - dashNb the intended total number of dashes, optional, default 200
  30885. * @returns the VertexData for the DashedLines
  30886. */
  30887. static CreateDashedLines(options: {
  30888. points: Vector3[];
  30889. dashSize?: number;
  30890. gapSize?: number;
  30891. dashNb?: number;
  30892. }): VertexData;
  30893. /**
  30894. * Creates the VertexData for a Ground
  30895. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30896. * - width the width (x direction) of the ground, optional, default 1
  30897. * - height the height (z direction) of the ground, optional, default 1
  30898. * - subdivisions the number of subdivisions per side, optional, default 1
  30899. * @returns the VertexData of the Ground
  30900. */
  30901. static CreateGround(options: {
  30902. width?: number;
  30903. height?: number;
  30904. subdivisions?: number;
  30905. subdivisionsX?: number;
  30906. subdivisionsY?: number;
  30907. }): VertexData;
  30908. /**
  30909. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30910. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30911. * * xmin the ground minimum X coordinate, optional, default -1
  30912. * * zmin the ground minimum Z coordinate, optional, default -1
  30913. * * xmax the ground maximum X coordinate, optional, default 1
  30914. * * zmax the ground maximum Z coordinate, optional, default 1
  30915. * * 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}
  30916. * * 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}
  30917. * @returns the VertexData of the TiledGround
  30918. */
  30919. static CreateTiledGround(options: {
  30920. xmin: number;
  30921. zmin: number;
  30922. xmax: number;
  30923. zmax: number;
  30924. subdivisions?: {
  30925. w: number;
  30926. h: number;
  30927. };
  30928. precision?: {
  30929. w: number;
  30930. h: number;
  30931. };
  30932. }): VertexData;
  30933. /**
  30934. * Creates the VertexData of the Ground designed from a heightmap
  30935. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30936. * * width the width (x direction) of the ground
  30937. * * height the height (z direction) of the ground
  30938. * * subdivisions the number of subdivisions per side
  30939. * * minHeight the minimum altitude on the ground, optional, default 0
  30940. * * maxHeight the maximum altitude on the ground, optional default 1
  30941. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30942. * * buffer the array holding the image color data
  30943. * * bufferWidth the width of image
  30944. * * bufferHeight the height of image
  30945. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30946. * @returns the VertexData of the Ground designed from a heightmap
  30947. */
  30948. static CreateGroundFromHeightMap(options: {
  30949. width: number;
  30950. height: number;
  30951. subdivisions: number;
  30952. minHeight: number;
  30953. maxHeight: number;
  30954. colorFilter: Color3;
  30955. buffer: Uint8Array;
  30956. bufferWidth: number;
  30957. bufferHeight: number;
  30958. alphaFilter: number;
  30959. }): VertexData;
  30960. /**
  30961. * Creates the VertexData for a Plane
  30962. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30963. * * size sets the width and height of the plane to the value of size, optional default 1
  30964. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30965. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30966. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30967. * * 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)
  30968. * * 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)
  30969. * @returns the VertexData of the box
  30970. */
  30971. static CreatePlane(options: {
  30972. size?: number;
  30973. width?: number;
  30974. height?: number;
  30975. sideOrientation?: number;
  30976. frontUVs?: Vector4;
  30977. backUVs?: Vector4;
  30978. }): VertexData;
  30979. /**
  30980. * Creates the VertexData of the Disc or regular Polygon
  30981. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30982. * * radius the radius of the disc, optional default 0.5
  30983. * * tessellation the number of polygon sides, optional, default 64
  30984. * * 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
  30985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30986. * * 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)
  30987. * * 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)
  30988. * @returns the VertexData of the box
  30989. */
  30990. static CreateDisc(options: {
  30991. radius?: number;
  30992. tessellation?: number;
  30993. arc?: number;
  30994. sideOrientation?: number;
  30995. frontUVs?: Vector4;
  30996. backUVs?: Vector4;
  30997. }): VertexData;
  30998. /**
  30999. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31000. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31001. * @param polygon a mesh built from polygonTriangulation.build()
  31002. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31003. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31004. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31005. * @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)
  31006. * @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)
  31007. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31008. * @returns the VertexData of the Polygon
  31009. */
  31010. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31011. /**
  31012. * Creates the VertexData of the IcoSphere
  31013. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31014. * * radius the radius of the IcoSphere, optional default 1
  31015. * * radiusX allows stretching in the x direction, optional, default radius
  31016. * * radiusY allows stretching in the y direction, optional, default radius
  31017. * * radiusZ allows stretching in the z direction, optional, default radius
  31018. * * flat when true creates a flat shaded mesh, optional, default true
  31019. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31021. * * 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)
  31022. * * 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)
  31023. * @returns the VertexData of the IcoSphere
  31024. */
  31025. static CreateIcoSphere(options: {
  31026. radius?: number;
  31027. radiusX?: number;
  31028. radiusY?: number;
  31029. radiusZ?: number;
  31030. flat?: boolean;
  31031. subdivisions?: number;
  31032. sideOrientation?: number;
  31033. frontUVs?: Vector4;
  31034. backUVs?: Vector4;
  31035. }): VertexData;
  31036. /**
  31037. * Creates the VertexData for a Polyhedron
  31038. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31039. * * type provided types are:
  31040. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31041. * * 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)
  31042. * * size the size of the IcoSphere, optional default 1
  31043. * * sizeX allows stretching in the x direction, optional, default size
  31044. * * sizeY allows stretching in the y direction, optional, default size
  31045. * * sizeZ allows stretching in the z direction, optional, default size
  31046. * * 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
  31047. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31048. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31049. * * flat when true creates a flat shaded mesh, optional, default true
  31050. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31052. * * 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)
  31053. * * 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)
  31054. * @returns the VertexData of the Polyhedron
  31055. */
  31056. static CreatePolyhedron(options: {
  31057. type?: number;
  31058. size?: number;
  31059. sizeX?: number;
  31060. sizeY?: number;
  31061. sizeZ?: number;
  31062. custom?: any;
  31063. faceUV?: Vector4[];
  31064. faceColors?: Color4[];
  31065. flat?: boolean;
  31066. sideOrientation?: number;
  31067. frontUVs?: Vector4;
  31068. backUVs?: Vector4;
  31069. }): VertexData;
  31070. /**
  31071. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31072. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31073. * @returns the VertexData of the Capsule
  31074. */
  31075. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31076. /**
  31077. * Creates the VertexData for a TorusKnot
  31078. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31079. * * radius the radius of the torus knot, optional, default 2
  31080. * * tube the thickness of the tube, optional, default 0.5
  31081. * * radialSegments the number of sides on each tube segments, optional, default 32
  31082. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31083. * * p the number of windings around the z axis, optional, default 2
  31084. * * q the number of windings around the x axis, optional, default 3
  31085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31086. * * 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)
  31087. * * 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)
  31088. * @returns the VertexData of the Torus Knot
  31089. */
  31090. static CreateTorusKnot(options: {
  31091. radius?: number;
  31092. tube?: number;
  31093. radialSegments?: number;
  31094. tubularSegments?: number;
  31095. p?: number;
  31096. q?: number;
  31097. sideOrientation?: number;
  31098. frontUVs?: Vector4;
  31099. backUVs?: Vector4;
  31100. }): VertexData;
  31101. /**
  31102. * Compute normals for given positions and indices
  31103. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31104. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31105. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31106. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31107. * * facetNormals : optional array of facet normals (vector3)
  31108. * * facetPositions : optional array of facet positions (vector3)
  31109. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31110. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31111. * * bInfo : optional bounding info, required for facetPartitioning computation
  31112. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31113. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31114. * * useRightHandedSystem: optional boolean to for right handed system computation
  31115. * * depthSort : optional boolean to enable the facet depth sort computation
  31116. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31117. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31118. */
  31119. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31120. facetNormals?: any;
  31121. facetPositions?: any;
  31122. facetPartitioning?: any;
  31123. ratio?: number;
  31124. bInfo?: any;
  31125. bbSize?: Vector3;
  31126. subDiv?: any;
  31127. useRightHandedSystem?: boolean;
  31128. depthSort?: boolean;
  31129. distanceTo?: Vector3;
  31130. depthSortedFacets?: any;
  31131. }): void;
  31132. /** @hidden */
  31133. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31134. /**
  31135. * Applies VertexData created from the imported parameters to the geometry
  31136. * @param parsedVertexData the parsed data from an imported file
  31137. * @param geometry the geometry to apply the VertexData to
  31138. */
  31139. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31140. }
  31141. }
  31142. declare module BABYLON {
  31143. /**
  31144. * Defines a target to use with MorphTargetManager
  31145. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31146. */
  31147. export class MorphTarget implements IAnimatable {
  31148. /** defines the name of the target */
  31149. name: string;
  31150. /**
  31151. * Gets or sets the list of animations
  31152. */
  31153. animations: Animation[];
  31154. private _scene;
  31155. private _positions;
  31156. private _normals;
  31157. private _tangents;
  31158. private _uvs;
  31159. private _influence;
  31160. private _uniqueId;
  31161. /**
  31162. * Observable raised when the influence changes
  31163. */
  31164. onInfluenceChanged: Observable<boolean>;
  31165. /** @hidden */
  31166. _onDataLayoutChanged: Observable<void>;
  31167. /**
  31168. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31169. */
  31170. get influence(): number;
  31171. set influence(influence: number);
  31172. /**
  31173. * Gets or sets the id of the morph Target
  31174. */
  31175. id: string;
  31176. private _animationPropertiesOverride;
  31177. /**
  31178. * Gets or sets the animation properties override
  31179. */
  31180. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31181. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31182. /**
  31183. * Creates a new MorphTarget
  31184. * @param name defines the name of the target
  31185. * @param influence defines the influence to use
  31186. * @param scene defines the scene the morphtarget belongs to
  31187. */
  31188. constructor(
  31189. /** defines the name of the target */
  31190. name: string, influence?: number, scene?: Nullable<Scene>);
  31191. /**
  31192. * Gets the unique ID of this manager
  31193. */
  31194. get uniqueId(): number;
  31195. /**
  31196. * Gets a boolean defining if the target contains position data
  31197. */
  31198. get hasPositions(): boolean;
  31199. /**
  31200. * Gets a boolean defining if the target contains normal data
  31201. */
  31202. get hasNormals(): boolean;
  31203. /**
  31204. * Gets a boolean defining if the target contains tangent data
  31205. */
  31206. get hasTangents(): boolean;
  31207. /**
  31208. * Gets a boolean defining if the target contains texture coordinates data
  31209. */
  31210. get hasUVs(): boolean;
  31211. /**
  31212. * Affects position data to this target
  31213. * @param data defines the position data to use
  31214. */
  31215. setPositions(data: Nullable<FloatArray>): void;
  31216. /**
  31217. * Gets the position data stored in this target
  31218. * @returns a FloatArray containing the position data (or null if not present)
  31219. */
  31220. getPositions(): Nullable<FloatArray>;
  31221. /**
  31222. * Affects normal data to this target
  31223. * @param data defines the normal data to use
  31224. */
  31225. setNormals(data: Nullable<FloatArray>): void;
  31226. /**
  31227. * Gets the normal data stored in this target
  31228. * @returns a FloatArray containing the normal data (or null if not present)
  31229. */
  31230. getNormals(): Nullable<FloatArray>;
  31231. /**
  31232. * Affects tangent data to this target
  31233. * @param data defines the tangent data to use
  31234. */
  31235. setTangents(data: Nullable<FloatArray>): void;
  31236. /**
  31237. * Gets the tangent data stored in this target
  31238. * @returns a FloatArray containing the tangent data (or null if not present)
  31239. */
  31240. getTangents(): Nullable<FloatArray>;
  31241. /**
  31242. * Affects texture coordinates data to this target
  31243. * @param data defines the texture coordinates data to use
  31244. */
  31245. setUVs(data: Nullable<FloatArray>): void;
  31246. /**
  31247. * Gets the texture coordinates data stored in this target
  31248. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31249. */
  31250. getUVs(): Nullable<FloatArray>;
  31251. /**
  31252. * Clone the current target
  31253. * @returns a new MorphTarget
  31254. */
  31255. clone(): MorphTarget;
  31256. /**
  31257. * Serializes the current target into a Serialization object
  31258. * @returns the serialized object
  31259. */
  31260. serialize(): any;
  31261. /**
  31262. * Returns the string "MorphTarget"
  31263. * @returns "MorphTarget"
  31264. */
  31265. getClassName(): string;
  31266. /**
  31267. * Creates a new target from serialized data
  31268. * @param serializationObject defines the serialized data to use
  31269. * @returns a new MorphTarget
  31270. */
  31271. static Parse(serializationObject: any): MorphTarget;
  31272. /**
  31273. * Creates a MorphTarget from mesh data
  31274. * @param mesh defines the source mesh
  31275. * @param name defines the name to use for the new target
  31276. * @param influence defines the influence to attach to the target
  31277. * @returns a new MorphTarget
  31278. */
  31279. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31280. }
  31281. }
  31282. declare module BABYLON {
  31283. /**
  31284. * This class is used to deform meshes using morphing between different targets
  31285. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31286. */
  31287. export class MorphTargetManager {
  31288. private _targets;
  31289. private _targetInfluenceChangedObservers;
  31290. private _targetDataLayoutChangedObservers;
  31291. private _activeTargets;
  31292. private _scene;
  31293. private _influences;
  31294. private _supportsNormals;
  31295. private _supportsTangents;
  31296. private _supportsUVs;
  31297. private _vertexCount;
  31298. private _uniqueId;
  31299. private _tempInfluences;
  31300. /**
  31301. * Gets or sets a boolean indicating if normals must be morphed
  31302. */
  31303. enableNormalMorphing: boolean;
  31304. /**
  31305. * Gets or sets a boolean indicating if tangents must be morphed
  31306. */
  31307. enableTangentMorphing: boolean;
  31308. /**
  31309. * Gets or sets a boolean indicating if UV must be morphed
  31310. */
  31311. enableUVMorphing: boolean;
  31312. /**
  31313. * Creates a new MorphTargetManager
  31314. * @param scene defines the current scene
  31315. */
  31316. constructor(scene?: Nullable<Scene>);
  31317. /**
  31318. * Gets the unique ID of this manager
  31319. */
  31320. get uniqueId(): number;
  31321. /**
  31322. * Gets the number of vertices handled by this manager
  31323. */
  31324. get vertexCount(): number;
  31325. /**
  31326. * Gets a boolean indicating if this manager supports morphing of normals
  31327. */
  31328. get supportsNormals(): boolean;
  31329. /**
  31330. * Gets a boolean indicating if this manager supports morphing of tangents
  31331. */
  31332. get supportsTangents(): boolean;
  31333. /**
  31334. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31335. */
  31336. get supportsUVs(): boolean;
  31337. /**
  31338. * Gets the number of targets stored in this manager
  31339. */
  31340. get numTargets(): number;
  31341. /**
  31342. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31343. */
  31344. get numInfluencers(): number;
  31345. /**
  31346. * Gets the list of influences (one per target)
  31347. */
  31348. get influences(): Float32Array;
  31349. /**
  31350. * Gets the active target at specified index. An active target is a target with an influence > 0
  31351. * @param index defines the index to check
  31352. * @returns the requested target
  31353. */
  31354. getActiveTarget(index: number): MorphTarget;
  31355. /**
  31356. * Gets the target at specified index
  31357. * @param index defines the index to check
  31358. * @returns the requested target
  31359. */
  31360. getTarget(index: number): MorphTarget;
  31361. /**
  31362. * Add a new target to this manager
  31363. * @param target defines the target to add
  31364. */
  31365. addTarget(target: MorphTarget): void;
  31366. /**
  31367. * Removes a target from the manager
  31368. * @param target defines the target to remove
  31369. */
  31370. removeTarget(target: MorphTarget): void;
  31371. /**
  31372. * Clone the current manager
  31373. * @returns a new MorphTargetManager
  31374. */
  31375. clone(): MorphTargetManager;
  31376. /**
  31377. * Serializes the current manager into a Serialization object
  31378. * @returns the serialized object
  31379. */
  31380. serialize(): any;
  31381. private _syncActiveTargets;
  31382. /**
  31383. * Syncrhonize the targets with all the meshes using this morph target manager
  31384. */
  31385. synchronize(): void;
  31386. /**
  31387. * Creates a new MorphTargetManager from serialized data
  31388. * @param serializationObject defines the serialized data
  31389. * @param scene defines the hosting scene
  31390. * @returns the new MorphTargetManager
  31391. */
  31392. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31393. }
  31394. }
  31395. declare module BABYLON {
  31396. /**
  31397. * Class used to represent a specific level of detail of a mesh
  31398. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31399. */
  31400. export class MeshLODLevel {
  31401. /** Defines the distance where this level should start being displayed */
  31402. distance: number;
  31403. /** Defines the mesh to use to render this level */
  31404. mesh: Nullable<Mesh>;
  31405. /**
  31406. * Creates a new LOD level
  31407. * @param distance defines the distance where this level should star being displayed
  31408. * @param mesh defines the mesh to use to render this level
  31409. */
  31410. constructor(
  31411. /** Defines the distance where this level should start being displayed */
  31412. distance: number,
  31413. /** Defines the mesh to use to render this level */
  31414. mesh: Nullable<Mesh>);
  31415. }
  31416. }
  31417. declare module BABYLON {
  31418. /**
  31419. * Helper class used to generate a canvas to manipulate images
  31420. */
  31421. export class CanvasGenerator {
  31422. /**
  31423. * Create a new canvas (or offscreen canvas depending on the context)
  31424. * @param width defines the expected width
  31425. * @param height defines the expected height
  31426. * @return a new canvas or offscreen canvas
  31427. */
  31428. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31429. }
  31430. }
  31431. declare module BABYLON {
  31432. /**
  31433. * Mesh representing the gorund
  31434. */
  31435. export class GroundMesh extends Mesh {
  31436. /** If octree should be generated */
  31437. generateOctree: boolean;
  31438. private _heightQuads;
  31439. /** @hidden */
  31440. _subdivisionsX: number;
  31441. /** @hidden */
  31442. _subdivisionsY: number;
  31443. /** @hidden */
  31444. _width: number;
  31445. /** @hidden */
  31446. _height: number;
  31447. /** @hidden */
  31448. _minX: number;
  31449. /** @hidden */
  31450. _maxX: number;
  31451. /** @hidden */
  31452. _minZ: number;
  31453. /** @hidden */
  31454. _maxZ: number;
  31455. constructor(name: string, scene: Scene);
  31456. /**
  31457. * "GroundMesh"
  31458. * @returns "GroundMesh"
  31459. */
  31460. getClassName(): string;
  31461. /**
  31462. * The minimum of x and y subdivisions
  31463. */
  31464. get subdivisions(): number;
  31465. /**
  31466. * X subdivisions
  31467. */
  31468. get subdivisionsX(): number;
  31469. /**
  31470. * Y subdivisions
  31471. */
  31472. get subdivisionsY(): number;
  31473. /**
  31474. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31475. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31476. * @param chunksCount the number of subdivisions for x and y
  31477. * @param octreeBlocksSize (Default: 32)
  31478. */
  31479. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31480. /**
  31481. * Returns a height (y) value in the Worl system :
  31482. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31483. * @param x x coordinate
  31484. * @param z z coordinate
  31485. * @returns the ground y position if (x, z) are outside the ground surface.
  31486. */
  31487. getHeightAtCoordinates(x: number, z: number): number;
  31488. /**
  31489. * Returns a normalized vector (Vector3) orthogonal to the ground
  31490. * at the ground coordinates (x, z) expressed in the World system.
  31491. * @param x x coordinate
  31492. * @param z z coordinate
  31493. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31494. */
  31495. getNormalAtCoordinates(x: number, z: number): Vector3;
  31496. /**
  31497. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31498. * at the ground coordinates (x, z) expressed in the World system.
  31499. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31500. * @param x x coordinate
  31501. * @param z z coordinate
  31502. * @param ref vector to store the result
  31503. * @returns the GroundMesh.
  31504. */
  31505. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31506. /**
  31507. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31508. * if the ground has been updated.
  31509. * This can be used in the render loop.
  31510. * @returns the GroundMesh.
  31511. */
  31512. updateCoordinateHeights(): GroundMesh;
  31513. private _getFacetAt;
  31514. private _initHeightQuads;
  31515. private _computeHeightQuads;
  31516. /**
  31517. * Serializes this ground mesh
  31518. * @param serializationObject object to write serialization to
  31519. */
  31520. serialize(serializationObject: any): void;
  31521. /**
  31522. * Parses a serialized ground mesh
  31523. * @param parsedMesh the serialized mesh
  31524. * @param scene the scene to create the ground mesh in
  31525. * @returns the created ground mesh
  31526. */
  31527. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31528. }
  31529. }
  31530. declare module BABYLON {
  31531. /**
  31532. * Interface for Physics-Joint data
  31533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31534. */
  31535. export interface PhysicsJointData {
  31536. /**
  31537. * The main pivot of the joint
  31538. */
  31539. mainPivot?: Vector3;
  31540. /**
  31541. * The connected pivot of the joint
  31542. */
  31543. connectedPivot?: Vector3;
  31544. /**
  31545. * The main axis of the joint
  31546. */
  31547. mainAxis?: Vector3;
  31548. /**
  31549. * The connected axis of the joint
  31550. */
  31551. connectedAxis?: Vector3;
  31552. /**
  31553. * The collision of the joint
  31554. */
  31555. collision?: boolean;
  31556. /**
  31557. * Native Oimo/Cannon/Energy data
  31558. */
  31559. nativeParams?: any;
  31560. }
  31561. /**
  31562. * This is a holder class for the physics joint created by the physics plugin
  31563. * It holds a set of functions to control the underlying joint
  31564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31565. */
  31566. export class PhysicsJoint {
  31567. /**
  31568. * The type of the physics joint
  31569. */
  31570. type: number;
  31571. /**
  31572. * The data for the physics joint
  31573. */
  31574. jointData: PhysicsJointData;
  31575. private _physicsJoint;
  31576. protected _physicsPlugin: IPhysicsEnginePlugin;
  31577. /**
  31578. * Initializes the physics joint
  31579. * @param type The type of the physics joint
  31580. * @param jointData The data for the physics joint
  31581. */
  31582. constructor(
  31583. /**
  31584. * The type of the physics joint
  31585. */
  31586. type: number,
  31587. /**
  31588. * The data for the physics joint
  31589. */
  31590. jointData: PhysicsJointData);
  31591. /**
  31592. * Gets the physics joint
  31593. */
  31594. get physicsJoint(): any;
  31595. /**
  31596. * Sets the physics joint
  31597. */
  31598. set physicsJoint(newJoint: any);
  31599. /**
  31600. * Sets the physics plugin
  31601. */
  31602. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31603. /**
  31604. * Execute a function that is physics-plugin specific.
  31605. * @param {Function} func the function that will be executed.
  31606. * It accepts two parameters: the physics world and the physics joint
  31607. */
  31608. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31609. /**
  31610. * Distance-Joint type
  31611. */
  31612. static DistanceJoint: number;
  31613. /**
  31614. * Hinge-Joint type
  31615. */
  31616. static HingeJoint: number;
  31617. /**
  31618. * Ball-and-Socket joint type
  31619. */
  31620. static BallAndSocketJoint: number;
  31621. /**
  31622. * Wheel-Joint type
  31623. */
  31624. static WheelJoint: number;
  31625. /**
  31626. * Slider-Joint type
  31627. */
  31628. static SliderJoint: number;
  31629. /**
  31630. * Prismatic-Joint type
  31631. */
  31632. static PrismaticJoint: number;
  31633. /**
  31634. * Universal-Joint type
  31635. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31636. */
  31637. static UniversalJoint: number;
  31638. /**
  31639. * Hinge-Joint 2 type
  31640. */
  31641. static Hinge2Joint: number;
  31642. /**
  31643. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31644. */
  31645. static PointToPointJoint: number;
  31646. /**
  31647. * Spring-Joint type
  31648. */
  31649. static SpringJoint: number;
  31650. /**
  31651. * Lock-Joint type
  31652. */
  31653. static LockJoint: number;
  31654. }
  31655. /**
  31656. * A class representing a physics distance joint
  31657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31658. */
  31659. export class DistanceJoint extends PhysicsJoint {
  31660. /**
  31661. *
  31662. * @param jointData The data for the Distance-Joint
  31663. */
  31664. constructor(jointData: DistanceJointData);
  31665. /**
  31666. * Update the predefined distance.
  31667. * @param maxDistance The maximum preferred distance
  31668. * @param minDistance The minimum preferred distance
  31669. */
  31670. updateDistance(maxDistance: number, minDistance?: number): void;
  31671. }
  31672. /**
  31673. * Represents a Motor-Enabled Joint
  31674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31675. */
  31676. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31677. /**
  31678. * Initializes the Motor-Enabled Joint
  31679. * @param type The type of the joint
  31680. * @param jointData The physica joint data for the joint
  31681. */
  31682. constructor(type: number, jointData: PhysicsJointData);
  31683. /**
  31684. * Set the motor values.
  31685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31686. * @param force the force to apply
  31687. * @param maxForce max force for this motor.
  31688. */
  31689. setMotor(force?: number, maxForce?: number): void;
  31690. /**
  31691. * Set the motor's limits.
  31692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31693. * @param upperLimit The upper limit of the motor
  31694. * @param lowerLimit The lower limit of the motor
  31695. */
  31696. setLimit(upperLimit: number, lowerLimit?: number): void;
  31697. }
  31698. /**
  31699. * This class represents a single physics Hinge-Joint
  31700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31701. */
  31702. export class HingeJoint extends MotorEnabledJoint {
  31703. /**
  31704. * Initializes the Hinge-Joint
  31705. * @param jointData The joint data for the Hinge-Joint
  31706. */
  31707. constructor(jointData: PhysicsJointData);
  31708. /**
  31709. * Set the motor values.
  31710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31711. * @param {number} force the force to apply
  31712. * @param {number} maxForce max force for this motor.
  31713. */
  31714. setMotor(force?: number, maxForce?: number): void;
  31715. /**
  31716. * Set the motor's limits.
  31717. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31718. * @param upperLimit The upper limit of the motor
  31719. * @param lowerLimit The lower limit of the motor
  31720. */
  31721. setLimit(upperLimit: number, lowerLimit?: number): void;
  31722. }
  31723. /**
  31724. * This class represents a dual hinge physics joint (same as wheel joint)
  31725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31726. */
  31727. export class Hinge2Joint extends MotorEnabledJoint {
  31728. /**
  31729. * Initializes the Hinge2-Joint
  31730. * @param jointData The joint data for the Hinge2-Joint
  31731. */
  31732. constructor(jointData: PhysicsJointData);
  31733. /**
  31734. * Set the motor values.
  31735. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31736. * @param {number} targetSpeed the speed the motor is to reach
  31737. * @param {number} maxForce max force for this motor.
  31738. * @param {motorIndex} the motor's index, 0 or 1.
  31739. */
  31740. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31741. /**
  31742. * Set the motor limits.
  31743. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31744. * @param {number} upperLimit the upper limit
  31745. * @param {number} lowerLimit lower limit
  31746. * @param {motorIndex} the motor's index, 0 or 1.
  31747. */
  31748. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31749. }
  31750. /**
  31751. * Interface for a motor enabled joint
  31752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31753. */
  31754. export interface IMotorEnabledJoint {
  31755. /**
  31756. * Physics joint
  31757. */
  31758. physicsJoint: any;
  31759. /**
  31760. * Sets the motor of the motor-enabled joint
  31761. * @param force The force of the motor
  31762. * @param maxForce The maximum force of the motor
  31763. * @param motorIndex The index of the motor
  31764. */
  31765. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31766. /**
  31767. * Sets the limit of the motor
  31768. * @param upperLimit The upper limit of the motor
  31769. * @param lowerLimit The lower limit of the motor
  31770. * @param motorIndex The index of the motor
  31771. */
  31772. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31773. }
  31774. /**
  31775. * Joint data for a Distance-Joint
  31776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31777. */
  31778. export interface DistanceJointData extends PhysicsJointData {
  31779. /**
  31780. * Max distance the 2 joint objects can be apart
  31781. */
  31782. maxDistance: number;
  31783. }
  31784. /**
  31785. * Joint data from a spring joint
  31786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31787. */
  31788. export interface SpringJointData extends PhysicsJointData {
  31789. /**
  31790. * Length of the spring
  31791. */
  31792. length: number;
  31793. /**
  31794. * Stiffness of the spring
  31795. */
  31796. stiffness: number;
  31797. /**
  31798. * Damping of the spring
  31799. */
  31800. damping: number;
  31801. /** this callback will be called when applying the force to the impostors. */
  31802. forceApplicationCallback: () => void;
  31803. }
  31804. }
  31805. declare module BABYLON {
  31806. /**
  31807. * Holds the data for the raycast result
  31808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31809. */
  31810. export class PhysicsRaycastResult {
  31811. private _hasHit;
  31812. private _hitDistance;
  31813. private _hitNormalWorld;
  31814. private _hitPointWorld;
  31815. private _rayFromWorld;
  31816. private _rayToWorld;
  31817. /**
  31818. * Gets if there was a hit
  31819. */
  31820. get hasHit(): boolean;
  31821. /**
  31822. * Gets the distance from the hit
  31823. */
  31824. get hitDistance(): number;
  31825. /**
  31826. * Gets the hit normal/direction in the world
  31827. */
  31828. get hitNormalWorld(): Vector3;
  31829. /**
  31830. * Gets the hit point in the world
  31831. */
  31832. get hitPointWorld(): Vector3;
  31833. /**
  31834. * Gets the ray "start point" of the ray in the world
  31835. */
  31836. get rayFromWorld(): Vector3;
  31837. /**
  31838. * Gets the ray "end point" of the ray in the world
  31839. */
  31840. get rayToWorld(): Vector3;
  31841. /**
  31842. * Sets the hit data (normal & point in world space)
  31843. * @param hitNormalWorld defines the normal in world space
  31844. * @param hitPointWorld defines the point in world space
  31845. */
  31846. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31847. /**
  31848. * Sets the distance from the start point to the hit point
  31849. * @param distance
  31850. */
  31851. setHitDistance(distance: number): void;
  31852. /**
  31853. * Calculates the distance manually
  31854. */
  31855. calculateHitDistance(): void;
  31856. /**
  31857. * Resets all the values to default
  31858. * @param from The from point on world space
  31859. * @param to The to point on world space
  31860. */
  31861. reset(from?: Vector3, to?: Vector3): void;
  31862. }
  31863. /**
  31864. * Interface for the size containing width and height
  31865. */
  31866. interface IXYZ {
  31867. /**
  31868. * X
  31869. */
  31870. x: number;
  31871. /**
  31872. * Y
  31873. */
  31874. y: number;
  31875. /**
  31876. * Z
  31877. */
  31878. z: number;
  31879. }
  31880. }
  31881. declare module BABYLON {
  31882. /**
  31883. * Interface used to describe a physics joint
  31884. */
  31885. export interface PhysicsImpostorJoint {
  31886. /** Defines the main impostor to which the joint is linked */
  31887. mainImpostor: PhysicsImpostor;
  31888. /** Defines the impostor that is connected to the main impostor using this joint */
  31889. connectedImpostor: PhysicsImpostor;
  31890. /** Defines the joint itself */
  31891. joint: PhysicsJoint;
  31892. }
  31893. /** @hidden */
  31894. export interface IPhysicsEnginePlugin {
  31895. world: any;
  31896. name: string;
  31897. setGravity(gravity: Vector3): void;
  31898. setTimeStep(timeStep: number): void;
  31899. getTimeStep(): number;
  31900. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31901. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31902. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31903. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31904. removePhysicsBody(impostor: PhysicsImpostor): void;
  31905. generateJoint(joint: PhysicsImpostorJoint): void;
  31906. removeJoint(joint: PhysicsImpostorJoint): void;
  31907. isSupported(): boolean;
  31908. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31910. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31911. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31912. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31913. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31914. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31915. getBodyMass(impostor: PhysicsImpostor): number;
  31916. getBodyFriction(impostor: PhysicsImpostor): number;
  31917. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31918. getBodyRestitution(impostor: PhysicsImpostor): number;
  31919. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31920. getBodyPressure?(impostor: PhysicsImpostor): number;
  31921. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31922. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31923. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31924. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31925. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31926. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31927. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31928. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31929. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31930. sleepBody(impostor: PhysicsImpostor): void;
  31931. wakeUpBody(impostor: PhysicsImpostor): void;
  31932. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31933. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31934. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31935. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31936. getRadius(impostor: PhysicsImpostor): number;
  31937. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31938. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31939. dispose(): void;
  31940. }
  31941. /**
  31942. * Interface used to define a physics engine
  31943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31944. */
  31945. export interface IPhysicsEngine {
  31946. /**
  31947. * Gets the gravity vector used by the simulation
  31948. */
  31949. gravity: Vector3;
  31950. /**
  31951. * Sets the gravity vector used by the simulation
  31952. * @param gravity defines the gravity vector to use
  31953. */
  31954. setGravity(gravity: Vector3): void;
  31955. /**
  31956. * Set the time step of the physics engine.
  31957. * Default is 1/60.
  31958. * To slow it down, enter 1/600 for example.
  31959. * To speed it up, 1/30
  31960. * @param newTimeStep the new timestep to apply to this world.
  31961. */
  31962. setTimeStep(newTimeStep: number): void;
  31963. /**
  31964. * Get the time step of the physics engine.
  31965. * @returns the current time step
  31966. */
  31967. getTimeStep(): number;
  31968. /**
  31969. * Set the sub time step of the physics engine.
  31970. * Default is 0 meaning there is no sub steps
  31971. * To increase physics resolution precision, set a small value (like 1 ms)
  31972. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31973. */
  31974. setSubTimeStep(subTimeStep: number): void;
  31975. /**
  31976. * Get the sub time step of the physics engine.
  31977. * @returns the current sub time step
  31978. */
  31979. getSubTimeStep(): number;
  31980. /**
  31981. * Release all resources
  31982. */
  31983. dispose(): void;
  31984. /**
  31985. * Gets the name of the current physics plugin
  31986. * @returns the name of the plugin
  31987. */
  31988. getPhysicsPluginName(): string;
  31989. /**
  31990. * Adding a new impostor for the impostor tracking.
  31991. * This will be done by the impostor itself.
  31992. * @param impostor the impostor to add
  31993. */
  31994. addImpostor(impostor: PhysicsImpostor): void;
  31995. /**
  31996. * Remove an impostor from the engine.
  31997. * This impostor and its mesh will not longer be updated by the physics engine.
  31998. * @param impostor the impostor to remove
  31999. */
  32000. removeImpostor(impostor: PhysicsImpostor): void;
  32001. /**
  32002. * Add a joint to the physics engine
  32003. * @param mainImpostor defines the main impostor to which the joint is added.
  32004. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32005. * @param joint defines the joint that will connect both impostors.
  32006. */
  32007. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32008. /**
  32009. * Removes a joint from the simulation
  32010. * @param mainImpostor defines the impostor used with the joint
  32011. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32012. * @param joint defines the joint to remove
  32013. */
  32014. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32015. /**
  32016. * Gets the current plugin used to run the simulation
  32017. * @returns current plugin
  32018. */
  32019. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32020. /**
  32021. * Gets the list of physic impostors
  32022. * @returns an array of PhysicsImpostor
  32023. */
  32024. getImpostors(): Array<PhysicsImpostor>;
  32025. /**
  32026. * Gets the impostor for a physics enabled object
  32027. * @param object defines the object impersonated by the impostor
  32028. * @returns the PhysicsImpostor or null if not found
  32029. */
  32030. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32031. /**
  32032. * Gets the impostor for a physics body object
  32033. * @param body defines physics body used by the impostor
  32034. * @returns the PhysicsImpostor or null if not found
  32035. */
  32036. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32037. /**
  32038. * Does a raycast in the physics world
  32039. * @param from when should the ray start?
  32040. * @param to when should the ray end?
  32041. * @returns PhysicsRaycastResult
  32042. */
  32043. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32044. /**
  32045. * Called by the scene. No need to call it.
  32046. * @param delta defines the timespam between frames
  32047. */
  32048. _step(delta: number): void;
  32049. }
  32050. }
  32051. declare module BABYLON {
  32052. /**
  32053. * The interface for the physics imposter parameters
  32054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32055. */
  32056. export interface PhysicsImpostorParameters {
  32057. /**
  32058. * The mass of the physics imposter
  32059. */
  32060. mass: number;
  32061. /**
  32062. * The friction of the physics imposter
  32063. */
  32064. friction?: number;
  32065. /**
  32066. * The coefficient of restitution of the physics imposter
  32067. */
  32068. restitution?: number;
  32069. /**
  32070. * The native options of the physics imposter
  32071. */
  32072. nativeOptions?: any;
  32073. /**
  32074. * Specifies if the parent should be ignored
  32075. */
  32076. ignoreParent?: boolean;
  32077. /**
  32078. * Specifies if bi-directional transformations should be disabled
  32079. */
  32080. disableBidirectionalTransformation?: boolean;
  32081. /**
  32082. * The pressure inside the physics imposter, soft object only
  32083. */
  32084. pressure?: number;
  32085. /**
  32086. * The stiffness the physics imposter, soft object only
  32087. */
  32088. stiffness?: number;
  32089. /**
  32090. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32091. */
  32092. velocityIterations?: number;
  32093. /**
  32094. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32095. */
  32096. positionIterations?: number;
  32097. /**
  32098. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32099. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32100. * Add to fix multiple points
  32101. */
  32102. fixedPoints?: number;
  32103. /**
  32104. * The collision margin around a soft object
  32105. */
  32106. margin?: number;
  32107. /**
  32108. * The collision margin around a soft object
  32109. */
  32110. damping?: number;
  32111. /**
  32112. * The path for a rope based on an extrusion
  32113. */
  32114. path?: any;
  32115. /**
  32116. * The shape of an extrusion used for a rope based on an extrusion
  32117. */
  32118. shape?: any;
  32119. }
  32120. /**
  32121. * Interface for a physics-enabled object
  32122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32123. */
  32124. export interface IPhysicsEnabledObject {
  32125. /**
  32126. * The position of the physics-enabled object
  32127. */
  32128. position: Vector3;
  32129. /**
  32130. * The rotation of the physics-enabled object
  32131. */
  32132. rotationQuaternion: Nullable<Quaternion>;
  32133. /**
  32134. * The scale of the physics-enabled object
  32135. */
  32136. scaling: Vector3;
  32137. /**
  32138. * The rotation of the physics-enabled object
  32139. */
  32140. rotation?: Vector3;
  32141. /**
  32142. * The parent of the physics-enabled object
  32143. */
  32144. parent?: any;
  32145. /**
  32146. * The bounding info of the physics-enabled object
  32147. * @returns The bounding info of the physics-enabled object
  32148. */
  32149. getBoundingInfo(): BoundingInfo;
  32150. /**
  32151. * Computes the world matrix
  32152. * @param force Specifies if the world matrix should be computed by force
  32153. * @returns A world matrix
  32154. */
  32155. computeWorldMatrix(force: boolean): Matrix;
  32156. /**
  32157. * Gets the world matrix
  32158. * @returns A world matrix
  32159. */
  32160. getWorldMatrix?(): Matrix;
  32161. /**
  32162. * Gets the child meshes
  32163. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32164. * @returns An array of abstract meshes
  32165. */
  32166. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32167. /**
  32168. * Gets the vertex data
  32169. * @param kind The type of vertex data
  32170. * @returns A nullable array of numbers, or a float32 array
  32171. */
  32172. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32173. /**
  32174. * Gets the indices from the mesh
  32175. * @returns A nullable array of index arrays
  32176. */
  32177. getIndices?(): Nullable<IndicesArray>;
  32178. /**
  32179. * Gets the scene from the mesh
  32180. * @returns the indices array or null
  32181. */
  32182. getScene?(): Scene;
  32183. /**
  32184. * Gets the absolute position from the mesh
  32185. * @returns the absolute position
  32186. */
  32187. getAbsolutePosition(): Vector3;
  32188. /**
  32189. * Gets the absolute pivot point from the mesh
  32190. * @returns the absolute pivot point
  32191. */
  32192. getAbsolutePivotPoint(): Vector3;
  32193. /**
  32194. * Rotates the mesh
  32195. * @param axis The axis of rotation
  32196. * @param amount The amount of rotation
  32197. * @param space The space of the rotation
  32198. * @returns The rotation transform node
  32199. */
  32200. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32201. /**
  32202. * Translates the mesh
  32203. * @param axis The axis of translation
  32204. * @param distance The distance of translation
  32205. * @param space The space of the translation
  32206. * @returns The transform node
  32207. */
  32208. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32209. /**
  32210. * Sets the absolute position of the mesh
  32211. * @param absolutePosition The absolute position of the mesh
  32212. * @returns The transform node
  32213. */
  32214. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32215. /**
  32216. * Gets the class name of the mesh
  32217. * @returns The class name
  32218. */
  32219. getClassName(): string;
  32220. }
  32221. /**
  32222. * Represents a physics imposter
  32223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32224. */
  32225. export class PhysicsImpostor {
  32226. /**
  32227. * The physics-enabled object used as the physics imposter
  32228. */
  32229. object: IPhysicsEnabledObject;
  32230. /**
  32231. * The type of the physics imposter
  32232. */
  32233. type: number;
  32234. private _options;
  32235. private _scene?;
  32236. /**
  32237. * The default object size of the imposter
  32238. */
  32239. static DEFAULT_OBJECT_SIZE: Vector3;
  32240. /**
  32241. * The identity quaternion of the imposter
  32242. */
  32243. static IDENTITY_QUATERNION: Quaternion;
  32244. /** @hidden */
  32245. _pluginData: any;
  32246. private _physicsEngine;
  32247. private _physicsBody;
  32248. private _bodyUpdateRequired;
  32249. private _onBeforePhysicsStepCallbacks;
  32250. private _onAfterPhysicsStepCallbacks;
  32251. /** @hidden */
  32252. _onPhysicsCollideCallbacks: Array<{
  32253. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32254. otherImpostors: Array<PhysicsImpostor>;
  32255. }>;
  32256. private _deltaPosition;
  32257. private _deltaRotation;
  32258. private _deltaRotationConjugated;
  32259. /** @hidden */
  32260. _isFromLine: boolean;
  32261. private _parent;
  32262. private _isDisposed;
  32263. private static _tmpVecs;
  32264. private static _tmpQuat;
  32265. /**
  32266. * Specifies if the physics imposter is disposed
  32267. */
  32268. get isDisposed(): boolean;
  32269. /**
  32270. * Gets the mass of the physics imposter
  32271. */
  32272. get mass(): number;
  32273. set mass(value: number);
  32274. /**
  32275. * Gets the coefficient of friction
  32276. */
  32277. get friction(): number;
  32278. /**
  32279. * Sets the coefficient of friction
  32280. */
  32281. set friction(value: number);
  32282. /**
  32283. * Gets the coefficient of restitution
  32284. */
  32285. get restitution(): number;
  32286. /**
  32287. * Sets the coefficient of restitution
  32288. */
  32289. set restitution(value: number);
  32290. /**
  32291. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32292. */
  32293. get pressure(): number;
  32294. /**
  32295. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32296. */
  32297. set pressure(value: number);
  32298. /**
  32299. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32300. */
  32301. get stiffness(): number;
  32302. /**
  32303. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32304. */
  32305. set stiffness(value: number);
  32306. /**
  32307. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32308. */
  32309. get velocityIterations(): number;
  32310. /**
  32311. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32312. */
  32313. set velocityIterations(value: number);
  32314. /**
  32315. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32316. */
  32317. get positionIterations(): number;
  32318. /**
  32319. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32320. */
  32321. set positionIterations(value: number);
  32322. /**
  32323. * The unique id of the physics imposter
  32324. * set by the physics engine when adding this impostor to the array
  32325. */
  32326. uniqueId: number;
  32327. /**
  32328. * @hidden
  32329. */
  32330. soft: boolean;
  32331. /**
  32332. * @hidden
  32333. */
  32334. segments: number;
  32335. private _joints;
  32336. /**
  32337. * Initializes the physics imposter
  32338. * @param object The physics-enabled object used as the physics imposter
  32339. * @param type The type of the physics imposter
  32340. * @param _options The options for the physics imposter
  32341. * @param _scene The Babylon scene
  32342. */
  32343. constructor(
  32344. /**
  32345. * The physics-enabled object used as the physics imposter
  32346. */
  32347. object: IPhysicsEnabledObject,
  32348. /**
  32349. * The type of the physics imposter
  32350. */
  32351. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32352. /**
  32353. * This function will completly initialize this impostor.
  32354. * It will create a new body - but only if this mesh has no parent.
  32355. * If it has, this impostor will not be used other than to define the impostor
  32356. * of the child mesh.
  32357. * @hidden
  32358. */
  32359. _init(): void;
  32360. private _getPhysicsParent;
  32361. /**
  32362. * Should a new body be generated.
  32363. * @returns boolean specifying if body initialization is required
  32364. */
  32365. isBodyInitRequired(): boolean;
  32366. /**
  32367. * Sets the updated scaling
  32368. * @param updated Specifies if the scaling is updated
  32369. */
  32370. setScalingUpdated(): void;
  32371. /**
  32372. * Force a regeneration of this or the parent's impostor's body.
  32373. * Use under cautious - This will remove all joints already implemented.
  32374. */
  32375. forceUpdate(): void;
  32376. /**
  32377. * Gets the body that holds this impostor. Either its own, or its parent.
  32378. */
  32379. get physicsBody(): any;
  32380. /**
  32381. * Get the parent of the physics imposter
  32382. * @returns Physics imposter or null
  32383. */
  32384. get parent(): Nullable<PhysicsImpostor>;
  32385. /**
  32386. * Sets the parent of the physics imposter
  32387. */
  32388. set parent(value: Nullable<PhysicsImpostor>);
  32389. /**
  32390. * Set the physics body. Used mainly by the physics engine/plugin
  32391. */
  32392. set physicsBody(physicsBody: any);
  32393. /**
  32394. * Resets the update flags
  32395. */
  32396. resetUpdateFlags(): void;
  32397. /**
  32398. * Gets the object extend size
  32399. * @returns the object extend size
  32400. */
  32401. getObjectExtendSize(): Vector3;
  32402. /**
  32403. * Gets the object center
  32404. * @returns The object center
  32405. */
  32406. getObjectCenter(): Vector3;
  32407. /**
  32408. * Get a specific parameter from the options parameters
  32409. * @param paramName The object parameter name
  32410. * @returns The object parameter
  32411. */
  32412. getParam(paramName: string): any;
  32413. /**
  32414. * Sets a specific parameter in the options given to the physics plugin
  32415. * @param paramName The parameter name
  32416. * @param value The value of the parameter
  32417. */
  32418. setParam(paramName: string, value: number): void;
  32419. /**
  32420. * Specifically change the body's mass option. Won't recreate the physics body object
  32421. * @param mass The mass of the physics imposter
  32422. */
  32423. setMass(mass: number): void;
  32424. /**
  32425. * Gets the linear velocity
  32426. * @returns linear velocity or null
  32427. */
  32428. getLinearVelocity(): Nullable<Vector3>;
  32429. /**
  32430. * Sets the linear velocity
  32431. * @param velocity linear velocity or null
  32432. */
  32433. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32434. /**
  32435. * Gets the angular velocity
  32436. * @returns angular velocity or null
  32437. */
  32438. getAngularVelocity(): Nullable<Vector3>;
  32439. /**
  32440. * Sets the angular velocity
  32441. * @param velocity The velocity or null
  32442. */
  32443. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32444. /**
  32445. * Execute a function with the physics plugin native code
  32446. * Provide a function the will have two variables - the world object and the physics body object
  32447. * @param func The function to execute with the physics plugin native code
  32448. */
  32449. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32450. /**
  32451. * Register a function that will be executed before the physics world is stepping forward
  32452. * @param func The function to execute before the physics world is stepped forward
  32453. */
  32454. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32455. /**
  32456. * Unregister a function that will be executed before the physics world is stepping forward
  32457. * @param func The function to execute before the physics world is stepped forward
  32458. */
  32459. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32460. /**
  32461. * Register a function that will be executed after the physics step
  32462. * @param func The function to execute after physics step
  32463. */
  32464. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32465. /**
  32466. * Unregisters a function that will be executed after the physics step
  32467. * @param func The function to execute after physics step
  32468. */
  32469. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32470. /**
  32471. * register a function that will be executed when this impostor collides against a different body
  32472. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32473. * @param func Callback that is executed on collision
  32474. */
  32475. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32476. /**
  32477. * Unregisters the physics imposter on contact
  32478. * @param collideAgainst The physics object to collide against
  32479. * @param func Callback to execute on collision
  32480. */
  32481. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32482. private _tmpQuat;
  32483. private _tmpQuat2;
  32484. /**
  32485. * Get the parent rotation
  32486. * @returns The parent rotation
  32487. */
  32488. getParentsRotation(): Quaternion;
  32489. /**
  32490. * this function is executed by the physics engine.
  32491. */
  32492. beforeStep: () => void;
  32493. /**
  32494. * this function is executed by the physics engine
  32495. */
  32496. afterStep: () => void;
  32497. /**
  32498. * Legacy collision detection event support
  32499. */
  32500. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32501. /**
  32502. * event and body object due to cannon's event-based architecture.
  32503. */
  32504. onCollide: (e: {
  32505. body: any;
  32506. point: Nullable<Vector3>;
  32507. }) => void;
  32508. /**
  32509. * Apply a force
  32510. * @param force The force to apply
  32511. * @param contactPoint The contact point for the force
  32512. * @returns The physics imposter
  32513. */
  32514. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32515. /**
  32516. * Apply an impulse
  32517. * @param force The impulse force
  32518. * @param contactPoint The contact point for the impulse force
  32519. * @returns The physics imposter
  32520. */
  32521. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32522. /**
  32523. * A help function to create a joint
  32524. * @param otherImpostor A physics imposter used to create a joint
  32525. * @param jointType The type of joint
  32526. * @param jointData The data for the joint
  32527. * @returns The physics imposter
  32528. */
  32529. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32530. /**
  32531. * Add a joint to this impostor with a different impostor
  32532. * @param otherImpostor A physics imposter used to add a joint
  32533. * @param joint The joint to add
  32534. * @returns The physics imposter
  32535. */
  32536. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32537. /**
  32538. * Add an anchor to a cloth impostor
  32539. * @param otherImpostor rigid impostor to anchor to
  32540. * @param width ratio across width from 0 to 1
  32541. * @param height ratio up height from 0 to 1
  32542. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32543. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32544. * @returns impostor the soft imposter
  32545. */
  32546. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32547. /**
  32548. * Add a hook to a rope impostor
  32549. * @param otherImpostor rigid impostor to anchor to
  32550. * @param length ratio across rope from 0 to 1
  32551. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32552. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32553. * @returns impostor the rope imposter
  32554. */
  32555. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32556. /**
  32557. * Will keep this body still, in a sleep mode.
  32558. * @returns the physics imposter
  32559. */
  32560. sleep(): PhysicsImpostor;
  32561. /**
  32562. * Wake the body up.
  32563. * @returns The physics imposter
  32564. */
  32565. wakeUp(): PhysicsImpostor;
  32566. /**
  32567. * Clones the physics imposter
  32568. * @param newObject The physics imposter clones to this physics-enabled object
  32569. * @returns A nullable physics imposter
  32570. */
  32571. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32572. /**
  32573. * Disposes the physics imposter
  32574. */
  32575. dispose(): void;
  32576. /**
  32577. * Sets the delta position
  32578. * @param position The delta position amount
  32579. */
  32580. setDeltaPosition(position: Vector3): void;
  32581. /**
  32582. * Sets the delta rotation
  32583. * @param rotation The delta rotation amount
  32584. */
  32585. setDeltaRotation(rotation: Quaternion): void;
  32586. /**
  32587. * Gets the box size of the physics imposter and stores the result in the input parameter
  32588. * @param result Stores the box size
  32589. * @returns The physics imposter
  32590. */
  32591. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32592. /**
  32593. * Gets the radius of the physics imposter
  32594. * @returns Radius of the physics imposter
  32595. */
  32596. getRadius(): number;
  32597. /**
  32598. * Sync a bone with this impostor
  32599. * @param bone The bone to sync to the impostor.
  32600. * @param boneMesh The mesh that the bone is influencing.
  32601. * @param jointPivot The pivot of the joint / bone in local space.
  32602. * @param distToJoint Optional distance from the impostor to the joint.
  32603. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32604. */
  32605. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32606. /**
  32607. * Sync impostor to a bone
  32608. * @param bone The bone that the impostor will be synced to.
  32609. * @param boneMesh The mesh that the bone is influencing.
  32610. * @param jointPivot The pivot of the joint / bone in local space.
  32611. * @param distToJoint Optional distance from the impostor to the joint.
  32612. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32613. * @param boneAxis Optional vector3 axis the bone is aligned with
  32614. */
  32615. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32616. /**
  32617. * No-Imposter type
  32618. */
  32619. static NoImpostor: number;
  32620. /**
  32621. * Sphere-Imposter type
  32622. */
  32623. static SphereImpostor: number;
  32624. /**
  32625. * Box-Imposter type
  32626. */
  32627. static BoxImpostor: number;
  32628. /**
  32629. * Plane-Imposter type
  32630. */
  32631. static PlaneImpostor: number;
  32632. /**
  32633. * Mesh-imposter type
  32634. */
  32635. static MeshImpostor: number;
  32636. /**
  32637. * Capsule-Impostor type (Ammo.js plugin only)
  32638. */
  32639. static CapsuleImpostor: number;
  32640. /**
  32641. * Cylinder-Imposter type
  32642. */
  32643. static CylinderImpostor: number;
  32644. /**
  32645. * Particle-Imposter type
  32646. */
  32647. static ParticleImpostor: number;
  32648. /**
  32649. * Heightmap-Imposter type
  32650. */
  32651. static HeightmapImpostor: number;
  32652. /**
  32653. * ConvexHull-Impostor type (Ammo.js plugin only)
  32654. */
  32655. static ConvexHullImpostor: number;
  32656. /**
  32657. * Custom-Imposter type (Ammo.js plugin only)
  32658. */
  32659. static CustomImpostor: number;
  32660. /**
  32661. * Rope-Imposter type
  32662. */
  32663. static RopeImpostor: number;
  32664. /**
  32665. * Cloth-Imposter type
  32666. */
  32667. static ClothImpostor: number;
  32668. /**
  32669. * Softbody-Imposter type
  32670. */
  32671. static SoftbodyImpostor: number;
  32672. }
  32673. }
  32674. declare module BABYLON {
  32675. /**
  32676. * @hidden
  32677. **/
  32678. export class _CreationDataStorage {
  32679. closePath?: boolean;
  32680. closeArray?: boolean;
  32681. idx: number[];
  32682. dashSize: number;
  32683. gapSize: number;
  32684. path3D: Path3D;
  32685. pathArray: Vector3[][];
  32686. arc: number;
  32687. radius: number;
  32688. cap: number;
  32689. tessellation: number;
  32690. }
  32691. /**
  32692. * @hidden
  32693. **/
  32694. class _InstanceDataStorage {
  32695. visibleInstances: any;
  32696. batchCache: _InstancesBatch;
  32697. instancesBufferSize: number;
  32698. instancesBuffer: Nullable<Buffer>;
  32699. instancesData: Float32Array;
  32700. overridenInstanceCount: number;
  32701. isFrozen: boolean;
  32702. previousBatch: Nullable<_InstancesBatch>;
  32703. hardwareInstancedRendering: boolean;
  32704. sideOrientation: number;
  32705. manualUpdate: boolean;
  32706. previousRenderId: number;
  32707. }
  32708. /**
  32709. * @hidden
  32710. **/
  32711. export class _InstancesBatch {
  32712. mustReturn: boolean;
  32713. visibleInstances: Nullable<InstancedMesh[]>[];
  32714. renderSelf: boolean[];
  32715. hardwareInstancedRendering: boolean[];
  32716. }
  32717. /**
  32718. * @hidden
  32719. **/
  32720. class _ThinInstanceDataStorage {
  32721. instancesCount: number;
  32722. matrixBuffer: Nullable<Buffer>;
  32723. matrixBufferSize: number;
  32724. matrixData: Nullable<Float32Array>;
  32725. boundingVectors: Array<Vector3>;
  32726. worldMatrices: Nullable<Matrix[]>;
  32727. }
  32728. /**
  32729. * Class used to represent renderable models
  32730. */
  32731. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32732. /**
  32733. * Mesh side orientation : usually the external or front surface
  32734. */
  32735. static readonly FRONTSIDE: number;
  32736. /**
  32737. * Mesh side orientation : usually the internal or back surface
  32738. */
  32739. static readonly BACKSIDE: number;
  32740. /**
  32741. * Mesh side orientation : both internal and external or front and back surfaces
  32742. */
  32743. static readonly DOUBLESIDE: number;
  32744. /**
  32745. * Mesh side orientation : by default, `FRONTSIDE`
  32746. */
  32747. static readonly DEFAULTSIDE: number;
  32748. /**
  32749. * Mesh cap setting : no cap
  32750. */
  32751. static readonly NO_CAP: number;
  32752. /**
  32753. * Mesh cap setting : one cap at the beginning of the mesh
  32754. */
  32755. static readonly CAP_START: number;
  32756. /**
  32757. * Mesh cap setting : one cap at the end of the mesh
  32758. */
  32759. static readonly CAP_END: number;
  32760. /**
  32761. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32762. */
  32763. static readonly CAP_ALL: number;
  32764. /**
  32765. * Mesh pattern setting : no flip or rotate
  32766. */
  32767. static readonly NO_FLIP: number;
  32768. /**
  32769. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32770. */
  32771. static readonly FLIP_TILE: number;
  32772. /**
  32773. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32774. */
  32775. static readonly ROTATE_TILE: number;
  32776. /**
  32777. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32778. */
  32779. static readonly FLIP_ROW: number;
  32780. /**
  32781. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32782. */
  32783. static readonly ROTATE_ROW: number;
  32784. /**
  32785. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32786. */
  32787. static readonly FLIP_N_ROTATE_TILE: number;
  32788. /**
  32789. * Mesh pattern setting : rotate pattern and rotate
  32790. */
  32791. static readonly FLIP_N_ROTATE_ROW: number;
  32792. /**
  32793. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32794. */
  32795. static readonly CENTER: number;
  32796. /**
  32797. * Mesh tile positioning : part tiles on left
  32798. */
  32799. static readonly LEFT: number;
  32800. /**
  32801. * Mesh tile positioning : part tiles on right
  32802. */
  32803. static readonly RIGHT: number;
  32804. /**
  32805. * Mesh tile positioning : part tiles on top
  32806. */
  32807. static readonly TOP: number;
  32808. /**
  32809. * Mesh tile positioning : part tiles on bottom
  32810. */
  32811. static readonly BOTTOM: number;
  32812. /**
  32813. * Gets the default side orientation.
  32814. * @param orientation the orientation to value to attempt to get
  32815. * @returns the default orientation
  32816. * @hidden
  32817. */
  32818. static _GetDefaultSideOrientation(orientation?: number): number;
  32819. private _internalMeshDataInfo;
  32820. get computeBonesUsingShaders(): boolean;
  32821. set computeBonesUsingShaders(value: boolean);
  32822. /**
  32823. * An event triggered before rendering the mesh
  32824. */
  32825. get onBeforeRenderObservable(): Observable<Mesh>;
  32826. /**
  32827. * An event triggered before binding the mesh
  32828. */
  32829. get onBeforeBindObservable(): Observable<Mesh>;
  32830. /**
  32831. * An event triggered after rendering the mesh
  32832. */
  32833. get onAfterRenderObservable(): Observable<Mesh>;
  32834. /**
  32835. * An event triggered before drawing the mesh
  32836. */
  32837. get onBeforeDrawObservable(): Observable<Mesh>;
  32838. private _onBeforeDrawObserver;
  32839. /**
  32840. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32841. */
  32842. set onBeforeDraw(callback: () => void);
  32843. get hasInstances(): boolean;
  32844. get hasThinInstances(): boolean;
  32845. /**
  32846. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32847. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32848. */
  32849. delayLoadState: number;
  32850. /**
  32851. * Gets the list of instances created from this mesh
  32852. * it is not supposed to be modified manually.
  32853. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32854. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32855. */
  32856. instances: InstancedMesh[];
  32857. /**
  32858. * Gets the file containing delay loading data for this mesh
  32859. */
  32860. delayLoadingFile: string;
  32861. /** @hidden */
  32862. _binaryInfo: any;
  32863. /**
  32864. * User defined function used to change how LOD level selection is done
  32865. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32866. */
  32867. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32868. /**
  32869. * Gets or sets the morph target manager
  32870. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32871. */
  32872. get morphTargetManager(): Nullable<MorphTargetManager>;
  32873. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32874. /** @hidden */
  32875. _creationDataStorage: Nullable<_CreationDataStorage>;
  32876. /** @hidden */
  32877. _geometry: Nullable<Geometry>;
  32878. /** @hidden */
  32879. _delayInfo: Array<string>;
  32880. /** @hidden */
  32881. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32882. /** @hidden */
  32883. _instanceDataStorage: _InstanceDataStorage;
  32884. /** @hidden */
  32885. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32886. private _effectiveMaterial;
  32887. /** @hidden */
  32888. _shouldGenerateFlatShading: boolean;
  32889. /** @hidden */
  32890. _originalBuilderSideOrientation: number;
  32891. /**
  32892. * Use this property to change the original side orientation defined at construction time
  32893. */
  32894. overrideMaterialSideOrientation: Nullable<number>;
  32895. /**
  32896. * Gets the source mesh (the one used to clone this one from)
  32897. */
  32898. get source(): Nullable<Mesh>;
  32899. /**
  32900. * Gets the list of clones of this mesh
  32901. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32902. * Note that useClonedMeshMap=true is the default setting
  32903. */
  32904. get cloneMeshMap(): Nullable<{
  32905. [id: string]: Mesh | undefined;
  32906. }>;
  32907. /**
  32908. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32909. */
  32910. get isUnIndexed(): boolean;
  32911. set isUnIndexed(value: boolean);
  32912. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32913. get worldMatrixInstancedBuffer(): Float32Array;
  32914. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32915. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32916. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32917. /**
  32918. * @constructor
  32919. * @param name The value used by scene.getMeshByName() to do a lookup.
  32920. * @param scene The scene to add this mesh to.
  32921. * @param parent The parent of this mesh, if it has one
  32922. * @param source An optional Mesh from which geometry is shared, cloned.
  32923. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32924. * When false, achieved by calling a clone(), also passing False.
  32925. * This will make creation of children, recursive.
  32926. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32927. */
  32928. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32929. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32930. doNotInstantiate: boolean;
  32931. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32932. /**
  32933. * Gets the class name
  32934. * @returns the string "Mesh".
  32935. */
  32936. getClassName(): string;
  32937. /** @hidden */
  32938. get _isMesh(): boolean;
  32939. /**
  32940. * Returns a description of this mesh
  32941. * @param fullDetails define if full details about this mesh must be used
  32942. * @returns a descriptive string representing this mesh
  32943. */
  32944. toString(fullDetails?: boolean): string;
  32945. /** @hidden */
  32946. _unBindEffect(): void;
  32947. /**
  32948. * Gets a boolean indicating if this mesh has LOD
  32949. */
  32950. get hasLODLevels(): boolean;
  32951. /**
  32952. * Gets the list of MeshLODLevel associated with the current mesh
  32953. * @returns an array of MeshLODLevel
  32954. */
  32955. getLODLevels(): MeshLODLevel[];
  32956. private _sortLODLevels;
  32957. /**
  32958. * Add a mesh as LOD level triggered at the given distance.
  32959. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32960. * @param distance The distance from the center of the object to show this level
  32961. * @param mesh The mesh to be added as LOD level (can be null)
  32962. * @return This mesh (for chaining)
  32963. */
  32964. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32965. /**
  32966. * Returns the LOD level mesh at the passed distance or null if not found.
  32967. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32968. * @param distance The distance from the center of the object to show this level
  32969. * @returns a Mesh or `null`
  32970. */
  32971. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32972. /**
  32973. * Remove a mesh from the LOD array
  32974. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32975. * @param mesh defines the mesh to be removed
  32976. * @return This mesh (for chaining)
  32977. */
  32978. removeLODLevel(mesh: Mesh): Mesh;
  32979. /**
  32980. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32981. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32982. * @param camera defines the camera to use to compute distance
  32983. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32984. * @return This mesh (for chaining)
  32985. */
  32986. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32987. /**
  32988. * Gets the mesh internal Geometry object
  32989. */
  32990. get geometry(): Nullable<Geometry>;
  32991. /**
  32992. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32993. * @returns the total number of vertices
  32994. */
  32995. getTotalVertices(): number;
  32996. /**
  32997. * Returns the content of an associated vertex buffer
  32998. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32999. * - VertexBuffer.PositionKind
  33000. * - VertexBuffer.UVKind
  33001. * - VertexBuffer.UV2Kind
  33002. * - VertexBuffer.UV3Kind
  33003. * - VertexBuffer.UV4Kind
  33004. * - VertexBuffer.UV5Kind
  33005. * - VertexBuffer.UV6Kind
  33006. * - VertexBuffer.ColorKind
  33007. * - VertexBuffer.MatricesIndicesKind
  33008. * - VertexBuffer.MatricesIndicesExtraKind
  33009. * - VertexBuffer.MatricesWeightsKind
  33010. * - VertexBuffer.MatricesWeightsExtraKind
  33011. * @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
  33012. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33013. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33014. */
  33015. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33016. /**
  33017. * Returns the mesh VertexBuffer object from the requested `kind`
  33018. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33019. * - VertexBuffer.PositionKind
  33020. * - VertexBuffer.NormalKind
  33021. * - VertexBuffer.UVKind
  33022. * - VertexBuffer.UV2Kind
  33023. * - VertexBuffer.UV3Kind
  33024. * - VertexBuffer.UV4Kind
  33025. * - VertexBuffer.UV5Kind
  33026. * - VertexBuffer.UV6Kind
  33027. * - VertexBuffer.ColorKind
  33028. * - VertexBuffer.MatricesIndicesKind
  33029. * - VertexBuffer.MatricesIndicesExtraKind
  33030. * - VertexBuffer.MatricesWeightsKind
  33031. * - VertexBuffer.MatricesWeightsExtraKind
  33032. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33033. */
  33034. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33035. /**
  33036. * Tests if a specific vertex buffer is associated with this mesh
  33037. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33038. * - VertexBuffer.PositionKind
  33039. * - VertexBuffer.NormalKind
  33040. * - VertexBuffer.UVKind
  33041. * - VertexBuffer.UV2Kind
  33042. * - VertexBuffer.UV3Kind
  33043. * - VertexBuffer.UV4Kind
  33044. * - VertexBuffer.UV5Kind
  33045. * - VertexBuffer.UV6Kind
  33046. * - VertexBuffer.ColorKind
  33047. * - VertexBuffer.MatricesIndicesKind
  33048. * - VertexBuffer.MatricesIndicesExtraKind
  33049. * - VertexBuffer.MatricesWeightsKind
  33050. * - VertexBuffer.MatricesWeightsExtraKind
  33051. * @returns a boolean
  33052. */
  33053. isVerticesDataPresent(kind: string): boolean;
  33054. /**
  33055. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33056. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33057. * - VertexBuffer.PositionKind
  33058. * - VertexBuffer.UVKind
  33059. * - VertexBuffer.UV2Kind
  33060. * - VertexBuffer.UV3Kind
  33061. * - VertexBuffer.UV4Kind
  33062. * - VertexBuffer.UV5Kind
  33063. * - VertexBuffer.UV6Kind
  33064. * - VertexBuffer.ColorKind
  33065. * - VertexBuffer.MatricesIndicesKind
  33066. * - VertexBuffer.MatricesIndicesExtraKind
  33067. * - VertexBuffer.MatricesWeightsKind
  33068. * - VertexBuffer.MatricesWeightsExtraKind
  33069. * @returns a boolean
  33070. */
  33071. isVertexBufferUpdatable(kind: string): boolean;
  33072. /**
  33073. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33074. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33075. * - VertexBuffer.PositionKind
  33076. * - VertexBuffer.NormalKind
  33077. * - VertexBuffer.UVKind
  33078. * - VertexBuffer.UV2Kind
  33079. * - VertexBuffer.UV3Kind
  33080. * - VertexBuffer.UV4Kind
  33081. * - VertexBuffer.UV5Kind
  33082. * - VertexBuffer.UV6Kind
  33083. * - VertexBuffer.ColorKind
  33084. * - VertexBuffer.MatricesIndicesKind
  33085. * - VertexBuffer.MatricesIndicesExtraKind
  33086. * - VertexBuffer.MatricesWeightsKind
  33087. * - VertexBuffer.MatricesWeightsExtraKind
  33088. * @returns an array of strings
  33089. */
  33090. getVerticesDataKinds(): string[];
  33091. /**
  33092. * Returns a positive integer : the total number of indices in this mesh geometry.
  33093. * @returns the numner of indices or zero if the mesh has no geometry.
  33094. */
  33095. getTotalIndices(): number;
  33096. /**
  33097. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33098. * @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.
  33099. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33100. * @returns the indices array or an empty array if the mesh has no geometry
  33101. */
  33102. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33103. get isBlocked(): boolean;
  33104. /**
  33105. * Determine if the current mesh is ready to be rendered
  33106. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33107. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33108. * @returns true if all associated assets are ready (material, textures, shaders)
  33109. */
  33110. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33111. /**
  33112. * 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.
  33113. */
  33114. get areNormalsFrozen(): boolean;
  33115. /**
  33116. * 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.
  33117. * @returns the current mesh
  33118. */
  33119. freezeNormals(): Mesh;
  33120. /**
  33121. * 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
  33122. * @returns the current mesh
  33123. */
  33124. unfreezeNormals(): Mesh;
  33125. /**
  33126. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33127. */
  33128. set overridenInstanceCount(count: number);
  33129. /** @hidden */
  33130. _preActivate(): Mesh;
  33131. /** @hidden */
  33132. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33133. /** @hidden */
  33134. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33135. protected _afterComputeWorldMatrix(): void;
  33136. /** @hidden */
  33137. _postActivate(): void;
  33138. /**
  33139. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33140. * This means the mesh underlying bounding box and sphere are recomputed.
  33141. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33142. * @returns the current mesh
  33143. */
  33144. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33145. /** @hidden */
  33146. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33147. /**
  33148. * This function will subdivide the mesh into multiple submeshes
  33149. * @param count defines the expected number of submeshes
  33150. */
  33151. subdivide(count: number): void;
  33152. /**
  33153. * Copy a FloatArray into a specific associated vertex buffer
  33154. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33155. * - VertexBuffer.PositionKind
  33156. * - VertexBuffer.UVKind
  33157. * - VertexBuffer.UV2Kind
  33158. * - VertexBuffer.UV3Kind
  33159. * - VertexBuffer.UV4Kind
  33160. * - VertexBuffer.UV5Kind
  33161. * - VertexBuffer.UV6Kind
  33162. * - VertexBuffer.ColorKind
  33163. * - VertexBuffer.MatricesIndicesKind
  33164. * - VertexBuffer.MatricesIndicesExtraKind
  33165. * - VertexBuffer.MatricesWeightsKind
  33166. * - VertexBuffer.MatricesWeightsExtraKind
  33167. * @param data defines the data source
  33168. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33169. * @param stride defines the data stride size (can be null)
  33170. * @returns the current mesh
  33171. */
  33172. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33173. /**
  33174. * Delete a vertex buffer associated with this mesh
  33175. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33176. * - VertexBuffer.PositionKind
  33177. * - VertexBuffer.UVKind
  33178. * - VertexBuffer.UV2Kind
  33179. * - VertexBuffer.UV3Kind
  33180. * - VertexBuffer.UV4Kind
  33181. * - VertexBuffer.UV5Kind
  33182. * - VertexBuffer.UV6Kind
  33183. * - VertexBuffer.ColorKind
  33184. * - VertexBuffer.MatricesIndicesKind
  33185. * - VertexBuffer.MatricesIndicesExtraKind
  33186. * - VertexBuffer.MatricesWeightsKind
  33187. * - VertexBuffer.MatricesWeightsExtraKind
  33188. */
  33189. removeVerticesData(kind: string): void;
  33190. /**
  33191. * Flags an associated vertex buffer as updatable
  33192. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33193. * - VertexBuffer.PositionKind
  33194. * - VertexBuffer.UVKind
  33195. * - VertexBuffer.UV2Kind
  33196. * - VertexBuffer.UV3Kind
  33197. * - VertexBuffer.UV4Kind
  33198. * - VertexBuffer.UV5Kind
  33199. * - VertexBuffer.UV6Kind
  33200. * - VertexBuffer.ColorKind
  33201. * - VertexBuffer.MatricesIndicesKind
  33202. * - VertexBuffer.MatricesIndicesExtraKind
  33203. * - VertexBuffer.MatricesWeightsKind
  33204. * - VertexBuffer.MatricesWeightsExtraKind
  33205. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33206. */
  33207. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33208. /**
  33209. * Sets the mesh global Vertex Buffer
  33210. * @param buffer defines the buffer to use
  33211. * @returns the current mesh
  33212. */
  33213. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33214. /**
  33215. * Update a specific associated vertex buffer
  33216. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33217. * - VertexBuffer.PositionKind
  33218. * - VertexBuffer.UVKind
  33219. * - VertexBuffer.UV2Kind
  33220. * - VertexBuffer.UV3Kind
  33221. * - VertexBuffer.UV4Kind
  33222. * - VertexBuffer.UV5Kind
  33223. * - VertexBuffer.UV6Kind
  33224. * - VertexBuffer.ColorKind
  33225. * - VertexBuffer.MatricesIndicesKind
  33226. * - VertexBuffer.MatricesIndicesExtraKind
  33227. * - VertexBuffer.MatricesWeightsKind
  33228. * - VertexBuffer.MatricesWeightsExtraKind
  33229. * @param data defines the data source
  33230. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33231. * @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)
  33232. * @returns the current mesh
  33233. */
  33234. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33235. /**
  33236. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33237. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33238. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33239. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33240. * @returns the current mesh
  33241. */
  33242. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33243. /**
  33244. * Creates a un-shared specific occurence of the geometry for the mesh.
  33245. * @returns the current mesh
  33246. */
  33247. makeGeometryUnique(): Mesh;
  33248. /**
  33249. * Set the index buffer of this mesh
  33250. * @param indices defines the source data
  33251. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33252. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33253. * @returns the current mesh
  33254. */
  33255. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33256. /**
  33257. * Update the current index buffer
  33258. * @param indices defines the source data
  33259. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33260. * @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)
  33261. * @returns the current mesh
  33262. */
  33263. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33264. /**
  33265. * Invert the geometry to move from a right handed system to a left handed one.
  33266. * @returns the current mesh
  33267. */
  33268. toLeftHanded(): Mesh;
  33269. /** @hidden */
  33270. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33271. /** @hidden */
  33272. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33273. /**
  33274. * Registers for this mesh a javascript function called just before the rendering process
  33275. * @param func defines the function to call before rendering this mesh
  33276. * @returns the current mesh
  33277. */
  33278. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33279. /**
  33280. * Disposes a previously registered javascript function called before the rendering
  33281. * @param func defines the function to remove
  33282. * @returns the current mesh
  33283. */
  33284. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33285. /**
  33286. * Registers for this mesh a javascript function called just after the rendering is complete
  33287. * @param func defines the function to call after rendering this mesh
  33288. * @returns the current mesh
  33289. */
  33290. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33291. /**
  33292. * Disposes a previously registered javascript function called after the rendering.
  33293. * @param func defines the function to remove
  33294. * @returns the current mesh
  33295. */
  33296. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33297. /** @hidden */
  33298. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33299. /** @hidden */
  33300. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33301. /** @hidden */
  33302. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33303. /** @hidden */
  33304. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33305. /** @hidden */
  33306. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33307. /** @hidden */
  33308. _rebuild(): void;
  33309. /** @hidden */
  33310. _freeze(): void;
  33311. /** @hidden */
  33312. _unFreeze(): void;
  33313. /**
  33314. * 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
  33315. * @param subMesh defines the subMesh to render
  33316. * @param enableAlphaMode defines if alpha mode can be changed
  33317. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33318. * @returns the current mesh
  33319. */
  33320. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33321. private _onBeforeDraw;
  33322. /**
  33323. * Renormalize the mesh and patch it up if there are no weights
  33324. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33325. * However in the case of zero weights then we set just a single influence to 1.
  33326. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33327. */
  33328. cleanMatrixWeights(): void;
  33329. private normalizeSkinFourWeights;
  33330. private normalizeSkinWeightsAndExtra;
  33331. /**
  33332. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33333. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33334. * the user know there was an issue with importing the mesh
  33335. * @returns a validation object with skinned, valid and report string
  33336. */
  33337. validateSkinning(): {
  33338. skinned: boolean;
  33339. valid: boolean;
  33340. report: string;
  33341. };
  33342. /** @hidden */
  33343. _checkDelayState(): Mesh;
  33344. private _queueLoad;
  33345. /**
  33346. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33347. * A mesh is in the frustum if its bounding box intersects the frustum
  33348. * @param frustumPlanes defines the frustum to test
  33349. * @returns true if the mesh is in the frustum planes
  33350. */
  33351. isInFrustum(frustumPlanes: Plane[]): boolean;
  33352. /**
  33353. * Sets the mesh material by the material or multiMaterial `id` property
  33354. * @param id is a string identifying the material or the multiMaterial
  33355. * @returns the current mesh
  33356. */
  33357. setMaterialByID(id: string): Mesh;
  33358. /**
  33359. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33360. * @returns an array of IAnimatable
  33361. */
  33362. getAnimatables(): IAnimatable[];
  33363. /**
  33364. * Modifies the mesh geometry according to the passed transformation matrix.
  33365. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33366. * The mesh normals are modified using the same transformation.
  33367. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33368. * @param transform defines the transform matrix to use
  33369. * @see https://doc.babylonjs.com/resources/baking_transformations
  33370. * @returns the current mesh
  33371. */
  33372. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33373. /**
  33374. * Modifies the mesh geometry according to its own current World Matrix.
  33375. * The mesh World Matrix is then reset.
  33376. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33377. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33378. * @see https://doc.babylonjs.com/resources/baking_transformations
  33379. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33380. * @returns the current mesh
  33381. */
  33382. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33383. /** @hidden */
  33384. get _positions(): Nullable<Vector3[]>;
  33385. /** @hidden */
  33386. _resetPointsArrayCache(): Mesh;
  33387. /** @hidden */
  33388. _generatePointsArray(): boolean;
  33389. /**
  33390. * Returns a new Mesh object generated from the current mesh properties.
  33391. * This method must not get confused with createInstance()
  33392. * @param name is a string, the name given to the new mesh
  33393. * @param newParent can be any Node object (default `null`)
  33394. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33395. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33396. * @returns a new mesh
  33397. */
  33398. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33399. /**
  33400. * Releases resources associated with this mesh.
  33401. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33402. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33403. */
  33404. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33405. /** @hidden */
  33406. _disposeInstanceSpecificData(): void;
  33407. /** @hidden */
  33408. _disposeThinInstanceSpecificData(): void;
  33409. /**
  33410. * Modifies the mesh geometry according to a displacement map.
  33411. * 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.
  33412. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33413. * @param url is a string, the URL from the image file is to be downloaded.
  33414. * @param minHeight is the lower limit of the displacement.
  33415. * @param maxHeight is the upper limit of the displacement.
  33416. * @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.
  33417. * @param uvOffset is an optional vector2 used to offset UV.
  33418. * @param uvScale is an optional vector2 used to scale UV.
  33419. * @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.
  33420. * @returns the Mesh.
  33421. */
  33422. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33423. /**
  33424. * Modifies the mesh geometry according to a displacementMap buffer.
  33425. * 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.
  33426. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33427. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33428. * @param heightMapWidth is the width of the buffer image.
  33429. * @param heightMapHeight is the height of the buffer image.
  33430. * @param minHeight is the lower limit of the displacement.
  33431. * @param maxHeight is the upper limit of the displacement.
  33432. * @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.
  33433. * @param uvOffset is an optional vector2 used to offset UV.
  33434. * @param uvScale is an optional vector2 used to scale UV.
  33435. * @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.
  33436. * @returns the Mesh.
  33437. */
  33438. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33439. /**
  33440. * Modify the mesh to get a flat shading rendering.
  33441. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33442. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33443. * @returns current mesh
  33444. */
  33445. convertToFlatShadedMesh(): Mesh;
  33446. /**
  33447. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33448. * In other words, more vertices, no more indices and a single bigger VBO.
  33449. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33450. * @returns current mesh
  33451. */
  33452. convertToUnIndexedMesh(): Mesh;
  33453. /**
  33454. * Inverses facet orientations.
  33455. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33456. * @param flipNormals will also inverts the normals
  33457. * @returns current mesh
  33458. */
  33459. flipFaces(flipNormals?: boolean): Mesh;
  33460. /**
  33461. * Increase the number of facets and hence vertices in a mesh
  33462. * Vertex normals are interpolated from existing vertex normals
  33463. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33464. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33465. */
  33466. increaseVertices(numberPerEdge: number): void;
  33467. /**
  33468. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33469. * This will undo any application of covertToFlatShadedMesh
  33470. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33471. */
  33472. forceSharedVertices(): void;
  33473. /** @hidden */
  33474. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33475. /** @hidden */
  33476. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33477. /**
  33478. * Creates a new InstancedMesh object from the mesh model.
  33479. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33480. * @param name defines the name of the new instance
  33481. * @returns a new InstancedMesh
  33482. */
  33483. createInstance(name: string): InstancedMesh;
  33484. /**
  33485. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33486. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33487. * @returns the current mesh
  33488. */
  33489. synchronizeInstances(): Mesh;
  33490. /**
  33491. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33492. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33493. * This should be used together with the simplification to avoid disappearing triangles.
  33494. * @param successCallback an optional success callback to be called after the optimization finished.
  33495. * @returns the current mesh
  33496. */
  33497. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33498. /**
  33499. * Serialize current mesh
  33500. * @param serializationObject defines the object which will receive the serialization data
  33501. */
  33502. serialize(serializationObject: any): void;
  33503. /** @hidden */
  33504. _syncGeometryWithMorphTargetManager(): void;
  33505. /** @hidden */
  33506. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33507. /**
  33508. * Returns a new Mesh object parsed from the source provided.
  33509. * @param parsedMesh is the source
  33510. * @param scene defines the hosting scene
  33511. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33512. * @returns a new Mesh
  33513. */
  33514. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33515. /**
  33516. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33518. * @param name defines the name of the mesh to create
  33519. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33520. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33521. * @param closePath creates a seam between the first and the last points of each path of the path array
  33522. * @param offset is taken in account only if the `pathArray` is containing a single path
  33523. * @param scene defines the hosting scene
  33524. * @param updatable defines if the mesh must be flagged as updatable
  33525. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33526. * @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)
  33527. * @returns a new Mesh
  33528. */
  33529. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33530. /**
  33531. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33532. * @param name defines the name of the mesh to create
  33533. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33534. * @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
  33535. * @param scene defines the hosting scene
  33536. * @param updatable defines if the mesh must be flagged as updatable
  33537. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33538. * @returns a new Mesh
  33539. */
  33540. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33541. /**
  33542. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33543. * @param name defines the name of the mesh to create
  33544. * @param size sets the size (float) of each box side (default 1)
  33545. * @param scene defines the hosting scene
  33546. * @param updatable defines if the mesh must be flagged as updatable
  33547. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33548. * @returns a new Mesh
  33549. */
  33550. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33551. /**
  33552. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33553. * @param name defines the name of the mesh to create
  33554. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33555. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33556. * @param scene defines the hosting scene
  33557. * @param updatable defines if the mesh must be flagged as updatable
  33558. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33559. * @returns a new Mesh
  33560. */
  33561. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33562. /**
  33563. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33564. * @param name defines the name of the mesh to create
  33565. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33566. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33567. * @param scene defines the hosting scene
  33568. * @returns a new Mesh
  33569. */
  33570. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33571. /**
  33572. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33573. * @param name defines the name of the mesh to create
  33574. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33575. * @param diameterTop set the top cap diameter (floats, default 1)
  33576. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33577. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33578. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  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 CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33585. /**
  33586. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  33589. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33590. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33591. * @param scene defines the hosting scene
  33592. * @param updatable defines if the mesh must be flagged as updatable
  33593. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33594. * @returns a new Mesh
  33595. */
  33596. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33597. /**
  33598. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33599. * @param name defines the name of the mesh to create
  33600. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33601. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33602. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33603. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33604. * @param p the number of windings on X axis (positive integers, default 2)
  33605. * @param q the number of windings on Y axis (positive integers, default 3)
  33606. * @param scene defines the hosting scene
  33607. * @param updatable defines if the mesh must be flagged as updatable
  33608. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33609. * @returns a new Mesh
  33610. */
  33611. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33612. /**
  33613. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33614. * @param name defines the name of the mesh to create
  33615. * @param points is an array successive Vector3
  33616. * @param scene defines the hosting scene
  33617. * @param updatable defines if the mesh must be flagged as updatable
  33618. * @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).
  33619. * @returns a new Mesh
  33620. */
  33621. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33622. /**
  33623. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33624. * @param name defines the name of the mesh to create
  33625. * @param points is an array successive Vector3
  33626. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33627. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33628. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33629. * @param scene defines the hosting scene
  33630. * @param updatable defines if the mesh must be flagged as updatable
  33631. * @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)
  33632. * @returns a new Mesh
  33633. */
  33634. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33635. /**
  33636. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33637. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33638. * 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.
  33639. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33640. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33641. * Remember you can only change the shape positions, not their number when updating a polygon.
  33642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33643. * @param name defines the name of the mesh to create
  33644. * @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
  33645. * @param scene defines the hosting scene
  33646. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33647. * @param updatable defines if the mesh must be flagged as updatable
  33648. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33649. * @param earcutInjection can be used to inject your own earcut reference
  33650. * @returns a new Mesh
  33651. */
  33652. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33653. /**
  33654. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33656. * @param name defines the name of the mesh to create
  33657. * @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
  33658. * @param depth defines the height of extrusion
  33659. * @param scene defines the hosting scene
  33660. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33661. * @param updatable defines if the mesh must be flagged as updatable
  33662. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33663. * @param earcutInjection can be used to inject your own earcut reference
  33664. * @returns a new Mesh
  33665. */
  33666. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33667. /**
  33668. * Creates an extruded shape mesh.
  33669. * 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
  33670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33672. * @param name defines the name of the mesh to create
  33673. * @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
  33674. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33675. * @param scale is the value to scale the shape
  33676. * @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
  33677. * @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
  33678. * @param scene defines the hosting scene
  33679. * @param updatable defines if the mesh must be flagged as updatable
  33680. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33681. * @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)
  33682. * @returns a new Mesh
  33683. */
  33684. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33685. /**
  33686. * Creates an custom extruded shape mesh.
  33687. * The custom extrusion is a parametric shape.
  33688. * It has no predefined shape. Its final shape will depend on the input parameters.
  33689. * Please consider using the same method from the MeshBuilder class instead
  33690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33691. * @param name defines the name of the mesh to create
  33692. * @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
  33693. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33694. * @param scaleFunction is a custom Javascript function called on each path point
  33695. * @param rotationFunction is a custom Javascript function called on each path point
  33696. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33697. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33698. * @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
  33699. * @param scene defines the hosting scene
  33700. * @param updatable defines if the mesh must be flagged as updatable
  33701. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33702. * @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)
  33703. * @returns a new Mesh
  33704. */
  33705. 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;
  33706. /**
  33707. * Creates lathe mesh.
  33708. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33709. * Please consider using the same method from the MeshBuilder class instead
  33710. * @param name defines the name of the mesh to create
  33711. * @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
  33712. * @param radius is the radius value of the lathe
  33713. * @param tessellation is the side number of the lathe.
  33714. * @param scene defines the hosting scene
  33715. * @param updatable defines if the mesh must be flagged as updatable
  33716. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33717. * @returns a new Mesh
  33718. */
  33719. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33720. /**
  33721. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33722. * @param name defines the name of the mesh to create
  33723. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33724. * @param scene defines the hosting scene
  33725. * @param updatable defines if the mesh must be flagged as updatable
  33726. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33727. * @returns a new Mesh
  33728. */
  33729. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33730. /**
  33731. * Creates a ground mesh.
  33732. * Please consider using the same method from the MeshBuilder class instead
  33733. * @param name defines the name of the mesh to create
  33734. * @param width set the width of the ground
  33735. * @param height set the height of the ground
  33736. * @param subdivisions sets the number of subdivisions per side
  33737. * @param scene defines the hosting scene
  33738. * @param updatable defines if the mesh must be flagged as updatable
  33739. * @returns a new Mesh
  33740. */
  33741. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33742. /**
  33743. * Creates a tiled ground mesh.
  33744. * Please consider using the same method from the MeshBuilder class instead
  33745. * @param name defines the name of the mesh to create
  33746. * @param xmin set the ground minimum X coordinate
  33747. * @param zmin set the ground minimum Y coordinate
  33748. * @param xmax set the ground maximum X coordinate
  33749. * @param zmax set the ground maximum Z coordinate
  33750. * @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
  33751. * @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
  33752. * @param scene defines the hosting scene
  33753. * @param updatable defines if the mesh must be flagged as updatable
  33754. * @returns a new Mesh
  33755. */
  33756. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33757. w: number;
  33758. h: number;
  33759. }, precision: {
  33760. w: number;
  33761. h: number;
  33762. }, scene: Scene, updatable?: boolean): Mesh;
  33763. /**
  33764. * Creates a ground mesh from a height map.
  33765. * Please consider using the same method from the MeshBuilder class instead
  33766. * @see https://doc.babylonjs.com/babylon101/height_map
  33767. * @param name defines the name of the mesh to create
  33768. * @param url sets the URL of the height map image resource
  33769. * @param width set the ground width size
  33770. * @param height set the ground height size
  33771. * @param subdivisions sets the number of subdivision per side
  33772. * @param minHeight is the minimum altitude on the ground
  33773. * @param maxHeight is the maximum altitude on the ground
  33774. * @param scene defines the hosting scene
  33775. * @param updatable defines if the mesh must be flagged as updatable
  33776. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33777. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33778. * @returns a new Mesh
  33779. */
  33780. 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;
  33781. /**
  33782. * Creates a tube mesh.
  33783. * The tube is a parametric shape.
  33784. * It has no predefined shape. Its final shape will depend on the input parameters.
  33785. * Please consider using the same method from the MeshBuilder class instead
  33786. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33787. * @param name defines the name of the mesh to create
  33788. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33789. * @param radius sets the tube radius size
  33790. * @param tessellation is the number of sides on the tubular surface
  33791. * @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
  33792. * @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
  33793. * @param scene defines the hosting scene
  33794. * @param updatable defines if the mesh must be flagged as updatable
  33795. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33796. * @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)
  33797. * @returns a new Mesh
  33798. */
  33799. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33800. (i: number, distance: number): number;
  33801. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33802. /**
  33803. * Creates a polyhedron mesh.
  33804. * Please consider using the same method from the MeshBuilder class instead.
  33805. * * 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
  33806. * * The parameter `size` (positive float, default 1) sets the polygon size
  33807. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33808. * * 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`
  33809. * * 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
  33810. * * 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)`)
  33811. * * 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
  33812. * * 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
  33813. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33814. * * 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
  33815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33816. * @param name defines the name of the mesh to create
  33817. * @param options defines the options used to create the mesh
  33818. * @param scene defines the hosting scene
  33819. * @returns a new Mesh
  33820. */
  33821. static CreatePolyhedron(name: string, options: {
  33822. type?: number;
  33823. size?: number;
  33824. sizeX?: number;
  33825. sizeY?: number;
  33826. sizeZ?: number;
  33827. custom?: any;
  33828. faceUV?: Vector4[];
  33829. faceColors?: Color4[];
  33830. updatable?: boolean;
  33831. sideOrientation?: number;
  33832. }, scene: Scene): Mesh;
  33833. /**
  33834. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33835. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33836. * * 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`)
  33837. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33838. * * 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
  33839. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33840. * * 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
  33841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33842. * @param name defines the name of the mesh
  33843. * @param options defines the options used to create the mesh
  33844. * @param scene defines the hosting scene
  33845. * @returns a new Mesh
  33846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33847. */
  33848. static CreateIcoSphere(name: string, options: {
  33849. radius?: number;
  33850. flat?: boolean;
  33851. subdivisions?: number;
  33852. sideOrientation?: number;
  33853. updatable?: boolean;
  33854. }, scene: Scene): Mesh;
  33855. /**
  33856. * Creates a decal mesh.
  33857. * Please consider using the same method from the MeshBuilder class instead.
  33858. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33859. * @param name defines the name of the mesh
  33860. * @param sourceMesh defines the mesh receiving the decal
  33861. * @param position sets the position of the decal in world coordinates
  33862. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33863. * @param size sets the decal scaling
  33864. * @param angle sets the angle to rotate the decal
  33865. * @returns a new Mesh
  33866. */
  33867. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33868. /** Creates a Capsule Mesh
  33869. * @param name defines the name of the mesh.
  33870. * @param options the constructors options used to shape the mesh.
  33871. * @param scene defines the scene the mesh is scoped to.
  33872. * @returns the capsule mesh
  33873. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33874. */
  33875. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33876. /**
  33877. * Prepare internal position array for software CPU skinning
  33878. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33879. */
  33880. setPositionsForCPUSkinning(): Float32Array;
  33881. /**
  33882. * Prepare internal normal array for software CPU skinning
  33883. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33884. */
  33885. setNormalsForCPUSkinning(): Float32Array;
  33886. /**
  33887. * Updates the vertex buffer by applying transformation from the bones
  33888. * @param skeleton defines the skeleton to apply to current mesh
  33889. * @returns the current mesh
  33890. */
  33891. applySkeleton(skeleton: Skeleton): Mesh;
  33892. /**
  33893. * 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
  33894. * @param meshes defines the list of meshes to scan
  33895. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33896. */
  33897. static MinMax(meshes: AbstractMesh[]): {
  33898. min: Vector3;
  33899. max: Vector3;
  33900. };
  33901. /**
  33902. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33903. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33904. * @returns a vector3
  33905. */
  33906. static Center(meshesOrMinMaxVector: {
  33907. min: Vector3;
  33908. max: Vector3;
  33909. } | AbstractMesh[]): Vector3;
  33910. /**
  33911. * Merge the array of meshes into a single mesh for performance reasons.
  33912. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33913. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33914. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33915. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33916. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33917. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33918. * @returns a new mesh
  33919. */
  33920. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33921. /** @hidden */
  33922. addInstance(instance: InstancedMesh): void;
  33923. /** @hidden */
  33924. removeInstance(instance: InstancedMesh): void;
  33925. }
  33926. }
  33927. declare module BABYLON {
  33928. /**
  33929. * This is the base class of all the camera used in the application.
  33930. * @see https://doc.babylonjs.com/features/cameras
  33931. */
  33932. export class Camera extends Node {
  33933. /** @hidden */
  33934. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33935. /**
  33936. * This is the default projection mode used by the cameras.
  33937. * It helps recreating a feeling of perspective and better appreciate depth.
  33938. * This is the best way to simulate real life cameras.
  33939. */
  33940. static readonly PERSPECTIVE_CAMERA: number;
  33941. /**
  33942. * This helps creating camera with an orthographic mode.
  33943. * 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.
  33944. */
  33945. static readonly ORTHOGRAPHIC_CAMERA: number;
  33946. /**
  33947. * This is the default FOV mode for perspective cameras.
  33948. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33949. */
  33950. static readonly FOVMODE_VERTICAL_FIXED: number;
  33951. /**
  33952. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33953. */
  33954. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33955. /**
  33956. * This specifies ther is no need for a camera rig.
  33957. * Basically only one eye is rendered corresponding to the camera.
  33958. */
  33959. static readonly RIG_MODE_NONE: number;
  33960. /**
  33961. * Simulates a camera Rig with one blue eye and one red eye.
  33962. * This can be use with 3d blue and red glasses.
  33963. */
  33964. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33965. /**
  33966. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33967. */
  33968. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33969. /**
  33970. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33971. */
  33972. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33973. /**
  33974. * Defines that both eyes of the camera will be rendered over under each other.
  33975. */
  33976. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33977. /**
  33978. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33979. */
  33980. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33981. /**
  33982. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33983. */
  33984. static readonly RIG_MODE_VR: number;
  33985. /**
  33986. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33987. */
  33988. static readonly RIG_MODE_WEBVR: number;
  33989. /**
  33990. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33991. */
  33992. static readonly RIG_MODE_CUSTOM: number;
  33993. /**
  33994. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33995. */
  33996. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33997. /**
  33998. * Define the input manager associated with the camera.
  33999. */
  34000. inputs: CameraInputsManager<Camera>;
  34001. /** @hidden */
  34002. _position: Vector3;
  34003. /**
  34004. * Define the current local position of the camera in the scene
  34005. */
  34006. get position(): Vector3;
  34007. set position(newPosition: Vector3);
  34008. protected _upVector: Vector3;
  34009. /**
  34010. * The vector the camera should consider as up.
  34011. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34012. */
  34013. set upVector(vec: Vector3);
  34014. get upVector(): Vector3;
  34015. /**
  34016. * Define the current limit on the left side for an orthographic camera
  34017. * In scene unit
  34018. */
  34019. orthoLeft: Nullable<number>;
  34020. /**
  34021. * Define the current limit on the right side for an orthographic camera
  34022. * In scene unit
  34023. */
  34024. orthoRight: Nullable<number>;
  34025. /**
  34026. * Define the current limit on the bottom side for an orthographic camera
  34027. * In scene unit
  34028. */
  34029. orthoBottom: Nullable<number>;
  34030. /**
  34031. * Define the current limit on the top side for an orthographic camera
  34032. * In scene unit
  34033. */
  34034. orthoTop: Nullable<number>;
  34035. /**
  34036. * Field Of View is set in Radians. (default is 0.8)
  34037. */
  34038. fov: number;
  34039. /**
  34040. * Define the minimum distance the camera can see from.
  34041. * This is important to note that the depth buffer are not infinite and the closer it starts
  34042. * the more your scene might encounter depth fighting issue.
  34043. */
  34044. minZ: number;
  34045. /**
  34046. * Define the maximum distance the camera can see to.
  34047. * This is important to note that the depth buffer are not infinite and the further it end
  34048. * the more your scene might encounter depth fighting issue.
  34049. */
  34050. maxZ: number;
  34051. /**
  34052. * Define the default inertia of the camera.
  34053. * This helps giving a smooth feeling to the camera movement.
  34054. */
  34055. inertia: number;
  34056. /**
  34057. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34058. */
  34059. mode: number;
  34060. /**
  34061. * Define whether the camera is intermediate.
  34062. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34063. */
  34064. isIntermediate: boolean;
  34065. /**
  34066. * Define the viewport of the camera.
  34067. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34068. */
  34069. viewport: Viewport;
  34070. /**
  34071. * Restricts the camera to viewing objects with the same layerMask.
  34072. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34073. */
  34074. layerMask: number;
  34075. /**
  34076. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34077. */
  34078. fovMode: number;
  34079. /**
  34080. * Rig mode of the camera.
  34081. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34082. * This is normally controlled byt the camera themselves as internal use.
  34083. */
  34084. cameraRigMode: number;
  34085. /**
  34086. * Defines the distance between both "eyes" in case of a RIG
  34087. */
  34088. interaxialDistance: number;
  34089. /**
  34090. * Defines if stereoscopic rendering is done side by side or over under.
  34091. */
  34092. isStereoscopicSideBySide: boolean;
  34093. /**
  34094. * 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
  34095. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34096. * else in the scene. (Eg. security camera)
  34097. *
  34098. * 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)
  34099. */
  34100. customRenderTargets: RenderTargetTexture[];
  34101. /**
  34102. * When set, the camera will render to this render target instead of the default canvas
  34103. *
  34104. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34105. */
  34106. outputRenderTarget: Nullable<RenderTargetTexture>;
  34107. /**
  34108. * Observable triggered when the camera view matrix has changed.
  34109. */
  34110. onViewMatrixChangedObservable: Observable<Camera>;
  34111. /**
  34112. * Observable triggered when the camera Projection matrix has changed.
  34113. */
  34114. onProjectionMatrixChangedObservable: Observable<Camera>;
  34115. /**
  34116. * Observable triggered when the inputs have been processed.
  34117. */
  34118. onAfterCheckInputsObservable: Observable<Camera>;
  34119. /**
  34120. * Observable triggered when reset has been called and applied to the camera.
  34121. */
  34122. onRestoreStateObservable: Observable<Camera>;
  34123. /**
  34124. * Is this camera a part of a rig system?
  34125. */
  34126. isRigCamera: boolean;
  34127. /**
  34128. * If isRigCamera set to true this will be set with the parent camera.
  34129. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34130. */
  34131. rigParent?: Camera;
  34132. /** @hidden */
  34133. _cameraRigParams: any;
  34134. /** @hidden */
  34135. _rigCameras: Camera[];
  34136. /** @hidden */
  34137. _rigPostProcess: Nullable<PostProcess>;
  34138. protected _webvrViewMatrix: Matrix;
  34139. /** @hidden */
  34140. _skipRendering: boolean;
  34141. /** @hidden */
  34142. _projectionMatrix: Matrix;
  34143. /** @hidden */
  34144. _postProcesses: Nullable<PostProcess>[];
  34145. /** @hidden */
  34146. _activeMeshes: SmartArray<AbstractMesh>;
  34147. protected _globalPosition: Vector3;
  34148. /** @hidden */
  34149. _computedViewMatrix: Matrix;
  34150. private _doNotComputeProjectionMatrix;
  34151. private _transformMatrix;
  34152. private _frustumPlanes;
  34153. private _refreshFrustumPlanes;
  34154. private _storedFov;
  34155. private _stateStored;
  34156. /**
  34157. * Instantiates a new camera object.
  34158. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34159. * @see https://doc.babylonjs.com/features/cameras
  34160. * @param name Defines the name of the camera in the scene
  34161. * @param position Defines the position of the camera
  34162. * @param scene Defines the scene the camera belongs too
  34163. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34164. */
  34165. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34166. /**
  34167. * Store current camera state (fov, position, etc..)
  34168. * @returns the camera
  34169. */
  34170. storeState(): Camera;
  34171. /**
  34172. * Restores the camera state values if it has been stored. You must call storeState() first
  34173. */
  34174. protected _restoreStateValues(): boolean;
  34175. /**
  34176. * Restored camera state. You must call storeState() first.
  34177. * @returns true if restored and false otherwise
  34178. */
  34179. restoreState(): boolean;
  34180. /**
  34181. * Gets the class name of the camera.
  34182. * @returns the class name
  34183. */
  34184. getClassName(): string;
  34185. /** @hidden */
  34186. readonly _isCamera: boolean;
  34187. /**
  34188. * Gets a string representation of the camera useful for debug purpose.
  34189. * @param fullDetails Defines that a more verboe level of logging is required
  34190. * @returns the string representation
  34191. */
  34192. toString(fullDetails?: boolean): string;
  34193. /**
  34194. * Gets the current world space position of the camera.
  34195. */
  34196. get globalPosition(): Vector3;
  34197. /**
  34198. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34199. * @returns the active meshe list
  34200. */
  34201. getActiveMeshes(): SmartArray<AbstractMesh>;
  34202. /**
  34203. * Check whether a mesh is part of the current active mesh list of the camera
  34204. * @param mesh Defines the mesh to check
  34205. * @returns true if active, false otherwise
  34206. */
  34207. isActiveMesh(mesh: Mesh): boolean;
  34208. /**
  34209. * Is this camera ready to be used/rendered
  34210. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34211. * @return true if the camera is ready
  34212. */
  34213. isReady(completeCheck?: boolean): boolean;
  34214. /** @hidden */
  34215. _initCache(): void;
  34216. /** @hidden */
  34217. _updateCache(ignoreParentClass?: boolean): void;
  34218. /** @hidden */
  34219. _isSynchronized(): boolean;
  34220. /** @hidden */
  34221. _isSynchronizedViewMatrix(): boolean;
  34222. /** @hidden */
  34223. _isSynchronizedProjectionMatrix(): boolean;
  34224. /**
  34225. * Attach the input controls to a specific dom element to get the input from.
  34226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34227. */
  34228. attachControl(noPreventDefault?: boolean): void;
  34229. /**
  34230. * Detach the current controls from the specified dom element.
  34231. */
  34232. detachControl(): void;
  34233. /**
  34234. * Update the camera state according to the different inputs gathered during the frame.
  34235. */
  34236. update(): void;
  34237. /** @hidden */
  34238. _checkInputs(): void;
  34239. /** @hidden */
  34240. get rigCameras(): Camera[];
  34241. /**
  34242. * Gets the post process used by the rig cameras
  34243. */
  34244. get rigPostProcess(): Nullable<PostProcess>;
  34245. /**
  34246. * Internal, gets the first post proces.
  34247. * @returns the first post process to be run on this camera.
  34248. */
  34249. _getFirstPostProcess(): Nullable<PostProcess>;
  34250. private _cascadePostProcessesToRigCams;
  34251. /**
  34252. * Attach a post process to the camera.
  34253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34254. * @param postProcess The post process to attach to the camera
  34255. * @param insertAt The position of the post process in case several of them are in use in the scene
  34256. * @returns the position the post process has been inserted at
  34257. */
  34258. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34259. /**
  34260. * Detach a post process to the camera.
  34261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34262. * @param postProcess The post process to detach from the camera
  34263. */
  34264. detachPostProcess(postProcess: PostProcess): void;
  34265. /**
  34266. * Gets the current world matrix of the camera
  34267. */
  34268. getWorldMatrix(): Matrix;
  34269. /** @hidden */
  34270. _getViewMatrix(): Matrix;
  34271. /**
  34272. * Gets the current view matrix of the camera.
  34273. * @param force forces the camera to recompute the matrix without looking at the cached state
  34274. * @returns the view matrix
  34275. */
  34276. getViewMatrix(force?: boolean): Matrix;
  34277. /**
  34278. * Freeze the projection matrix.
  34279. * It will prevent the cache check of the camera projection compute and can speed up perf
  34280. * if no parameter of the camera are meant to change
  34281. * @param projection Defines manually a projection if necessary
  34282. */
  34283. freezeProjectionMatrix(projection?: Matrix): void;
  34284. /**
  34285. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34286. */
  34287. unfreezeProjectionMatrix(): void;
  34288. /**
  34289. * Gets the current projection matrix of the camera.
  34290. * @param force forces the camera to recompute the matrix without looking at the cached state
  34291. * @returns the projection matrix
  34292. */
  34293. getProjectionMatrix(force?: boolean): Matrix;
  34294. /**
  34295. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34296. * @returns a Matrix
  34297. */
  34298. getTransformationMatrix(): Matrix;
  34299. private _updateFrustumPlanes;
  34300. /**
  34301. * Checks if a cullable object (mesh...) is in the camera frustum
  34302. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34303. * @param target The object to check
  34304. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34305. * @returns true if the object is in frustum otherwise false
  34306. */
  34307. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34308. /**
  34309. * Checks if a cullable object (mesh...) is in the camera frustum
  34310. * Unlike isInFrustum this cheks the full bounding box
  34311. * @param target The object to check
  34312. * @returns true if the object is in frustum otherwise false
  34313. */
  34314. isCompletelyInFrustum(target: ICullable): boolean;
  34315. /**
  34316. * Gets a ray in the forward direction from the camera.
  34317. * @param length Defines the length of the ray to create
  34318. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34319. * @param origin Defines the start point of the ray which defaults to the camera position
  34320. * @returns the forward ray
  34321. */
  34322. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34323. /**
  34324. * Gets a ray in the forward direction from the camera.
  34325. * @param refRay the ray to (re)use when setting the values
  34326. * @param length Defines the length of the ray to create
  34327. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34328. * @param origin Defines the start point of the ray which defaults to the camera position
  34329. * @returns the forward ray
  34330. */
  34331. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34332. /**
  34333. * Releases resources associated with this node.
  34334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34336. */
  34337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34338. /** @hidden */
  34339. _isLeftCamera: boolean;
  34340. /**
  34341. * Gets the left camera of a rig setup in case of Rigged Camera
  34342. */
  34343. get isLeftCamera(): boolean;
  34344. /** @hidden */
  34345. _isRightCamera: boolean;
  34346. /**
  34347. * Gets the right camera of a rig setup in case of Rigged Camera
  34348. */
  34349. get isRightCamera(): boolean;
  34350. /**
  34351. * Gets the left camera of a rig setup in case of Rigged Camera
  34352. */
  34353. get leftCamera(): Nullable<FreeCamera>;
  34354. /**
  34355. * Gets the right camera of a rig setup in case of Rigged Camera
  34356. */
  34357. get rightCamera(): Nullable<FreeCamera>;
  34358. /**
  34359. * Gets the left camera target of a rig setup in case of Rigged Camera
  34360. * @returns the target position
  34361. */
  34362. getLeftTarget(): Nullable<Vector3>;
  34363. /**
  34364. * Gets the right camera target of a rig setup in case of Rigged Camera
  34365. * @returns the target position
  34366. */
  34367. getRightTarget(): Nullable<Vector3>;
  34368. /**
  34369. * @hidden
  34370. */
  34371. setCameraRigMode(mode: number, rigParams: any): void;
  34372. /** @hidden */
  34373. static _setStereoscopicRigMode(camera: Camera): void;
  34374. /** @hidden */
  34375. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34376. /** @hidden */
  34377. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34378. /** @hidden */
  34379. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34380. /** @hidden */
  34381. _getVRProjectionMatrix(): Matrix;
  34382. protected _updateCameraRotationMatrix(): void;
  34383. protected _updateWebVRCameraRotationMatrix(): void;
  34384. /**
  34385. * This function MUST be overwritten by the different WebVR cameras available.
  34386. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34387. * @hidden
  34388. */
  34389. _getWebVRProjectionMatrix(): Matrix;
  34390. /**
  34391. * This function MUST be overwritten by the different WebVR cameras available.
  34392. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34393. * @hidden
  34394. */
  34395. _getWebVRViewMatrix(): Matrix;
  34396. /** @hidden */
  34397. setCameraRigParameter(name: string, value: any): void;
  34398. /**
  34399. * needs to be overridden by children so sub has required properties to be copied
  34400. * @hidden
  34401. */
  34402. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34403. /**
  34404. * May need to be overridden by children
  34405. * @hidden
  34406. */
  34407. _updateRigCameras(): void;
  34408. /** @hidden */
  34409. _setupInputs(): void;
  34410. /**
  34411. * Serialiaze the camera setup to a json represention
  34412. * @returns the JSON representation
  34413. */
  34414. serialize(): any;
  34415. /**
  34416. * Clones the current camera.
  34417. * @param name The cloned camera name
  34418. * @returns the cloned camera
  34419. */
  34420. clone(name: string): Camera;
  34421. /**
  34422. * Gets the direction of the camera relative to a given local axis.
  34423. * @param localAxis Defines the reference axis to provide a relative direction.
  34424. * @return the direction
  34425. */
  34426. getDirection(localAxis: Vector3): Vector3;
  34427. /**
  34428. * Returns the current camera absolute rotation
  34429. */
  34430. get absoluteRotation(): Quaternion;
  34431. /**
  34432. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34433. * @param localAxis Defines the reference axis to provide a relative direction.
  34434. * @param result Defines the vector to store the result in
  34435. */
  34436. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34437. /**
  34438. * Gets a camera constructor for a given camera type
  34439. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34440. * @param name The name of the camera the result will be able to instantiate
  34441. * @param scene The scene the result will construct the camera in
  34442. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34443. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34444. * @returns a factory method to construc the camera
  34445. */
  34446. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34447. /**
  34448. * Compute the world matrix of the camera.
  34449. * @returns the camera world matrix
  34450. */
  34451. computeWorldMatrix(): Matrix;
  34452. /**
  34453. * Parse a JSON and creates the camera from the parsed information
  34454. * @param parsedCamera The JSON to parse
  34455. * @param scene The scene to instantiate the camera in
  34456. * @returns the newly constructed camera
  34457. */
  34458. static Parse(parsedCamera: any, scene: Scene): Camera;
  34459. }
  34460. }
  34461. declare module BABYLON {
  34462. /**
  34463. * Class containing static functions to help procedurally build meshes
  34464. */
  34465. export class DiscBuilder {
  34466. /**
  34467. * Creates a plane polygonal mesh. By default, this is a disc
  34468. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34469. * * 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
  34470. * * 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
  34471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34472. * * 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
  34473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34474. * @param name defines the name of the mesh
  34475. * @param options defines the options used to create the mesh
  34476. * @param scene defines the hosting scene
  34477. * @returns the plane polygonal mesh
  34478. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34479. */
  34480. static CreateDisc(name: string, options: {
  34481. radius?: number;
  34482. tessellation?: number;
  34483. arc?: number;
  34484. updatable?: boolean;
  34485. sideOrientation?: number;
  34486. frontUVs?: Vector4;
  34487. backUVs?: Vector4;
  34488. }, scene?: Nullable<Scene>): Mesh;
  34489. }
  34490. }
  34491. declare module BABYLON {
  34492. /**
  34493. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34494. *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.
  34495. * The SPS is also a particle system. It provides some methods to manage the particles.
  34496. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34497. *
  34498. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34499. */
  34500. export class SolidParticleSystem implements IDisposable {
  34501. /**
  34502. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34503. * Example : var p = SPS.particles[i];
  34504. */
  34505. particles: SolidParticle[];
  34506. /**
  34507. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34508. */
  34509. nbParticles: number;
  34510. /**
  34511. * If the particles must ever face the camera (default false). Useful for planar particles.
  34512. */
  34513. billboard: boolean;
  34514. /**
  34515. * Recompute normals when adding a shape
  34516. */
  34517. recomputeNormals: boolean;
  34518. /**
  34519. * This a counter ofr your own usage. It's not set by any SPS functions.
  34520. */
  34521. counter: number;
  34522. /**
  34523. * The SPS name. This name is also given to the underlying mesh.
  34524. */
  34525. name: string;
  34526. /**
  34527. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34528. */
  34529. mesh: Mesh;
  34530. /**
  34531. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34532. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34533. */
  34534. vars: any;
  34535. /**
  34536. * This array is populated when the SPS is set as 'pickable'.
  34537. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34538. * Each element of this array is an object `{idx: int, faceId: int}`.
  34539. * `idx` is the picked particle index in the `SPS.particles` array
  34540. * `faceId` is the picked face index counted within this particle.
  34541. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34542. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34543. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34544. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34545. */
  34546. pickedParticles: {
  34547. idx: number;
  34548. faceId: number;
  34549. }[];
  34550. /**
  34551. * This array is populated when the SPS is set as 'pickable'
  34552. * Each key of this array is a submesh index.
  34553. * Each element of this array is a second array defined like this :
  34554. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34555. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34556. * `idx` is the picked particle index in the `SPS.particles` array
  34557. * `faceId` is the picked face index counted within this particle.
  34558. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34559. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34560. */
  34561. pickedBySubMesh: {
  34562. idx: number;
  34563. faceId: number;
  34564. }[][];
  34565. /**
  34566. * This array is populated when `enableDepthSort` is set to true.
  34567. * Each element of this array is an instance of the class DepthSortedParticle.
  34568. */
  34569. depthSortedParticles: DepthSortedParticle[];
  34570. /**
  34571. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34572. * @hidden
  34573. */
  34574. _bSphereOnly: boolean;
  34575. /**
  34576. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34577. * @hidden
  34578. */
  34579. _bSphereRadiusFactor: number;
  34580. private _scene;
  34581. private _positions;
  34582. private _indices;
  34583. private _normals;
  34584. private _colors;
  34585. private _uvs;
  34586. private _indices32;
  34587. private _positions32;
  34588. private _normals32;
  34589. private _fixedNormal32;
  34590. private _colors32;
  34591. private _uvs32;
  34592. private _index;
  34593. private _updatable;
  34594. private _pickable;
  34595. private _isVisibilityBoxLocked;
  34596. private _alwaysVisible;
  34597. private _depthSort;
  34598. private _expandable;
  34599. private _shapeCounter;
  34600. private _copy;
  34601. private _color;
  34602. private _computeParticleColor;
  34603. private _computeParticleTexture;
  34604. private _computeParticleRotation;
  34605. private _computeParticleVertex;
  34606. private _computeBoundingBox;
  34607. private _depthSortParticles;
  34608. private _camera;
  34609. private _mustUnrotateFixedNormals;
  34610. private _particlesIntersect;
  34611. private _needs32Bits;
  34612. private _isNotBuilt;
  34613. private _lastParticleId;
  34614. private _idxOfId;
  34615. private _multimaterialEnabled;
  34616. private _useModelMaterial;
  34617. private _indicesByMaterial;
  34618. private _materialIndexes;
  34619. private _depthSortFunction;
  34620. private _materialSortFunction;
  34621. private _materials;
  34622. private _multimaterial;
  34623. private _materialIndexesById;
  34624. private _defaultMaterial;
  34625. private _autoUpdateSubMeshes;
  34626. private _tmpVertex;
  34627. /**
  34628. * Creates a SPS (Solid Particle System) object.
  34629. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34630. * @param scene (Scene) is the scene in which the SPS is added.
  34631. * @param options defines the options of the sps e.g.
  34632. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34633. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34634. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34635. * * 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.
  34636. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34637. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34638. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34639. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34640. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34641. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34642. */
  34643. constructor(name: string, scene: Scene, options?: {
  34644. updatable?: boolean;
  34645. isPickable?: boolean;
  34646. enableDepthSort?: boolean;
  34647. particleIntersection?: boolean;
  34648. boundingSphereOnly?: boolean;
  34649. bSphereRadiusFactor?: number;
  34650. expandable?: boolean;
  34651. useModelMaterial?: boolean;
  34652. enableMultiMaterial?: boolean;
  34653. });
  34654. /**
  34655. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34656. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34657. * @returns the created mesh
  34658. */
  34659. buildMesh(): Mesh;
  34660. /**
  34661. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34662. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34663. * Thus the particles generated from `digest()` have their property `position` set yet.
  34664. * @param mesh ( Mesh ) is the mesh to be digested
  34665. * @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
  34666. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34667. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34668. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34669. * @returns the current SPS
  34670. */
  34671. digest(mesh: Mesh, options?: {
  34672. facetNb?: number;
  34673. number?: number;
  34674. delta?: number;
  34675. storage?: [];
  34676. }): SolidParticleSystem;
  34677. /**
  34678. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34679. * @hidden
  34680. */
  34681. private _unrotateFixedNormals;
  34682. /**
  34683. * Resets the temporary working copy particle
  34684. * @hidden
  34685. */
  34686. private _resetCopy;
  34687. /**
  34688. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34689. * @param p the current index in the positions array to be updated
  34690. * @param ind the current index in the indices array
  34691. * @param shape a Vector3 array, the shape geometry
  34692. * @param positions the positions array to be updated
  34693. * @param meshInd the shape indices array
  34694. * @param indices the indices array to be updated
  34695. * @param meshUV the shape uv array
  34696. * @param uvs the uv array to be updated
  34697. * @param meshCol the shape color array
  34698. * @param colors the color array to be updated
  34699. * @param meshNor the shape normals array
  34700. * @param normals the normals array to be updated
  34701. * @param idx the particle index
  34702. * @param idxInShape the particle index in its shape
  34703. * @param options the addShape() method passed options
  34704. * @model the particle model
  34705. * @hidden
  34706. */
  34707. private _meshBuilder;
  34708. /**
  34709. * Returns a shape Vector3 array from positions float array
  34710. * @param positions float array
  34711. * @returns a vector3 array
  34712. * @hidden
  34713. */
  34714. private _posToShape;
  34715. /**
  34716. * Returns a shapeUV array from a float uvs (array deep copy)
  34717. * @param uvs as a float array
  34718. * @returns a shapeUV array
  34719. * @hidden
  34720. */
  34721. private _uvsToShapeUV;
  34722. /**
  34723. * Adds a new particle object in the particles array
  34724. * @param idx particle index in particles array
  34725. * @param id particle id
  34726. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34727. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34728. * @param model particle ModelShape object
  34729. * @param shapeId model shape identifier
  34730. * @param idxInShape index of the particle in the current model
  34731. * @param bInfo model bounding info object
  34732. * @param storage target storage array, if any
  34733. * @hidden
  34734. */
  34735. private _addParticle;
  34736. /**
  34737. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34738. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34739. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34740. * @param nb (positive integer) the number of particles to be created from this model
  34741. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34742. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34743. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34744. * @returns the number of shapes in the system
  34745. */
  34746. addShape(mesh: Mesh, nb: number, options?: {
  34747. positionFunction?: any;
  34748. vertexFunction?: any;
  34749. storage?: [];
  34750. }): number;
  34751. /**
  34752. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34753. * @hidden
  34754. */
  34755. private _rebuildParticle;
  34756. /**
  34757. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34758. * @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.
  34759. * @returns the SPS.
  34760. */
  34761. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34762. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34763. * Returns an array with the removed particles.
  34764. * 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.
  34765. * The SPS can't be empty so at least one particle needs to remain in place.
  34766. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34767. * @param start index of the first particle to remove
  34768. * @param end index of the last particle to remove (included)
  34769. * @returns an array populated with the removed particles
  34770. */
  34771. removeParticles(start: number, end: number): SolidParticle[];
  34772. /**
  34773. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34774. * @param solidParticleArray an array populated with Solid Particles objects
  34775. * @returns the SPS
  34776. */
  34777. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34778. /**
  34779. * Creates a new particle and modifies the SPS mesh geometry :
  34780. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34781. * - calls _addParticle() to populate the particle array
  34782. * factorized code from addShape() and insertParticlesFromArray()
  34783. * @param idx particle index in the particles array
  34784. * @param i particle index in its shape
  34785. * @param modelShape particle ModelShape object
  34786. * @param shape shape vertex array
  34787. * @param meshInd shape indices array
  34788. * @param meshUV shape uv array
  34789. * @param meshCol shape color array
  34790. * @param meshNor shape normals array
  34791. * @param bbInfo shape bounding info
  34792. * @param storage target particle storage
  34793. * @options addShape() passed options
  34794. * @hidden
  34795. */
  34796. private _insertNewParticle;
  34797. /**
  34798. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34799. * This method calls `updateParticle()` for each particle of the SPS.
  34800. * For an animated SPS, it is usually called within the render loop.
  34801. * 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.
  34802. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34803. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34804. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34805. * @returns the SPS.
  34806. */
  34807. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34808. /**
  34809. * Disposes the SPS.
  34810. */
  34811. dispose(): void;
  34812. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34813. * idx is the particle index in the SPS
  34814. * faceId is the picked face index counted within this particle.
  34815. * Returns null if the pickInfo can't identify a picked particle.
  34816. * @param pickingInfo (PickingInfo object)
  34817. * @returns {idx: number, faceId: number} or null
  34818. */
  34819. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34820. idx: number;
  34821. faceId: number;
  34822. }>;
  34823. /**
  34824. * Returns a SolidParticle object from its identifier : particle.id
  34825. * @param id (integer) the particle Id
  34826. * @returns the searched particle or null if not found in the SPS.
  34827. */
  34828. getParticleById(id: number): Nullable<SolidParticle>;
  34829. /**
  34830. * Returns a new array populated with the particles having the passed shapeId.
  34831. * @param shapeId (integer) the shape identifier
  34832. * @returns a new solid particle array
  34833. */
  34834. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34835. /**
  34836. * Populates the passed array "ref" with the particles having the passed shapeId.
  34837. * @param shapeId the shape identifier
  34838. * @returns the SPS
  34839. * @param ref
  34840. */
  34841. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34842. /**
  34843. * Computes the required SubMeshes according the materials assigned to the particles.
  34844. * @returns the solid particle system.
  34845. * Does nothing if called before the SPS mesh is built.
  34846. */
  34847. computeSubMeshes(): SolidParticleSystem;
  34848. /**
  34849. * Sorts the solid particles by material when MultiMaterial is enabled.
  34850. * Updates the indices32 array.
  34851. * Updates the indicesByMaterial array.
  34852. * Updates the mesh indices array.
  34853. * @returns the SPS
  34854. * @hidden
  34855. */
  34856. private _sortParticlesByMaterial;
  34857. /**
  34858. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34859. * @hidden
  34860. */
  34861. private _setMaterialIndexesById;
  34862. /**
  34863. * Returns an array with unique values of Materials from the passed array
  34864. * @param array the material array to be checked and filtered
  34865. * @hidden
  34866. */
  34867. private _filterUniqueMaterialId;
  34868. /**
  34869. * Sets a new Standard Material as _defaultMaterial if not already set.
  34870. * @hidden
  34871. */
  34872. private _setDefaultMaterial;
  34873. /**
  34874. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34876. * @returns the SPS.
  34877. */
  34878. refreshVisibleSize(): SolidParticleSystem;
  34879. /**
  34880. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34881. * @param size the size (float) of the visibility box
  34882. * note : this doesn't lock the SPS mesh bounding box.
  34883. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34884. */
  34885. setVisibilityBox(size: number): void;
  34886. /**
  34887. * Gets whether the SPS as always visible or not
  34888. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34889. */
  34890. get isAlwaysVisible(): boolean;
  34891. /**
  34892. * Sets the SPS as always visible or not
  34893. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34894. */
  34895. set isAlwaysVisible(val: boolean);
  34896. /**
  34897. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34898. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34899. */
  34900. set isVisibilityBoxLocked(val: boolean);
  34901. /**
  34902. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34903. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34904. */
  34905. get isVisibilityBoxLocked(): boolean;
  34906. /**
  34907. * Tells to `setParticles()` to compute the particle rotations or not.
  34908. * Default value : true. The SPS is faster when it's set to false.
  34909. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34910. */
  34911. set computeParticleRotation(val: boolean);
  34912. /**
  34913. * Tells to `setParticles()` to compute the particle colors or not.
  34914. * Default value : true. The SPS is faster when it's set to false.
  34915. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34916. */
  34917. set computeParticleColor(val: boolean);
  34918. set computeParticleTexture(val: boolean);
  34919. /**
  34920. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34921. * Default value : false. The SPS is faster when it's set to false.
  34922. * Note : the particle custom vertex positions aren't stored values.
  34923. */
  34924. set computeParticleVertex(val: boolean);
  34925. /**
  34926. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34927. */
  34928. set computeBoundingBox(val: boolean);
  34929. /**
  34930. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34931. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34932. * Default : `true`
  34933. */
  34934. set depthSortParticles(val: boolean);
  34935. /**
  34936. * Gets if `setParticles()` computes the particle rotations or not.
  34937. * Default value : true. The SPS is faster when it's set to false.
  34938. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34939. */
  34940. get computeParticleRotation(): boolean;
  34941. /**
  34942. * Gets if `setParticles()` computes the particle colors or not.
  34943. * Default value : true. The SPS is faster when it's set to false.
  34944. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34945. */
  34946. get computeParticleColor(): boolean;
  34947. /**
  34948. * Gets if `setParticles()` computes the particle textures or not.
  34949. * Default value : true. The SPS is faster when it's set to false.
  34950. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34951. */
  34952. get computeParticleTexture(): boolean;
  34953. /**
  34954. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34955. * Default value : false. The SPS is faster when it's set to false.
  34956. * Note : the particle custom vertex positions aren't stored values.
  34957. */
  34958. get computeParticleVertex(): boolean;
  34959. /**
  34960. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34961. */
  34962. get computeBoundingBox(): boolean;
  34963. /**
  34964. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34965. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34966. * Default : `true`
  34967. */
  34968. get depthSortParticles(): boolean;
  34969. /**
  34970. * Gets if the SPS is created as expandable at construction time.
  34971. * Default : `false`
  34972. */
  34973. get expandable(): boolean;
  34974. /**
  34975. * Gets if the SPS supports the Multi Materials
  34976. */
  34977. get multimaterialEnabled(): boolean;
  34978. /**
  34979. * Gets if the SPS uses the model materials for its own multimaterial.
  34980. */
  34981. get useModelMaterial(): boolean;
  34982. /**
  34983. * The SPS used material array.
  34984. */
  34985. get materials(): Material[];
  34986. /**
  34987. * Sets the SPS MultiMaterial from the passed materials.
  34988. * Note : the passed array is internally copied and not used then by reference.
  34989. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34990. */
  34991. setMultiMaterial(materials: Material[]): void;
  34992. /**
  34993. * The SPS computed multimaterial object
  34994. */
  34995. get multimaterial(): MultiMaterial;
  34996. set multimaterial(mm: MultiMaterial);
  34997. /**
  34998. * If the subMeshes must be updated on the next call to setParticles()
  34999. */
  35000. get autoUpdateSubMeshes(): boolean;
  35001. set autoUpdateSubMeshes(val: boolean);
  35002. /**
  35003. * This function does nothing. It may be overwritten to set all the particle first values.
  35004. * The SPS doesn't call this function, you may have to call it by your own.
  35005. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35006. */
  35007. initParticles(): void;
  35008. /**
  35009. * This function does nothing. It may be overwritten to recycle a particle.
  35010. * The SPS doesn't call this function, you may have to call it by your own.
  35011. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35012. * @param particle The particle to recycle
  35013. * @returns the recycled particle
  35014. */
  35015. recycleParticle(particle: SolidParticle): SolidParticle;
  35016. /**
  35017. * Updates a particle : this function should be overwritten by the user.
  35018. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35019. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35020. * @example : just set a particle position or velocity and recycle conditions
  35021. * @param particle The particle to update
  35022. * @returns the updated particle
  35023. */
  35024. updateParticle(particle: SolidParticle): SolidParticle;
  35025. /**
  35026. * Updates a vertex of a particle : it can be overwritten by the user.
  35027. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35028. * @param particle the current particle
  35029. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35030. * @param pt the index of the current vertex in the particle shape
  35031. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35032. * @example : just set a vertex particle position or color
  35033. * @returns the sps
  35034. */
  35035. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35036. /**
  35037. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35038. * This does nothing and may be overwritten by the user.
  35039. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35040. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35041. * @param update the boolean update value actually passed to setParticles()
  35042. */
  35043. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35044. /**
  35045. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35046. * This will be passed three parameters.
  35047. * This does nothing and may be overwritten by the user.
  35048. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35049. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35050. * @param update the boolean update value actually passed to setParticles()
  35051. */
  35052. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35053. }
  35054. }
  35055. declare module BABYLON {
  35056. /**
  35057. * Represents one particle of a solid particle system.
  35058. */
  35059. export class SolidParticle {
  35060. /**
  35061. * particle global index
  35062. */
  35063. idx: number;
  35064. /**
  35065. * particle identifier
  35066. */
  35067. id: number;
  35068. /**
  35069. * The color of the particle
  35070. */
  35071. color: Nullable<Color4>;
  35072. /**
  35073. * The world space position of the particle.
  35074. */
  35075. position: Vector3;
  35076. /**
  35077. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35078. */
  35079. rotation: Vector3;
  35080. /**
  35081. * The world space rotation quaternion of the particle.
  35082. */
  35083. rotationQuaternion: Nullable<Quaternion>;
  35084. /**
  35085. * The scaling of the particle.
  35086. */
  35087. scaling: Vector3;
  35088. /**
  35089. * The uvs of the particle.
  35090. */
  35091. uvs: Vector4;
  35092. /**
  35093. * The current speed of the particle.
  35094. */
  35095. velocity: Vector3;
  35096. /**
  35097. * The pivot point in the particle local space.
  35098. */
  35099. pivot: Vector3;
  35100. /**
  35101. * Must the particle be translated from its pivot point in its local space ?
  35102. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35103. * Default : false
  35104. */
  35105. translateFromPivot: boolean;
  35106. /**
  35107. * Is the particle active or not ?
  35108. */
  35109. alive: boolean;
  35110. /**
  35111. * Is the particle visible or not ?
  35112. */
  35113. isVisible: boolean;
  35114. /**
  35115. * Index of this particle in the global "positions" array (Internal use)
  35116. * @hidden
  35117. */
  35118. _pos: number;
  35119. /**
  35120. * @hidden Index of this particle in the global "indices" array (Internal use)
  35121. */
  35122. _ind: number;
  35123. /**
  35124. * @hidden ModelShape of this particle (Internal use)
  35125. */
  35126. _model: ModelShape;
  35127. /**
  35128. * ModelShape id of this particle
  35129. */
  35130. shapeId: number;
  35131. /**
  35132. * Index of the particle in its shape id
  35133. */
  35134. idxInShape: number;
  35135. /**
  35136. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35137. */
  35138. _modelBoundingInfo: BoundingInfo;
  35139. /**
  35140. * @hidden Particle BoundingInfo object (Internal use)
  35141. */
  35142. _boundingInfo: BoundingInfo;
  35143. /**
  35144. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35145. */
  35146. _sps: SolidParticleSystem;
  35147. /**
  35148. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35149. */
  35150. _stillInvisible: boolean;
  35151. /**
  35152. * @hidden Last computed particle rotation matrix
  35153. */
  35154. _rotationMatrix: number[];
  35155. /**
  35156. * Parent particle Id, if any.
  35157. * Default null.
  35158. */
  35159. parentId: Nullable<number>;
  35160. /**
  35161. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35162. */
  35163. materialIndex: Nullable<number>;
  35164. /**
  35165. * Custom object or properties.
  35166. */
  35167. props: Nullable<any>;
  35168. /**
  35169. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35170. * The possible values are :
  35171. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35172. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35173. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35174. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35175. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35176. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35177. * */
  35178. cullingStrategy: number;
  35179. /**
  35180. * @hidden Internal global position in the SPS.
  35181. */
  35182. _globalPosition: Vector3;
  35183. /**
  35184. * Creates a Solid Particle object.
  35185. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35186. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35187. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35188. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35189. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35190. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35191. * @param shapeId (integer) is the model shape identifier in the SPS.
  35192. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35193. * @param sps defines the sps it is associated to
  35194. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35195. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35196. */
  35197. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35198. /**
  35199. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35200. * @param target the particle target
  35201. * @returns the current particle
  35202. */
  35203. copyToRef(target: SolidParticle): SolidParticle;
  35204. /**
  35205. * Legacy support, changed scale to scaling
  35206. */
  35207. get scale(): Vector3;
  35208. /**
  35209. * Legacy support, changed scale to scaling
  35210. */
  35211. set scale(scale: Vector3);
  35212. /**
  35213. * Legacy support, changed quaternion to rotationQuaternion
  35214. */
  35215. get quaternion(): Nullable<Quaternion>;
  35216. /**
  35217. * Legacy support, changed quaternion to rotationQuaternion
  35218. */
  35219. set quaternion(q: Nullable<Quaternion>);
  35220. /**
  35221. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35222. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35223. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35224. * @returns true if it intersects
  35225. */
  35226. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35227. /**
  35228. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35229. * A particle is in the frustum if its bounding box intersects the frustum
  35230. * @param frustumPlanes defines the frustum to test
  35231. * @returns true if the particle is in the frustum planes
  35232. */
  35233. isInFrustum(frustumPlanes: Plane[]): boolean;
  35234. /**
  35235. * get the rotation matrix of the particle
  35236. * @hidden
  35237. */
  35238. getRotationMatrix(m: Matrix): void;
  35239. }
  35240. /**
  35241. * Represents the shape of the model used by one particle of a solid particle system.
  35242. * SPS internal tool, don't use it manually.
  35243. */
  35244. export class ModelShape {
  35245. /**
  35246. * The shape id
  35247. * @hidden
  35248. */
  35249. shapeID: number;
  35250. /**
  35251. * flat array of model positions (internal use)
  35252. * @hidden
  35253. */
  35254. _shape: Vector3[];
  35255. /**
  35256. * flat array of model UVs (internal use)
  35257. * @hidden
  35258. */
  35259. _shapeUV: number[];
  35260. /**
  35261. * color array of the model
  35262. * @hidden
  35263. */
  35264. _shapeColors: number[];
  35265. /**
  35266. * indices array of the model
  35267. * @hidden
  35268. */
  35269. _indices: number[];
  35270. /**
  35271. * normals array of the model
  35272. * @hidden
  35273. */
  35274. _normals: number[];
  35275. /**
  35276. * length of the shape in the model indices array (internal use)
  35277. * @hidden
  35278. */
  35279. _indicesLength: number;
  35280. /**
  35281. * Custom position function (internal use)
  35282. * @hidden
  35283. */
  35284. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35285. /**
  35286. * Custom vertex function (internal use)
  35287. * @hidden
  35288. */
  35289. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35290. /**
  35291. * Model material (internal use)
  35292. * @hidden
  35293. */
  35294. _material: Nullable<Material>;
  35295. /**
  35296. * 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.
  35297. * SPS internal tool, don't use it manually.
  35298. * @hidden
  35299. */
  35300. 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>);
  35301. }
  35302. /**
  35303. * Represents a Depth Sorted Particle in the solid particle system.
  35304. * @hidden
  35305. */
  35306. export class DepthSortedParticle {
  35307. /**
  35308. * Particle index
  35309. */
  35310. idx: number;
  35311. /**
  35312. * Index of the particle in the "indices" array
  35313. */
  35314. ind: number;
  35315. /**
  35316. * Length of the particle shape in the "indices" array
  35317. */
  35318. indicesLength: number;
  35319. /**
  35320. * Squared distance from the particle to the camera
  35321. */
  35322. sqDistance: number;
  35323. /**
  35324. * Material index when used with MultiMaterials
  35325. */
  35326. materialIndex: number;
  35327. /**
  35328. * Creates a new sorted particle
  35329. * @param materialIndex
  35330. */
  35331. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35332. }
  35333. /**
  35334. * Represents a solid particle vertex
  35335. */
  35336. export class SolidParticleVertex {
  35337. /**
  35338. * Vertex position
  35339. */
  35340. position: Vector3;
  35341. /**
  35342. * Vertex color
  35343. */
  35344. color: Color4;
  35345. /**
  35346. * Vertex UV
  35347. */
  35348. uv: Vector2;
  35349. /**
  35350. * Creates a new solid particle vertex
  35351. */
  35352. constructor();
  35353. /** Vertex x coordinate */
  35354. get x(): number;
  35355. set x(val: number);
  35356. /** Vertex y coordinate */
  35357. get y(): number;
  35358. set y(val: number);
  35359. /** Vertex z coordinate */
  35360. get z(): number;
  35361. set z(val: number);
  35362. }
  35363. }
  35364. declare module BABYLON {
  35365. /**
  35366. * @hidden
  35367. */
  35368. export class _MeshCollisionData {
  35369. _checkCollisions: boolean;
  35370. _collisionMask: number;
  35371. _collisionGroup: number;
  35372. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35373. _collider: Nullable<Collider>;
  35374. _oldPositionForCollisions: Vector3;
  35375. _diffPositionForCollisions: Vector3;
  35376. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35377. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35378. _collisionResponse: boolean;
  35379. }
  35380. }
  35381. declare module BABYLON {
  35382. /** @hidden */
  35383. class _FacetDataStorage {
  35384. facetPositions: Vector3[];
  35385. facetNormals: Vector3[];
  35386. facetPartitioning: number[][];
  35387. facetNb: number;
  35388. partitioningSubdivisions: number;
  35389. partitioningBBoxRatio: number;
  35390. facetDataEnabled: boolean;
  35391. facetParameters: any;
  35392. bbSize: Vector3;
  35393. subDiv: {
  35394. max: number;
  35395. X: number;
  35396. Y: number;
  35397. Z: number;
  35398. };
  35399. facetDepthSort: boolean;
  35400. facetDepthSortEnabled: boolean;
  35401. depthSortedIndices: IndicesArray;
  35402. depthSortedFacets: {
  35403. ind: number;
  35404. sqDistance: number;
  35405. }[];
  35406. facetDepthSortFunction: (f1: {
  35407. ind: number;
  35408. sqDistance: number;
  35409. }, f2: {
  35410. ind: number;
  35411. sqDistance: number;
  35412. }) => number;
  35413. facetDepthSortFrom: Vector3;
  35414. facetDepthSortOrigin: Vector3;
  35415. invertedMatrix: Matrix;
  35416. }
  35417. /**
  35418. * @hidden
  35419. **/
  35420. class _InternalAbstractMeshDataInfo {
  35421. _hasVertexAlpha: boolean;
  35422. _useVertexColors: boolean;
  35423. _numBoneInfluencers: number;
  35424. _applyFog: boolean;
  35425. _receiveShadows: boolean;
  35426. _facetData: _FacetDataStorage;
  35427. _visibility: number;
  35428. _skeleton: Nullable<Skeleton>;
  35429. _layerMask: number;
  35430. _computeBonesUsingShaders: boolean;
  35431. _isActive: boolean;
  35432. _onlyForInstances: boolean;
  35433. _isActiveIntermediate: boolean;
  35434. _onlyForInstancesIntermediate: boolean;
  35435. _actAsRegularMesh: boolean;
  35436. _currentLOD: Nullable<AbstractMesh>;
  35437. }
  35438. /**
  35439. * Class used to store all common mesh properties
  35440. */
  35441. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35442. /** No occlusion */
  35443. static OCCLUSION_TYPE_NONE: number;
  35444. /** Occlusion set to optimisitic */
  35445. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35446. /** Occlusion set to strict */
  35447. static OCCLUSION_TYPE_STRICT: number;
  35448. /** Use an accurante occlusion algorithm */
  35449. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35450. /** Use a conservative occlusion algorithm */
  35451. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35452. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35453. * Test order :
  35454. * Is the bounding sphere outside the frustum ?
  35455. * If not, are the bounding box vertices outside the frustum ?
  35456. * It not, then the cullable object is in the frustum.
  35457. */
  35458. static readonly CULLINGSTRATEGY_STANDARD: number;
  35459. /** Culling strategy : Bounding Sphere Only.
  35460. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35461. * It's also less accurate than the standard because some not visible objects can still be selected.
  35462. * Test : is the bounding sphere outside the frustum ?
  35463. * If not, then the cullable object is in the frustum.
  35464. */
  35465. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35466. /** Culling strategy : Optimistic Inclusion.
  35467. * This in an inclusion test first, then the standard exclusion test.
  35468. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35469. * 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.
  35470. * Anyway, it's as accurate as the standard strategy.
  35471. * Test :
  35472. * Is the cullable object bounding sphere center in the frustum ?
  35473. * If not, apply the default culling strategy.
  35474. */
  35475. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35476. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35477. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35478. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35479. * 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.
  35480. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35481. * Test :
  35482. * Is the cullable object bounding sphere center in the frustum ?
  35483. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35484. */
  35485. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35486. /**
  35487. * No billboard
  35488. */
  35489. static get BILLBOARDMODE_NONE(): number;
  35490. /** Billboard on X axis */
  35491. static get BILLBOARDMODE_X(): number;
  35492. /** Billboard on Y axis */
  35493. static get BILLBOARDMODE_Y(): number;
  35494. /** Billboard on Z axis */
  35495. static get BILLBOARDMODE_Z(): number;
  35496. /** Billboard on all axes */
  35497. static get BILLBOARDMODE_ALL(): number;
  35498. /** Billboard on using position instead of orientation */
  35499. static get BILLBOARDMODE_USE_POSITION(): number;
  35500. /** @hidden */
  35501. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35502. /**
  35503. * The culling strategy to use to check whether the mesh must be rendered or not.
  35504. * This value can be changed at any time and will be used on the next render mesh selection.
  35505. * The possible values are :
  35506. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35507. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35508. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35509. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35510. * Please read each static variable documentation to get details about the culling process.
  35511. * */
  35512. cullingStrategy: number;
  35513. /**
  35514. * Gets the number of facets in the mesh
  35515. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35516. */
  35517. get facetNb(): number;
  35518. /**
  35519. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35521. */
  35522. get partitioningSubdivisions(): number;
  35523. set partitioningSubdivisions(nb: number);
  35524. /**
  35525. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35526. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35527. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35528. */
  35529. get partitioningBBoxRatio(): number;
  35530. set partitioningBBoxRatio(ratio: number);
  35531. /**
  35532. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35533. * Works only for updatable meshes.
  35534. * Doesn't work with multi-materials
  35535. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35536. */
  35537. get mustDepthSortFacets(): boolean;
  35538. set mustDepthSortFacets(sort: boolean);
  35539. /**
  35540. * The location (Vector3) where the facet depth sort must be computed from.
  35541. * By default, the active camera position.
  35542. * Used only when facet depth sort is enabled
  35543. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35544. */
  35545. get facetDepthSortFrom(): Vector3;
  35546. set facetDepthSortFrom(location: Vector3);
  35547. /**
  35548. * gets a boolean indicating if facetData is enabled
  35549. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35550. */
  35551. get isFacetDataEnabled(): boolean;
  35552. /** @hidden */
  35553. _updateNonUniformScalingState(value: boolean): boolean;
  35554. /**
  35555. * An event triggered when this mesh collides with another one
  35556. */
  35557. onCollideObservable: Observable<AbstractMesh>;
  35558. /** Set a function to call when this mesh collides with another one */
  35559. set onCollide(callback: () => void);
  35560. /**
  35561. * An event triggered when the collision's position changes
  35562. */
  35563. onCollisionPositionChangeObservable: Observable<Vector3>;
  35564. /** Set a function to call when the collision's position changes */
  35565. set onCollisionPositionChange(callback: () => void);
  35566. /**
  35567. * An event triggered when material is changed
  35568. */
  35569. onMaterialChangedObservable: Observable<AbstractMesh>;
  35570. /**
  35571. * Gets or sets the orientation for POV movement & rotation
  35572. */
  35573. definedFacingForward: boolean;
  35574. /** @hidden */
  35575. _occlusionQuery: Nullable<WebGLQuery>;
  35576. /** @hidden */
  35577. _renderingGroup: Nullable<RenderingGroup>;
  35578. /**
  35579. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35580. */
  35581. get visibility(): number;
  35582. /**
  35583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35584. */
  35585. set visibility(value: number);
  35586. /** Gets or sets the alpha index used to sort transparent meshes
  35587. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35588. */
  35589. alphaIndex: number;
  35590. /**
  35591. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35592. */
  35593. isVisible: boolean;
  35594. /**
  35595. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35596. */
  35597. isPickable: boolean;
  35598. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35599. showSubMeshesBoundingBox: boolean;
  35600. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35601. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35602. */
  35603. isBlocker: boolean;
  35604. /**
  35605. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35606. */
  35607. enablePointerMoveEvents: boolean;
  35608. private _renderingGroupId;
  35609. /**
  35610. * Specifies the rendering group id for this mesh (0 by default)
  35611. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35612. */
  35613. get renderingGroupId(): number;
  35614. set renderingGroupId(value: number);
  35615. private _material;
  35616. /** Gets or sets current material */
  35617. get material(): Nullable<Material>;
  35618. set material(value: Nullable<Material>);
  35619. /**
  35620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35621. * @see https://doc.babylonjs.com/babylon101/shadows
  35622. */
  35623. get receiveShadows(): boolean;
  35624. set receiveShadows(value: boolean);
  35625. /** Defines color to use when rendering outline */
  35626. outlineColor: Color3;
  35627. /** Define width to use when rendering outline */
  35628. outlineWidth: number;
  35629. /** Defines color to use when rendering overlay */
  35630. overlayColor: Color3;
  35631. /** Defines alpha to use when rendering overlay */
  35632. overlayAlpha: number;
  35633. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35634. get hasVertexAlpha(): boolean;
  35635. set hasVertexAlpha(value: boolean);
  35636. /** 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) */
  35637. get useVertexColors(): boolean;
  35638. set useVertexColors(value: boolean);
  35639. /**
  35640. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35641. */
  35642. get computeBonesUsingShaders(): boolean;
  35643. set computeBonesUsingShaders(value: boolean);
  35644. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35645. get numBoneInfluencers(): number;
  35646. set numBoneInfluencers(value: number);
  35647. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35648. get applyFog(): boolean;
  35649. set applyFog(value: boolean);
  35650. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35651. useOctreeForRenderingSelection: boolean;
  35652. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35653. useOctreeForPicking: boolean;
  35654. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35655. useOctreeForCollisions: boolean;
  35656. /**
  35657. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35658. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35659. */
  35660. get layerMask(): number;
  35661. set layerMask(value: number);
  35662. /**
  35663. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35664. */
  35665. alwaysSelectAsActiveMesh: boolean;
  35666. /**
  35667. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35668. */
  35669. doNotSyncBoundingInfo: boolean;
  35670. /**
  35671. * Gets or sets the current action manager
  35672. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35673. */
  35674. actionManager: Nullable<AbstractActionManager>;
  35675. private _meshCollisionData;
  35676. /**
  35677. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35678. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35679. */
  35680. ellipsoid: Vector3;
  35681. /**
  35682. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35683. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35684. */
  35685. ellipsoidOffset: Vector3;
  35686. /**
  35687. * Gets or sets a collision mask used to mask collisions (default is -1).
  35688. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35689. */
  35690. get collisionMask(): number;
  35691. set collisionMask(mask: number);
  35692. /**
  35693. * Gets or sets a collision response flag (default is true).
  35694. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35695. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35696. * to respond to the collision.
  35697. */
  35698. get collisionResponse(): boolean;
  35699. set collisionResponse(response: boolean);
  35700. /**
  35701. * Gets or sets the current collision group mask (-1 by default).
  35702. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35703. */
  35704. get collisionGroup(): number;
  35705. set collisionGroup(mask: number);
  35706. /**
  35707. * Gets or sets current surrounding meshes (null by default).
  35708. *
  35709. * By default collision detection is tested against every mesh in the scene.
  35710. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35711. * meshes will be tested for the collision.
  35712. *
  35713. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35714. */
  35715. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35716. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35717. /**
  35718. * Defines edge width used when edgesRenderer is enabled
  35719. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35720. */
  35721. edgesWidth: number;
  35722. /**
  35723. * Defines edge color used when edgesRenderer is enabled
  35724. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35725. */
  35726. edgesColor: Color4;
  35727. /** @hidden */
  35728. _edgesRenderer: Nullable<IEdgesRenderer>;
  35729. /** @hidden */
  35730. _masterMesh: Nullable<AbstractMesh>;
  35731. /** @hidden */
  35732. _boundingInfo: Nullable<BoundingInfo>;
  35733. /** @hidden */
  35734. _renderId: number;
  35735. /**
  35736. * Gets or sets the list of subMeshes
  35737. * @see https://doc.babylonjs.com/how_to/multi_materials
  35738. */
  35739. subMeshes: SubMesh[];
  35740. /** @hidden */
  35741. _intersectionsInProgress: AbstractMesh[];
  35742. /** @hidden */
  35743. _unIndexed: boolean;
  35744. /** @hidden */
  35745. _lightSources: Light[];
  35746. /** Gets the list of lights affecting that mesh */
  35747. get lightSources(): Light[];
  35748. /** @hidden */
  35749. get _positions(): Nullable<Vector3[]>;
  35750. /** @hidden */
  35751. _waitingData: {
  35752. lods: Nullable<any>;
  35753. actions: Nullable<any>;
  35754. freezeWorldMatrix: Nullable<boolean>;
  35755. };
  35756. /** @hidden */
  35757. _bonesTransformMatrices: Nullable<Float32Array>;
  35758. /** @hidden */
  35759. _transformMatrixTexture: Nullable<RawTexture>;
  35760. /**
  35761. * Gets or sets a skeleton to apply skining transformations
  35762. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35763. */
  35764. set skeleton(value: Nullable<Skeleton>);
  35765. get skeleton(): Nullable<Skeleton>;
  35766. /**
  35767. * An event triggered when the mesh is rebuilt.
  35768. */
  35769. onRebuildObservable: Observable<AbstractMesh>;
  35770. /**
  35771. * Creates a new AbstractMesh
  35772. * @param name defines the name of the mesh
  35773. * @param scene defines the hosting scene
  35774. */
  35775. constructor(name: string, scene?: Nullable<Scene>);
  35776. /**
  35777. * Returns the string "AbstractMesh"
  35778. * @returns "AbstractMesh"
  35779. */
  35780. getClassName(): string;
  35781. /**
  35782. * Gets a string representation of the current mesh
  35783. * @param fullDetails defines a boolean indicating if full details must be included
  35784. * @returns a string representation of the current mesh
  35785. */
  35786. toString(fullDetails?: boolean): string;
  35787. /**
  35788. * @hidden
  35789. */
  35790. protected _getEffectiveParent(): Nullable<Node>;
  35791. /** @hidden */
  35792. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35793. /** @hidden */
  35794. _rebuild(): void;
  35795. /** @hidden */
  35796. _resyncLightSources(): void;
  35797. /** @hidden */
  35798. _resyncLightSource(light: Light): void;
  35799. /** @hidden */
  35800. _unBindEffect(): void;
  35801. /** @hidden */
  35802. _removeLightSource(light: Light, dispose: boolean): void;
  35803. private _markSubMeshesAsDirty;
  35804. /** @hidden */
  35805. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35806. /** @hidden */
  35807. _markSubMeshesAsAttributesDirty(): void;
  35808. /** @hidden */
  35809. _markSubMeshesAsMiscDirty(): void;
  35810. /**
  35811. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35812. */
  35813. get scaling(): Vector3;
  35814. set scaling(newScaling: Vector3);
  35815. /**
  35816. * Returns true if the mesh is blocked. Implemented by child classes
  35817. */
  35818. get isBlocked(): boolean;
  35819. /**
  35820. * Returns the mesh itself by default. Implemented by child classes
  35821. * @param camera defines the camera to use to pick the right LOD level
  35822. * @returns the currentAbstractMesh
  35823. */
  35824. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35825. /**
  35826. * Returns 0 by default. Implemented by child classes
  35827. * @returns an integer
  35828. */
  35829. getTotalVertices(): number;
  35830. /**
  35831. * Returns a positive integer : the total number of indices in this mesh geometry.
  35832. * @returns the numner of indices or zero if the mesh has no geometry.
  35833. */
  35834. getTotalIndices(): number;
  35835. /**
  35836. * Returns null by default. Implemented by child classes
  35837. * @returns null
  35838. */
  35839. getIndices(): Nullable<IndicesArray>;
  35840. /**
  35841. * Returns the array of the requested vertex data kind. Implemented by child classes
  35842. * @param kind defines the vertex data kind to use
  35843. * @returns null
  35844. */
  35845. getVerticesData(kind: string): Nullable<FloatArray>;
  35846. /**
  35847. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35848. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35849. * Note that a new underlying VertexBuffer object is created each call.
  35850. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35851. * @param kind defines vertex data kind:
  35852. * * VertexBuffer.PositionKind
  35853. * * VertexBuffer.UVKind
  35854. * * VertexBuffer.UV2Kind
  35855. * * VertexBuffer.UV3Kind
  35856. * * VertexBuffer.UV4Kind
  35857. * * VertexBuffer.UV5Kind
  35858. * * VertexBuffer.UV6Kind
  35859. * * VertexBuffer.ColorKind
  35860. * * VertexBuffer.MatricesIndicesKind
  35861. * * VertexBuffer.MatricesIndicesExtraKind
  35862. * * VertexBuffer.MatricesWeightsKind
  35863. * * VertexBuffer.MatricesWeightsExtraKind
  35864. * @param data defines the data source
  35865. * @param updatable defines if the data must be flagged as updatable (or static)
  35866. * @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
  35867. * @returns the current mesh
  35868. */
  35869. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35870. /**
  35871. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35872. * If the mesh has no geometry, it is simply returned as it is.
  35873. * @param kind defines vertex data kind:
  35874. * * VertexBuffer.PositionKind
  35875. * * VertexBuffer.UVKind
  35876. * * VertexBuffer.UV2Kind
  35877. * * VertexBuffer.UV3Kind
  35878. * * VertexBuffer.UV4Kind
  35879. * * VertexBuffer.UV5Kind
  35880. * * VertexBuffer.UV6Kind
  35881. * * VertexBuffer.ColorKind
  35882. * * VertexBuffer.MatricesIndicesKind
  35883. * * VertexBuffer.MatricesIndicesExtraKind
  35884. * * VertexBuffer.MatricesWeightsKind
  35885. * * VertexBuffer.MatricesWeightsExtraKind
  35886. * @param data defines the data source
  35887. * @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
  35888. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35889. * @returns the current mesh
  35890. */
  35891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35892. /**
  35893. * Sets the mesh indices,
  35894. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35895. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35896. * @param totalVertices Defines the total number of vertices
  35897. * @returns the current mesh
  35898. */
  35899. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35900. /**
  35901. * Gets a boolean indicating if specific vertex data is present
  35902. * @param kind defines the vertex data kind to use
  35903. * @returns true is data kind is present
  35904. */
  35905. isVerticesDataPresent(kind: string): boolean;
  35906. /**
  35907. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35908. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35909. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35910. * @returns a BoundingInfo
  35911. */
  35912. getBoundingInfo(): BoundingInfo;
  35913. /**
  35914. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35915. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35916. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35917. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35918. * @returns the current mesh
  35919. */
  35920. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35921. /**
  35922. * Overwrite the current bounding info
  35923. * @param boundingInfo defines the new bounding info
  35924. * @returns the current mesh
  35925. */
  35926. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35927. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35928. get useBones(): boolean;
  35929. /** @hidden */
  35930. _preActivate(): void;
  35931. /** @hidden */
  35932. _preActivateForIntermediateRendering(renderId: number): void;
  35933. /** @hidden */
  35934. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35935. /** @hidden */
  35936. _postActivate(): void;
  35937. /** @hidden */
  35938. _freeze(): void;
  35939. /** @hidden */
  35940. _unFreeze(): void;
  35941. /**
  35942. * Gets the current world matrix
  35943. * @returns a Matrix
  35944. */
  35945. getWorldMatrix(): Matrix;
  35946. /** @hidden */
  35947. _getWorldMatrixDeterminant(): number;
  35948. /**
  35949. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35950. */
  35951. get isAnInstance(): boolean;
  35952. /**
  35953. * Gets a boolean indicating if this mesh has instances
  35954. */
  35955. get hasInstances(): boolean;
  35956. /**
  35957. * Gets a boolean indicating if this mesh has thin instances
  35958. */
  35959. get hasThinInstances(): boolean;
  35960. /**
  35961. * Perform relative position change from the point of view of behind the front of the mesh.
  35962. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35963. * Supports definition of mesh facing forward or backward
  35964. * @param amountRight defines the distance on the right axis
  35965. * @param amountUp defines the distance on the up axis
  35966. * @param amountForward defines the distance on the forward axis
  35967. * @returns the current mesh
  35968. */
  35969. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35970. /**
  35971. * Calculate relative position change from the point of view of behind the front of the mesh.
  35972. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35973. * Supports definition of mesh facing forward or backward
  35974. * @param amountRight defines the distance on the right axis
  35975. * @param amountUp defines the distance on the up axis
  35976. * @param amountForward defines the distance on the forward axis
  35977. * @returns the new displacement vector
  35978. */
  35979. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35980. /**
  35981. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35982. * Supports definition of mesh facing forward or backward
  35983. * @param flipBack defines the flip
  35984. * @param twirlClockwise defines the twirl
  35985. * @param tiltRight defines the tilt
  35986. * @returns the current mesh
  35987. */
  35988. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35989. /**
  35990. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35991. * Supports definition of mesh facing forward or backward.
  35992. * @param flipBack defines the flip
  35993. * @param twirlClockwise defines the twirl
  35994. * @param tiltRight defines the tilt
  35995. * @returns the new rotation vector
  35996. */
  35997. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35998. /**
  35999. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36000. * This means the mesh underlying bounding box and sphere are recomputed.
  36001. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36002. * @returns the current mesh
  36003. */
  36004. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36005. /** @hidden */
  36006. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36007. /** @hidden */
  36008. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36009. /** @hidden */
  36010. _updateBoundingInfo(): AbstractMesh;
  36011. /** @hidden */
  36012. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36013. /** @hidden */
  36014. protected _afterComputeWorldMatrix(): void;
  36015. /** @hidden */
  36016. get _effectiveMesh(): AbstractMesh;
  36017. /**
  36018. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36019. * A mesh is in the frustum if its bounding box intersects the frustum
  36020. * @param frustumPlanes defines the frustum to test
  36021. * @returns true if the mesh is in the frustum planes
  36022. */
  36023. isInFrustum(frustumPlanes: Plane[]): boolean;
  36024. /**
  36025. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36026. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36027. * @param frustumPlanes defines the frustum to test
  36028. * @returns true if the mesh is completely in the frustum planes
  36029. */
  36030. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36031. /**
  36032. * True if the mesh intersects another mesh or a SolidParticle object
  36033. * @param mesh defines a target mesh or SolidParticle to test
  36034. * @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)
  36035. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36036. * @returns true if there is an intersection
  36037. */
  36038. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36039. /**
  36040. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36041. * @param point defines the point to test
  36042. * @returns true if there is an intersection
  36043. */
  36044. intersectsPoint(point: Vector3): boolean;
  36045. /**
  36046. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36047. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36048. */
  36049. get checkCollisions(): boolean;
  36050. set checkCollisions(collisionEnabled: boolean);
  36051. /**
  36052. * Gets Collider object used to compute collisions (not physics)
  36053. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36054. */
  36055. get collider(): Nullable<Collider>;
  36056. /**
  36057. * Move the mesh using collision engine
  36058. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36059. * @param displacement defines the requested displacement vector
  36060. * @returns the current mesh
  36061. */
  36062. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36063. private _onCollisionPositionChange;
  36064. /** @hidden */
  36065. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36066. /** @hidden */
  36067. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36068. /** @hidden */
  36069. _checkCollision(collider: Collider): AbstractMesh;
  36070. /** @hidden */
  36071. _generatePointsArray(): boolean;
  36072. /**
  36073. * Checks if the passed Ray intersects with the mesh
  36074. * @param ray defines the ray to use
  36075. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36076. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36077. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36078. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36079. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36080. * @returns the picking info
  36081. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36082. */
  36083. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36084. /**
  36085. * Clones the current mesh
  36086. * @param name defines the mesh name
  36087. * @param newParent defines the new mesh parent
  36088. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36089. * @returns the new mesh
  36090. */
  36091. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36092. /**
  36093. * Disposes all the submeshes of the current meshnp
  36094. * @returns the current mesh
  36095. */
  36096. releaseSubMeshes(): AbstractMesh;
  36097. /**
  36098. * Releases resources associated with this abstract mesh.
  36099. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36100. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36101. */
  36102. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36103. /**
  36104. * Adds the passed mesh as a child to the current mesh
  36105. * @param mesh defines the child mesh
  36106. * @returns the current mesh
  36107. */
  36108. addChild(mesh: AbstractMesh): AbstractMesh;
  36109. /**
  36110. * Removes the passed mesh from the current mesh children list
  36111. * @param mesh defines the child mesh
  36112. * @returns the current mesh
  36113. */
  36114. removeChild(mesh: AbstractMesh): AbstractMesh;
  36115. /** @hidden */
  36116. private _initFacetData;
  36117. /**
  36118. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36119. * This method can be called within the render loop.
  36120. * 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
  36121. * @returns the current mesh
  36122. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36123. */
  36124. updateFacetData(): AbstractMesh;
  36125. /**
  36126. * Returns the facetLocalNormals array.
  36127. * The normals are expressed in the mesh local spac
  36128. * @returns an array of Vector3
  36129. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36130. */
  36131. getFacetLocalNormals(): Vector3[];
  36132. /**
  36133. * Returns the facetLocalPositions array.
  36134. * The facet positions are expressed in the mesh local space
  36135. * @returns an array of Vector3
  36136. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36137. */
  36138. getFacetLocalPositions(): Vector3[];
  36139. /**
  36140. * Returns the facetLocalPartioning array
  36141. * @returns an array of array of numbers
  36142. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36143. */
  36144. getFacetLocalPartitioning(): number[][];
  36145. /**
  36146. * Returns the i-th facet position in the world system.
  36147. * This method allocates a new Vector3 per call
  36148. * @param i defines the facet index
  36149. * @returns a new Vector3
  36150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36151. */
  36152. getFacetPosition(i: number): Vector3;
  36153. /**
  36154. * Sets the reference Vector3 with the i-th facet position in the world system
  36155. * @param i defines the facet index
  36156. * @param ref defines the target vector
  36157. * @returns the current mesh
  36158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36159. */
  36160. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36161. /**
  36162. * Returns the i-th facet normal in the world system.
  36163. * This method allocates a new Vector3 per call
  36164. * @param i defines the facet index
  36165. * @returns a new Vector3
  36166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36167. */
  36168. getFacetNormal(i: number): Vector3;
  36169. /**
  36170. * Sets the reference Vector3 with the i-th facet normal in the world system
  36171. * @param i defines the facet index
  36172. * @param ref defines the target vector
  36173. * @returns the current mesh
  36174. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36175. */
  36176. getFacetNormalToRef(i: number, ref: Vector3): this;
  36177. /**
  36178. * 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)
  36179. * @param x defines x coordinate
  36180. * @param y defines y coordinate
  36181. * @param z defines z coordinate
  36182. * @returns the array of facet indexes
  36183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36184. */
  36185. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36186. /**
  36187. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36188. * @param projected sets as the (x,y,z) world projection on the facet
  36189. * @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
  36190. * @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
  36191. * @param x defines x coordinate
  36192. * @param y defines y coordinate
  36193. * @param z defines z coordinate
  36194. * @returns the face index if found (or null instead)
  36195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36196. */
  36197. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36198. /**
  36199. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36200. * @param projected sets as the (x,y,z) local projection on the facet
  36201. * @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
  36202. * @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
  36203. * @param x defines x coordinate
  36204. * @param y defines y coordinate
  36205. * @param z defines z coordinate
  36206. * @returns the face index if found (or null instead)
  36207. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36208. */
  36209. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36210. /**
  36211. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36212. * @returns the parameters
  36213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36214. */
  36215. getFacetDataParameters(): any;
  36216. /**
  36217. * Disables the feature FacetData and frees the related memory
  36218. * @returns the current mesh
  36219. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36220. */
  36221. disableFacetData(): AbstractMesh;
  36222. /**
  36223. * Updates the AbstractMesh indices array
  36224. * @param indices defines the data source
  36225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36226. * @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)
  36227. * @returns the current mesh
  36228. */
  36229. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36230. /**
  36231. * Creates new normals data for the mesh
  36232. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36233. * @returns the current mesh
  36234. */
  36235. createNormals(updatable: boolean): AbstractMesh;
  36236. /**
  36237. * Align the mesh with a normal
  36238. * @param normal defines the normal to use
  36239. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36240. * @returns the current mesh
  36241. */
  36242. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36243. /** @hidden */
  36244. _checkOcclusionQuery(): boolean;
  36245. /**
  36246. * Disables the mesh edge rendering mode
  36247. * @returns the currentAbstractMesh
  36248. */
  36249. disableEdgesRendering(): AbstractMesh;
  36250. /**
  36251. * Enables the edge rendering mode on the mesh.
  36252. * This mode makes the mesh edges visible
  36253. * @param epsilon defines the maximal distance between two angles to detect a face
  36254. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36255. * @returns the currentAbstractMesh
  36256. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36257. */
  36258. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36259. /**
  36260. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36261. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36262. */
  36263. getConnectedParticleSystems(): IParticleSystem[];
  36264. }
  36265. }
  36266. declare module BABYLON {
  36267. /**
  36268. * Interface used to define ActionEvent
  36269. */
  36270. export interface IActionEvent {
  36271. /** The mesh or sprite that triggered the action */
  36272. source: any;
  36273. /** The X mouse cursor position at the time of the event */
  36274. pointerX: number;
  36275. /** The Y mouse cursor position at the time of the event */
  36276. pointerY: number;
  36277. /** The mesh that is currently pointed at (can be null) */
  36278. meshUnderPointer: Nullable<AbstractMesh>;
  36279. /** the original (browser) event that triggered the ActionEvent */
  36280. sourceEvent?: any;
  36281. /** additional data for the event */
  36282. additionalData?: any;
  36283. }
  36284. /**
  36285. * ActionEvent is the event being sent when an action is triggered.
  36286. */
  36287. export class ActionEvent implements IActionEvent {
  36288. /** The mesh or sprite that triggered the action */
  36289. source: any;
  36290. /** The X mouse cursor position at the time of the event */
  36291. pointerX: number;
  36292. /** The Y mouse cursor position at the time of the event */
  36293. pointerY: number;
  36294. /** The mesh that is currently pointed at (can be null) */
  36295. meshUnderPointer: Nullable<AbstractMesh>;
  36296. /** the original (browser) event that triggered the ActionEvent */
  36297. sourceEvent?: any;
  36298. /** additional data for the event */
  36299. additionalData?: any;
  36300. /**
  36301. * Creates a new ActionEvent
  36302. * @param source The mesh or sprite that triggered the action
  36303. * @param pointerX The X mouse cursor position at the time of the event
  36304. * @param pointerY The Y mouse cursor position at the time of the event
  36305. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36306. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36307. * @param additionalData additional data for the event
  36308. */
  36309. constructor(
  36310. /** The mesh or sprite that triggered the action */
  36311. source: any,
  36312. /** The X mouse cursor position at the time of the event */
  36313. pointerX: number,
  36314. /** The Y mouse cursor position at the time of the event */
  36315. pointerY: number,
  36316. /** The mesh that is currently pointed at (can be null) */
  36317. meshUnderPointer: Nullable<AbstractMesh>,
  36318. /** the original (browser) event that triggered the ActionEvent */
  36319. sourceEvent?: any,
  36320. /** additional data for the event */
  36321. additionalData?: any);
  36322. /**
  36323. * Helper function to auto-create an ActionEvent from a source mesh.
  36324. * @param source The source mesh that triggered the event
  36325. * @param evt The original (browser) event
  36326. * @param additionalData additional data for the event
  36327. * @returns the new ActionEvent
  36328. */
  36329. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36330. /**
  36331. * Helper function to auto-create an ActionEvent from a source sprite
  36332. * @param source The source sprite that triggered the event
  36333. * @param scene Scene associated with the sprite
  36334. * @param evt The original (browser) event
  36335. * @param additionalData additional data for the event
  36336. * @returns the new ActionEvent
  36337. */
  36338. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36339. /**
  36340. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36341. * @param scene the scene where the event occurred
  36342. * @param evt The original (browser) event
  36343. * @returns the new ActionEvent
  36344. */
  36345. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36346. /**
  36347. * Helper function to auto-create an ActionEvent from a primitive
  36348. * @param prim defines the target primitive
  36349. * @param pointerPos defines the pointer position
  36350. * @param evt The original (browser) event
  36351. * @param additionalData additional data for the event
  36352. * @returns the new ActionEvent
  36353. */
  36354. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36355. }
  36356. }
  36357. declare module BABYLON {
  36358. /**
  36359. * Abstract class used to decouple action Manager from scene and meshes.
  36360. * Do not instantiate.
  36361. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36362. */
  36363. export abstract class AbstractActionManager implements IDisposable {
  36364. /** Gets the list of active triggers */
  36365. static Triggers: {
  36366. [key: string]: number;
  36367. };
  36368. /** Gets the cursor to use when hovering items */
  36369. hoverCursor: string;
  36370. /** Gets the list of actions */
  36371. actions: IAction[];
  36372. /**
  36373. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36374. */
  36375. isRecursive: boolean;
  36376. /**
  36377. * Releases all associated resources
  36378. */
  36379. abstract dispose(): void;
  36380. /**
  36381. * Does this action manager has pointer triggers
  36382. */
  36383. abstract get hasPointerTriggers(): boolean;
  36384. /**
  36385. * Does this action manager has pick triggers
  36386. */
  36387. abstract get hasPickTriggers(): boolean;
  36388. /**
  36389. * Process a specific trigger
  36390. * @param trigger defines the trigger to process
  36391. * @param evt defines the event details to be processed
  36392. */
  36393. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36394. /**
  36395. * Does this action manager handles actions of any of the given triggers
  36396. * @param triggers defines the triggers to be tested
  36397. * @return a boolean indicating whether one (or more) of the triggers is handled
  36398. */
  36399. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36400. /**
  36401. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36402. * speed.
  36403. * @param triggerA defines the trigger to be tested
  36404. * @param triggerB defines the trigger to be tested
  36405. * @return a boolean indicating whether one (or more) of the triggers is handled
  36406. */
  36407. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36408. /**
  36409. * Does this action manager handles actions of a given trigger
  36410. * @param trigger defines the trigger to be tested
  36411. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36412. * @return whether the trigger is handled
  36413. */
  36414. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36415. /**
  36416. * Serialize this manager to a JSON object
  36417. * @param name defines the property name to store this manager
  36418. * @returns a JSON representation of this manager
  36419. */
  36420. abstract serialize(name: string): any;
  36421. /**
  36422. * Registers an action to this action manager
  36423. * @param action defines the action to be registered
  36424. * @return the action amended (prepared) after registration
  36425. */
  36426. abstract registerAction(action: IAction): Nullable<IAction>;
  36427. /**
  36428. * Unregisters an action to this action manager
  36429. * @param action defines the action to be unregistered
  36430. * @return a boolean indicating whether the action has been unregistered
  36431. */
  36432. abstract unregisterAction(action: IAction): Boolean;
  36433. /**
  36434. * Does exist one action manager with at least one trigger
  36435. **/
  36436. static get HasTriggers(): boolean;
  36437. /**
  36438. * Does exist one action manager with at least one pick trigger
  36439. **/
  36440. static get HasPickTriggers(): boolean;
  36441. /**
  36442. * Does exist one action manager that handles actions of a given trigger
  36443. * @param trigger defines the trigger to be tested
  36444. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36445. **/
  36446. static HasSpecificTrigger(trigger: number): boolean;
  36447. }
  36448. }
  36449. declare module BABYLON {
  36450. /**
  36451. * Defines how a node can be built from a string name.
  36452. */
  36453. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36454. /**
  36455. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36456. */
  36457. export class Node implements IBehaviorAware<Node> {
  36458. /** @hidden */
  36459. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36460. private static _NodeConstructors;
  36461. /**
  36462. * Add a new node constructor
  36463. * @param type defines the type name of the node to construct
  36464. * @param constructorFunc defines the constructor function
  36465. */
  36466. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36467. /**
  36468. * Returns a node constructor based on type name
  36469. * @param type defines the type name
  36470. * @param name defines the new node name
  36471. * @param scene defines the hosting scene
  36472. * @param options defines optional options to transmit to constructors
  36473. * @returns the new constructor or null
  36474. */
  36475. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36476. /**
  36477. * Gets or sets the name of the node
  36478. */
  36479. name: string;
  36480. /**
  36481. * Gets or sets the id of the node
  36482. */
  36483. id: string;
  36484. /**
  36485. * Gets or sets the unique id of the node
  36486. */
  36487. uniqueId: number;
  36488. /**
  36489. * Gets or sets a string used to store user defined state for the node
  36490. */
  36491. state: string;
  36492. /**
  36493. * Gets or sets an object used to store user defined information for the node
  36494. */
  36495. metadata: any;
  36496. /**
  36497. * For internal use only. Please do not use.
  36498. */
  36499. reservedDataStore: any;
  36500. /**
  36501. * List of inspectable custom properties (used by the Inspector)
  36502. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36503. */
  36504. inspectableCustomProperties: IInspectable[];
  36505. private _doNotSerialize;
  36506. /**
  36507. * Gets or sets a boolean used to define if the node must be serialized
  36508. */
  36509. get doNotSerialize(): boolean;
  36510. set doNotSerialize(value: boolean);
  36511. /** @hidden */
  36512. _isDisposed: boolean;
  36513. /**
  36514. * Gets a list of Animations associated with the node
  36515. */
  36516. animations: Animation[];
  36517. protected _ranges: {
  36518. [name: string]: Nullable<AnimationRange>;
  36519. };
  36520. /**
  36521. * Callback raised when the node is ready to be used
  36522. */
  36523. onReady: Nullable<(node: Node) => void>;
  36524. private _isEnabled;
  36525. private _isParentEnabled;
  36526. private _isReady;
  36527. /** @hidden */
  36528. _currentRenderId: number;
  36529. private _parentUpdateId;
  36530. /** @hidden */
  36531. _childUpdateId: number;
  36532. /** @hidden */
  36533. _waitingParentId: Nullable<string>;
  36534. /** @hidden */
  36535. _scene: Scene;
  36536. /** @hidden */
  36537. _cache: any;
  36538. private _parentNode;
  36539. private _children;
  36540. /** @hidden */
  36541. _worldMatrix: Matrix;
  36542. /** @hidden */
  36543. _worldMatrixDeterminant: number;
  36544. /** @hidden */
  36545. _worldMatrixDeterminantIsDirty: boolean;
  36546. /** @hidden */
  36547. private _sceneRootNodesIndex;
  36548. /**
  36549. * Gets a boolean indicating if the node has been disposed
  36550. * @returns true if the node was disposed
  36551. */
  36552. isDisposed(): boolean;
  36553. /**
  36554. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36555. * @see https://doc.babylonjs.com/how_to/parenting
  36556. */
  36557. set parent(parent: Nullable<Node>);
  36558. get parent(): Nullable<Node>;
  36559. /** @hidden */
  36560. _addToSceneRootNodes(): void;
  36561. /** @hidden */
  36562. _removeFromSceneRootNodes(): void;
  36563. private _animationPropertiesOverride;
  36564. /**
  36565. * Gets or sets the animation properties override
  36566. */
  36567. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36568. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36569. /**
  36570. * Gets a string identifying the name of the class
  36571. * @returns "Node" string
  36572. */
  36573. getClassName(): string;
  36574. /** @hidden */
  36575. readonly _isNode: boolean;
  36576. /**
  36577. * An event triggered when the mesh is disposed
  36578. */
  36579. onDisposeObservable: Observable<Node>;
  36580. private _onDisposeObserver;
  36581. /**
  36582. * Sets a callback that will be raised when the node will be disposed
  36583. */
  36584. set onDispose(callback: () => void);
  36585. /**
  36586. * Creates a new Node
  36587. * @param name the name and id to be given to this node
  36588. * @param scene the scene this node will be added to
  36589. */
  36590. constructor(name: string, scene?: Nullable<Scene>);
  36591. /**
  36592. * Gets the scene of the node
  36593. * @returns a scene
  36594. */
  36595. getScene(): Scene;
  36596. /**
  36597. * Gets the engine of the node
  36598. * @returns a Engine
  36599. */
  36600. getEngine(): Engine;
  36601. private _behaviors;
  36602. /**
  36603. * Attach a behavior to the node
  36604. * @see https://doc.babylonjs.com/features/behaviour
  36605. * @param behavior defines the behavior to attach
  36606. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36607. * @returns the current Node
  36608. */
  36609. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36610. /**
  36611. * Remove an attached behavior
  36612. * @see https://doc.babylonjs.com/features/behaviour
  36613. * @param behavior defines the behavior to attach
  36614. * @returns the current Node
  36615. */
  36616. removeBehavior(behavior: Behavior<Node>): Node;
  36617. /**
  36618. * Gets the list of attached behaviors
  36619. * @see https://doc.babylonjs.com/features/behaviour
  36620. */
  36621. get behaviors(): Behavior<Node>[];
  36622. /**
  36623. * Gets an attached behavior by name
  36624. * @param name defines the name of the behavior to look for
  36625. * @see https://doc.babylonjs.com/features/behaviour
  36626. * @returns null if behavior was not found else the requested behavior
  36627. */
  36628. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36629. /**
  36630. * Returns the latest update of the World matrix
  36631. * @returns a Matrix
  36632. */
  36633. getWorldMatrix(): Matrix;
  36634. /** @hidden */
  36635. _getWorldMatrixDeterminant(): number;
  36636. /**
  36637. * Returns directly the latest state of the mesh World matrix.
  36638. * A Matrix is returned.
  36639. */
  36640. get worldMatrixFromCache(): Matrix;
  36641. /** @hidden */
  36642. _initCache(): void;
  36643. /** @hidden */
  36644. updateCache(force?: boolean): void;
  36645. /** @hidden */
  36646. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36647. /** @hidden */
  36648. _updateCache(ignoreParentClass?: boolean): void;
  36649. /** @hidden */
  36650. _isSynchronized(): boolean;
  36651. /** @hidden */
  36652. _markSyncedWithParent(): void;
  36653. /** @hidden */
  36654. isSynchronizedWithParent(): boolean;
  36655. /** @hidden */
  36656. isSynchronized(): boolean;
  36657. /**
  36658. * Is this node ready to be used/rendered
  36659. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36660. * @return true if the node is ready
  36661. */
  36662. isReady(completeCheck?: boolean): boolean;
  36663. /**
  36664. * Is this node enabled?
  36665. * 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
  36666. * @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
  36667. * @return whether this node (and its parent) is enabled
  36668. */
  36669. isEnabled(checkAncestors?: boolean): boolean;
  36670. /** @hidden */
  36671. protected _syncParentEnabledState(): void;
  36672. /**
  36673. * Set the enabled state of this node
  36674. * @param value defines the new enabled state
  36675. */
  36676. setEnabled(value: boolean): void;
  36677. /**
  36678. * Is this node a descendant of the given node?
  36679. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36680. * @param ancestor defines the parent node to inspect
  36681. * @returns a boolean indicating if this node is a descendant of the given node
  36682. */
  36683. isDescendantOf(ancestor: Node): boolean;
  36684. /** @hidden */
  36685. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36686. /**
  36687. * Will return all nodes that have this node as ascendant
  36688. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  36689. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36690. * @return all children nodes of all types
  36691. */
  36692. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36693. /**
  36694. * Get all child-meshes of this node
  36695. * @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)
  36696. * @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
  36697. * @returns an array of AbstractMesh
  36698. */
  36699. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36700. /**
  36701. * Get all direct children of this node
  36702. * @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
  36703. * @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)
  36704. * @returns an array of Node
  36705. */
  36706. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36707. /** @hidden */
  36708. _setReady(state: boolean): void;
  36709. /**
  36710. * Get an animation by name
  36711. * @param name defines the name of the animation to look for
  36712. * @returns null if not found else the requested animation
  36713. */
  36714. getAnimationByName(name: string): Nullable<Animation>;
  36715. /**
  36716. * Creates an animation range for this node
  36717. * @param name defines the name of the range
  36718. * @param from defines the starting key
  36719. * @param to defines the end key
  36720. */
  36721. createAnimationRange(name: string, from: number, to: number): void;
  36722. /**
  36723. * Delete a specific animation range
  36724. * @param name defines the name of the range to delete
  36725. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36726. */
  36727. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36728. /**
  36729. * Get an animation range by name
  36730. * @param name defines the name of the animation range to look for
  36731. * @returns null if not found else the requested animation range
  36732. */
  36733. getAnimationRange(name: string): Nullable<AnimationRange>;
  36734. /**
  36735. * Gets the list of all animation ranges defined on this node
  36736. * @returns an array
  36737. */
  36738. getAnimationRanges(): Nullable<AnimationRange>[];
  36739. /**
  36740. * Will start the animation sequence
  36741. * @param name defines the range frames for animation sequence
  36742. * @param loop defines if the animation should loop (false by default)
  36743. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36744. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36745. * @returns the object created for this animation. If range does not exist, it will return null
  36746. */
  36747. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36748. /**
  36749. * Serialize animation ranges into a JSON compatible object
  36750. * @returns serialization object
  36751. */
  36752. serializeAnimationRanges(): any;
  36753. /**
  36754. * Computes the world matrix of the node
  36755. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36756. * @returns the world matrix
  36757. */
  36758. computeWorldMatrix(force?: boolean): Matrix;
  36759. /**
  36760. * Releases resources associated with this node.
  36761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36763. */
  36764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36765. /**
  36766. * Parse animation range data from a serialization object and store them into a given node
  36767. * @param node defines where to store the animation ranges
  36768. * @param parsedNode defines the serialization object to read data from
  36769. * @param scene defines the hosting scene
  36770. */
  36771. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36772. /**
  36773. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36774. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36775. * @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
  36776. * @returns the new bounding vectors
  36777. */
  36778. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36779. min: Vector3;
  36780. max: Vector3;
  36781. };
  36782. }
  36783. }
  36784. declare module BABYLON {
  36785. /**
  36786. * @hidden
  36787. */
  36788. export class _IAnimationState {
  36789. key: number;
  36790. repeatCount: number;
  36791. workValue?: any;
  36792. loopMode?: number;
  36793. offsetValue?: any;
  36794. highLimitValue?: any;
  36795. }
  36796. /**
  36797. * Class used to store any kind of animation
  36798. */
  36799. export class Animation {
  36800. /**Name of the animation */
  36801. name: string;
  36802. /**Property to animate */
  36803. targetProperty: string;
  36804. /**The frames per second of the animation */
  36805. framePerSecond: number;
  36806. /**The data type of the animation */
  36807. dataType: number;
  36808. /**The loop mode of the animation */
  36809. loopMode?: number | undefined;
  36810. /**Specifies if blending should be enabled */
  36811. enableBlending?: boolean | undefined;
  36812. /**
  36813. * Use matrix interpolation instead of using direct key value when animating matrices
  36814. */
  36815. static AllowMatricesInterpolation: boolean;
  36816. /**
  36817. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36818. */
  36819. static AllowMatrixDecomposeForInterpolation: boolean;
  36820. /** Define the Url to load snippets */
  36821. static SnippetUrl: string;
  36822. /** Snippet ID if the animation was created from the snippet server */
  36823. snippetId: string;
  36824. /**
  36825. * Stores the key frames of the animation
  36826. */
  36827. private _keys;
  36828. /**
  36829. * Stores the easing function of the animation
  36830. */
  36831. private _easingFunction;
  36832. /**
  36833. * @hidden Internal use only
  36834. */
  36835. _runtimeAnimations: RuntimeAnimation[];
  36836. /**
  36837. * The set of event that will be linked to this animation
  36838. */
  36839. private _events;
  36840. /**
  36841. * Stores an array of target property paths
  36842. */
  36843. targetPropertyPath: string[];
  36844. /**
  36845. * Stores the blending speed of the animation
  36846. */
  36847. blendingSpeed: number;
  36848. /**
  36849. * Stores the animation ranges for the animation
  36850. */
  36851. private _ranges;
  36852. /**
  36853. * @hidden Internal use
  36854. */
  36855. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36856. /**
  36857. * Sets up an animation
  36858. * @param property The property to animate
  36859. * @param animationType The animation type to apply
  36860. * @param framePerSecond The frames per second of the animation
  36861. * @param easingFunction The easing function used in the animation
  36862. * @returns The created animation
  36863. */
  36864. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36865. /**
  36866. * Create and start an animation on a node
  36867. * @param name defines the name of the global animation that will be run on all nodes
  36868. * @param node defines the root node where the animation will take place
  36869. * @param targetProperty defines property to animate
  36870. * @param framePerSecond defines the number of frame per second yo use
  36871. * @param totalFrame defines the number of frames in total
  36872. * @param from defines the initial value
  36873. * @param to defines the final value
  36874. * @param loopMode defines which loop mode you want to use (off by default)
  36875. * @param easingFunction defines the easing function to use (linear by default)
  36876. * @param onAnimationEnd defines the callback to call when animation end
  36877. * @returns the animatable created for this animation
  36878. */
  36879. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36880. /**
  36881. * Create and start an animation on a node and its descendants
  36882. * @param name defines the name of the global animation that will be run on all nodes
  36883. * @param node defines the root node where the animation will take place
  36884. * @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
  36885. * @param targetProperty defines property to animate
  36886. * @param framePerSecond defines the number of frame per second to use
  36887. * @param totalFrame defines the number of frames in total
  36888. * @param from defines the initial value
  36889. * @param to defines the final value
  36890. * @param loopMode defines which loop mode you want to use (off by default)
  36891. * @param easingFunction defines the easing function to use (linear by default)
  36892. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36893. * @returns the list of animatables created for all nodes
  36894. * @example https://www.babylonjs-playground.com/#MH0VLI
  36895. */
  36896. 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[]>;
  36897. /**
  36898. * Creates a new animation, merges it with the existing animations and starts it
  36899. * @param name Name of the animation
  36900. * @param node Node which contains the scene that begins the animations
  36901. * @param targetProperty Specifies which property to animate
  36902. * @param framePerSecond The frames per second of the animation
  36903. * @param totalFrame The total number of frames
  36904. * @param from The frame at the beginning of the animation
  36905. * @param to The frame at the end of the animation
  36906. * @param loopMode Specifies the loop mode of the animation
  36907. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36908. * @param onAnimationEnd Callback to run once the animation is complete
  36909. * @returns Nullable animation
  36910. */
  36911. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36912. /**
  36913. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36914. * @param sourceAnimation defines the Animation containing keyframes to convert
  36915. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36916. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36917. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36918. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36919. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36920. */
  36921. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36922. /**
  36923. * Transition property of an host to the target Value
  36924. * @param property The property to transition
  36925. * @param targetValue The target Value of the property
  36926. * @param host The object where the property to animate belongs
  36927. * @param scene Scene used to run the animation
  36928. * @param frameRate Framerate (in frame/s) to use
  36929. * @param transition The transition type we want to use
  36930. * @param duration The duration of the animation, in milliseconds
  36931. * @param onAnimationEnd Callback trigger at the end of the animation
  36932. * @returns Nullable animation
  36933. */
  36934. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36935. /**
  36936. * Return the array of runtime animations currently using this animation
  36937. */
  36938. get runtimeAnimations(): RuntimeAnimation[];
  36939. /**
  36940. * Specifies if any of the runtime animations are currently running
  36941. */
  36942. get hasRunningRuntimeAnimations(): boolean;
  36943. /**
  36944. * Initializes the animation
  36945. * @param name Name of the animation
  36946. * @param targetProperty Property to animate
  36947. * @param framePerSecond The frames per second of the animation
  36948. * @param dataType The data type of the animation
  36949. * @param loopMode The loop mode of the animation
  36950. * @param enableBlending Specifies if blending should be enabled
  36951. */
  36952. constructor(
  36953. /**Name of the animation */
  36954. name: string,
  36955. /**Property to animate */
  36956. targetProperty: string,
  36957. /**The frames per second of the animation */
  36958. framePerSecond: number,
  36959. /**The data type of the animation */
  36960. dataType: number,
  36961. /**The loop mode of the animation */
  36962. loopMode?: number | undefined,
  36963. /**Specifies if blending should be enabled */
  36964. enableBlending?: boolean | undefined);
  36965. /**
  36966. * Converts the animation to a string
  36967. * @param fullDetails support for multiple levels of logging within scene loading
  36968. * @returns String form of the animation
  36969. */
  36970. toString(fullDetails?: boolean): string;
  36971. /**
  36972. * Add an event to this animation
  36973. * @param event Event to add
  36974. */
  36975. addEvent(event: AnimationEvent): void;
  36976. /**
  36977. * Remove all events found at the given frame
  36978. * @param frame The frame to remove events from
  36979. */
  36980. removeEvents(frame: number): void;
  36981. /**
  36982. * Retrieves all the events from the animation
  36983. * @returns Events from the animation
  36984. */
  36985. getEvents(): AnimationEvent[];
  36986. /**
  36987. * Creates an animation range
  36988. * @param name Name of the animation range
  36989. * @param from Starting frame of the animation range
  36990. * @param to Ending frame of the animation
  36991. */
  36992. createRange(name: string, from: number, to: number): void;
  36993. /**
  36994. * Deletes an animation range by name
  36995. * @param name Name of the animation range to delete
  36996. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36997. */
  36998. deleteRange(name: string, deleteFrames?: boolean): void;
  36999. /**
  37000. * Gets the animation range by name, or null if not defined
  37001. * @param name Name of the animation range
  37002. * @returns Nullable animation range
  37003. */
  37004. getRange(name: string): Nullable<AnimationRange>;
  37005. /**
  37006. * Gets the key frames from the animation
  37007. * @returns The key frames of the animation
  37008. */
  37009. getKeys(): Array<IAnimationKey>;
  37010. /**
  37011. * Gets the highest frame rate of the animation
  37012. * @returns Highest frame rate of the animation
  37013. */
  37014. getHighestFrame(): number;
  37015. /**
  37016. * Gets the easing function of the animation
  37017. * @returns Easing function of the animation
  37018. */
  37019. getEasingFunction(): IEasingFunction;
  37020. /**
  37021. * Sets the easing function of the animation
  37022. * @param easingFunction A custom mathematical formula for animation
  37023. */
  37024. setEasingFunction(easingFunction: EasingFunction): void;
  37025. /**
  37026. * Interpolates a scalar linearly
  37027. * @param startValue Start value of the animation curve
  37028. * @param endValue End value of the animation curve
  37029. * @param gradient Scalar amount to interpolate
  37030. * @returns Interpolated scalar value
  37031. */
  37032. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37033. /**
  37034. * Interpolates a scalar cubically
  37035. * @param startValue Start value of the animation curve
  37036. * @param outTangent End tangent of the animation
  37037. * @param endValue End value of the animation curve
  37038. * @param inTangent Start tangent of the animation curve
  37039. * @param gradient Scalar amount to interpolate
  37040. * @returns Interpolated scalar value
  37041. */
  37042. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37043. /**
  37044. * Interpolates a quaternion using a spherical linear interpolation
  37045. * @param startValue Start value of the animation curve
  37046. * @param endValue End value of the animation curve
  37047. * @param gradient Scalar amount to interpolate
  37048. * @returns Interpolated quaternion value
  37049. */
  37050. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37051. /**
  37052. * Interpolates a quaternion cubically
  37053. * @param startValue Start value of the animation curve
  37054. * @param outTangent End tangent of the animation curve
  37055. * @param endValue End value of the animation curve
  37056. * @param inTangent Start tangent of the animation curve
  37057. * @param gradient Scalar amount to interpolate
  37058. * @returns Interpolated quaternion value
  37059. */
  37060. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37061. /**
  37062. * Interpolates a Vector3 linearl
  37063. * @param startValue Start value of the animation curve
  37064. * @param endValue End value of the animation curve
  37065. * @param gradient Scalar amount to interpolate
  37066. * @returns Interpolated scalar value
  37067. */
  37068. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37069. /**
  37070. * Interpolates a Vector3 cubically
  37071. * @param startValue Start value of the animation curve
  37072. * @param outTangent End tangent of the animation
  37073. * @param endValue End value of the animation curve
  37074. * @param inTangent Start tangent of the animation curve
  37075. * @param gradient Scalar amount to interpolate
  37076. * @returns InterpolatedVector3 value
  37077. */
  37078. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37079. /**
  37080. * Interpolates a Vector2 linearly
  37081. * @param startValue Start value of the animation curve
  37082. * @param endValue End value of the animation curve
  37083. * @param gradient Scalar amount to interpolate
  37084. * @returns Interpolated Vector2 value
  37085. */
  37086. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37087. /**
  37088. * Interpolates a Vector2 cubically
  37089. * @param startValue Start value of the animation curve
  37090. * @param outTangent End tangent of the animation
  37091. * @param endValue End value of the animation curve
  37092. * @param inTangent Start tangent of the animation curve
  37093. * @param gradient Scalar amount to interpolate
  37094. * @returns Interpolated Vector2 value
  37095. */
  37096. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37097. /**
  37098. * Interpolates a size linearly
  37099. * @param startValue Start value of the animation curve
  37100. * @param endValue End value of the animation curve
  37101. * @param gradient Scalar amount to interpolate
  37102. * @returns Interpolated Size value
  37103. */
  37104. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37105. /**
  37106. * Interpolates a Color3 linearly
  37107. * @param startValue Start value of the animation curve
  37108. * @param endValue End value of the animation curve
  37109. * @param gradient Scalar amount to interpolate
  37110. * @returns Interpolated Color3 value
  37111. */
  37112. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37113. /**
  37114. * Interpolates a Color4 linearly
  37115. * @param startValue Start value of the animation curve
  37116. * @param endValue End value of the animation curve
  37117. * @param gradient Scalar amount to interpolate
  37118. * @returns Interpolated Color3 value
  37119. */
  37120. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37121. /**
  37122. * @hidden Internal use only
  37123. */
  37124. _getKeyValue(value: any): any;
  37125. /**
  37126. * @hidden Internal use only
  37127. */
  37128. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37129. /**
  37130. * Defines the function to use to interpolate matrices
  37131. * @param startValue defines the start matrix
  37132. * @param endValue defines the end matrix
  37133. * @param gradient defines the gradient between both matrices
  37134. * @param result defines an optional target matrix where to store the interpolation
  37135. * @returns the interpolated matrix
  37136. */
  37137. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37138. /**
  37139. * Makes a copy of the animation
  37140. * @returns Cloned animation
  37141. */
  37142. clone(): Animation;
  37143. /**
  37144. * Sets the key frames of the animation
  37145. * @param values The animation key frames to set
  37146. */
  37147. setKeys(values: Array<IAnimationKey>): void;
  37148. /**
  37149. * Serializes the animation to an object
  37150. * @returns Serialized object
  37151. */
  37152. serialize(): any;
  37153. /**
  37154. * Float animation type
  37155. */
  37156. static readonly ANIMATIONTYPE_FLOAT: number;
  37157. /**
  37158. * Vector3 animation type
  37159. */
  37160. static readonly ANIMATIONTYPE_VECTOR3: number;
  37161. /**
  37162. * Quaternion animation type
  37163. */
  37164. static readonly ANIMATIONTYPE_QUATERNION: number;
  37165. /**
  37166. * Matrix animation type
  37167. */
  37168. static readonly ANIMATIONTYPE_MATRIX: number;
  37169. /**
  37170. * Color3 animation type
  37171. */
  37172. static readonly ANIMATIONTYPE_COLOR3: number;
  37173. /**
  37174. * Color3 animation type
  37175. */
  37176. static readonly ANIMATIONTYPE_COLOR4: number;
  37177. /**
  37178. * Vector2 animation type
  37179. */
  37180. static readonly ANIMATIONTYPE_VECTOR2: number;
  37181. /**
  37182. * Size animation type
  37183. */
  37184. static readonly ANIMATIONTYPE_SIZE: number;
  37185. /**
  37186. * Relative Loop Mode
  37187. */
  37188. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37189. /**
  37190. * Cycle Loop Mode
  37191. */
  37192. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37193. /**
  37194. * Constant Loop Mode
  37195. */
  37196. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37197. /** @hidden */
  37198. static _UniversalLerp(left: any, right: any, amount: number): any;
  37199. /**
  37200. * Parses an animation object and creates an animation
  37201. * @param parsedAnimation Parsed animation object
  37202. * @returns Animation object
  37203. */
  37204. static Parse(parsedAnimation: any): Animation;
  37205. /**
  37206. * Appends the serialized animations from the source animations
  37207. * @param source Source containing the animations
  37208. * @param destination Target to store the animations
  37209. */
  37210. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37211. /**
  37212. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37213. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37214. * @param url defines the url to load from
  37215. * @returns a promise that will resolve to the new animation or an array of animations
  37216. */
  37217. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37218. /**
  37219. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37220. * @param snippetId defines the snippet to load
  37221. * @returns a promise that will resolve to the new animation or a new array of animations
  37222. */
  37223. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37224. }
  37225. }
  37226. declare module BABYLON {
  37227. /**
  37228. * Interface containing an array of animations
  37229. */
  37230. export interface IAnimatable {
  37231. /**
  37232. * Array of animations
  37233. */
  37234. animations: Nullable<Array<Animation>>;
  37235. }
  37236. }
  37237. declare module BABYLON {
  37238. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37239. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37240. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37241. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37242. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37243. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37244. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37245. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37246. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37247. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37248. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37249. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37250. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37251. /**
  37252. * Decorator used to define property that can be serialized as reference to a camera
  37253. * @param sourceName defines the name of the property to decorate
  37254. */
  37255. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37256. /**
  37257. * Class used to help serialization objects
  37258. */
  37259. export class SerializationHelper {
  37260. /** @hidden */
  37261. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37262. /** @hidden */
  37263. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37264. /** @hidden */
  37265. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37266. /** @hidden */
  37267. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37268. /**
  37269. * Appends the serialized animations from the source animations
  37270. * @param source Source containing the animations
  37271. * @param destination Target to store the animations
  37272. */
  37273. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37274. /**
  37275. * Static function used to serialized a specific entity
  37276. * @param entity defines the entity to serialize
  37277. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37278. * @returns a JSON compatible object representing the serialization of the entity
  37279. */
  37280. static Serialize<T>(entity: T, serializationObject?: any): any;
  37281. /**
  37282. * Creates a new entity from a serialization data object
  37283. * @param creationFunction defines a function used to instanciated the new entity
  37284. * @param source defines the source serialization data
  37285. * @param scene defines the hosting scene
  37286. * @param rootUrl defines the root url for resources
  37287. * @returns a new entity
  37288. */
  37289. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37290. /**
  37291. * Clones an object
  37292. * @param creationFunction defines the function used to instanciate the new object
  37293. * @param source defines the source object
  37294. * @returns the cloned object
  37295. */
  37296. static Clone<T>(creationFunction: () => T, source: T): T;
  37297. /**
  37298. * Instanciates a new object based on a source one (some data will be shared between both object)
  37299. * @param creationFunction defines the function used to instanciate the new object
  37300. * @param source defines the source object
  37301. * @returns the new object
  37302. */
  37303. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37304. }
  37305. }
  37306. declare module BABYLON {
  37307. /**
  37308. * Base class of all the textures in babylon.
  37309. * It groups all the common properties the materials, post process, lights... might need
  37310. * in order to make a correct use of the texture.
  37311. */
  37312. export class BaseTexture implements IAnimatable {
  37313. /**
  37314. * Default anisotropic filtering level for the application.
  37315. * It is set to 4 as a good tradeoff between perf and quality.
  37316. */
  37317. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37318. /**
  37319. * Gets or sets the unique id of the texture
  37320. */
  37321. uniqueId: number;
  37322. /**
  37323. * Define the name of the texture.
  37324. */
  37325. name: string;
  37326. /**
  37327. * Gets or sets an object used to store user defined information.
  37328. */
  37329. metadata: any;
  37330. /**
  37331. * For internal use only. Please do not use.
  37332. */
  37333. reservedDataStore: any;
  37334. private _hasAlpha;
  37335. /**
  37336. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37337. */
  37338. set hasAlpha(value: boolean);
  37339. get hasAlpha(): boolean;
  37340. /**
  37341. * Defines if the alpha value should be determined via the rgb values.
  37342. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37343. */
  37344. getAlphaFromRGB: boolean;
  37345. /**
  37346. * Intensity or strength of the texture.
  37347. * It is commonly used by materials to fine tune the intensity of the texture
  37348. */
  37349. level: number;
  37350. /**
  37351. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37352. * This is part of the texture as textures usually maps to one uv set.
  37353. */
  37354. coordinatesIndex: number;
  37355. protected _coordinatesMode: number;
  37356. /**
  37357. * How a texture is mapped.
  37358. *
  37359. * | Value | Type | Description |
  37360. * | ----- | ----------------------------------- | ----------- |
  37361. * | 0 | EXPLICIT_MODE | |
  37362. * | 1 | SPHERICAL_MODE | |
  37363. * | 2 | PLANAR_MODE | |
  37364. * | 3 | CUBIC_MODE | |
  37365. * | 4 | PROJECTION_MODE | |
  37366. * | 5 | SKYBOX_MODE | |
  37367. * | 6 | INVCUBIC_MODE | |
  37368. * | 7 | EQUIRECTANGULAR_MODE | |
  37369. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37370. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37371. */
  37372. set coordinatesMode(value: number);
  37373. get coordinatesMode(): number;
  37374. private _wrapU;
  37375. /**
  37376. * | Value | Type | Description |
  37377. * | ----- | ------------------ | ----------- |
  37378. * | 0 | CLAMP_ADDRESSMODE | |
  37379. * | 1 | WRAP_ADDRESSMODE | |
  37380. * | 2 | MIRROR_ADDRESSMODE | |
  37381. */
  37382. get wrapU(): number;
  37383. set wrapU(value: number);
  37384. private _wrapV;
  37385. /**
  37386. * | Value | Type | Description |
  37387. * | ----- | ------------------ | ----------- |
  37388. * | 0 | CLAMP_ADDRESSMODE | |
  37389. * | 1 | WRAP_ADDRESSMODE | |
  37390. * | 2 | MIRROR_ADDRESSMODE | |
  37391. */
  37392. get wrapV(): number;
  37393. set wrapV(value: number);
  37394. /**
  37395. * | Value | Type | Description |
  37396. * | ----- | ------------------ | ----------- |
  37397. * | 0 | CLAMP_ADDRESSMODE | |
  37398. * | 1 | WRAP_ADDRESSMODE | |
  37399. * | 2 | MIRROR_ADDRESSMODE | |
  37400. */
  37401. wrapR: number;
  37402. /**
  37403. * With compliant hardware and browser (supporting anisotropic filtering)
  37404. * this defines the level of anisotropic filtering in the texture.
  37405. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37406. */
  37407. anisotropicFilteringLevel: number;
  37408. /**
  37409. * Define if the texture is a cube texture or if false a 2d texture.
  37410. */
  37411. get isCube(): boolean;
  37412. set isCube(value: boolean);
  37413. /**
  37414. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37415. */
  37416. get is3D(): boolean;
  37417. set is3D(value: boolean);
  37418. /**
  37419. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37420. */
  37421. get is2DArray(): boolean;
  37422. set is2DArray(value: boolean);
  37423. private _gammaSpace;
  37424. /**
  37425. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37426. * HDR texture are usually stored in linear space.
  37427. * This only impacts the PBR and Background materials
  37428. */
  37429. get gammaSpace(): boolean;
  37430. set gammaSpace(gamma: boolean);
  37431. /**
  37432. * Gets or sets whether or not the texture contains RGBD data.
  37433. */
  37434. get isRGBD(): boolean;
  37435. set isRGBD(value: boolean);
  37436. /**
  37437. * Is Z inverted in the texture (useful in a cube texture).
  37438. */
  37439. invertZ: boolean;
  37440. /**
  37441. * Are mip maps generated for this texture or not.
  37442. */
  37443. get noMipmap(): boolean;
  37444. /**
  37445. * @hidden
  37446. */
  37447. lodLevelInAlpha: boolean;
  37448. /**
  37449. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37450. */
  37451. get lodGenerationOffset(): number;
  37452. set lodGenerationOffset(value: number);
  37453. /**
  37454. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37455. */
  37456. get lodGenerationScale(): number;
  37457. set lodGenerationScale(value: number);
  37458. /**
  37459. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37460. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37461. * average roughness values.
  37462. */
  37463. get linearSpecularLOD(): boolean;
  37464. set linearSpecularLOD(value: boolean);
  37465. /**
  37466. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37467. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37468. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37469. */
  37470. get irradianceTexture(): Nullable<BaseTexture>;
  37471. set irradianceTexture(value: Nullable<BaseTexture>);
  37472. /**
  37473. * Define if the texture is a render target.
  37474. */
  37475. isRenderTarget: boolean;
  37476. /**
  37477. * Define the unique id of the texture in the scene.
  37478. */
  37479. get uid(): string;
  37480. /** @hidden */
  37481. _prefiltered: boolean;
  37482. /**
  37483. * Return a string representation of the texture.
  37484. * @returns the texture as a string
  37485. */
  37486. toString(): string;
  37487. /**
  37488. * Get the class name of the texture.
  37489. * @returns "BaseTexture"
  37490. */
  37491. getClassName(): string;
  37492. /**
  37493. * Define the list of animation attached to the texture.
  37494. */
  37495. animations: Animation[];
  37496. /**
  37497. * An event triggered when the texture is disposed.
  37498. */
  37499. onDisposeObservable: Observable<BaseTexture>;
  37500. private _onDisposeObserver;
  37501. /**
  37502. * Callback triggered when the texture has been disposed.
  37503. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37504. */
  37505. set onDispose(callback: () => void);
  37506. /**
  37507. * Define the current state of the loading sequence when in delayed load mode.
  37508. */
  37509. delayLoadState: number;
  37510. protected _scene: Nullable<Scene>;
  37511. protected _engine: Nullable<ThinEngine>;
  37512. /** @hidden */
  37513. _texture: Nullable<InternalTexture>;
  37514. private _uid;
  37515. /**
  37516. * Define if the texture is preventinga material to render or not.
  37517. * If not and the texture is not ready, the engine will use a default black texture instead.
  37518. */
  37519. get isBlocking(): boolean;
  37520. /**
  37521. * Instantiates a new BaseTexture.
  37522. * Base class of all the textures in babylon.
  37523. * It groups all the common properties the materials, post process, lights... might need
  37524. * in order to make a correct use of the texture.
  37525. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37526. */
  37527. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37528. /**
  37529. * Get the scene the texture belongs to.
  37530. * @returns the scene or null if undefined
  37531. */
  37532. getScene(): Nullable<Scene>;
  37533. /** @hidden */
  37534. protected _getEngine(): Nullable<ThinEngine>;
  37535. /**
  37536. * Checks if the texture has the same transform matrix than another texture
  37537. * @param texture texture to check against
  37538. * @returns true if the transforms are the same, else false
  37539. */
  37540. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37541. /**
  37542. * Get the texture transform matrix used to offset tile the texture for istance.
  37543. * @returns the transformation matrix
  37544. */
  37545. getTextureMatrix(): Matrix;
  37546. /**
  37547. * Get the texture reflection matrix used to rotate/transform the reflection.
  37548. * @returns the reflection matrix
  37549. */
  37550. getReflectionTextureMatrix(): Matrix;
  37551. /**
  37552. * Get the underlying lower level texture from Babylon.
  37553. * @returns the insternal texture
  37554. */
  37555. getInternalTexture(): Nullable<InternalTexture>;
  37556. /**
  37557. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37558. * @returns true if ready or not blocking
  37559. */
  37560. isReadyOrNotBlocking(): boolean;
  37561. /**
  37562. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37563. * @returns true if fully ready
  37564. */
  37565. isReady(): boolean;
  37566. private _cachedSize;
  37567. /**
  37568. * Get the size of the texture.
  37569. * @returns the texture size.
  37570. */
  37571. getSize(): ISize;
  37572. /**
  37573. * Get the base size of the texture.
  37574. * It can be different from the size if the texture has been resized for POT for instance
  37575. * @returns the base size
  37576. */
  37577. getBaseSize(): ISize;
  37578. /**
  37579. * Update the sampling mode of the texture.
  37580. * Default is Trilinear mode.
  37581. *
  37582. * | Value | Type | Description |
  37583. * | ----- | ------------------ | ----------- |
  37584. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37585. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37586. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37587. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37588. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37589. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37590. * | 7 | NEAREST_LINEAR | |
  37591. * | 8 | NEAREST_NEAREST | |
  37592. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37593. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37594. * | 11 | LINEAR_LINEAR | |
  37595. * | 12 | LINEAR_NEAREST | |
  37596. *
  37597. * > _mag_: magnification filter (close to the viewer)
  37598. * > _min_: minification filter (far from the viewer)
  37599. * > _mip_: filter used between mip map levels
  37600. *@param samplingMode Define the new sampling mode of the texture
  37601. */
  37602. updateSamplingMode(samplingMode: number): void;
  37603. /**
  37604. * Scales the texture if is `canRescale()`
  37605. * @param ratio the resize factor we want to use to rescale
  37606. */
  37607. scale(ratio: number): void;
  37608. /**
  37609. * Get if the texture can rescale.
  37610. */
  37611. get canRescale(): boolean;
  37612. /** @hidden */
  37613. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37614. /** @hidden */
  37615. _rebuild(): void;
  37616. /**
  37617. * Triggers the load sequence in delayed load mode.
  37618. */
  37619. delayLoad(): void;
  37620. /**
  37621. * Clones the texture.
  37622. * @returns the cloned texture
  37623. */
  37624. clone(): Nullable<BaseTexture>;
  37625. /**
  37626. * Get the texture underlying type (INT, FLOAT...)
  37627. */
  37628. get textureType(): number;
  37629. /**
  37630. * Get the texture underlying format (RGB, RGBA...)
  37631. */
  37632. get textureFormat(): number;
  37633. /**
  37634. * Indicates that textures need to be re-calculated for all materials
  37635. */
  37636. protected _markAllSubMeshesAsTexturesDirty(): void;
  37637. /**
  37638. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37639. * This will returns an RGBA array buffer containing either in values (0-255) or
  37640. * float values (0-1) depending of the underlying buffer type.
  37641. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37642. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37643. * @param buffer defines a user defined buffer to fill with data (can be null)
  37644. * @returns The Array buffer containing the pixels data.
  37645. */
  37646. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37647. /**
  37648. * Release and destroy the underlying lower level texture aka internalTexture.
  37649. */
  37650. releaseInternalTexture(): void;
  37651. /** @hidden */
  37652. get _lodTextureHigh(): Nullable<BaseTexture>;
  37653. /** @hidden */
  37654. get _lodTextureMid(): Nullable<BaseTexture>;
  37655. /** @hidden */
  37656. get _lodTextureLow(): Nullable<BaseTexture>;
  37657. /**
  37658. * Dispose the texture and release its associated resources.
  37659. */
  37660. dispose(): void;
  37661. /**
  37662. * Serialize the texture into a JSON representation that can be parsed later on.
  37663. * @returns the JSON representation of the texture
  37664. */
  37665. serialize(): any;
  37666. /**
  37667. * Helper function to be called back once a list of texture contains only ready textures.
  37668. * @param textures Define the list of textures to wait for
  37669. * @param callback Define the callback triggered once the entire list will be ready
  37670. */
  37671. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37672. private static _isScene;
  37673. }
  37674. }
  37675. declare module BABYLON {
  37676. /**
  37677. * Options to be used when creating an effect.
  37678. */
  37679. export interface IEffectCreationOptions {
  37680. /**
  37681. * Atrributes that will be used in the shader.
  37682. */
  37683. attributes: string[];
  37684. /**
  37685. * Uniform varible names that will be set in the shader.
  37686. */
  37687. uniformsNames: string[];
  37688. /**
  37689. * Uniform buffer variable names that will be set in the shader.
  37690. */
  37691. uniformBuffersNames: string[];
  37692. /**
  37693. * Sampler texture variable names that will be set in the shader.
  37694. */
  37695. samplers: string[];
  37696. /**
  37697. * Define statements that will be set in the shader.
  37698. */
  37699. defines: any;
  37700. /**
  37701. * Possible fallbacks for this effect to improve performance when needed.
  37702. */
  37703. fallbacks: Nullable<IEffectFallbacks>;
  37704. /**
  37705. * Callback that will be called when the shader is compiled.
  37706. */
  37707. onCompiled: Nullable<(effect: Effect) => void>;
  37708. /**
  37709. * Callback that will be called if an error occurs during shader compilation.
  37710. */
  37711. onError: Nullable<(effect: Effect, errors: string) => void>;
  37712. /**
  37713. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37714. */
  37715. indexParameters?: any;
  37716. /**
  37717. * Max number of lights that can be used in the shader.
  37718. */
  37719. maxSimultaneousLights?: number;
  37720. /**
  37721. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37722. */
  37723. transformFeedbackVaryings?: Nullable<string[]>;
  37724. /**
  37725. * 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
  37726. */
  37727. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37728. /**
  37729. * Is this effect rendering to several color attachments ?
  37730. */
  37731. multiTarget?: boolean;
  37732. }
  37733. /**
  37734. * Effect containing vertex and fragment shader that can be executed on an object.
  37735. */
  37736. export class Effect implements IDisposable {
  37737. /**
  37738. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37739. */
  37740. static ShadersRepository: string;
  37741. /**
  37742. * Enable logging of the shader code when a compilation error occurs
  37743. */
  37744. static LogShaderCodeOnCompilationError: boolean;
  37745. /**
  37746. * Name of the effect.
  37747. */
  37748. name: any;
  37749. /**
  37750. * String container all the define statements that should be set on the shader.
  37751. */
  37752. defines: string;
  37753. /**
  37754. * Callback that will be called when the shader is compiled.
  37755. */
  37756. onCompiled: Nullable<(effect: Effect) => void>;
  37757. /**
  37758. * Callback that will be called if an error occurs during shader compilation.
  37759. */
  37760. onError: Nullable<(effect: Effect, errors: string) => void>;
  37761. /**
  37762. * Callback that will be called when effect is bound.
  37763. */
  37764. onBind: Nullable<(effect: Effect) => void>;
  37765. /**
  37766. * Unique ID of the effect.
  37767. */
  37768. uniqueId: number;
  37769. /**
  37770. * Observable that will be called when the shader is compiled.
  37771. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37772. */
  37773. onCompileObservable: Observable<Effect>;
  37774. /**
  37775. * Observable that will be called if an error occurs during shader compilation.
  37776. */
  37777. onErrorObservable: Observable<Effect>;
  37778. /** @hidden */
  37779. _onBindObservable: Nullable<Observable<Effect>>;
  37780. /**
  37781. * @hidden
  37782. * Specifies if the effect was previously ready
  37783. */
  37784. _wasPreviouslyReady: boolean;
  37785. /**
  37786. * Observable that will be called when effect is bound.
  37787. */
  37788. get onBindObservable(): Observable<Effect>;
  37789. /** @hidden */
  37790. _bonesComputationForcedToCPU: boolean;
  37791. /** @hidden */
  37792. _multiTarget: boolean;
  37793. private static _uniqueIdSeed;
  37794. private _engine;
  37795. private _uniformBuffersNames;
  37796. private _uniformBuffersNamesList;
  37797. private _uniformsNames;
  37798. private _samplerList;
  37799. private _samplers;
  37800. private _isReady;
  37801. private _compilationError;
  37802. private _allFallbacksProcessed;
  37803. private _attributesNames;
  37804. private _attributes;
  37805. private _attributeLocationByName;
  37806. private _uniforms;
  37807. /**
  37808. * Key for the effect.
  37809. * @hidden
  37810. */
  37811. _key: string;
  37812. private _indexParameters;
  37813. private _fallbacks;
  37814. private _vertexSourceCode;
  37815. private _fragmentSourceCode;
  37816. private _vertexSourceCodeOverride;
  37817. private _fragmentSourceCodeOverride;
  37818. private _transformFeedbackVaryings;
  37819. private _rawVertexSourceCode;
  37820. private _rawFragmentSourceCode;
  37821. /**
  37822. * Compiled shader to webGL program.
  37823. * @hidden
  37824. */
  37825. _pipelineContext: Nullable<IPipelineContext>;
  37826. private _valueCache;
  37827. private static _baseCache;
  37828. /**
  37829. * Instantiates an effect.
  37830. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37831. * @param baseName Name of the effect.
  37832. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37833. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37834. * @param samplers List of sampler variables that will be passed to the shader.
  37835. * @param engine Engine to be used to render the effect
  37836. * @param defines Define statements to be added to the shader.
  37837. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37838. * @param onCompiled Callback that will be called when the shader is compiled.
  37839. * @param onError Callback that will be called if an error occurs during shader compilation.
  37840. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37841. */
  37842. 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);
  37843. private _useFinalCode;
  37844. /**
  37845. * Unique key for this effect
  37846. */
  37847. get key(): string;
  37848. /**
  37849. * If the effect has been compiled and prepared.
  37850. * @returns if the effect is compiled and prepared.
  37851. */
  37852. isReady(): boolean;
  37853. private _isReadyInternal;
  37854. /**
  37855. * The engine the effect was initialized with.
  37856. * @returns the engine.
  37857. */
  37858. getEngine(): Engine;
  37859. /**
  37860. * The pipeline context for this effect
  37861. * @returns the associated pipeline context
  37862. */
  37863. getPipelineContext(): Nullable<IPipelineContext>;
  37864. /**
  37865. * The set of names of attribute variables for the shader.
  37866. * @returns An array of attribute names.
  37867. */
  37868. getAttributesNames(): string[];
  37869. /**
  37870. * Returns the attribute at the given index.
  37871. * @param index The index of the attribute.
  37872. * @returns The location of the attribute.
  37873. */
  37874. getAttributeLocation(index: number): number;
  37875. /**
  37876. * Returns the attribute based on the name of the variable.
  37877. * @param name of the attribute to look up.
  37878. * @returns the attribute location.
  37879. */
  37880. getAttributeLocationByName(name: string): number;
  37881. /**
  37882. * The number of attributes.
  37883. * @returns the numnber of attributes.
  37884. */
  37885. getAttributesCount(): number;
  37886. /**
  37887. * Gets the index of a uniform variable.
  37888. * @param uniformName of the uniform to look up.
  37889. * @returns the index.
  37890. */
  37891. getUniformIndex(uniformName: string): number;
  37892. /**
  37893. * Returns the attribute based on the name of the variable.
  37894. * @param uniformName of the uniform to look up.
  37895. * @returns the location of the uniform.
  37896. */
  37897. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37898. /**
  37899. * Returns an array of sampler variable names
  37900. * @returns The array of sampler variable names.
  37901. */
  37902. getSamplers(): string[];
  37903. /**
  37904. * Returns an array of uniform variable names
  37905. * @returns The array of uniform variable names.
  37906. */
  37907. getUniformNames(): string[];
  37908. /**
  37909. * Returns an array of uniform buffer variable names
  37910. * @returns The array of uniform buffer variable names.
  37911. */
  37912. getUniformBuffersNames(): string[];
  37913. /**
  37914. * Returns the index parameters used to create the effect
  37915. * @returns The index parameters object
  37916. */
  37917. getIndexParameters(): any;
  37918. /**
  37919. * The error from the last compilation.
  37920. * @returns the error string.
  37921. */
  37922. getCompilationError(): string;
  37923. /**
  37924. * Gets a boolean indicating that all fallbacks were used during compilation
  37925. * @returns true if all fallbacks were used
  37926. */
  37927. allFallbacksProcessed(): boolean;
  37928. /**
  37929. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37930. * @param func The callback to be used.
  37931. */
  37932. executeWhenCompiled(func: (effect: Effect) => void): void;
  37933. private _checkIsReady;
  37934. private _loadShader;
  37935. /**
  37936. * Gets the vertex shader source code of this effect
  37937. */
  37938. get vertexSourceCode(): string;
  37939. /**
  37940. * Gets the fragment shader source code of this effect
  37941. */
  37942. get fragmentSourceCode(): string;
  37943. /**
  37944. * Gets the vertex shader source code before it has been processed by the preprocessor
  37945. */
  37946. get rawVertexSourceCode(): string;
  37947. /**
  37948. * Gets the fragment shader source code before it has been processed by the preprocessor
  37949. */
  37950. get rawFragmentSourceCode(): string;
  37951. /**
  37952. * Recompiles the webGL program
  37953. * @param vertexSourceCode The source code for the vertex shader.
  37954. * @param fragmentSourceCode The source code for the fragment shader.
  37955. * @param onCompiled Callback called when completed.
  37956. * @param onError Callback called on error.
  37957. * @hidden
  37958. */
  37959. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37960. /**
  37961. * Prepares the effect
  37962. * @hidden
  37963. */
  37964. _prepareEffect(): void;
  37965. private _getShaderCodeAndErrorLine;
  37966. private _processCompilationErrors;
  37967. /**
  37968. * Checks if the effect is supported. (Must be called after compilation)
  37969. */
  37970. get isSupported(): boolean;
  37971. /**
  37972. * Binds a texture to the engine to be used as output of the shader.
  37973. * @param channel Name of the output variable.
  37974. * @param texture Texture to bind.
  37975. * @hidden
  37976. */
  37977. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37978. /**
  37979. * Sets a texture on the engine to be used in the shader.
  37980. * @param channel Name of the sampler variable.
  37981. * @param texture Texture to set.
  37982. */
  37983. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37984. /**
  37985. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37986. * @param channel Name of the sampler variable.
  37987. * @param texture Texture to set.
  37988. */
  37989. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37990. /**
  37991. * Sets an array of textures on the engine to be used in the shader.
  37992. * @param channel Name of the variable.
  37993. * @param textures Textures to set.
  37994. */
  37995. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37996. /**
  37997. * 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)
  37998. * @param channel Name of the sampler variable.
  37999. * @param postProcess Post process to get the input texture from.
  38000. */
  38001. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38002. /**
  38003. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38004. * 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)
  38005. * @param channel Name of the sampler variable.
  38006. * @param postProcess Post process to get the output texture from.
  38007. */
  38008. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38009. /** @hidden */
  38010. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38011. /** @hidden */
  38012. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38013. /** @hidden */
  38014. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38015. /** @hidden */
  38016. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38017. /**
  38018. * Binds a buffer to a uniform.
  38019. * @param buffer Buffer to bind.
  38020. * @param name Name of the uniform variable to bind to.
  38021. */
  38022. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38023. /**
  38024. * Binds block to a uniform.
  38025. * @param blockName Name of the block to bind.
  38026. * @param index Index to bind.
  38027. */
  38028. bindUniformBlock(blockName: string, index: number): void;
  38029. /**
  38030. * Sets an interger value on a uniform variable.
  38031. * @param uniformName Name of the variable.
  38032. * @param value Value to be set.
  38033. * @returns this effect.
  38034. */
  38035. setInt(uniformName: string, value: number): Effect;
  38036. /**
  38037. * Sets an int array on a uniform variable.
  38038. * @param uniformName Name of the variable.
  38039. * @param array array to be set.
  38040. * @returns this effect.
  38041. */
  38042. setIntArray(uniformName: string, array: Int32Array): Effect;
  38043. /**
  38044. * 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)
  38045. * @param uniformName Name of the variable.
  38046. * @param array array to be set.
  38047. * @returns this effect.
  38048. */
  38049. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38050. /**
  38051. * 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)
  38052. * @param uniformName Name of the variable.
  38053. * @param array array to be set.
  38054. * @returns this effect.
  38055. */
  38056. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38057. /**
  38058. * 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)
  38059. * @param uniformName Name of the variable.
  38060. * @param array array to be set.
  38061. * @returns this effect.
  38062. */
  38063. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38064. /**
  38065. * Sets an float array on a uniform variable.
  38066. * @param uniformName Name of the variable.
  38067. * @param array array to be set.
  38068. * @returns this effect.
  38069. */
  38070. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38071. /**
  38072. * 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)
  38073. * @param uniformName Name of the variable.
  38074. * @param array array to be set.
  38075. * @returns this effect.
  38076. */
  38077. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38078. /**
  38079. * 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)
  38080. * @param uniformName Name of the variable.
  38081. * @param array array to be set.
  38082. * @returns this effect.
  38083. */
  38084. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38085. /**
  38086. * 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)
  38087. * @param uniformName Name of the variable.
  38088. * @param array array to be set.
  38089. * @returns this effect.
  38090. */
  38091. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38092. /**
  38093. * Sets an array on a uniform variable.
  38094. * @param uniformName Name of the variable.
  38095. * @param array array to be set.
  38096. * @returns this effect.
  38097. */
  38098. setArray(uniformName: string, array: number[]): Effect;
  38099. /**
  38100. * 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)
  38101. * @param uniformName Name of the variable.
  38102. * @param array array to be set.
  38103. * @returns this effect.
  38104. */
  38105. setArray2(uniformName: string, array: number[]): Effect;
  38106. /**
  38107. * 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)
  38108. * @param uniformName Name of the variable.
  38109. * @param array array to be set.
  38110. * @returns this effect.
  38111. */
  38112. setArray3(uniformName: string, array: number[]): Effect;
  38113. /**
  38114. * 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)
  38115. * @param uniformName Name of the variable.
  38116. * @param array array to be set.
  38117. * @returns this effect.
  38118. */
  38119. setArray4(uniformName: string, array: number[]): Effect;
  38120. /**
  38121. * Sets matrices on a uniform variable.
  38122. * @param uniformName Name of the variable.
  38123. * @param matrices matrices to be set.
  38124. * @returns this effect.
  38125. */
  38126. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38127. /**
  38128. * Sets matrix on a uniform variable.
  38129. * @param uniformName Name of the variable.
  38130. * @param matrix matrix to be set.
  38131. * @returns this effect.
  38132. */
  38133. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38134. /**
  38135. * 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)
  38136. * @param uniformName Name of the variable.
  38137. * @param matrix matrix to be set.
  38138. * @returns this effect.
  38139. */
  38140. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38141. /**
  38142. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38143. * @param uniformName Name of the variable.
  38144. * @param matrix matrix to be set.
  38145. * @returns this effect.
  38146. */
  38147. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38148. /**
  38149. * Sets a float on a uniform variable.
  38150. * @param uniformName Name of the variable.
  38151. * @param value value to be set.
  38152. * @returns this effect.
  38153. */
  38154. setFloat(uniformName: string, value: number): Effect;
  38155. /**
  38156. * Sets a boolean on a uniform variable.
  38157. * @param uniformName Name of the variable.
  38158. * @param bool value to be set.
  38159. * @returns this effect.
  38160. */
  38161. setBool(uniformName: string, bool: boolean): Effect;
  38162. /**
  38163. * Sets a Vector2 on a uniform variable.
  38164. * @param uniformName Name of the variable.
  38165. * @param vector2 vector2 to be set.
  38166. * @returns this effect.
  38167. */
  38168. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38169. /**
  38170. * Sets a float2 on a uniform variable.
  38171. * @param uniformName Name of the variable.
  38172. * @param x First float in float2.
  38173. * @param y Second float in float2.
  38174. * @returns this effect.
  38175. */
  38176. setFloat2(uniformName: string, x: number, y: number): Effect;
  38177. /**
  38178. * Sets a Vector3 on a uniform variable.
  38179. * @param uniformName Name of the variable.
  38180. * @param vector3 Value to be set.
  38181. * @returns this effect.
  38182. */
  38183. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38184. /**
  38185. * Sets a float3 on a uniform variable.
  38186. * @param uniformName Name of the variable.
  38187. * @param x First float in float3.
  38188. * @param y Second float in float3.
  38189. * @param z Third float in float3.
  38190. * @returns this effect.
  38191. */
  38192. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38193. /**
  38194. * Sets a Vector4 on a uniform variable.
  38195. * @param uniformName Name of the variable.
  38196. * @param vector4 Value to be set.
  38197. * @returns this effect.
  38198. */
  38199. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38200. /**
  38201. * Sets a float4 on a uniform variable.
  38202. * @param uniformName Name of the variable.
  38203. * @param x First float in float4.
  38204. * @param y Second float in float4.
  38205. * @param z Third float in float4.
  38206. * @param w Fourth float in float4.
  38207. * @returns this effect.
  38208. */
  38209. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38210. /**
  38211. * Sets a Color3 on a uniform variable.
  38212. * @param uniformName Name of the variable.
  38213. * @param color3 Value to be set.
  38214. * @returns this effect.
  38215. */
  38216. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38217. /**
  38218. * Sets a Color4 on a uniform variable.
  38219. * @param uniformName Name of the variable.
  38220. * @param color3 Value to be set.
  38221. * @param alpha Alpha value to be set.
  38222. * @returns this effect.
  38223. */
  38224. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38225. /**
  38226. * Sets a Color4 on a uniform variable
  38227. * @param uniformName defines the name of the variable
  38228. * @param color4 defines the value to be set
  38229. * @returns this effect.
  38230. */
  38231. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38232. /** Release all associated resources */
  38233. dispose(): void;
  38234. /**
  38235. * This function will add a new shader to the shader store
  38236. * @param name the name of the shader
  38237. * @param pixelShader optional pixel shader content
  38238. * @param vertexShader optional vertex shader content
  38239. */
  38240. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38241. /**
  38242. * Store of each shader (The can be looked up using effect.key)
  38243. */
  38244. static ShadersStore: {
  38245. [key: string]: string;
  38246. };
  38247. /**
  38248. * Store of each included file for a shader (The can be looked up using effect.key)
  38249. */
  38250. static IncludesShadersStore: {
  38251. [key: string]: string;
  38252. };
  38253. /**
  38254. * Resets the cache of effects.
  38255. */
  38256. static ResetCache(): void;
  38257. }
  38258. }
  38259. declare module BABYLON {
  38260. /**
  38261. * Interface used to describe the capabilities of the engine relatively to the current browser
  38262. */
  38263. export interface EngineCapabilities {
  38264. /** Maximum textures units per fragment shader */
  38265. maxTexturesImageUnits: number;
  38266. /** Maximum texture units per vertex shader */
  38267. maxVertexTextureImageUnits: number;
  38268. /** Maximum textures units in the entire pipeline */
  38269. maxCombinedTexturesImageUnits: number;
  38270. /** Maximum texture size */
  38271. maxTextureSize: number;
  38272. /** Maximum texture samples */
  38273. maxSamples?: number;
  38274. /** Maximum cube texture size */
  38275. maxCubemapTextureSize: number;
  38276. /** Maximum render texture size */
  38277. maxRenderTextureSize: number;
  38278. /** Maximum number of vertex attributes */
  38279. maxVertexAttribs: number;
  38280. /** Maximum number of varyings */
  38281. maxVaryingVectors: number;
  38282. /** Maximum number of uniforms per vertex shader */
  38283. maxVertexUniformVectors: number;
  38284. /** Maximum number of uniforms per fragment shader */
  38285. maxFragmentUniformVectors: number;
  38286. /** Defines if standard derivates (dx/dy) are supported */
  38287. standardDerivatives: boolean;
  38288. /** Defines if s3tc texture compression is supported */
  38289. s3tc?: WEBGL_compressed_texture_s3tc;
  38290. /** Defines if pvrtc texture compression is supported */
  38291. pvrtc: any;
  38292. /** Defines if etc1 texture compression is supported */
  38293. etc1: any;
  38294. /** Defines if etc2 texture compression is supported */
  38295. etc2: any;
  38296. /** Defines if astc texture compression is supported */
  38297. astc: any;
  38298. /** Defines if bptc texture compression is supported */
  38299. bptc: any;
  38300. /** Defines if float textures are supported */
  38301. textureFloat: boolean;
  38302. /** Defines if vertex array objects are supported */
  38303. vertexArrayObject: boolean;
  38304. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38305. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38306. /** Gets the maximum level of anisotropy supported */
  38307. maxAnisotropy: number;
  38308. /** Defines if instancing is supported */
  38309. instancedArrays: boolean;
  38310. /** Defines if 32 bits indices are supported */
  38311. uintIndices: boolean;
  38312. /** Defines if high precision shaders are supported */
  38313. highPrecisionShaderSupported: boolean;
  38314. /** Defines if depth reading in the fragment shader is supported */
  38315. fragmentDepthSupported: boolean;
  38316. /** Defines if float texture linear filtering is supported*/
  38317. textureFloatLinearFiltering: boolean;
  38318. /** Defines if rendering to float textures is supported */
  38319. textureFloatRender: boolean;
  38320. /** Defines if half float textures are supported*/
  38321. textureHalfFloat: boolean;
  38322. /** Defines if half float texture linear filtering is supported*/
  38323. textureHalfFloatLinearFiltering: boolean;
  38324. /** Defines if rendering to half float textures is supported */
  38325. textureHalfFloatRender: boolean;
  38326. /** Defines if textureLOD shader command is supported */
  38327. textureLOD: boolean;
  38328. /** Defines if draw buffers extension is supported */
  38329. drawBuffersExtension: boolean;
  38330. /** Defines if depth textures are supported */
  38331. depthTextureExtension: boolean;
  38332. /** Defines if float color buffer are supported */
  38333. colorBufferFloat: boolean;
  38334. /** Gets disjoint timer query extension (null if not supported) */
  38335. timerQuery?: EXT_disjoint_timer_query;
  38336. /** Defines if timestamp can be used with timer query */
  38337. canUseTimestampForTimerQuery: boolean;
  38338. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38339. multiview?: any;
  38340. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38341. oculusMultiview?: any;
  38342. /** Function used to let the system compiles shaders in background */
  38343. parallelShaderCompile?: {
  38344. COMPLETION_STATUS_KHR: number;
  38345. };
  38346. /** Max number of texture samples for MSAA */
  38347. maxMSAASamples: number;
  38348. /** Defines if the blend min max extension is supported */
  38349. blendMinMax: boolean;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /**
  38354. * @hidden
  38355. **/
  38356. export class DepthCullingState {
  38357. private _isDepthTestDirty;
  38358. private _isDepthMaskDirty;
  38359. private _isDepthFuncDirty;
  38360. private _isCullFaceDirty;
  38361. private _isCullDirty;
  38362. private _isZOffsetDirty;
  38363. private _isFrontFaceDirty;
  38364. private _depthTest;
  38365. private _depthMask;
  38366. private _depthFunc;
  38367. private _cull;
  38368. private _cullFace;
  38369. private _zOffset;
  38370. private _frontFace;
  38371. /**
  38372. * Initializes the state.
  38373. */
  38374. constructor();
  38375. get isDirty(): boolean;
  38376. get zOffset(): number;
  38377. set zOffset(value: number);
  38378. get cullFace(): Nullable<number>;
  38379. set cullFace(value: Nullable<number>);
  38380. get cull(): Nullable<boolean>;
  38381. set cull(value: Nullable<boolean>);
  38382. get depthFunc(): Nullable<number>;
  38383. set depthFunc(value: Nullable<number>);
  38384. get depthMask(): boolean;
  38385. set depthMask(value: boolean);
  38386. get depthTest(): boolean;
  38387. set depthTest(value: boolean);
  38388. get frontFace(): Nullable<number>;
  38389. set frontFace(value: Nullable<number>);
  38390. reset(): void;
  38391. apply(gl: WebGLRenderingContext): void;
  38392. }
  38393. }
  38394. declare module BABYLON {
  38395. /**
  38396. * @hidden
  38397. **/
  38398. export class StencilState {
  38399. /** 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 */
  38400. static readonly ALWAYS: number;
  38401. /** Passed to stencilOperation to specify that stencil value must be kept */
  38402. static readonly KEEP: number;
  38403. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38404. static readonly REPLACE: number;
  38405. private _isStencilTestDirty;
  38406. private _isStencilMaskDirty;
  38407. private _isStencilFuncDirty;
  38408. private _isStencilOpDirty;
  38409. private _stencilTest;
  38410. private _stencilMask;
  38411. private _stencilFunc;
  38412. private _stencilFuncRef;
  38413. private _stencilFuncMask;
  38414. private _stencilOpStencilFail;
  38415. private _stencilOpDepthFail;
  38416. private _stencilOpStencilDepthPass;
  38417. get isDirty(): boolean;
  38418. get stencilFunc(): number;
  38419. set stencilFunc(value: number);
  38420. get stencilFuncRef(): number;
  38421. set stencilFuncRef(value: number);
  38422. get stencilFuncMask(): number;
  38423. set stencilFuncMask(value: number);
  38424. get stencilOpStencilFail(): number;
  38425. set stencilOpStencilFail(value: number);
  38426. get stencilOpDepthFail(): number;
  38427. set stencilOpDepthFail(value: number);
  38428. get stencilOpStencilDepthPass(): number;
  38429. set stencilOpStencilDepthPass(value: number);
  38430. get stencilMask(): number;
  38431. set stencilMask(value: number);
  38432. get stencilTest(): boolean;
  38433. set stencilTest(value: boolean);
  38434. constructor();
  38435. reset(): void;
  38436. apply(gl: WebGLRenderingContext): void;
  38437. }
  38438. }
  38439. declare module BABYLON {
  38440. /**
  38441. * @hidden
  38442. **/
  38443. export class AlphaState {
  38444. private _isAlphaBlendDirty;
  38445. private _isBlendFunctionParametersDirty;
  38446. private _isBlendEquationParametersDirty;
  38447. private _isBlendConstantsDirty;
  38448. private _alphaBlend;
  38449. private _blendFunctionParameters;
  38450. private _blendEquationParameters;
  38451. private _blendConstants;
  38452. /**
  38453. * Initializes the state.
  38454. */
  38455. constructor();
  38456. get isDirty(): boolean;
  38457. get alphaBlend(): boolean;
  38458. set alphaBlend(value: boolean);
  38459. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38460. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38461. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38462. reset(): void;
  38463. apply(gl: WebGLRenderingContext): void;
  38464. }
  38465. }
  38466. declare module BABYLON {
  38467. /** @hidden */
  38468. export class WebGLShaderProcessor implements IShaderProcessor {
  38469. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38470. }
  38471. }
  38472. declare module BABYLON {
  38473. /** @hidden */
  38474. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38475. attributeProcessor(attribute: string): string;
  38476. varyingProcessor(varying: string, isFragment: boolean): string;
  38477. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38478. }
  38479. }
  38480. declare module BABYLON {
  38481. /**
  38482. * Interface for attribute information associated with buffer instanciation
  38483. */
  38484. export interface InstancingAttributeInfo {
  38485. /**
  38486. * Name of the GLSL attribute
  38487. * if attribute index is not specified, this is used to retrieve the index from the effect
  38488. */
  38489. attributeName: string;
  38490. /**
  38491. * Index/offset of the attribute in the vertex shader
  38492. * if not specified, this will be computes from the name.
  38493. */
  38494. index?: number;
  38495. /**
  38496. * size of the attribute, 1, 2, 3 or 4
  38497. */
  38498. attributeSize: number;
  38499. /**
  38500. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38501. */
  38502. offset: number;
  38503. /**
  38504. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38505. * default to 1
  38506. */
  38507. divisor?: number;
  38508. /**
  38509. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38510. * default is FLOAT
  38511. */
  38512. attributeType?: number;
  38513. /**
  38514. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38515. */
  38516. normalized?: boolean;
  38517. }
  38518. }
  38519. declare module BABYLON {
  38520. interface ThinEngine {
  38521. /**
  38522. * Update a video texture
  38523. * @param texture defines the texture to update
  38524. * @param video defines the video element to use
  38525. * @param invertY defines if data must be stored with Y axis inverted
  38526. */
  38527. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38528. }
  38529. }
  38530. declare module BABYLON {
  38531. interface ThinEngine {
  38532. /**
  38533. * Creates a dynamic texture
  38534. * @param width defines the width of the texture
  38535. * @param height defines the height of the texture
  38536. * @param generateMipMaps defines if the engine should generate the mip levels
  38537. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38538. * @returns the dynamic texture inside an InternalTexture
  38539. */
  38540. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38541. /**
  38542. * Update the content of a dynamic texture
  38543. * @param texture defines the texture to update
  38544. * @param canvas defines the canvas containing the source
  38545. * @param invertY defines if data must be stored with Y axis inverted
  38546. * @param premulAlpha defines if alpha is stored as premultiplied
  38547. * @param format defines the format of the data
  38548. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38549. */
  38550. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. /**
  38555. * Settings for finer control over video usage
  38556. */
  38557. export interface VideoTextureSettings {
  38558. /**
  38559. * Applies `autoplay` to video, if specified
  38560. */
  38561. autoPlay?: boolean;
  38562. /**
  38563. * Applies `muted` to video, if specified
  38564. */
  38565. muted?: boolean;
  38566. /**
  38567. * Applies `loop` to video, if specified
  38568. */
  38569. loop?: boolean;
  38570. /**
  38571. * Automatically updates internal texture from video at every frame in the render loop
  38572. */
  38573. autoUpdateTexture: boolean;
  38574. /**
  38575. * Image src displayed during the video loading or until the user interacts with the video.
  38576. */
  38577. poster?: string;
  38578. }
  38579. /**
  38580. * If you want to display a video in your scene, this is the special texture for that.
  38581. * This special texture works similar to other textures, with the exception of a few parameters.
  38582. * @see https://doc.babylonjs.com/how_to/video_texture
  38583. */
  38584. export class VideoTexture extends Texture {
  38585. /**
  38586. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38587. */
  38588. readonly autoUpdateTexture: boolean;
  38589. /**
  38590. * The video instance used by the texture internally
  38591. */
  38592. readonly video: HTMLVideoElement;
  38593. private _onUserActionRequestedObservable;
  38594. /**
  38595. * Event triggerd when a dom action is required by the user to play the video.
  38596. * This happens due to recent changes in browser policies preventing video to auto start.
  38597. */
  38598. get onUserActionRequestedObservable(): Observable<Texture>;
  38599. private _generateMipMaps;
  38600. private _stillImageCaptured;
  38601. private _displayingPosterTexture;
  38602. private _settings;
  38603. private _createInternalTextureOnEvent;
  38604. private _frameId;
  38605. private _currentSrc;
  38606. /**
  38607. * Creates a video texture.
  38608. * If you want to display a video in your scene, this is the special texture for that.
  38609. * This special texture works similar to other textures, with the exception of a few parameters.
  38610. * @see https://doc.babylonjs.com/how_to/video_texture
  38611. * @param name optional name, will detect from video source, if not defined
  38612. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38613. * @param scene is obviously the current scene.
  38614. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38615. * @param invertY is false by default but can be used to invert video on Y axis
  38616. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38617. * @param settings allows finer control over video usage
  38618. */
  38619. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38620. private _getName;
  38621. private _getVideo;
  38622. private _createInternalTexture;
  38623. private reset;
  38624. /**
  38625. * @hidden Internal method to initiate `update`.
  38626. */
  38627. _rebuild(): void;
  38628. /**
  38629. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38630. */
  38631. update(): void;
  38632. /**
  38633. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38634. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38635. */
  38636. updateTexture(isVisible: boolean): void;
  38637. protected _updateInternalTexture: () => void;
  38638. /**
  38639. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38640. * @param url New url.
  38641. */
  38642. updateURL(url: string): void;
  38643. /**
  38644. * Clones the texture.
  38645. * @returns the cloned texture
  38646. */
  38647. clone(): VideoTexture;
  38648. /**
  38649. * Dispose the texture and release its associated resources.
  38650. */
  38651. dispose(): void;
  38652. /**
  38653. * Creates a video texture straight from a stream.
  38654. * @param scene Define the scene the texture should be created in
  38655. * @param stream Define the stream the texture should be created from
  38656. * @returns The created video texture as a promise
  38657. */
  38658. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38659. /**
  38660. * Creates a video texture straight from your WebCam video feed.
  38661. * @param scene Define the scene the texture should be created in
  38662. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38663. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38664. * @returns The created video texture as a promise
  38665. */
  38666. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38667. minWidth: number;
  38668. maxWidth: number;
  38669. minHeight: number;
  38670. maxHeight: number;
  38671. deviceId: string;
  38672. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38673. /**
  38674. * Creates a video texture straight from your WebCam video feed.
  38675. * @param scene Define the scene the texture should be created in
  38676. * @param onReady Define a callback to triggered once the texture will be ready
  38677. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38678. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38679. */
  38680. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38681. minWidth: number;
  38682. maxWidth: number;
  38683. minHeight: number;
  38684. maxHeight: number;
  38685. deviceId: string;
  38686. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38687. }
  38688. }
  38689. declare module BABYLON {
  38690. /**
  38691. * Defines the interface used by objects working like Scene
  38692. * @hidden
  38693. */
  38694. export interface ISceneLike {
  38695. _addPendingData(data: any): void;
  38696. _removePendingData(data: any): void;
  38697. offlineProvider: IOfflineProvider;
  38698. }
  38699. /**
  38700. * Information about the current host
  38701. */
  38702. export interface HostInformation {
  38703. /**
  38704. * Defines if the current host is a mobile
  38705. */
  38706. isMobile: boolean;
  38707. }
  38708. /** Interface defining initialization parameters for Engine class */
  38709. export interface EngineOptions extends WebGLContextAttributes {
  38710. /**
  38711. * Defines if the engine should no exceed a specified device ratio
  38712. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38713. */
  38714. limitDeviceRatio?: number;
  38715. /**
  38716. * Defines if webvr should be enabled automatically
  38717. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38718. */
  38719. autoEnableWebVR?: boolean;
  38720. /**
  38721. * Defines if webgl2 should be turned off even if supported
  38722. * @see https://doc.babylonjs.com/features/webgl2
  38723. */
  38724. disableWebGL2Support?: boolean;
  38725. /**
  38726. * Defines if webaudio should be initialized as well
  38727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38728. */
  38729. audioEngine?: boolean;
  38730. /**
  38731. * Defines if animations should run using a deterministic lock step
  38732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38733. */
  38734. deterministicLockstep?: boolean;
  38735. /** Defines the maximum steps to use with deterministic lock step mode */
  38736. lockstepMaxSteps?: number;
  38737. /** Defines the seconds between each deterministic lock step */
  38738. timeStep?: number;
  38739. /**
  38740. * Defines that engine should ignore context lost events
  38741. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38742. */
  38743. doNotHandleContextLost?: boolean;
  38744. /**
  38745. * Defines that engine should ignore modifying touch action attribute and style
  38746. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38747. */
  38748. doNotHandleTouchAction?: boolean;
  38749. /**
  38750. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38751. */
  38752. useHighPrecisionFloats?: boolean;
  38753. /**
  38754. * Make the canvas XR Compatible for XR sessions
  38755. */
  38756. xrCompatible?: boolean;
  38757. /**
  38758. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38759. */
  38760. useHighPrecisionMatrix?: boolean;
  38761. /**
  38762. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38763. */
  38764. failIfMajorPerformanceCaveat?: boolean;
  38765. }
  38766. /**
  38767. * The base engine class (root of all engines)
  38768. */
  38769. export class ThinEngine {
  38770. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38771. static ExceptionList: ({
  38772. key: string;
  38773. capture: string;
  38774. captureConstraint: number;
  38775. targets: string[];
  38776. } | {
  38777. key: string;
  38778. capture: null;
  38779. captureConstraint: null;
  38780. targets: string[];
  38781. })[];
  38782. /** @hidden */
  38783. static _TextureLoaders: IInternalTextureLoader[];
  38784. /**
  38785. * Returns the current npm package of the sdk
  38786. */
  38787. static get NpmPackage(): string;
  38788. /**
  38789. * Returns the current version of the framework
  38790. */
  38791. static get Version(): string;
  38792. /**
  38793. * Returns a string describing the current engine
  38794. */
  38795. get description(): string;
  38796. /**
  38797. * Gets or sets the epsilon value used by collision engine
  38798. */
  38799. static CollisionsEpsilon: number;
  38800. /**
  38801. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38802. */
  38803. static get ShadersRepository(): string;
  38804. static set ShadersRepository(value: string);
  38805. /** @hidden */
  38806. _shaderProcessor: IShaderProcessor;
  38807. /**
  38808. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38809. */
  38810. forcePOTTextures: boolean;
  38811. /**
  38812. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38813. */
  38814. isFullscreen: boolean;
  38815. /**
  38816. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38817. */
  38818. cullBackFaces: boolean;
  38819. /**
  38820. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38821. */
  38822. renderEvenInBackground: boolean;
  38823. /**
  38824. * Gets or sets a boolean indicating that cache can be kept between frames
  38825. */
  38826. preventCacheWipeBetweenFrames: boolean;
  38827. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38828. validateShaderPrograms: boolean;
  38829. /**
  38830. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38831. * This can provide greater z depth for distant objects.
  38832. */
  38833. useReverseDepthBuffer: boolean;
  38834. /**
  38835. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38836. */
  38837. disableUniformBuffers: boolean;
  38838. /** @hidden */
  38839. _uniformBuffers: UniformBuffer[];
  38840. /**
  38841. * Gets a boolean indicating that the engine supports uniform buffers
  38842. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38843. */
  38844. get supportsUniformBuffers(): boolean;
  38845. /** @hidden */
  38846. _gl: WebGLRenderingContext;
  38847. /** @hidden */
  38848. _webGLVersion: number;
  38849. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38850. protected _windowIsBackground: boolean;
  38851. protected _creationOptions: EngineOptions;
  38852. protected _highPrecisionShadersAllowed: boolean;
  38853. /** @hidden */
  38854. get _shouldUseHighPrecisionShader(): boolean;
  38855. /**
  38856. * Gets a boolean indicating that only power of 2 textures are supported
  38857. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38858. */
  38859. get needPOTTextures(): boolean;
  38860. /** @hidden */
  38861. _badOS: boolean;
  38862. /** @hidden */
  38863. _badDesktopOS: boolean;
  38864. private _hardwareScalingLevel;
  38865. /** @hidden */
  38866. _caps: EngineCapabilities;
  38867. private _isStencilEnable;
  38868. private _glVersion;
  38869. private _glRenderer;
  38870. private _glVendor;
  38871. /** @hidden */
  38872. _videoTextureSupported: boolean;
  38873. protected _renderingQueueLaunched: boolean;
  38874. protected _activeRenderLoops: (() => void)[];
  38875. /**
  38876. * Observable signaled when a context lost event is raised
  38877. */
  38878. onContextLostObservable: Observable<ThinEngine>;
  38879. /**
  38880. * Observable signaled when a context restored event is raised
  38881. */
  38882. onContextRestoredObservable: Observable<ThinEngine>;
  38883. private _onContextLost;
  38884. private _onContextRestored;
  38885. protected _contextWasLost: boolean;
  38886. /** @hidden */
  38887. _doNotHandleContextLost: boolean;
  38888. /**
  38889. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38891. */
  38892. get doNotHandleContextLost(): boolean;
  38893. set doNotHandleContextLost(value: boolean);
  38894. /**
  38895. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38896. */
  38897. disableVertexArrayObjects: boolean;
  38898. /** @hidden */
  38899. protected _colorWrite: boolean;
  38900. /** @hidden */
  38901. protected _colorWriteChanged: boolean;
  38902. /** @hidden */
  38903. protected _depthCullingState: DepthCullingState;
  38904. /** @hidden */
  38905. protected _stencilState: StencilState;
  38906. /** @hidden */
  38907. _alphaState: AlphaState;
  38908. /** @hidden */
  38909. _alphaMode: number;
  38910. /** @hidden */
  38911. _alphaEquation: number;
  38912. /** @hidden */
  38913. _internalTexturesCache: InternalTexture[];
  38914. /** @hidden */
  38915. protected _activeChannel: number;
  38916. private _currentTextureChannel;
  38917. /** @hidden */
  38918. protected _boundTexturesCache: {
  38919. [key: string]: Nullable<InternalTexture>;
  38920. };
  38921. /** @hidden */
  38922. protected _currentEffect: Nullable<Effect>;
  38923. /** @hidden */
  38924. protected _currentProgram: Nullable<WebGLProgram>;
  38925. private _compiledEffects;
  38926. private _vertexAttribArraysEnabled;
  38927. /** @hidden */
  38928. protected _cachedViewport: Nullable<IViewportLike>;
  38929. private _cachedVertexArrayObject;
  38930. /** @hidden */
  38931. protected _cachedVertexBuffers: any;
  38932. /** @hidden */
  38933. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38934. /** @hidden */
  38935. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38936. /** @hidden */
  38937. _currentRenderTarget: Nullable<InternalTexture>;
  38938. private _uintIndicesCurrentlySet;
  38939. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38940. /** @hidden */
  38941. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38942. /** @hidden */
  38943. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38944. private _currentBufferPointers;
  38945. private _currentInstanceLocations;
  38946. private _currentInstanceBuffers;
  38947. private _textureUnits;
  38948. /** @hidden */
  38949. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38950. /** @hidden */
  38951. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38952. /** @hidden */
  38953. _boundRenderFunction: any;
  38954. private _vaoRecordInProgress;
  38955. private _mustWipeVertexAttributes;
  38956. private _emptyTexture;
  38957. private _emptyCubeTexture;
  38958. private _emptyTexture3D;
  38959. private _emptyTexture2DArray;
  38960. /** @hidden */
  38961. _frameHandler: number;
  38962. private _nextFreeTextureSlots;
  38963. private _maxSimultaneousTextures;
  38964. private _activeRequests;
  38965. /** @hidden */
  38966. _transformTextureUrl: Nullable<(url: string) => string>;
  38967. /**
  38968. * Gets information about the current host
  38969. */
  38970. hostInformation: HostInformation;
  38971. protected get _supportsHardwareTextureRescaling(): boolean;
  38972. private _framebufferDimensionsObject;
  38973. /**
  38974. * sets the object from which width and height will be taken from when getting render width and height
  38975. * Will fallback to the gl object
  38976. * @param dimensions the framebuffer width and height that will be used.
  38977. */
  38978. set framebufferDimensionsObject(dimensions: Nullable<{
  38979. framebufferWidth: number;
  38980. framebufferHeight: number;
  38981. }>);
  38982. /**
  38983. * Gets the current viewport
  38984. */
  38985. get currentViewport(): Nullable<IViewportLike>;
  38986. /**
  38987. * Gets the default empty texture
  38988. */
  38989. get emptyTexture(): InternalTexture;
  38990. /**
  38991. * Gets the default empty 3D texture
  38992. */
  38993. get emptyTexture3D(): InternalTexture;
  38994. /**
  38995. * Gets the default empty 2D array texture
  38996. */
  38997. get emptyTexture2DArray(): InternalTexture;
  38998. /**
  38999. * Gets the default empty cube texture
  39000. */
  39001. get emptyCubeTexture(): InternalTexture;
  39002. /**
  39003. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39004. */
  39005. readonly premultipliedAlpha: boolean;
  39006. /**
  39007. * Observable event triggered before each texture is initialized
  39008. */
  39009. onBeforeTextureInitObservable: Observable<Texture>;
  39010. /**
  39011. * Creates a new engine
  39012. * @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
  39013. * @param antialias defines enable antialiasing (default: false)
  39014. * @param options defines further options to be sent to the getContext() function
  39015. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39016. */
  39017. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39018. private _rebuildInternalTextures;
  39019. private _rebuildEffects;
  39020. /**
  39021. * Gets a boolean indicating if all created effects are ready
  39022. * @returns true if all effects are ready
  39023. */
  39024. areAllEffectsReady(): boolean;
  39025. protected _rebuildBuffers(): void;
  39026. protected _initGLContext(): void;
  39027. /**
  39028. * Gets version of the current webGL context
  39029. */
  39030. get webGLVersion(): number;
  39031. /**
  39032. * Gets a string identifying the name of the class
  39033. * @returns "Engine" string
  39034. */
  39035. getClassName(): string;
  39036. /**
  39037. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39038. */
  39039. get isStencilEnable(): boolean;
  39040. /** @hidden */
  39041. _prepareWorkingCanvas(): void;
  39042. /**
  39043. * Reset the texture cache to empty state
  39044. */
  39045. resetTextureCache(): void;
  39046. /**
  39047. * Gets an object containing information about the current webGL context
  39048. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39049. */
  39050. getGlInfo(): {
  39051. vendor: string;
  39052. renderer: string;
  39053. version: string;
  39054. };
  39055. /**
  39056. * Defines the hardware scaling level.
  39057. * By default the hardware scaling level is computed from the window device ratio.
  39058. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  39059. * @param level defines the level to use
  39060. */
  39061. setHardwareScalingLevel(level: number): void;
  39062. /**
  39063. * Gets the current hardware scaling level.
  39064. * By default the hardware scaling level is computed from the window device ratio.
  39065. * 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.
  39066. * @returns a number indicating the current hardware scaling level
  39067. */
  39068. getHardwareScalingLevel(): number;
  39069. /**
  39070. * Gets the list of loaded textures
  39071. * @returns an array containing all loaded textures
  39072. */
  39073. getLoadedTexturesCache(): InternalTexture[];
  39074. /**
  39075. * Gets the object containing all engine capabilities
  39076. * @returns the EngineCapabilities object
  39077. */
  39078. getCaps(): EngineCapabilities;
  39079. /**
  39080. * stop executing a render loop function and remove it from the execution array
  39081. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39082. */
  39083. stopRenderLoop(renderFunction?: () => void): void;
  39084. /** @hidden */
  39085. _renderLoop(): void;
  39086. /**
  39087. * Gets the HTML canvas attached with the current webGL context
  39088. * @returns a HTML canvas
  39089. */
  39090. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39091. /**
  39092. * Gets host window
  39093. * @returns the host window object
  39094. */
  39095. getHostWindow(): Nullable<Window>;
  39096. /**
  39097. * Gets the current render width
  39098. * @param useScreen defines if screen size must be used (or the current render target if any)
  39099. * @returns a number defining the current render width
  39100. */
  39101. getRenderWidth(useScreen?: boolean): number;
  39102. /**
  39103. * Gets the current render height
  39104. * @param useScreen defines if screen size must be used (or the current render target if any)
  39105. * @returns a number defining the current render height
  39106. */
  39107. getRenderHeight(useScreen?: boolean): number;
  39108. /**
  39109. * Can be used to override the current requestAnimationFrame requester.
  39110. * @hidden
  39111. */
  39112. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39113. /**
  39114. * Register and execute a render loop. The engine can have more than one render function
  39115. * @param renderFunction defines the function to continuously execute
  39116. */
  39117. runRenderLoop(renderFunction: () => void): void;
  39118. /**
  39119. * Clear the current render buffer or the current render target (if any is set up)
  39120. * @param color defines the color to use
  39121. * @param backBuffer defines if the back buffer must be cleared
  39122. * @param depth defines if the depth buffer must be cleared
  39123. * @param stencil defines if the stencil buffer must be cleared
  39124. */
  39125. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39126. private _viewportCached;
  39127. /** @hidden */
  39128. _viewport(x: number, y: number, width: number, height: number): void;
  39129. /**
  39130. * Set the WebGL's viewport
  39131. * @param viewport defines the viewport element to be used
  39132. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39133. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39134. */
  39135. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39136. /**
  39137. * Begin a new frame
  39138. */
  39139. beginFrame(): void;
  39140. /**
  39141. * Enf the current frame
  39142. */
  39143. endFrame(): void;
  39144. /**
  39145. * Resize the view according to the canvas' size
  39146. */
  39147. resize(): void;
  39148. /**
  39149. * Force a specific size of the canvas
  39150. * @param width defines the new canvas' width
  39151. * @param height defines the new canvas' height
  39152. * @returns true if the size was changed
  39153. */
  39154. setSize(width: number, height: number): boolean;
  39155. /**
  39156. * Binds the frame buffer to the specified texture.
  39157. * @param texture The texture to render to or null for the default canvas
  39158. * @param faceIndex The face of the texture to render to in case of cube texture
  39159. * @param requiredWidth The width of the target to render to
  39160. * @param requiredHeight The height of the target to render to
  39161. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39162. * @param lodLevel defines the lod level to bind to the frame buffer
  39163. * @param layer defines the 2d array index to bind to frame buffer to
  39164. */
  39165. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39166. /** @hidden */
  39167. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39168. /**
  39169. * Unbind the current render target texture from the webGL context
  39170. * @param texture defines the render target texture to unbind
  39171. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39172. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39173. */
  39174. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39175. /**
  39176. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39177. */
  39178. flushFramebuffer(): void;
  39179. /**
  39180. * Unbind the current render target and bind the default framebuffer
  39181. */
  39182. restoreDefaultFramebuffer(): void;
  39183. /** @hidden */
  39184. protected _resetVertexBufferBinding(): void;
  39185. /**
  39186. * Creates a vertex buffer
  39187. * @param data the data for the vertex buffer
  39188. * @returns the new WebGL static buffer
  39189. */
  39190. createVertexBuffer(data: DataArray): DataBuffer;
  39191. private _createVertexBuffer;
  39192. /**
  39193. * Creates a dynamic vertex buffer
  39194. * @param data the data for the dynamic vertex buffer
  39195. * @returns the new WebGL dynamic buffer
  39196. */
  39197. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39198. protected _resetIndexBufferBinding(): void;
  39199. /**
  39200. * Creates a new index buffer
  39201. * @param indices defines the content of the index buffer
  39202. * @param updatable defines if the index buffer must be updatable
  39203. * @returns a new webGL buffer
  39204. */
  39205. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39206. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39207. /**
  39208. * Bind a webGL buffer to the webGL context
  39209. * @param buffer defines the buffer to bind
  39210. */
  39211. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39212. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39213. private bindBuffer;
  39214. /**
  39215. * update the bound buffer with the given data
  39216. * @param data defines the data to update
  39217. */
  39218. updateArrayBuffer(data: Float32Array): void;
  39219. private _vertexAttribPointer;
  39220. /** @hidden */
  39221. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39222. private _bindVertexBuffersAttributes;
  39223. /**
  39224. * Records a vertex array object
  39225. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39226. * @param vertexBuffers defines the list of vertex buffers to store
  39227. * @param indexBuffer defines the index buffer to store
  39228. * @param effect defines the effect to store
  39229. * @returns the new vertex array object
  39230. */
  39231. recordVertexArrayObject(vertexBuffers: {
  39232. [key: string]: VertexBuffer;
  39233. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39234. /**
  39235. * Bind a specific vertex array object
  39236. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39237. * @param vertexArrayObject defines the vertex array object to bind
  39238. * @param indexBuffer defines the index buffer to bind
  39239. */
  39240. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39241. /**
  39242. * Bind webGl buffers directly to the webGL context
  39243. * @param vertexBuffer defines the vertex buffer to bind
  39244. * @param indexBuffer defines the index buffer to bind
  39245. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39246. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39247. * @param effect defines the effect associated with the vertex buffer
  39248. */
  39249. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39250. private _unbindVertexArrayObject;
  39251. /**
  39252. * Bind a list of vertex buffers to the webGL context
  39253. * @param vertexBuffers defines the list of vertex buffers to bind
  39254. * @param indexBuffer defines the index buffer to bind
  39255. * @param effect defines the effect associated with the vertex buffers
  39256. */
  39257. bindBuffers(vertexBuffers: {
  39258. [key: string]: Nullable<VertexBuffer>;
  39259. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39260. /**
  39261. * Unbind all instance attributes
  39262. */
  39263. unbindInstanceAttributes(): void;
  39264. /**
  39265. * Release and free the memory of a vertex array object
  39266. * @param vao defines the vertex array object to delete
  39267. */
  39268. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39269. /** @hidden */
  39270. _releaseBuffer(buffer: DataBuffer): boolean;
  39271. protected _deleteBuffer(buffer: DataBuffer): void;
  39272. /**
  39273. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39274. * @param instancesBuffer defines the webGL buffer to update and bind
  39275. * @param data defines the data to store in the buffer
  39276. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39277. */
  39278. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39279. /**
  39280. * Bind the content of a webGL buffer used with instantiation
  39281. * @param instancesBuffer defines the webGL buffer to bind
  39282. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39283. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39284. */
  39285. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39286. /**
  39287. * Disable the instance attribute corresponding to the name in parameter
  39288. * @param name defines the name of the attribute to disable
  39289. */
  39290. disableInstanceAttributeByName(name: string): void;
  39291. /**
  39292. * Disable the instance attribute corresponding to the location in parameter
  39293. * @param attributeLocation defines the attribute location of the attribute to disable
  39294. */
  39295. disableInstanceAttribute(attributeLocation: number): void;
  39296. /**
  39297. * Disable the attribute corresponding to the location in parameter
  39298. * @param attributeLocation defines the attribute location of the attribute to disable
  39299. */
  39300. disableAttributeByIndex(attributeLocation: number): void;
  39301. /**
  39302. * Send a draw order
  39303. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39304. * @param indexStart defines the starting index
  39305. * @param indexCount defines the number of index to draw
  39306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39307. */
  39308. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39309. /**
  39310. * Draw a list of points
  39311. * @param verticesStart defines the index of first vertex to draw
  39312. * @param verticesCount defines the count of vertices to draw
  39313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39314. */
  39315. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39316. /**
  39317. * Draw a list of unindexed primitives
  39318. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39319. * @param verticesStart defines the index of first vertex to draw
  39320. * @param verticesCount defines the count of vertices to draw
  39321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39322. */
  39323. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39324. /**
  39325. * Draw a list of indexed primitives
  39326. * @param fillMode defines the primitive to use
  39327. * @param indexStart defines the starting index
  39328. * @param indexCount defines the number of index to draw
  39329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39330. */
  39331. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39332. /**
  39333. * Draw a list of unindexed primitives
  39334. * @param fillMode defines the primitive to use
  39335. * @param verticesStart defines the index of first vertex to draw
  39336. * @param verticesCount defines the count of vertices to draw
  39337. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39338. */
  39339. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39340. private _drawMode;
  39341. /** @hidden */
  39342. protected _reportDrawCall(): void;
  39343. /** @hidden */
  39344. _releaseEffect(effect: Effect): void;
  39345. /** @hidden */
  39346. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39347. /**
  39348. * Create a new effect (used to store vertex/fragment shaders)
  39349. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39350. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39351. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39352. * @param samplers defines an array of string used to represent textures
  39353. * @param defines defines the string containing the defines to use to compile the shaders
  39354. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39355. * @param onCompiled defines a function to call when the effect creation is successful
  39356. * @param onError defines a function to call when the effect creation has failed
  39357. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39358. * @returns the new Effect
  39359. */
  39360. 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;
  39361. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39362. private _compileShader;
  39363. private _compileRawShader;
  39364. /** @hidden */
  39365. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39366. /**
  39367. * Directly creates a webGL program
  39368. * @param pipelineContext defines the pipeline context to attach to
  39369. * @param vertexCode defines the vertex shader code to use
  39370. * @param fragmentCode defines the fragment shader code to use
  39371. * @param context defines the webGL context to use (if not set, the current one will be used)
  39372. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39373. * @returns the new webGL program
  39374. */
  39375. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39376. /**
  39377. * Creates a webGL program
  39378. * @param pipelineContext defines the pipeline context to attach to
  39379. * @param vertexCode defines the vertex shader code to use
  39380. * @param fragmentCode defines the fragment shader code to use
  39381. * @param defines defines the string containing the defines to use to compile the shaders
  39382. * @param context defines the webGL context to use (if not set, the current one will be used)
  39383. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39384. * @returns the new webGL program
  39385. */
  39386. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39387. /**
  39388. * Creates a new pipeline context
  39389. * @returns the new pipeline
  39390. */
  39391. createPipelineContext(): IPipelineContext;
  39392. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39393. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39394. /** @hidden */
  39395. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39396. /** @hidden */
  39397. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39398. /** @hidden */
  39399. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39400. /**
  39401. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39402. * @param pipelineContext defines the pipeline context to use
  39403. * @param uniformsNames defines the list of uniform names
  39404. * @returns an array of webGL uniform locations
  39405. */
  39406. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39407. /**
  39408. * Gets the lsit of active attributes for a given webGL program
  39409. * @param pipelineContext defines the pipeline context to use
  39410. * @param attributesNames defines the list of attribute names to get
  39411. * @returns an array of indices indicating the offset of each attribute
  39412. */
  39413. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39414. /**
  39415. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39416. * @param effect defines the effect to activate
  39417. */
  39418. enableEffect(effect: Nullable<Effect>): void;
  39419. /**
  39420. * Set the value of an uniform to a number (int)
  39421. * @param uniform defines the webGL uniform location where to store the value
  39422. * @param value defines the int number to store
  39423. * @returns true if the value was set
  39424. */
  39425. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39426. /**
  39427. * Set the value of an uniform to an array of int32
  39428. * @param uniform defines the webGL uniform location where to store the value
  39429. * @param array defines the array of int32 to store
  39430. * @returns true if the value was set
  39431. */
  39432. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39433. /**
  39434. * Set the value of an uniform to an array of int32 (stored as vec2)
  39435. * @param uniform defines the webGL uniform location where to store the value
  39436. * @param array defines the array of int32 to store
  39437. * @returns true if the value was set
  39438. */
  39439. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39440. /**
  39441. * Set the value of an uniform to an array of int32 (stored as vec3)
  39442. * @param uniform defines the webGL uniform location where to store the value
  39443. * @param array defines the array of int32 to store
  39444. * @returns true if the value was set
  39445. */
  39446. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39447. /**
  39448. * Set the value of an uniform to an array of int32 (stored as vec4)
  39449. * @param uniform defines the webGL uniform location where to store the value
  39450. * @param array defines the array of int32 to store
  39451. * @returns true if the value was set
  39452. */
  39453. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39454. /**
  39455. * Set the value of an uniform to an array of number
  39456. * @param uniform defines the webGL uniform location where to store the value
  39457. * @param array defines the array of number to store
  39458. * @returns true if the value was set
  39459. */
  39460. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39461. /**
  39462. * Set the value of an uniform to an array of number (stored as vec2)
  39463. * @param uniform defines the webGL uniform location where to store the value
  39464. * @param array defines the array of number to store
  39465. * @returns true if the value was set
  39466. */
  39467. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39468. /**
  39469. * Set the value of an uniform to an array of number (stored as vec3)
  39470. * @param uniform defines the webGL uniform location where to store the value
  39471. * @param array defines the array of number to store
  39472. * @returns true if the value was set
  39473. */
  39474. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39475. /**
  39476. * Set the value of an uniform to an array of number (stored as vec4)
  39477. * @param uniform defines the webGL uniform location where to store the value
  39478. * @param array defines the array of number to store
  39479. * @returns true if the value was set
  39480. */
  39481. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39482. /**
  39483. * Set the value of an uniform to an array of float32 (stored as matrices)
  39484. * @param uniform defines the webGL uniform location where to store the value
  39485. * @param matrices defines the array of float32 to store
  39486. * @returns true if the value was set
  39487. */
  39488. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39489. /**
  39490. * Set the value of an uniform to a matrix (3x3)
  39491. * @param uniform defines the webGL uniform location where to store the value
  39492. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39493. * @returns true if the value was set
  39494. */
  39495. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39496. /**
  39497. * Set the value of an uniform to a matrix (2x2)
  39498. * @param uniform defines the webGL uniform location where to store the value
  39499. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39500. * @returns true if the value was set
  39501. */
  39502. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39503. /**
  39504. * Set the value of an uniform to a number (float)
  39505. * @param uniform defines the webGL uniform location where to store the value
  39506. * @param value defines the float number to store
  39507. * @returns true if the value was transfered
  39508. */
  39509. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39510. /**
  39511. * Set the value of an uniform to a vec2
  39512. * @param uniform defines the webGL uniform location where to store the value
  39513. * @param x defines the 1st component of the value
  39514. * @param y defines the 2nd component of the value
  39515. * @returns true if the value was set
  39516. */
  39517. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39518. /**
  39519. * Set the value of an uniform to a vec3
  39520. * @param uniform defines the webGL uniform location where to store the value
  39521. * @param x defines the 1st component of the value
  39522. * @param y defines the 2nd component of the value
  39523. * @param z defines the 3rd component of the value
  39524. * @returns true if the value was set
  39525. */
  39526. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39527. /**
  39528. * Set the value of an uniform to a vec4
  39529. * @param uniform defines the webGL uniform location where to store the value
  39530. * @param x defines the 1st component of the value
  39531. * @param y defines the 2nd component of the value
  39532. * @param z defines the 3rd component of the value
  39533. * @param w defines the 4th component of the value
  39534. * @returns true if the value was set
  39535. */
  39536. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39537. /**
  39538. * Apply all cached states (depth, culling, stencil and alpha)
  39539. */
  39540. applyStates(): void;
  39541. /**
  39542. * Enable or disable color writing
  39543. * @param enable defines the state to set
  39544. */
  39545. setColorWrite(enable: boolean): void;
  39546. /**
  39547. * Gets a boolean indicating if color writing is enabled
  39548. * @returns the current color writing state
  39549. */
  39550. getColorWrite(): boolean;
  39551. /**
  39552. * Gets the depth culling state manager
  39553. */
  39554. get depthCullingState(): DepthCullingState;
  39555. /**
  39556. * Gets the alpha state manager
  39557. */
  39558. get alphaState(): AlphaState;
  39559. /**
  39560. * Gets the stencil state manager
  39561. */
  39562. get stencilState(): StencilState;
  39563. /**
  39564. * Clears the list of texture accessible through engine.
  39565. * This can help preventing texture load conflict due to name collision.
  39566. */
  39567. clearInternalTexturesCache(): void;
  39568. /**
  39569. * Force the entire cache to be cleared
  39570. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39571. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39572. */
  39573. wipeCaches(bruteForce?: boolean): void;
  39574. /** @hidden */
  39575. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39576. min: number;
  39577. mag: number;
  39578. };
  39579. /** @hidden */
  39580. _createTexture(): WebGLTexture;
  39581. /**
  39582. * Usually called from Texture.ts.
  39583. * Passed information to create a WebGLTexture
  39584. * @param url defines a value which contains one of the following:
  39585. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39586. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39587. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39588. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39589. * @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)
  39590. * @param scene needed for loading to the correct scene
  39591. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39592. * @param onLoad optional callback to be called upon successful completion
  39593. * @param onError optional callback to be called upon failure
  39594. * @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
  39595. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39596. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39597. * @param forcedExtension defines the extension to use to pick the right loader
  39598. * @param mimeType defines an optional mime type
  39599. * @param loaderOptions options to be passed to the loader
  39600. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39601. */
  39602. 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;
  39603. /**
  39604. * Loads an image as an HTMLImageElement.
  39605. * @param input url string, ArrayBuffer, or Blob to load
  39606. * @param onLoad callback called when the image successfully loads
  39607. * @param onError callback called when the image fails to load
  39608. * @param offlineProvider offline provider for caching
  39609. * @param mimeType optional mime type
  39610. * @returns the HTMLImageElement of the loaded image
  39611. * @hidden
  39612. */
  39613. 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>;
  39614. /**
  39615. * @hidden
  39616. */
  39617. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39618. private _unpackFlipYCached;
  39619. /**
  39620. * In case you are sharing the context with other applications, it might
  39621. * be interested to not cache the unpack flip y state to ensure a consistent
  39622. * value would be set.
  39623. */
  39624. enableUnpackFlipYCached: boolean;
  39625. /** @hidden */
  39626. _unpackFlipY(value: boolean): void;
  39627. /** @hidden */
  39628. _getUnpackAlignement(): number;
  39629. private _getTextureTarget;
  39630. /**
  39631. * Update the sampling mode of a given texture
  39632. * @param samplingMode defines the required sampling mode
  39633. * @param texture defines the texture to update
  39634. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39635. */
  39636. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39637. /**
  39638. * Update the sampling mode of a given texture
  39639. * @param texture defines the texture to update
  39640. * @param wrapU defines the texture wrap mode of the u coordinates
  39641. * @param wrapV defines the texture wrap mode of the v coordinates
  39642. * @param wrapR defines the texture wrap mode of the r coordinates
  39643. */
  39644. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39645. /** @hidden */
  39646. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39647. width: number;
  39648. height: number;
  39649. layers?: number;
  39650. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39651. /** @hidden */
  39652. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39653. /** @hidden */
  39654. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39655. /**
  39656. * Update a portion of an internal texture
  39657. * @param texture defines the texture to update
  39658. * @param imageData defines the data to store into the texture
  39659. * @param xOffset defines the x coordinates of the update rectangle
  39660. * @param yOffset defines the y coordinates of the update rectangle
  39661. * @param width defines the width of the update rectangle
  39662. * @param height defines the height of the update rectangle
  39663. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39664. * @param lod defines the lod level to update (0 by default)
  39665. */
  39666. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39667. /** @hidden */
  39668. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39669. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39670. private _prepareWebGLTexture;
  39671. /** @hidden */
  39672. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39673. private _getDepthStencilBuffer;
  39674. /** @hidden */
  39675. _releaseFramebufferObjects(texture: InternalTexture): void;
  39676. /** @hidden */
  39677. _releaseTexture(texture: InternalTexture): void;
  39678. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39679. protected _setProgram(program: WebGLProgram): void;
  39680. protected _boundUniforms: {
  39681. [key: number]: WebGLUniformLocation;
  39682. };
  39683. /**
  39684. * Binds an effect to the webGL context
  39685. * @param effect defines the effect to bind
  39686. */
  39687. bindSamplers(effect: Effect): void;
  39688. private _activateCurrentTexture;
  39689. /** @hidden */
  39690. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39691. /** @hidden */
  39692. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39693. /**
  39694. * Unbind all textures from the webGL context
  39695. */
  39696. unbindAllTextures(): void;
  39697. /**
  39698. * Sets a texture to the according uniform.
  39699. * @param channel The texture channel
  39700. * @param uniform The uniform to set
  39701. * @param texture The texture to apply
  39702. */
  39703. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39704. private _bindSamplerUniformToChannel;
  39705. private _getTextureWrapMode;
  39706. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39707. /**
  39708. * Sets an array of texture to the webGL context
  39709. * @param channel defines the channel where the texture array must be set
  39710. * @param uniform defines the associated uniform location
  39711. * @param textures defines the array of textures to bind
  39712. */
  39713. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39714. /** @hidden */
  39715. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39716. private _setTextureParameterFloat;
  39717. private _setTextureParameterInteger;
  39718. /**
  39719. * Unbind all vertex attributes from the webGL context
  39720. */
  39721. unbindAllAttributes(): void;
  39722. /**
  39723. * 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
  39724. */
  39725. releaseEffects(): void;
  39726. /**
  39727. * Dispose and release all associated resources
  39728. */
  39729. dispose(): void;
  39730. /**
  39731. * Attach a new callback raised when context lost event is fired
  39732. * @param callback defines the callback to call
  39733. */
  39734. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39735. /**
  39736. * Attach a new callback raised when context restored event is fired
  39737. * @param callback defines the callback to call
  39738. */
  39739. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39740. /**
  39741. * Get the current error code of the webGL context
  39742. * @returns the error code
  39743. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39744. */
  39745. getError(): number;
  39746. private _canRenderToFloatFramebuffer;
  39747. private _canRenderToHalfFloatFramebuffer;
  39748. private _canRenderToFramebuffer;
  39749. /** @hidden */
  39750. _getWebGLTextureType(type: number): number;
  39751. /** @hidden */
  39752. _getInternalFormat(format: number): number;
  39753. /** @hidden */
  39754. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39755. /** @hidden */
  39756. _getRGBAMultiSampleBufferFormat(type: number): number;
  39757. /** @hidden */
  39758. _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;
  39759. /**
  39760. * Loads a file from a url
  39761. * @param url url to load
  39762. * @param onSuccess callback called when the file successfully loads
  39763. * @param onProgress callback called while file is loading (if the server supports this mode)
  39764. * @param offlineProvider defines the offline provider for caching
  39765. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39766. * @param onError callback called when the file fails to load
  39767. * @returns a file request object
  39768. * @hidden
  39769. */
  39770. 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;
  39771. /**
  39772. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39773. * @param x defines the x coordinate of the rectangle where pixels must be read
  39774. * @param y defines the y coordinate of the rectangle where pixels must be read
  39775. * @param width defines the width of the rectangle where pixels must be read
  39776. * @param height defines the height of the rectangle where pixels must be read
  39777. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39778. * @returns a Uint8Array containing RGBA colors
  39779. */
  39780. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39781. private static _IsSupported;
  39782. private static _HasMajorPerformanceCaveat;
  39783. /**
  39784. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39785. */
  39786. static get IsSupported(): boolean;
  39787. /**
  39788. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39789. * @returns true if the engine can be created
  39790. * @ignorenaming
  39791. */
  39792. static isSupported(): boolean;
  39793. /**
  39794. * 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)
  39795. */
  39796. static get HasMajorPerformanceCaveat(): boolean;
  39797. /**
  39798. * Find the next highest power of two.
  39799. * @param x Number to start search from.
  39800. * @return Next highest power of two.
  39801. */
  39802. static CeilingPOT(x: number): number;
  39803. /**
  39804. * Find the next lowest power of two.
  39805. * @param x Number to start search from.
  39806. * @return Next lowest power of two.
  39807. */
  39808. static FloorPOT(x: number): number;
  39809. /**
  39810. * Find the nearest power of two.
  39811. * @param x Number to start search from.
  39812. * @return Next nearest power of two.
  39813. */
  39814. static NearestPOT(x: number): number;
  39815. /**
  39816. * Get the closest exponent of two
  39817. * @param value defines the value to approximate
  39818. * @param max defines the maximum value to return
  39819. * @param mode defines how to define the closest value
  39820. * @returns closest exponent of two of the given value
  39821. */
  39822. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39823. /**
  39824. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39825. * @param func - the function to be called
  39826. * @param requester - the object that will request the next frame. Falls back to window.
  39827. * @returns frame number
  39828. */
  39829. static QueueNewFrame(func: () => void, requester?: any): number;
  39830. /**
  39831. * Gets host document
  39832. * @returns the host document object
  39833. */
  39834. getHostDocument(): Nullable<Document>;
  39835. }
  39836. }
  39837. declare module BABYLON {
  39838. /**
  39839. * Defines the source of the internal texture
  39840. */
  39841. export enum InternalTextureSource {
  39842. /**
  39843. * The source of the texture data is unknown
  39844. */
  39845. Unknown = 0,
  39846. /**
  39847. * Texture data comes from an URL
  39848. */
  39849. Url = 1,
  39850. /**
  39851. * Texture data is only used for temporary storage
  39852. */
  39853. Temp = 2,
  39854. /**
  39855. * Texture data comes from raw data (ArrayBuffer)
  39856. */
  39857. Raw = 3,
  39858. /**
  39859. * Texture content is dynamic (video or dynamic texture)
  39860. */
  39861. Dynamic = 4,
  39862. /**
  39863. * Texture content is generated by rendering to it
  39864. */
  39865. RenderTarget = 5,
  39866. /**
  39867. * Texture content is part of a multi render target process
  39868. */
  39869. MultiRenderTarget = 6,
  39870. /**
  39871. * Texture data comes from a cube data file
  39872. */
  39873. Cube = 7,
  39874. /**
  39875. * Texture data comes from a raw cube data
  39876. */
  39877. CubeRaw = 8,
  39878. /**
  39879. * Texture data come from a prefiltered cube data file
  39880. */
  39881. CubePrefiltered = 9,
  39882. /**
  39883. * Texture content is raw 3D data
  39884. */
  39885. Raw3D = 10,
  39886. /**
  39887. * Texture content is raw 2D array data
  39888. */
  39889. Raw2DArray = 11,
  39890. /**
  39891. * Texture content is a depth texture
  39892. */
  39893. Depth = 12,
  39894. /**
  39895. * Texture data comes from a raw cube data encoded with RGBD
  39896. */
  39897. CubeRawRGBD = 13
  39898. }
  39899. /**
  39900. * Class used to store data associated with WebGL texture data for the engine
  39901. * This class should not be used directly
  39902. */
  39903. export class InternalTexture {
  39904. /** @hidden */
  39905. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39906. /**
  39907. * Defines if the texture is ready
  39908. */
  39909. isReady: boolean;
  39910. /**
  39911. * Defines if the texture is a cube texture
  39912. */
  39913. isCube: boolean;
  39914. /**
  39915. * Defines if the texture contains 3D data
  39916. */
  39917. is3D: boolean;
  39918. /**
  39919. * Defines if the texture contains 2D array data
  39920. */
  39921. is2DArray: boolean;
  39922. /**
  39923. * Defines if the texture contains multiview data
  39924. */
  39925. isMultiview: boolean;
  39926. /**
  39927. * Gets the URL used to load this texture
  39928. */
  39929. url: string;
  39930. /**
  39931. * Gets the sampling mode of the texture
  39932. */
  39933. samplingMode: number;
  39934. /**
  39935. * Gets a boolean indicating if the texture needs mipmaps generation
  39936. */
  39937. generateMipMaps: boolean;
  39938. /**
  39939. * Gets the number of samples used by the texture (WebGL2+ only)
  39940. */
  39941. samples: number;
  39942. /**
  39943. * Gets the type of the texture (int, float...)
  39944. */
  39945. type: number;
  39946. /**
  39947. * Gets the format of the texture (RGB, RGBA...)
  39948. */
  39949. format: number;
  39950. /**
  39951. * Observable called when the texture is loaded
  39952. */
  39953. onLoadedObservable: Observable<InternalTexture>;
  39954. /**
  39955. * Gets the width of the texture
  39956. */
  39957. width: number;
  39958. /**
  39959. * Gets the height of the texture
  39960. */
  39961. height: number;
  39962. /**
  39963. * Gets the depth of the texture
  39964. */
  39965. depth: number;
  39966. /**
  39967. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39968. */
  39969. baseWidth: number;
  39970. /**
  39971. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39972. */
  39973. baseHeight: number;
  39974. /**
  39975. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39976. */
  39977. baseDepth: number;
  39978. /**
  39979. * Gets a boolean indicating if the texture is inverted on Y axis
  39980. */
  39981. invertY: boolean;
  39982. /** @hidden */
  39983. _invertVScale: boolean;
  39984. /** @hidden */
  39985. _associatedChannel: number;
  39986. /** @hidden */
  39987. _source: InternalTextureSource;
  39988. /** @hidden */
  39989. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39990. /** @hidden */
  39991. _bufferView: Nullable<ArrayBufferView>;
  39992. /** @hidden */
  39993. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39994. /** @hidden */
  39995. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39996. /** @hidden */
  39997. _size: number;
  39998. /** @hidden */
  39999. _extension: string;
  40000. /** @hidden */
  40001. _files: Nullable<string[]>;
  40002. /** @hidden */
  40003. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40004. /** @hidden */
  40005. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40006. /** @hidden */
  40007. _framebuffer: Nullable<WebGLFramebuffer>;
  40008. /** @hidden */
  40009. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40010. /** @hidden */
  40011. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40012. /** @hidden */
  40013. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40014. /** @hidden */
  40015. _attachments: Nullable<number[]>;
  40016. /** @hidden */
  40017. _textureArray: Nullable<InternalTexture[]>;
  40018. /** @hidden */
  40019. _cachedCoordinatesMode: Nullable<number>;
  40020. /** @hidden */
  40021. _cachedWrapU: Nullable<number>;
  40022. /** @hidden */
  40023. _cachedWrapV: Nullable<number>;
  40024. /** @hidden */
  40025. _cachedWrapR: Nullable<number>;
  40026. /** @hidden */
  40027. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40028. /** @hidden */
  40029. _isDisabled: boolean;
  40030. /** @hidden */
  40031. _compression: Nullable<string>;
  40032. /** @hidden */
  40033. _generateStencilBuffer: boolean;
  40034. /** @hidden */
  40035. _generateDepthBuffer: boolean;
  40036. /** @hidden */
  40037. _comparisonFunction: number;
  40038. /** @hidden */
  40039. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40040. /** @hidden */
  40041. _lodGenerationScale: number;
  40042. /** @hidden */
  40043. _lodGenerationOffset: number;
  40044. /** @hidden */
  40045. _depthStencilTexture: Nullable<InternalTexture>;
  40046. /** @hidden */
  40047. _colorTextureArray: Nullable<WebGLTexture>;
  40048. /** @hidden */
  40049. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40050. /** @hidden */
  40051. _lodTextureHigh: Nullable<BaseTexture>;
  40052. /** @hidden */
  40053. _lodTextureMid: Nullable<BaseTexture>;
  40054. /** @hidden */
  40055. _lodTextureLow: Nullable<BaseTexture>;
  40056. /** @hidden */
  40057. _isRGBD: boolean;
  40058. /** @hidden */
  40059. _linearSpecularLOD: boolean;
  40060. /** @hidden */
  40061. _irradianceTexture: Nullable<BaseTexture>;
  40062. /** @hidden */
  40063. _webGLTexture: Nullable<WebGLTexture>;
  40064. /** @hidden */
  40065. _references: number;
  40066. /** @hidden */
  40067. _gammaSpace: Nullable<boolean>;
  40068. private _engine;
  40069. /**
  40070. * Gets the Engine the texture belongs to.
  40071. * @returns The babylon engine
  40072. */
  40073. getEngine(): ThinEngine;
  40074. /**
  40075. * Gets the data source type of the texture
  40076. */
  40077. get source(): InternalTextureSource;
  40078. /**
  40079. * Creates a new InternalTexture
  40080. * @param engine defines the engine to use
  40081. * @param source defines the type of data that will be used
  40082. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40083. */
  40084. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40085. /**
  40086. * Increments the number of references (ie. the number of Texture that point to it)
  40087. */
  40088. incrementReferences(): void;
  40089. /**
  40090. * Change the size of the texture (not the size of the content)
  40091. * @param width defines the new width
  40092. * @param height defines the new height
  40093. * @param depth defines the new depth (1 by default)
  40094. */
  40095. updateSize(width: int, height: int, depth?: int): void;
  40096. /** @hidden */
  40097. _rebuild(): void;
  40098. /** @hidden */
  40099. _swapAndDie(target: InternalTexture): void;
  40100. /**
  40101. * Dispose the current allocated resources
  40102. */
  40103. dispose(): void;
  40104. }
  40105. }
  40106. declare module BABYLON {
  40107. /**
  40108. * Interface used to present a loading screen while loading a scene
  40109. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40110. */
  40111. export interface ILoadingScreen {
  40112. /**
  40113. * Function called to display the loading screen
  40114. */
  40115. displayLoadingUI: () => void;
  40116. /**
  40117. * Function called to hide the loading screen
  40118. */
  40119. hideLoadingUI: () => void;
  40120. /**
  40121. * Gets or sets the color to use for the background
  40122. */
  40123. loadingUIBackgroundColor: string;
  40124. /**
  40125. * Gets or sets the text to display while loading
  40126. */
  40127. loadingUIText: string;
  40128. }
  40129. /**
  40130. * Class used for the default loading screen
  40131. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40132. */
  40133. export class DefaultLoadingScreen implements ILoadingScreen {
  40134. private _renderingCanvas;
  40135. private _loadingText;
  40136. private _loadingDivBackgroundColor;
  40137. private _loadingDiv;
  40138. private _loadingTextDiv;
  40139. /** Gets or sets the logo url to use for the default loading screen */
  40140. static DefaultLogoUrl: string;
  40141. /** Gets or sets the spinner url to use for the default loading screen */
  40142. static DefaultSpinnerUrl: string;
  40143. /**
  40144. * Creates a new default loading screen
  40145. * @param _renderingCanvas defines the canvas used to render the scene
  40146. * @param _loadingText defines the default text to display
  40147. * @param _loadingDivBackgroundColor defines the default background color
  40148. */
  40149. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40150. /**
  40151. * Function called to display the loading screen
  40152. */
  40153. displayLoadingUI(): void;
  40154. /**
  40155. * Function called to hide the loading screen
  40156. */
  40157. hideLoadingUI(): void;
  40158. /**
  40159. * Gets or sets the text to display while loading
  40160. */
  40161. set loadingUIText(text: string);
  40162. get loadingUIText(): string;
  40163. /**
  40164. * Gets or sets the color to use for the background
  40165. */
  40166. get loadingUIBackgroundColor(): string;
  40167. set loadingUIBackgroundColor(color: string);
  40168. private _resizeLoadingUI;
  40169. }
  40170. }
  40171. declare module BABYLON {
  40172. /**
  40173. * Interface for any object that can request an animation frame
  40174. */
  40175. export interface ICustomAnimationFrameRequester {
  40176. /**
  40177. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40178. */
  40179. renderFunction?: Function;
  40180. /**
  40181. * Called to request the next frame to render to
  40182. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40183. */
  40184. requestAnimationFrame: Function;
  40185. /**
  40186. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40187. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40188. */
  40189. requestID?: number;
  40190. }
  40191. }
  40192. declare module BABYLON {
  40193. /**
  40194. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40195. */
  40196. export class PerformanceMonitor {
  40197. private _enabled;
  40198. private _rollingFrameTime;
  40199. private _lastFrameTimeMs;
  40200. /**
  40201. * constructor
  40202. * @param frameSampleSize The number of samples required to saturate the sliding window
  40203. */
  40204. constructor(frameSampleSize?: number);
  40205. /**
  40206. * Samples current frame
  40207. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40208. */
  40209. sampleFrame(timeMs?: number): void;
  40210. /**
  40211. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40212. */
  40213. get averageFrameTime(): number;
  40214. /**
  40215. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40216. */
  40217. get averageFrameTimeVariance(): number;
  40218. /**
  40219. * Returns the frame time of the most recent frame
  40220. */
  40221. get instantaneousFrameTime(): number;
  40222. /**
  40223. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40224. */
  40225. get averageFPS(): number;
  40226. /**
  40227. * Returns the average framerate in frames per second using the most recent frame time
  40228. */
  40229. get instantaneousFPS(): number;
  40230. /**
  40231. * Returns true if enough samples have been taken to completely fill the sliding window
  40232. */
  40233. get isSaturated(): boolean;
  40234. /**
  40235. * Enables contributions to the sliding window sample set
  40236. */
  40237. enable(): void;
  40238. /**
  40239. * Disables contributions to the sliding window sample set
  40240. * Samples will not be interpolated over the disabled period
  40241. */
  40242. disable(): void;
  40243. /**
  40244. * Returns true if sampling is enabled
  40245. */
  40246. get isEnabled(): boolean;
  40247. /**
  40248. * Resets performance monitor
  40249. */
  40250. reset(): void;
  40251. }
  40252. /**
  40253. * RollingAverage
  40254. *
  40255. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40256. */
  40257. export class RollingAverage {
  40258. /**
  40259. * Current average
  40260. */
  40261. average: number;
  40262. /**
  40263. * Current variance
  40264. */
  40265. variance: number;
  40266. protected _samples: Array<number>;
  40267. protected _sampleCount: number;
  40268. protected _pos: number;
  40269. protected _m2: number;
  40270. /**
  40271. * constructor
  40272. * @param length The number of samples required to saturate the sliding window
  40273. */
  40274. constructor(length: number);
  40275. /**
  40276. * Adds a sample to the sample set
  40277. * @param v The sample value
  40278. */
  40279. add(v: number): void;
  40280. /**
  40281. * Returns previously added values or null if outside of history or outside the sliding window domain
  40282. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40283. * @return Value previously recorded with add() or null if outside of range
  40284. */
  40285. history(i: number): number;
  40286. /**
  40287. * Returns true if enough samples have been taken to completely fill the sliding window
  40288. * @return true if sample-set saturated
  40289. */
  40290. isSaturated(): boolean;
  40291. /**
  40292. * Resets the rolling average (equivalent to 0 samples taken so far)
  40293. */
  40294. reset(): void;
  40295. /**
  40296. * Wraps a value around the sample range boundaries
  40297. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40298. * @return Wrapped position in sample range
  40299. */
  40300. protected _wrapPosition(i: number): number;
  40301. }
  40302. }
  40303. declare module BABYLON {
  40304. /**
  40305. * This class is used to track a performance counter which is number based.
  40306. * The user has access to many properties which give statistics of different nature.
  40307. *
  40308. * The implementer can track two kinds of Performance Counter: time and count.
  40309. * 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.
  40310. * 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.
  40311. */
  40312. export class PerfCounter {
  40313. /**
  40314. * Gets or sets a global boolean to turn on and off all the counters
  40315. */
  40316. static Enabled: boolean;
  40317. /**
  40318. * Returns the smallest value ever
  40319. */
  40320. get min(): number;
  40321. /**
  40322. * Returns the biggest value ever
  40323. */
  40324. get max(): number;
  40325. /**
  40326. * Returns the average value since the performance counter is running
  40327. */
  40328. get average(): number;
  40329. /**
  40330. * Returns the average value of the last second the counter was monitored
  40331. */
  40332. get lastSecAverage(): number;
  40333. /**
  40334. * Returns the current value
  40335. */
  40336. get current(): number;
  40337. /**
  40338. * Gets the accumulated total
  40339. */
  40340. get total(): number;
  40341. /**
  40342. * Gets the total value count
  40343. */
  40344. get count(): number;
  40345. /**
  40346. * Creates a new counter
  40347. */
  40348. constructor();
  40349. /**
  40350. * Call this method to start monitoring a new frame.
  40351. * 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.
  40352. */
  40353. fetchNewFrame(): void;
  40354. /**
  40355. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40356. * @param newCount the count value to add to the monitored count
  40357. * @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.
  40358. */
  40359. addCount(newCount: number, fetchResult: boolean): void;
  40360. /**
  40361. * Start monitoring this performance counter
  40362. */
  40363. beginMonitoring(): void;
  40364. /**
  40365. * Compute the time lapsed since the previous beginMonitoring() call.
  40366. * @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
  40367. */
  40368. endMonitoring(newFrame?: boolean): void;
  40369. private _fetchResult;
  40370. private _startMonitoringTime;
  40371. private _min;
  40372. private _max;
  40373. private _average;
  40374. private _current;
  40375. private _totalValueCount;
  40376. private _totalAccumulated;
  40377. private _lastSecAverage;
  40378. private _lastSecAccumulated;
  40379. private _lastSecTime;
  40380. private _lastSecValueCount;
  40381. }
  40382. }
  40383. declare module BABYLON {
  40384. interface ThinEngine {
  40385. /** @hidden */
  40386. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40387. }
  40388. }
  40389. declare module BABYLON {
  40390. /**
  40391. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40393. */
  40394. export class Analyser {
  40395. /**
  40396. * Gets or sets the smoothing
  40397. * @ignorenaming
  40398. */
  40399. SMOOTHING: number;
  40400. /**
  40401. * Gets or sets the FFT table size
  40402. * @ignorenaming
  40403. */
  40404. FFT_SIZE: number;
  40405. /**
  40406. * Gets or sets the bar graph amplitude
  40407. * @ignorenaming
  40408. */
  40409. BARGRAPHAMPLITUDE: number;
  40410. /**
  40411. * Gets or sets the position of the debug canvas
  40412. * @ignorenaming
  40413. */
  40414. DEBUGCANVASPOS: {
  40415. x: number;
  40416. y: number;
  40417. };
  40418. /**
  40419. * Gets or sets the debug canvas size
  40420. * @ignorenaming
  40421. */
  40422. DEBUGCANVASSIZE: {
  40423. width: number;
  40424. height: number;
  40425. };
  40426. private _byteFreqs;
  40427. private _byteTime;
  40428. private _floatFreqs;
  40429. private _webAudioAnalyser;
  40430. private _debugCanvas;
  40431. private _debugCanvasContext;
  40432. private _scene;
  40433. private _registerFunc;
  40434. private _audioEngine;
  40435. /**
  40436. * Creates a new analyser
  40437. * @param scene defines hosting scene
  40438. */
  40439. constructor(scene: Scene);
  40440. /**
  40441. * Get the number of data values you will have to play with for the visualization
  40442. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40443. * @returns a number
  40444. */
  40445. getFrequencyBinCount(): number;
  40446. /**
  40447. * Gets the current frequency data as a byte array
  40448. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40449. * @returns a Uint8Array
  40450. */
  40451. getByteFrequencyData(): Uint8Array;
  40452. /**
  40453. * Gets the current waveform as a byte array
  40454. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40455. * @returns a Uint8Array
  40456. */
  40457. getByteTimeDomainData(): Uint8Array;
  40458. /**
  40459. * Gets the current frequency data as a float array
  40460. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40461. * @returns a Float32Array
  40462. */
  40463. getFloatFrequencyData(): Float32Array;
  40464. /**
  40465. * Renders the debug canvas
  40466. */
  40467. drawDebugCanvas(): void;
  40468. /**
  40469. * Stops rendering the debug canvas and removes it
  40470. */
  40471. stopDebugCanvas(): void;
  40472. /**
  40473. * Connects two audio nodes
  40474. * @param inputAudioNode defines first node to connect
  40475. * @param outputAudioNode defines second node to connect
  40476. */
  40477. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40478. /**
  40479. * Releases all associated resources
  40480. */
  40481. dispose(): void;
  40482. }
  40483. }
  40484. declare module BABYLON {
  40485. /**
  40486. * This represents an audio engine and it is responsible
  40487. * to play, synchronize and analyse sounds throughout the application.
  40488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40489. */
  40490. export interface IAudioEngine extends IDisposable {
  40491. /**
  40492. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40493. */
  40494. readonly canUseWebAudio: boolean;
  40495. /**
  40496. * Gets the current AudioContext if available.
  40497. */
  40498. readonly audioContext: Nullable<AudioContext>;
  40499. /**
  40500. * The master gain node defines the global audio volume of your audio engine.
  40501. */
  40502. readonly masterGain: GainNode;
  40503. /**
  40504. * Gets whether or not mp3 are supported by your browser.
  40505. */
  40506. readonly isMP3supported: boolean;
  40507. /**
  40508. * Gets whether or not ogg are supported by your browser.
  40509. */
  40510. readonly isOGGsupported: boolean;
  40511. /**
  40512. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40513. * @ignoreNaming
  40514. */
  40515. WarnedWebAudioUnsupported: boolean;
  40516. /**
  40517. * Defines if the audio engine relies on a custom unlocked button.
  40518. * In this case, the embedded button will not be displayed.
  40519. */
  40520. useCustomUnlockedButton: boolean;
  40521. /**
  40522. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40523. */
  40524. readonly unlocked: boolean;
  40525. /**
  40526. * Event raised when audio has been unlocked on the browser.
  40527. */
  40528. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40529. /**
  40530. * Event raised when audio has been locked on the browser.
  40531. */
  40532. onAudioLockedObservable: Observable<IAudioEngine>;
  40533. /**
  40534. * Flags the audio engine in Locked state.
  40535. * This happens due to new browser policies preventing audio to autoplay.
  40536. */
  40537. lock(): void;
  40538. /**
  40539. * Unlocks the audio engine once a user action has been done on the dom.
  40540. * This is helpful to resume play once browser policies have been satisfied.
  40541. */
  40542. unlock(): void;
  40543. /**
  40544. * Gets the global volume sets on the master gain.
  40545. * @returns the global volume if set or -1 otherwise
  40546. */
  40547. getGlobalVolume(): number;
  40548. /**
  40549. * Sets the global volume of your experience (sets on the master gain).
  40550. * @param newVolume Defines the new global volume of the application
  40551. */
  40552. setGlobalVolume(newVolume: number): void;
  40553. /**
  40554. * Connect the audio engine to an audio analyser allowing some amazing
  40555. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40556. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40557. * @param analyser The analyser to connect to the engine
  40558. */
  40559. connectToAnalyser(analyser: Analyser): void;
  40560. }
  40561. }
  40562. declare module BABYLON {
  40563. /**
  40564. * Defines the interface used by display changed events
  40565. */
  40566. export interface IDisplayChangedEventArgs {
  40567. /** Gets the vrDisplay object (if any) */
  40568. vrDisplay: Nullable<any>;
  40569. /** Gets a boolean indicating if webVR is supported */
  40570. vrSupported: boolean;
  40571. }
  40572. /**
  40573. * Defines the interface used by objects containing a viewport (like a camera)
  40574. */
  40575. interface IViewportOwnerLike {
  40576. /**
  40577. * Gets or sets the viewport
  40578. */
  40579. viewport: IViewportLike;
  40580. }
  40581. /**
  40582. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40583. */
  40584. export class Engine extends ThinEngine {
  40585. /** Defines that alpha blending is disabled */
  40586. static readonly ALPHA_DISABLE: number;
  40587. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40588. static readonly ALPHA_ADD: number;
  40589. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40590. static readonly ALPHA_COMBINE: number;
  40591. /** Defines that alpha blending to DEST - SRC * DEST */
  40592. static readonly ALPHA_SUBTRACT: number;
  40593. /** Defines that alpha blending to SRC * DEST */
  40594. static readonly ALPHA_MULTIPLY: number;
  40595. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40596. static readonly ALPHA_MAXIMIZED: number;
  40597. /** Defines that alpha blending to SRC + DEST */
  40598. static readonly ALPHA_ONEONE: number;
  40599. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40600. static readonly ALPHA_PREMULTIPLIED: number;
  40601. /**
  40602. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40603. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40604. */
  40605. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40606. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40607. static readonly ALPHA_INTERPOLATE: number;
  40608. /**
  40609. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40610. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40611. */
  40612. static readonly ALPHA_SCREENMODE: number;
  40613. /** Defines that the ressource is not delayed*/
  40614. static readonly DELAYLOADSTATE_NONE: number;
  40615. /** Defines that the ressource was successfully delay loaded */
  40616. static readonly DELAYLOADSTATE_LOADED: number;
  40617. /** Defines that the ressource is currently delay loading */
  40618. static readonly DELAYLOADSTATE_LOADING: number;
  40619. /** Defines that the ressource is delayed and has not started loading */
  40620. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40621. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40622. static readonly NEVER: number;
  40623. /** 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 */
  40624. static readonly ALWAYS: number;
  40625. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40626. static readonly LESS: number;
  40627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40628. static readonly EQUAL: number;
  40629. /** 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 */
  40630. static readonly LEQUAL: number;
  40631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40632. static readonly GREATER: number;
  40633. /** 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 */
  40634. static readonly GEQUAL: number;
  40635. /** 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 */
  40636. static readonly NOTEQUAL: number;
  40637. /** Passed to stencilOperation to specify that stencil value must be kept */
  40638. static readonly KEEP: number;
  40639. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40640. static readonly REPLACE: number;
  40641. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40642. static readonly INCR: number;
  40643. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40644. static readonly DECR: number;
  40645. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40646. static readonly INVERT: number;
  40647. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40648. static readonly INCR_WRAP: number;
  40649. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40650. static readonly DECR_WRAP: number;
  40651. /** Texture is not repeating outside of 0..1 UVs */
  40652. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40653. /** Texture is repeating outside of 0..1 UVs */
  40654. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40655. /** Texture is repeating and mirrored */
  40656. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40657. /** ALPHA */
  40658. static readonly TEXTUREFORMAT_ALPHA: number;
  40659. /** LUMINANCE */
  40660. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40661. /** LUMINANCE_ALPHA */
  40662. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40663. /** RGB */
  40664. static readonly TEXTUREFORMAT_RGB: number;
  40665. /** RGBA */
  40666. static readonly TEXTUREFORMAT_RGBA: number;
  40667. /** RED */
  40668. static readonly TEXTUREFORMAT_RED: number;
  40669. /** RED (2nd reference) */
  40670. static readonly TEXTUREFORMAT_R: number;
  40671. /** RG */
  40672. static readonly TEXTUREFORMAT_RG: number;
  40673. /** RED_INTEGER */
  40674. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40675. /** RED_INTEGER (2nd reference) */
  40676. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40677. /** RG_INTEGER */
  40678. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40679. /** RGB_INTEGER */
  40680. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40681. /** RGBA_INTEGER */
  40682. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40683. /** UNSIGNED_BYTE */
  40684. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40685. /** UNSIGNED_BYTE (2nd reference) */
  40686. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40687. /** FLOAT */
  40688. static readonly TEXTURETYPE_FLOAT: number;
  40689. /** HALF_FLOAT */
  40690. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40691. /** BYTE */
  40692. static readonly TEXTURETYPE_BYTE: number;
  40693. /** SHORT */
  40694. static readonly TEXTURETYPE_SHORT: number;
  40695. /** UNSIGNED_SHORT */
  40696. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40697. /** INT */
  40698. static readonly TEXTURETYPE_INT: number;
  40699. /** UNSIGNED_INT */
  40700. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40701. /** UNSIGNED_SHORT_4_4_4_4 */
  40702. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40703. /** UNSIGNED_SHORT_5_5_5_1 */
  40704. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40705. /** UNSIGNED_SHORT_5_6_5 */
  40706. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40707. /** UNSIGNED_INT_2_10_10_10_REV */
  40708. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40709. /** UNSIGNED_INT_24_8 */
  40710. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40711. /** UNSIGNED_INT_10F_11F_11F_REV */
  40712. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40713. /** UNSIGNED_INT_5_9_9_9_REV */
  40714. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40715. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40716. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40717. /** nearest is mag = nearest and min = nearest and mip = linear */
  40718. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40719. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40720. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40721. /** Trilinear is mag = linear and min = linear and mip = linear */
  40722. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40723. /** nearest is mag = nearest and min = nearest and mip = linear */
  40724. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40726. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40727. /** Trilinear is mag = linear and min = linear and mip = linear */
  40728. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40729. /** mag = nearest and min = nearest and mip = nearest */
  40730. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40731. /** mag = nearest and min = linear and mip = nearest */
  40732. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40733. /** mag = nearest and min = linear and mip = linear */
  40734. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40735. /** mag = nearest and min = linear and mip = none */
  40736. static readonly TEXTURE_NEAREST_LINEAR: number;
  40737. /** mag = nearest and min = nearest and mip = none */
  40738. static readonly TEXTURE_NEAREST_NEAREST: number;
  40739. /** mag = linear and min = nearest and mip = nearest */
  40740. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40741. /** mag = linear and min = nearest and mip = linear */
  40742. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40743. /** mag = linear and min = linear and mip = none */
  40744. static readonly TEXTURE_LINEAR_LINEAR: number;
  40745. /** mag = linear and min = nearest and mip = none */
  40746. static readonly TEXTURE_LINEAR_NEAREST: number;
  40747. /** Explicit coordinates mode */
  40748. static readonly TEXTURE_EXPLICIT_MODE: number;
  40749. /** Spherical coordinates mode */
  40750. static readonly TEXTURE_SPHERICAL_MODE: number;
  40751. /** Planar coordinates mode */
  40752. static readonly TEXTURE_PLANAR_MODE: number;
  40753. /** Cubic coordinates mode */
  40754. static readonly TEXTURE_CUBIC_MODE: number;
  40755. /** Projection coordinates mode */
  40756. static readonly TEXTURE_PROJECTION_MODE: number;
  40757. /** Skybox coordinates mode */
  40758. static readonly TEXTURE_SKYBOX_MODE: number;
  40759. /** Inverse Cubic coordinates mode */
  40760. static readonly TEXTURE_INVCUBIC_MODE: number;
  40761. /** Equirectangular coordinates mode */
  40762. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40763. /** Equirectangular Fixed coordinates mode */
  40764. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40765. /** Equirectangular Fixed Mirrored coordinates mode */
  40766. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40767. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40768. static readonly SCALEMODE_FLOOR: number;
  40769. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40770. static readonly SCALEMODE_NEAREST: number;
  40771. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40772. static readonly SCALEMODE_CEILING: number;
  40773. /**
  40774. * Returns the current npm package of the sdk
  40775. */
  40776. static get NpmPackage(): string;
  40777. /**
  40778. * Returns the current version of the framework
  40779. */
  40780. static get Version(): string;
  40781. /** Gets the list of created engines */
  40782. static get Instances(): Engine[];
  40783. /**
  40784. * Gets the latest created engine
  40785. */
  40786. static get LastCreatedEngine(): Nullable<Engine>;
  40787. /**
  40788. * Gets the latest created scene
  40789. */
  40790. static get LastCreatedScene(): Nullable<Scene>;
  40791. /**
  40792. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40793. * @param flag defines which part of the materials must be marked as dirty
  40794. * @param predicate defines a predicate used to filter which materials should be affected
  40795. */
  40796. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40797. /**
  40798. * Method called to create the default loading screen.
  40799. * This can be overriden in your own app.
  40800. * @param canvas The rendering canvas element
  40801. * @returns The loading screen
  40802. */
  40803. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40804. /**
  40805. * Method called to create the default rescale post process on each engine.
  40806. */
  40807. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40808. /**
  40809. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40810. **/
  40811. enableOfflineSupport: boolean;
  40812. /**
  40813. * 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)
  40814. **/
  40815. disableManifestCheck: boolean;
  40816. /**
  40817. * Gets the list of created scenes
  40818. */
  40819. scenes: Scene[];
  40820. /**
  40821. * Event raised when a new scene is created
  40822. */
  40823. onNewSceneAddedObservable: Observable<Scene>;
  40824. /**
  40825. * Gets the list of created postprocesses
  40826. */
  40827. postProcesses: PostProcess[];
  40828. /**
  40829. * Gets a boolean indicating if the pointer is currently locked
  40830. */
  40831. isPointerLock: boolean;
  40832. /**
  40833. * Observable event triggered each time the rendering canvas is resized
  40834. */
  40835. onResizeObservable: Observable<Engine>;
  40836. /**
  40837. * Observable event triggered each time the canvas loses focus
  40838. */
  40839. onCanvasBlurObservable: Observable<Engine>;
  40840. /**
  40841. * Observable event triggered each time the canvas gains focus
  40842. */
  40843. onCanvasFocusObservable: Observable<Engine>;
  40844. /**
  40845. * Observable event triggered each time the canvas receives pointerout event
  40846. */
  40847. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40848. /**
  40849. * Observable raised when the engine begins a new frame
  40850. */
  40851. onBeginFrameObservable: Observable<Engine>;
  40852. /**
  40853. * If set, will be used to request the next animation frame for the render loop
  40854. */
  40855. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40856. /**
  40857. * Observable raised when the engine ends the current frame
  40858. */
  40859. onEndFrameObservable: Observable<Engine>;
  40860. /**
  40861. * Observable raised when the engine is about to compile a shader
  40862. */
  40863. onBeforeShaderCompilationObservable: Observable<Engine>;
  40864. /**
  40865. * Observable raised when the engine has jsut compiled a shader
  40866. */
  40867. onAfterShaderCompilationObservable: Observable<Engine>;
  40868. /**
  40869. * Gets the audio engine
  40870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40871. * @ignorenaming
  40872. */
  40873. static audioEngine: IAudioEngine;
  40874. /**
  40875. * Default AudioEngine factory responsible of creating the Audio Engine.
  40876. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40877. */
  40878. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40879. /**
  40880. * Default offline support factory responsible of creating a tool used to store data locally.
  40881. * By default, this will create a Database object if the workload has been embedded.
  40882. */
  40883. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40884. private _loadingScreen;
  40885. private _pointerLockRequested;
  40886. private _rescalePostProcess;
  40887. private _deterministicLockstep;
  40888. private _lockstepMaxSteps;
  40889. private _timeStep;
  40890. protected get _supportsHardwareTextureRescaling(): boolean;
  40891. private _fps;
  40892. private _deltaTime;
  40893. /** @hidden */
  40894. _drawCalls: PerfCounter;
  40895. /** 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 */
  40896. canvasTabIndex: number;
  40897. /**
  40898. * Turn this value on if you want to pause FPS computation when in background
  40899. */
  40900. disablePerformanceMonitorInBackground: boolean;
  40901. private _performanceMonitor;
  40902. /**
  40903. * Gets the performance monitor attached to this engine
  40904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40905. */
  40906. get performanceMonitor(): PerformanceMonitor;
  40907. private _onFocus;
  40908. private _onBlur;
  40909. private _onCanvasPointerOut;
  40910. private _onCanvasBlur;
  40911. private _onCanvasFocus;
  40912. private _onFullscreenChange;
  40913. private _onPointerLockChange;
  40914. /**
  40915. * Gets the HTML element used to attach event listeners
  40916. * @returns a HTML element
  40917. */
  40918. getInputElement(): Nullable<HTMLElement>;
  40919. /**
  40920. * Creates a new engine
  40921. * @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
  40922. * @param antialias defines enable antialiasing (default: false)
  40923. * @param options defines further options to be sent to the getContext() function
  40924. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40925. */
  40926. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40927. /**
  40928. * Gets current aspect ratio
  40929. * @param viewportOwner defines the camera to use to get the aspect ratio
  40930. * @param useScreen defines if screen size must be used (or the current render target if any)
  40931. * @returns a number defining the aspect ratio
  40932. */
  40933. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40934. /**
  40935. * Gets current screen aspect ratio
  40936. * @returns a number defining the aspect ratio
  40937. */
  40938. getScreenAspectRatio(): number;
  40939. /**
  40940. * Gets the client rect of the HTML canvas attached with the current webGL context
  40941. * @returns a client rectanglee
  40942. */
  40943. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40944. /**
  40945. * Gets the client rect of the HTML element used for events
  40946. * @returns a client rectanglee
  40947. */
  40948. getInputElementClientRect(): Nullable<ClientRect>;
  40949. /**
  40950. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40952. * @returns true if engine is in deterministic lock step mode
  40953. */
  40954. isDeterministicLockStep(): boolean;
  40955. /**
  40956. * Gets the max steps when engine is running in deterministic lock step
  40957. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40958. * @returns the max steps
  40959. */
  40960. getLockstepMaxSteps(): number;
  40961. /**
  40962. * Returns the time in ms between steps when using deterministic lock step.
  40963. * @returns time step in (ms)
  40964. */
  40965. getTimeStep(): number;
  40966. /**
  40967. * Force the mipmap generation for the given render target texture
  40968. * @param texture defines the render target texture to use
  40969. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40970. */
  40971. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40972. /** States */
  40973. /**
  40974. * Set various states to the webGL context
  40975. * @param culling defines backface culling state
  40976. * @param zOffset defines the value to apply to zOffset (0 by default)
  40977. * @param force defines if states must be applied even if cache is up to date
  40978. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40979. */
  40980. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40981. /**
  40982. * Set the z offset to apply to current rendering
  40983. * @param value defines the offset to apply
  40984. */
  40985. setZOffset(value: number): void;
  40986. /**
  40987. * Gets the current value of the zOffset
  40988. * @returns the current zOffset state
  40989. */
  40990. getZOffset(): number;
  40991. /**
  40992. * Enable or disable depth buffering
  40993. * @param enable defines the state to set
  40994. */
  40995. setDepthBuffer(enable: boolean): void;
  40996. /**
  40997. * Gets a boolean indicating if depth writing is enabled
  40998. * @returns the current depth writing state
  40999. */
  41000. getDepthWrite(): boolean;
  41001. /**
  41002. * Enable or disable depth writing
  41003. * @param enable defines the state to set
  41004. */
  41005. setDepthWrite(enable: boolean): void;
  41006. /**
  41007. * Gets a boolean indicating if stencil buffer is enabled
  41008. * @returns the current stencil buffer state
  41009. */
  41010. getStencilBuffer(): boolean;
  41011. /**
  41012. * Enable or disable the stencil buffer
  41013. * @param enable defines if the stencil buffer must be enabled or disabled
  41014. */
  41015. setStencilBuffer(enable: boolean): void;
  41016. /**
  41017. * Gets the current stencil mask
  41018. * @returns a number defining the new stencil mask to use
  41019. */
  41020. getStencilMask(): number;
  41021. /**
  41022. * Sets the current stencil mask
  41023. * @param mask defines the new stencil mask to use
  41024. */
  41025. setStencilMask(mask: number): void;
  41026. /**
  41027. * Gets the current stencil function
  41028. * @returns a number defining the stencil function to use
  41029. */
  41030. getStencilFunction(): number;
  41031. /**
  41032. * Gets the current stencil reference value
  41033. * @returns a number defining the stencil reference value to use
  41034. */
  41035. getStencilFunctionReference(): number;
  41036. /**
  41037. * Gets the current stencil mask
  41038. * @returns a number defining the stencil mask to use
  41039. */
  41040. getStencilFunctionMask(): number;
  41041. /**
  41042. * Sets the current stencil function
  41043. * @param stencilFunc defines the new stencil function to use
  41044. */
  41045. setStencilFunction(stencilFunc: number): void;
  41046. /**
  41047. * Sets the current stencil reference
  41048. * @param reference defines the new stencil reference to use
  41049. */
  41050. setStencilFunctionReference(reference: number): void;
  41051. /**
  41052. * Sets the current stencil mask
  41053. * @param mask defines the new stencil mask to use
  41054. */
  41055. setStencilFunctionMask(mask: number): void;
  41056. /**
  41057. * Gets the current stencil operation when stencil fails
  41058. * @returns a number defining stencil operation to use when stencil fails
  41059. */
  41060. getStencilOperationFail(): number;
  41061. /**
  41062. * Gets the current stencil operation when depth fails
  41063. * @returns a number defining stencil operation to use when depth fails
  41064. */
  41065. getStencilOperationDepthFail(): number;
  41066. /**
  41067. * Gets the current stencil operation when stencil passes
  41068. * @returns a number defining stencil operation to use when stencil passes
  41069. */
  41070. getStencilOperationPass(): number;
  41071. /**
  41072. * Sets the stencil operation to use when stencil fails
  41073. * @param operation defines the stencil operation to use when stencil fails
  41074. */
  41075. setStencilOperationFail(operation: number): void;
  41076. /**
  41077. * Sets the stencil operation to use when depth fails
  41078. * @param operation defines the stencil operation to use when depth fails
  41079. */
  41080. setStencilOperationDepthFail(operation: number): void;
  41081. /**
  41082. * Sets the stencil operation to use when stencil passes
  41083. * @param operation defines the stencil operation to use when stencil passes
  41084. */
  41085. setStencilOperationPass(operation: number): void;
  41086. /**
  41087. * Sets a boolean indicating if the dithering state is enabled or disabled
  41088. * @param value defines the dithering state
  41089. */
  41090. setDitheringState(value: boolean): void;
  41091. /**
  41092. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41093. * @param value defines the rasterizer state
  41094. */
  41095. setRasterizerState(value: boolean): void;
  41096. /**
  41097. * Gets the current depth function
  41098. * @returns a number defining the depth function
  41099. */
  41100. getDepthFunction(): Nullable<number>;
  41101. /**
  41102. * Sets the current depth function
  41103. * @param depthFunc defines the function to use
  41104. */
  41105. setDepthFunction(depthFunc: number): void;
  41106. /**
  41107. * Sets the current depth function to GREATER
  41108. */
  41109. setDepthFunctionToGreater(): void;
  41110. /**
  41111. * Sets the current depth function to GEQUAL
  41112. */
  41113. setDepthFunctionToGreaterOrEqual(): void;
  41114. /**
  41115. * Sets the current depth function to LESS
  41116. */
  41117. setDepthFunctionToLess(): void;
  41118. /**
  41119. * Sets the current depth function to LEQUAL
  41120. */
  41121. setDepthFunctionToLessOrEqual(): void;
  41122. private _cachedStencilBuffer;
  41123. private _cachedStencilFunction;
  41124. private _cachedStencilMask;
  41125. private _cachedStencilOperationPass;
  41126. private _cachedStencilOperationFail;
  41127. private _cachedStencilOperationDepthFail;
  41128. private _cachedStencilReference;
  41129. /**
  41130. * Caches the the state of the stencil buffer
  41131. */
  41132. cacheStencilState(): void;
  41133. /**
  41134. * Restores the state of the stencil buffer
  41135. */
  41136. restoreStencilState(): void;
  41137. /**
  41138. * Directly set the WebGL Viewport
  41139. * @param x defines the x coordinate of the viewport (in screen space)
  41140. * @param y defines the y coordinate of the viewport (in screen space)
  41141. * @param width defines the width of the viewport (in screen space)
  41142. * @param height defines the height of the viewport (in screen space)
  41143. * @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
  41144. */
  41145. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41146. /**
  41147. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41148. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41149. * @param y defines the y-coordinate of the corner of the clear rectangle
  41150. * @param width defines the width of the clear rectangle
  41151. * @param height defines the height of the clear rectangle
  41152. * @param clearColor defines the clear color
  41153. */
  41154. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41155. /**
  41156. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41157. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41158. * @param y defines the y-coordinate of the corner of the clear rectangle
  41159. * @param width defines the width of the clear rectangle
  41160. * @param height defines the height of the clear rectangle
  41161. */
  41162. enableScissor(x: number, y: number, width: number, height: number): void;
  41163. /**
  41164. * Disable previously set scissor test rectangle
  41165. */
  41166. disableScissor(): void;
  41167. protected _reportDrawCall(): void;
  41168. /**
  41169. * Initializes a webVR display and starts listening to display change events
  41170. * The onVRDisplayChangedObservable will be notified upon these changes
  41171. * @returns The onVRDisplayChangedObservable
  41172. */
  41173. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41174. /** @hidden */
  41175. _prepareVRComponent(): void;
  41176. /** @hidden */
  41177. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41178. /** @hidden */
  41179. _submitVRFrame(): void;
  41180. /**
  41181. * Call this function to leave webVR mode
  41182. * Will do nothing if webVR is not supported or if there is no webVR device
  41183. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41184. */
  41185. disableVR(): void;
  41186. /**
  41187. * Gets a boolean indicating that the system is in VR mode and is presenting
  41188. * @returns true if VR mode is engaged
  41189. */
  41190. isVRPresenting(): boolean;
  41191. /** @hidden */
  41192. _requestVRFrame(): void;
  41193. /** @hidden */
  41194. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41195. /**
  41196. * Gets the source code of the vertex shader associated with a specific webGL program
  41197. * @param program defines the program to use
  41198. * @returns a string containing the source code of the vertex shader associated with the program
  41199. */
  41200. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41201. /**
  41202. * Gets the source code of the fragment shader associated with a specific webGL program
  41203. * @param program defines the program to use
  41204. * @returns a string containing the source code of the fragment shader associated with the program
  41205. */
  41206. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41207. /**
  41208. * Sets a depth stencil texture from a render target to the according uniform.
  41209. * @param channel The texture channel
  41210. * @param uniform The uniform to set
  41211. * @param texture The render target texture containing the depth stencil texture to apply
  41212. */
  41213. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41214. /**
  41215. * Sets a texture to the webGL context from a postprocess
  41216. * @param channel defines the channel to use
  41217. * @param postProcess defines the source postprocess
  41218. */
  41219. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41220. /**
  41221. * Binds the output of the passed in post process to the texture channel specified
  41222. * @param channel The channel the texture should be bound to
  41223. * @param postProcess The post process which's output should be bound
  41224. */
  41225. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41226. protected _rebuildBuffers(): void;
  41227. /** @hidden */
  41228. _renderFrame(): void;
  41229. _renderLoop(): void;
  41230. /** @hidden */
  41231. _renderViews(): boolean;
  41232. /**
  41233. * Toggle full screen mode
  41234. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41235. */
  41236. switchFullscreen(requestPointerLock: boolean): void;
  41237. /**
  41238. * Enters full screen mode
  41239. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41240. */
  41241. enterFullscreen(requestPointerLock: boolean): void;
  41242. /**
  41243. * Exits full screen mode
  41244. */
  41245. exitFullscreen(): void;
  41246. /**
  41247. * Enters Pointerlock mode
  41248. */
  41249. enterPointerlock(): void;
  41250. /**
  41251. * Exits Pointerlock mode
  41252. */
  41253. exitPointerlock(): void;
  41254. /**
  41255. * Begin a new frame
  41256. */
  41257. beginFrame(): void;
  41258. /**
  41259. * Enf the current frame
  41260. */
  41261. endFrame(): void;
  41262. resize(): void;
  41263. /**
  41264. * Force a specific size of the canvas
  41265. * @param width defines the new canvas' width
  41266. * @param height defines the new canvas' height
  41267. * @returns true if the size was changed
  41268. */
  41269. setSize(width: number, height: number): boolean;
  41270. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41272. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41273. _releaseTexture(texture: InternalTexture): void;
  41274. /**
  41275. * @hidden
  41276. * Rescales a texture
  41277. * @param source input texutre
  41278. * @param destination destination texture
  41279. * @param scene scene to use to render the resize
  41280. * @param internalFormat format to use when resizing
  41281. * @param onComplete callback to be called when resize has completed
  41282. */
  41283. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41284. /**
  41285. * Gets the current framerate
  41286. * @returns a number representing the framerate
  41287. */
  41288. getFps(): number;
  41289. /**
  41290. * Gets the time spent between current and previous frame
  41291. * @returns a number representing the delta time in ms
  41292. */
  41293. getDeltaTime(): number;
  41294. private _measureFps;
  41295. /** @hidden */
  41296. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41297. /**
  41298. * Updates the sample count of a render target texture
  41299. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41300. * @param texture defines the texture to update
  41301. * @param samples defines the sample count to set
  41302. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41303. */
  41304. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41305. /**
  41306. * Updates a depth texture Comparison Mode and Function.
  41307. * If the comparison Function is equal to 0, the mode will be set to none.
  41308. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41309. * @param texture The texture to set the comparison function for
  41310. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41311. */
  41312. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41313. /**
  41314. * Creates a webGL buffer to use with instanciation
  41315. * @param capacity defines the size of the buffer
  41316. * @returns the webGL buffer
  41317. */
  41318. createInstancesBuffer(capacity: number): DataBuffer;
  41319. /**
  41320. * Delete a webGL buffer used with instanciation
  41321. * @param buffer defines the webGL buffer to delete
  41322. */
  41323. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41324. private _clientWaitAsync;
  41325. /** @hidden */
  41326. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41327. dispose(): void;
  41328. private _disableTouchAction;
  41329. /**
  41330. * Display the loading screen
  41331. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41332. */
  41333. displayLoadingUI(): void;
  41334. /**
  41335. * Hide the loading screen
  41336. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41337. */
  41338. hideLoadingUI(): void;
  41339. /**
  41340. * Gets the current loading screen object
  41341. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41342. */
  41343. get loadingScreen(): ILoadingScreen;
  41344. /**
  41345. * Sets the current loading screen object
  41346. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41347. */
  41348. set loadingScreen(loadingScreen: ILoadingScreen);
  41349. /**
  41350. * Sets the current loading screen text
  41351. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41352. */
  41353. set loadingUIText(text: string);
  41354. /**
  41355. * Sets the current loading screen background color
  41356. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41357. */
  41358. set loadingUIBackgroundColor(color: string);
  41359. /** Pointerlock and fullscreen */
  41360. /**
  41361. * Ask the browser to promote the current element to pointerlock mode
  41362. * @param element defines the DOM element to promote
  41363. */
  41364. static _RequestPointerlock(element: HTMLElement): void;
  41365. /**
  41366. * Asks the browser to exit pointerlock mode
  41367. */
  41368. static _ExitPointerlock(): void;
  41369. /**
  41370. * Ask the browser to promote the current element to fullscreen rendering mode
  41371. * @param element defines the DOM element to promote
  41372. */
  41373. static _RequestFullscreen(element: HTMLElement): void;
  41374. /**
  41375. * Asks the browser to exit fullscreen mode
  41376. */
  41377. static _ExitFullscreen(): void;
  41378. }
  41379. }
  41380. declare module BABYLON {
  41381. /**
  41382. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41383. * during the life time of the application.
  41384. */
  41385. export class EngineStore {
  41386. /** Gets the list of created engines */
  41387. static Instances: Engine[];
  41388. /** @hidden */
  41389. static _LastCreatedScene: Nullable<Scene>;
  41390. /**
  41391. * Gets the latest created engine
  41392. */
  41393. static get LastCreatedEngine(): Nullable<Engine>;
  41394. /**
  41395. * Gets the latest created scene
  41396. */
  41397. static get LastCreatedScene(): Nullable<Scene>;
  41398. /**
  41399. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41400. * @ignorenaming
  41401. */
  41402. static UseFallbackTexture: boolean;
  41403. /**
  41404. * Texture content used if a texture cannot loaded
  41405. * @ignorenaming
  41406. */
  41407. static FallbackTexture: string;
  41408. }
  41409. }
  41410. declare module BABYLON {
  41411. /**
  41412. * Helper class that provides a small promise polyfill
  41413. */
  41414. export class PromisePolyfill {
  41415. /**
  41416. * Static function used to check if the polyfill is required
  41417. * If this is the case then the function will inject the polyfill to window.Promise
  41418. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41419. */
  41420. static Apply(force?: boolean): void;
  41421. }
  41422. }
  41423. declare module BABYLON {
  41424. /**
  41425. * Interface for screenshot methods with describe argument called `size` as object with options
  41426. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41427. */
  41428. export interface IScreenshotSize {
  41429. /**
  41430. * number in pixels for canvas height
  41431. */
  41432. height?: number;
  41433. /**
  41434. * multiplier allowing render at a higher or lower resolution
  41435. * If value is defined then height and width will be ignored and taken from camera
  41436. */
  41437. precision?: number;
  41438. /**
  41439. * number in pixels for canvas width
  41440. */
  41441. width?: number;
  41442. }
  41443. }
  41444. declare module BABYLON {
  41445. interface IColor4Like {
  41446. r: float;
  41447. g: float;
  41448. b: float;
  41449. a: float;
  41450. }
  41451. /**
  41452. * Class containing a set of static utilities functions
  41453. */
  41454. export class Tools {
  41455. /**
  41456. * Gets or sets the base URL to use to load assets
  41457. */
  41458. static get BaseUrl(): string;
  41459. static set BaseUrl(value: string);
  41460. /**
  41461. * Enable/Disable Custom HTTP Request Headers globally.
  41462. * default = false
  41463. * @see CustomRequestHeaders
  41464. */
  41465. static UseCustomRequestHeaders: boolean;
  41466. /**
  41467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41468. * i.e. when loading files, where the server/service expects an Authorization header
  41469. */
  41470. static CustomRequestHeaders: {
  41471. [key: string]: string;
  41472. };
  41473. /**
  41474. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41475. */
  41476. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41477. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41478. /**
  41479. * Default behaviour for cors in the application.
  41480. * It can be a string if the expected behavior is identical in the entire app.
  41481. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41482. */
  41483. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41484. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41485. /**
  41486. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41487. * @ignorenaming
  41488. */
  41489. static get UseFallbackTexture(): boolean;
  41490. static set UseFallbackTexture(value: boolean);
  41491. /**
  41492. * Use this object to register external classes like custom textures or material
  41493. * to allow the laoders to instantiate them
  41494. */
  41495. static get RegisteredExternalClasses(): {
  41496. [key: string]: Object;
  41497. };
  41498. static set RegisteredExternalClasses(classes: {
  41499. [key: string]: Object;
  41500. });
  41501. /**
  41502. * Texture content used if a texture cannot loaded
  41503. * @ignorenaming
  41504. */
  41505. static get fallbackTexture(): string;
  41506. static set fallbackTexture(value: string);
  41507. /**
  41508. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41509. * @param u defines the coordinate on X axis
  41510. * @param v defines the coordinate on Y axis
  41511. * @param width defines the width of the source data
  41512. * @param height defines the height of the source data
  41513. * @param pixels defines the source byte array
  41514. * @param color defines the output color
  41515. */
  41516. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41517. /**
  41518. * Interpolates between a and b via alpha
  41519. * @param a The lower value (returned when alpha = 0)
  41520. * @param b The upper value (returned when alpha = 1)
  41521. * @param alpha The interpolation-factor
  41522. * @return The mixed value
  41523. */
  41524. static Mix(a: number, b: number, alpha: number): number;
  41525. /**
  41526. * Tries to instantiate a new object from a given class name
  41527. * @param className defines the class name to instantiate
  41528. * @returns the new object or null if the system was not able to do the instantiation
  41529. */
  41530. static Instantiate(className: string): any;
  41531. /**
  41532. * Provides a slice function that will work even on IE
  41533. * @param data defines the array to slice
  41534. * @param start defines the start of the data (optional)
  41535. * @param end defines the end of the data (optional)
  41536. * @returns the new sliced array
  41537. */
  41538. static Slice<T>(data: T, start?: number, end?: number): T;
  41539. /**
  41540. * Provides a slice function that will work even on IE
  41541. * The difference between this and Slice is that this will force-convert to array
  41542. * @param data defines the array to slice
  41543. * @param start defines the start of the data (optional)
  41544. * @param end defines the end of the data (optional)
  41545. * @returns the new sliced array
  41546. */
  41547. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41548. /**
  41549. * Polyfill for setImmediate
  41550. * @param action defines the action to execute after the current execution block
  41551. */
  41552. static SetImmediate(action: () => void): void;
  41553. /**
  41554. * Function indicating if a number is an exponent of 2
  41555. * @param value defines the value to test
  41556. * @returns true if the value is an exponent of 2
  41557. */
  41558. static IsExponentOfTwo(value: number): boolean;
  41559. private static _tmpFloatArray;
  41560. /**
  41561. * Returns the nearest 32-bit single precision float representation of a Number
  41562. * @param value A Number. If the parameter is of a different type, it will get converted
  41563. * to a number or to NaN if it cannot be converted
  41564. * @returns number
  41565. */
  41566. static FloatRound(value: number): number;
  41567. /**
  41568. * Extracts the filename from a path
  41569. * @param path defines the path to use
  41570. * @returns the filename
  41571. */
  41572. static GetFilename(path: string): string;
  41573. /**
  41574. * Extracts the "folder" part of a path (everything before the filename).
  41575. * @param uri The URI to extract the info from
  41576. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41577. * @returns The "folder" part of the path
  41578. */
  41579. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41580. /**
  41581. * Extracts text content from a DOM element hierarchy
  41582. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41583. */
  41584. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41585. /**
  41586. * Convert an angle in radians to degrees
  41587. * @param angle defines the angle to convert
  41588. * @returns the angle in degrees
  41589. */
  41590. static ToDegrees(angle: number): number;
  41591. /**
  41592. * Convert an angle in degrees to radians
  41593. * @param angle defines the angle to convert
  41594. * @returns the angle in radians
  41595. */
  41596. static ToRadians(angle: number): number;
  41597. /**
  41598. * Returns an array if obj is not an array
  41599. * @param obj defines the object to evaluate as an array
  41600. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41601. * @returns either obj directly if obj is an array or a new array containing obj
  41602. */
  41603. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41604. /**
  41605. * Gets the pointer prefix to use
  41606. * @param engine defines the engine we are finding the prefix for
  41607. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41608. */
  41609. static GetPointerPrefix(engine: Engine): string;
  41610. /**
  41611. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41612. * @param url define the url we are trying
  41613. * @param element define the dom element where to configure the cors policy
  41614. */
  41615. static SetCorsBehavior(url: string | string[], element: {
  41616. crossOrigin: string | null;
  41617. }): void;
  41618. /**
  41619. * Removes unwanted characters from an url
  41620. * @param url defines the url to clean
  41621. * @returns the cleaned url
  41622. */
  41623. static CleanUrl(url: string): string;
  41624. /**
  41625. * Gets or sets a function used to pre-process url before using them to load assets
  41626. */
  41627. static get PreprocessUrl(): (url: string) => string;
  41628. static set PreprocessUrl(processor: (url: string) => string);
  41629. /**
  41630. * Loads an image as an HTMLImageElement.
  41631. * @param input url string, ArrayBuffer, or Blob to load
  41632. * @param onLoad callback called when the image successfully loads
  41633. * @param onError callback called when the image fails to load
  41634. * @param offlineProvider offline provider for caching
  41635. * @param mimeType optional mime type
  41636. * @returns the HTMLImageElement of the loaded image
  41637. */
  41638. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41639. /**
  41640. * Loads a file from a url
  41641. * @param url url string, ArrayBuffer, or Blob to load
  41642. * @param onSuccess callback called when the file successfully loads
  41643. * @param onProgress callback called while file is loading (if the server supports this mode)
  41644. * @param offlineProvider defines the offline provider for caching
  41645. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41646. * @param onError callback called when the file fails to load
  41647. * @returns a file request object
  41648. */
  41649. 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;
  41650. /**
  41651. * Loads a file from a url
  41652. * @param url the file url to load
  41653. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41654. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41655. */
  41656. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41657. /**
  41658. * Load a script (identified by an url). When the url returns, the
  41659. * content of this file is added into a new script element, attached to the DOM (body element)
  41660. * @param scriptUrl defines the url of the script to laod
  41661. * @param onSuccess defines the callback called when the script is loaded
  41662. * @param onError defines the callback to call if an error occurs
  41663. * @param scriptId defines the id of the script element
  41664. */
  41665. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41666. /**
  41667. * Load an asynchronous script (identified by an url). When the url returns, the
  41668. * content of this file is added into a new script element, attached to the DOM (body element)
  41669. * @param scriptUrl defines the url of the script to laod
  41670. * @param scriptId defines the id of the script element
  41671. * @returns a promise request object
  41672. */
  41673. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41674. /**
  41675. * Loads a file from a blob
  41676. * @param fileToLoad defines the blob to use
  41677. * @param callback defines the callback to call when data is loaded
  41678. * @param progressCallback defines the callback to call during loading process
  41679. * @returns a file request object
  41680. */
  41681. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41682. /**
  41683. * Reads a file from a File object
  41684. * @param file defines the file to load
  41685. * @param onSuccess defines the callback to call when data is loaded
  41686. * @param onProgress defines the callback to call during loading process
  41687. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41688. * @param onError defines the callback to call when an error occurs
  41689. * @returns a file request object
  41690. */
  41691. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41692. /**
  41693. * Creates a data url from a given string content
  41694. * @param content defines the content to convert
  41695. * @returns the new data url link
  41696. */
  41697. static FileAsURL(content: string): string;
  41698. /**
  41699. * Format the given number to a specific decimal format
  41700. * @param value defines the number to format
  41701. * @param decimals defines the number of decimals to use
  41702. * @returns the formatted string
  41703. */
  41704. static Format(value: number, decimals?: number): string;
  41705. /**
  41706. * Tries to copy an object by duplicating every property
  41707. * @param source defines the source object
  41708. * @param destination defines the target object
  41709. * @param doNotCopyList defines a list of properties to avoid
  41710. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41711. */
  41712. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41713. /**
  41714. * Gets a boolean indicating if the given object has no own property
  41715. * @param obj defines the object to test
  41716. * @returns true if object has no own property
  41717. */
  41718. static IsEmpty(obj: any): boolean;
  41719. /**
  41720. * Function used to register events at window level
  41721. * @param windowElement defines the Window object to use
  41722. * @param events defines the events to register
  41723. */
  41724. static RegisterTopRootEvents(windowElement: Window, events: {
  41725. name: string;
  41726. handler: Nullable<(e: FocusEvent) => any>;
  41727. }[]): void;
  41728. /**
  41729. * Function used to unregister events from window level
  41730. * @param windowElement defines the Window object to use
  41731. * @param events defines the events to unregister
  41732. */
  41733. static UnregisterTopRootEvents(windowElement: Window, events: {
  41734. name: string;
  41735. handler: Nullable<(e: FocusEvent) => any>;
  41736. }[]): void;
  41737. /**
  41738. * @ignore
  41739. */
  41740. static _ScreenshotCanvas: HTMLCanvasElement;
  41741. /**
  41742. * Dumps the current bound framebuffer
  41743. * @param width defines the rendering width
  41744. * @param height defines the rendering height
  41745. * @param engine defines the hosting engine
  41746. * @param successCallback defines the callback triggered once the data are available
  41747. * @param mimeType defines the mime type of the result
  41748. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41749. */
  41750. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41751. /**
  41752. * Converts the canvas data to blob.
  41753. * This acts as a polyfill for browsers not supporting the to blob function.
  41754. * @param canvas Defines the canvas to extract the data from
  41755. * @param successCallback Defines the callback triggered once the data are available
  41756. * @param mimeType Defines the mime type of the result
  41757. */
  41758. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41759. /**
  41760. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41761. * @param successCallback defines the callback triggered once the data are available
  41762. * @param mimeType defines the mime type of the result
  41763. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41764. */
  41765. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41766. /**
  41767. * Downloads a blob in the browser
  41768. * @param blob defines the blob to download
  41769. * @param fileName defines the name of the downloaded file
  41770. */
  41771. static Download(blob: Blob, fileName: string): void;
  41772. /**
  41773. * Will return the right value of the noPreventDefault variable
  41774. * Needed to keep backwards compatibility to the old API.
  41775. *
  41776. * @param args arguments passed to the attachControl function
  41777. * @returns the correct value for noPreventDefault
  41778. */
  41779. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41780. /**
  41781. * Captures a screenshot of the current rendering
  41782. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41783. * @param engine defines the rendering engine
  41784. * @param camera defines the source camera
  41785. * @param size This parameter can be set to a single number or to an object with the
  41786. * following (optional) properties: precision, width, height. If a single number is passed,
  41787. * it will be used for both width and height. If an object is passed, the screenshot size
  41788. * will be derived from the parameters. The precision property is a multiplier allowing
  41789. * rendering at a higher or lower resolution
  41790. * @param successCallback defines the callback receives a single parameter which contains the
  41791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41792. * src parameter of an <img> to display it
  41793. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41794. * Check your browser for supported MIME types
  41795. */
  41796. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41797. /**
  41798. * Captures a screenshot of the current rendering
  41799. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41800. * @param engine defines the rendering engine
  41801. * @param camera defines the source camera
  41802. * @param size This parameter can be set to a single number or to an object with the
  41803. * following (optional) properties: precision, width, height. If a single number is passed,
  41804. * it will be used for both width and height. If an object is passed, the screenshot size
  41805. * will be derived from the parameters. The precision property is a multiplier allowing
  41806. * rendering at a higher or lower resolution
  41807. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41808. * Check your browser for supported MIME types
  41809. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41810. * to the src parameter of an <img> to display it
  41811. */
  41812. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41813. /**
  41814. * Generates an image screenshot from the specified camera.
  41815. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41816. * @param engine The engine to use for rendering
  41817. * @param camera The camera to use for rendering
  41818. * @param size This parameter can be set to a single number or to an object with the
  41819. * following (optional) properties: precision, width, height. If a single number is passed,
  41820. * it will be used for both width and height. If an object is passed, the screenshot size
  41821. * will be derived from the parameters. The precision property is a multiplier allowing
  41822. * rendering at a higher or lower resolution
  41823. * @param successCallback The callback receives a single parameter which contains the
  41824. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41825. * src parameter of an <img> to display it
  41826. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41827. * Check your browser for supported MIME types
  41828. * @param samples Texture samples (default: 1)
  41829. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41830. * @param fileName A name for for the downloaded file.
  41831. */
  41832. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41833. /**
  41834. * Generates an image screenshot from the specified camera.
  41835. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41836. * @param engine The engine to use for rendering
  41837. * @param camera The camera to use for rendering
  41838. * @param size This parameter can be set to a single number or to an object with the
  41839. * following (optional) properties: precision, width, height. If a single number is passed,
  41840. * it will be used for both width and height. If an object is passed, the screenshot size
  41841. * will be derived from the parameters. The precision property is a multiplier allowing
  41842. * rendering at a higher or lower resolution
  41843. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41844. * Check your browser for supported MIME types
  41845. * @param samples Texture samples (default: 1)
  41846. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41847. * @param fileName A name for for the downloaded file.
  41848. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41849. * to the src parameter of an <img> to display it
  41850. */
  41851. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41852. /**
  41853. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41854. * Be aware Math.random() could cause collisions, but:
  41855. * "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"
  41856. * @returns a pseudo random id
  41857. */
  41858. static RandomId(): string;
  41859. /**
  41860. * Test if the given uri is a base64 string
  41861. * @param uri The uri to test
  41862. * @return True if the uri is a base64 string or false otherwise
  41863. */
  41864. static IsBase64(uri: string): boolean;
  41865. /**
  41866. * Decode the given base64 uri.
  41867. * @param uri The uri to decode
  41868. * @return The decoded base64 data.
  41869. */
  41870. static DecodeBase64(uri: string): ArrayBuffer;
  41871. /**
  41872. * Gets the absolute url.
  41873. * @param url the input url
  41874. * @return the absolute url
  41875. */
  41876. static GetAbsoluteUrl(url: string): string;
  41877. /**
  41878. * No log
  41879. */
  41880. static readonly NoneLogLevel: number;
  41881. /**
  41882. * Only message logs
  41883. */
  41884. static readonly MessageLogLevel: number;
  41885. /**
  41886. * Only warning logs
  41887. */
  41888. static readonly WarningLogLevel: number;
  41889. /**
  41890. * Only error logs
  41891. */
  41892. static readonly ErrorLogLevel: number;
  41893. /**
  41894. * All logs
  41895. */
  41896. static readonly AllLogLevel: number;
  41897. /**
  41898. * Gets a value indicating the number of loading errors
  41899. * @ignorenaming
  41900. */
  41901. static get errorsCount(): number;
  41902. /**
  41903. * Callback called when a new log is added
  41904. */
  41905. static OnNewCacheEntry: (entry: string) => void;
  41906. /**
  41907. * Log a message to the console
  41908. * @param message defines the message to log
  41909. */
  41910. static Log(message: string): void;
  41911. /**
  41912. * Write a warning message to the console
  41913. * @param message defines the message to log
  41914. */
  41915. static Warn(message: string): void;
  41916. /**
  41917. * Write an error message to the console
  41918. * @param message defines the message to log
  41919. */
  41920. static Error(message: string): void;
  41921. /**
  41922. * Gets current log cache (list of logs)
  41923. */
  41924. static get LogCache(): string;
  41925. /**
  41926. * Clears the log cache
  41927. */
  41928. static ClearLogCache(): void;
  41929. /**
  41930. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41931. */
  41932. static set LogLevels(level: number);
  41933. /**
  41934. * Checks if the window object exists
  41935. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41936. */
  41937. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41938. /**
  41939. * No performance log
  41940. */
  41941. static readonly PerformanceNoneLogLevel: number;
  41942. /**
  41943. * Use user marks to log performance
  41944. */
  41945. static readonly PerformanceUserMarkLogLevel: number;
  41946. /**
  41947. * Log performance to the console
  41948. */
  41949. static readonly PerformanceConsoleLogLevel: number;
  41950. private static _performance;
  41951. /**
  41952. * Sets the current performance log level
  41953. */
  41954. static set PerformanceLogLevel(level: number);
  41955. private static _StartPerformanceCounterDisabled;
  41956. private static _EndPerformanceCounterDisabled;
  41957. private static _StartUserMark;
  41958. private static _EndUserMark;
  41959. private static _StartPerformanceConsole;
  41960. private static _EndPerformanceConsole;
  41961. /**
  41962. * Starts a performance counter
  41963. */
  41964. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41965. /**
  41966. * Ends a specific performance coutner
  41967. */
  41968. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41969. /**
  41970. * Gets either window.performance.now() if supported or Date.now() else
  41971. */
  41972. static get Now(): number;
  41973. /**
  41974. * This method will return the name of the class used to create the instance of the given object.
  41975. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41976. * @param object the object to get the class name from
  41977. * @param isType defines if the object is actually a type
  41978. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41979. */
  41980. static GetClassName(object: any, isType?: boolean): string;
  41981. /**
  41982. * Gets the first element of an array satisfying a given predicate
  41983. * @param array defines the array to browse
  41984. * @param predicate defines the predicate to use
  41985. * @returns null if not found or the element
  41986. */
  41987. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41988. /**
  41989. * This method will return the name of the full name of the class, including its owning module (if any).
  41990. * 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).
  41991. * @param object the object to get the class name from
  41992. * @param isType defines if the object is actually a type
  41993. * @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.
  41994. * @ignorenaming
  41995. */
  41996. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41997. /**
  41998. * Returns a promise that resolves after the given amount of time.
  41999. * @param delay Number of milliseconds to delay
  42000. * @returns Promise that resolves after the given amount of time
  42001. */
  42002. static DelayAsync(delay: number): Promise<void>;
  42003. /**
  42004. * Utility function to detect if the current user agent is Safari
  42005. * @returns whether or not the current user agent is safari
  42006. */
  42007. static IsSafari(): boolean;
  42008. }
  42009. /**
  42010. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42011. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42012. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42013. * @param name The name of the class, case should be preserved
  42014. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42015. */
  42016. export function className(name: string, module?: string): (target: Object) => void;
  42017. /**
  42018. * An implementation of a loop for asynchronous functions.
  42019. */
  42020. export class AsyncLoop {
  42021. /**
  42022. * Defines the number of iterations for the loop
  42023. */
  42024. iterations: number;
  42025. /**
  42026. * Defines the current index of the loop.
  42027. */
  42028. index: number;
  42029. private _done;
  42030. private _fn;
  42031. private _successCallback;
  42032. /**
  42033. * Constructor.
  42034. * @param iterations the number of iterations.
  42035. * @param func the function to run each iteration
  42036. * @param successCallback the callback that will be called upon succesful execution
  42037. * @param offset starting offset.
  42038. */
  42039. constructor(
  42040. /**
  42041. * Defines the number of iterations for the loop
  42042. */
  42043. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42044. /**
  42045. * Execute the next iteration. Must be called after the last iteration was finished.
  42046. */
  42047. executeNext(): void;
  42048. /**
  42049. * Break the loop and run the success callback.
  42050. */
  42051. breakLoop(): void;
  42052. /**
  42053. * Create and run an async loop.
  42054. * @param iterations the number of iterations.
  42055. * @param fn the function to run each iteration
  42056. * @param successCallback the callback that will be called upon succesful execution
  42057. * @param offset starting offset.
  42058. * @returns the created async loop object
  42059. */
  42060. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42061. /**
  42062. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42063. * @param iterations total number of iterations
  42064. * @param syncedIterations number of synchronous iterations in each async iteration.
  42065. * @param fn the function to call each iteration.
  42066. * @param callback a success call back that will be called when iterating stops.
  42067. * @param breakFunction a break condition (optional)
  42068. * @param timeout timeout settings for the setTimeout function. default - 0.
  42069. * @returns the created async loop object
  42070. */
  42071. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42072. }
  42073. }
  42074. declare module BABYLON {
  42075. /**
  42076. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42077. * The underlying implementation relies on an associative array to ensure the best performances.
  42078. * The value can be anything including 'null' but except 'undefined'
  42079. */
  42080. export class StringDictionary<T> {
  42081. /**
  42082. * This will clear this dictionary and copy the content from the 'source' one.
  42083. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42084. * @param source the dictionary to take the content from and copy to this dictionary
  42085. */
  42086. copyFrom(source: StringDictionary<T>): void;
  42087. /**
  42088. * Get a value based from its key
  42089. * @param key the given key to get the matching value from
  42090. * @return the value if found, otherwise undefined is returned
  42091. */
  42092. get(key: string): T | undefined;
  42093. /**
  42094. * Get a value from its key or add it if it doesn't exist.
  42095. * This method will ensure you that a given key/data will be present in the dictionary.
  42096. * @param key the given key to get the matching value from
  42097. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42098. * The factory will only be invoked if there's no data for the given key.
  42099. * @return the value corresponding to the key.
  42100. */
  42101. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42102. /**
  42103. * Get a value from its key if present in the dictionary otherwise add it
  42104. * @param key the key to get the value from
  42105. * @param val if there's no such key/value pair in the dictionary add it with this value
  42106. * @return the value corresponding to the key
  42107. */
  42108. getOrAdd(key: string, val: T): T;
  42109. /**
  42110. * Check if there's a given key in the dictionary
  42111. * @param key the key to check for
  42112. * @return true if the key is present, false otherwise
  42113. */
  42114. contains(key: string): boolean;
  42115. /**
  42116. * Add a new key and its corresponding value
  42117. * @param key the key to add
  42118. * @param value the value corresponding to the key
  42119. * @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
  42120. */
  42121. add(key: string, value: T): boolean;
  42122. /**
  42123. * Update a specific value associated to a key
  42124. * @param key defines the key to use
  42125. * @param value defines the value to store
  42126. * @returns true if the value was updated (or false if the key was not found)
  42127. */
  42128. set(key: string, value: T): boolean;
  42129. /**
  42130. * Get the element of the given key and remove it from the dictionary
  42131. * @param key defines the key to search
  42132. * @returns the value associated with the key or null if not found
  42133. */
  42134. getAndRemove(key: string): Nullable<T>;
  42135. /**
  42136. * Remove a key/value from the dictionary.
  42137. * @param key the key to remove
  42138. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42139. */
  42140. remove(key: string): boolean;
  42141. /**
  42142. * Clear the whole content of the dictionary
  42143. */
  42144. clear(): void;
  42145. /**
  42146. * Gets the current count
  42147. */
  42148. get count(): number;
  42149. /**
  42150. * Execute a callback on each key/val of the dictionary.
  42151. * Note that you can remove any element in this dictionary in the callback implementation
  42152. * @param callback the callback to execute on a given key/value pair
  42153. */
  42154. forEach(callback: (key: string, val: T) => void): void;
  42155. /**
  42156. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42157. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42158. * Note that you can remove any element in this dictionary in the callback implementation
  42159. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42160. * @returns the first item
  42161. */
  42162. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42163. private _count;
  42164. private _data;
  42165. }
  42166. }
  42167. declare module BABYLON {
  42168. /** @hidden */
  42169. export interface ICollisionCoordinator {
  42170. createCollider(): Collider;
  42171. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42172. init(scene: Scene): void;
  42173. }
  42174. /** @hidden */
  42175. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42176. private _scene;
  42177. private _scaledPosition;
  42178. private _scaledVelocity;
  42179. private _finalPosition;
  42180. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42181. createCollider(): Collider;
  42182. init(scene: Scene): void;
  42183. private _collideWithWorld;
  42184. }
  42185. }
  42186. declare module BABYLON {
  42187. /**
  42188. * Class used to manage all inputs for the scene.
  42189. */
  42190. export class InputManager {
  42191. /** The distance in pixel that you have to move to prevent some events */
  42192. static DragMovementThreshold: number;
  42193. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42194. static LongPressDelay: number;
  42195. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42196. static DoubleClickDelay: number;
  42197. /** If you need to check double click without raising a single click at first click, enable this flag */
  42198. static ExclusiveDoubleClickMode: boolean;
  42199. /** 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. */
  42200. private _alreadyAttached;
  42201. private _alreadyAttachedTo;
  42202. private _wheelEventName;
  42203. private _onPointerMove;
  42204. private _onPointerDown;
  42205. private _onPointerUp;
  42206. private _initClickEvent;
  42207. private _initActionManager;
  42208. private _delayedSimpleClick;
  42209. private _delayedSimpleClickTimeout;
  42210. private _previousDelayedSimpleClickTimeout;
  42211. private _meshPickProceed;
  42212. private _previousButtonPressed;
  42213. private _currentPickResult;
  42214. private _previousPickResult;
  42215. private _totalPointersPressed;
  42216. private _doubleClickOccured;
  42217. private _pointerOverMesh;
  42218. private _pickedDownMesh;
  42219. private _pickedUpMesh;
  42220. private _pointerX;
  42221. private _pointerY;
  42222. private _unTranslatedPointerX;
  42223. private _unTranslatedPointerY;
  42224. private _startingPointerPosition;
  42225. private _previousStartingPointerPosition;
  42226. private _startingPointerTime;
  42227. private _previousStartingPointerTime;
  42228. private _pointerCaptures;
  42229. private _meshUnderPointerId;
  42230. private _onKeyDown;
  42231. private _onKeyUp;
  42232. private _keyboardIsAttached;
  42233. private _onCanvasFocusObserver;
  42234. private _onCanvasBlurObserver;
  42235. private _scene;
  42236. /**
  42237. * Creates a new InputManager
  42238. * @param scene defines the hosting scene
  42239. */
  42240. constructor(scene: Scene);
  42241. /**
  42242. * Gets the mesh that is currently under the pointer
  42243. */
  42244. get meshUnderPointer(): Nullable<AbstractMesh>;
  42245. /**
  42246. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42247. * @param pointerId the pointer id to use
  42248. * @returns The mesh under this pointer id or null if not found
  42249. */
  42250. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42251. /**
  42252. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42253. */
  42254. get unTranslatedPointer(): Vector2;
  42255. /**
  42256. * Gets or sets the current on-screen X position of the pointer
  42257. */
  42258. get pointerX(): number;
  42259. set pointerX(value: number);
  42260. /**
  42261. * Gets or sets the current on-screen Y position of the pointer
  42262. */
  42263. get pointerY(): number;
  42264. set pointerY(value: number);
  42265. private _updatePointerPosition;
  42266. private _processPointerMove;
  42267. private _setRayOnPointerInfo;
  42268. private _checkPrePointerObservable;
  42269. /**
  42270. * Use this method to simulate a pointer move on a mesh
  42271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42274. */
  42275. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42276. /**
  42277. * Use this method to simulate a pointer down on a mesh
  42278. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42279. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42280. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42281. */
  42282. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42283. private _processPointerDown;
  42284. /** @hidden */
  42285. _isPointerSwiping(): boolean;
  42286. /**
  42287. * Use this method to simulate a pointer up on a mesh
  42288. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42289. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42290. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42291. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42292. */
  42293. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42294. private _processPointerUp;
  42295. /**
  42296. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42297. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42298. * @returns true if the pointer was captured
  42299. */
  42300. isPointerCaptured(pointerId?: number): boolean;
  42301. /**
  42302. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42303. * @param attachUp defines if you want to attach events to pointerup
  42304. * @param attachDown defines if you want to attach events to pointerdown
  42305. * @param attachMove defines if you want to attach events to pointermove
  42306. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42307. */
  42308. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42309. /**
  42310. * Detaches all event handlers
  42311. */
  42312. detachControl(): void;
  42313. /**
  42314. * Force the value of meshUnderPointer
  42315. * @param mesh defines the mesh to use
  42316. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42317. */
  42318. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42319. /**
  42320. * Gets the mesh under the pointer
  42321. * @returns a Mesh or null if no mesh is under the pointer
  42322. */
  42323. getPointerOverMesh(): Nullable<AbstractMesh>;
  42324. }
  42325. }
  42326. declare module BABYLON {
  42327. /**
  42328. * This class defines the direct association between an animation and a target
  42329. */
  42330. export class TargetedAnimation {
  42331. /**
  42332. * Animation to perform
  42333. */
  42334. animation: Animation;
  42335. /**
  42336. * Target to animate
  42337. */
  42338. target: any;
  42339. /**
  42340. * Returns the string "TargetedAnimation"
  42341. * @returns "TargetedAnimation"
  42342. */
  42343. getClassName(): string;
  42344. /**
  42345. * Serialize the object
  42346. * @returns the JSON object representing the current entity
  42347. */
  42348. serialize(): any;
  42349. }
  42350. /**
  42351. * Use this class to create coordinated animations on multiple targets
  42352. */
  42353. export class AnimationGroup implements IDisposable {
  42354. /** The name of the animation group */
  42355. name: string;
  42356. private _scene;
  42357. private _targetedAnimations;
  42358. private _animatables;
  42359. private _from;
  42360. private _to;
  42361. private _isStarted;
  42362. private _isPaused;
  42363. private _speedRatio;
  42364. private _loopAnimation;
  42365. private _isAdditive;
  42366. /**
  42367. * Gets or sets the unique id of the node
  42368. */
  42369. uniqueId: number;
  42370. /**
  42371. * This observable will notify when one animation have ended
  42372. */
  42373. onAnimationEndObservable: Observable<TargetedAnimation>;
  42374. /**
  42375. * Observer raised when one animation loops
  42376. */
  42377. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42378. /**
  42379. * Observer raised when all animations have looped
  42380. */
  42381. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42382. /**
  42383. * This observable will notify when all animations have ended.
  42384. */
  42385. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42386. /**
  42387. * This observable will notify when all animations have paused.
  42388. */
  42389. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42390. /**
  42391. * This observable will notify when all animations are playing.
  42392. */
  42393. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42394. /**
  42395. * Gets the first frame
  42396. */
  42397. get from(): number;
  42398. /**
  42399. * Gets the last frame
  42400. */
  42401. get to(): number;
  42402. /**
  42403. * Define if the animations are started
  42404. */
  42405. get isStarted(): boolean;
  42406. /**
  42407. * Gets a value indicating that the current group is playing
  42408. */
  42409. get isPlaying(): boolean;
  42410. /**
  42411. * Gets or sets the speed ratio to use for all animations
  42412. */
  42413. get speedRatio(): number;
  42414. /**
  42415. * Gets or sets the speed ratio to use for all animations
  42416. */
  42417. set speedRatio(value: number);
  42418. /**
  42419. * Gets or sets if all animations should loop or not
  42420. */
  42421. get loopAnimation(): boolean;
  42422. set loopAnimation(value: boolean);
  42423. /**
  42424. * Gets or sets if all animations should be evaluated additively
  42425. */
  42426. get isAdditive(): boolean;
  42427. set isAdditive(value: boolean);
  42428. /**
  42429. * Gets the targeted animations for this animation group
  42430. */
  42431. get targetedAnimations(): Array<TargetedAnimation>;
  42432. /**
  42433. * returning the list of animatables controlled by this animation group.
  42434. */
  42435. get animatables(): Array<Animatable>;
  42436. /**
  42437. * Gets the list of target animations
  42438. */
  42439. get children(): TargetedAnimation[];
  42440. /**
  42441. * Instantiates a new Animation Group.
  42442. * This helps managing several animations at once.
  42443. * @see https://doc.babylonjs.com/how_to/group
  42444. * @param name Defines the name of the group
  42445. * @param scene Defines the scene the group belongs to
  42446. */
  42447. constructor(
  42448. /** The name of the animation group */
  42449. name: string, scene?: Nullable<Scene>);
  42450. /**
  42451. * Add an animation (with its target) in the group
  42452. * @param animation defines the animation we want to add
  42453. * @param target defines the target of the animation
  42454. * @returns the TargetedAnimation object
  42455. */
  42456. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42457. /**
  42458. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42459. * It can add constant keys at begin or end
  42460. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42461. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42462. * @returns the animation group
  42463. */
  42464. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42465. private _animationLoopCount;
  42466. private _animationLoopFlags;
  42467. private _processLoop;
  42468. /**
  42469. * Start all animations on given targets
  42470. * @param loop defines if animations must loop
  42471. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42472. * @param from defines the from key (optional)
  42473. * @param to defines the to key (optional)
  42474. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42475. * @returns the current animation group
  42476. */
  42477. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42478. /**
  42479. * Pause all animations
  42480. * @returns the animation group
  42481. */
  42482. pause(): AnimationGroup;
  42483. /**
  42484. * Play all animations to initial state
  42485. * This function will start() the animations if they were not started or will restart() them if they were paused
  42486. * @param loop defines if animations must loop
  42487. * @returns the animation group
  42488. */
  42489. play(loop?: boolean): AnimationGroup;
  42490. /**
  42491. * Reset all animations to initial state
  42492. * @returns the animation group
  42493. */
  42494. reset(): AnimationGroup;
  42495. /**
  42496. * Restart animations from key 0
  42497. * @returns the animation group
  42498. */
  42499. restart(): AnimationGroup;
  42500. /**
  42501. * Stop all animations
  42502. * @returns the animation group
  42503. */
  42504. stop(): AnimationGroup;
  42505. /**
  42506. * Set animation weight for all animatables
  42507. * @param weight defines the weight to use
  42508. * @return the animationGroup
  42509. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42510. */
  42511. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42512. /**
  42513. * Synchronize and normalize all animatables with a source animatable
  42514. * @param root defines the root animatable to synchronize with
  42515. * @return the animationGroup
  42516. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42517. */
  42518. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42519. /**
  42520. * Goes to a specific frame in this animation group
  42521. * @param frame the frame number to go to
  42522. * @return the animationGroup
  42523. */
  42524. goToFrame(frame: number): AnimationGroup;
  42525. /**
  42526. * Dispose all associated resources
  42527. */
  42528. dispose(): void;
  42529. private _checkAnimationGroupEnded;
  42530. /**
  42531. * Clone the current animation group and returns a copy
  42532. * @param newName defines the name of the new group
  42533. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42534. * @returns the new aniamtion group
  42535. */
  42536. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42537. /**
  42538. * Serializes the animationGroup to an object
  42539. * @returns Serialized object
  42540. */
  42541. serialize(): any;
  42542. /**
  42543. * Returns a new AnimationGroup object parsed from the source provided.
  42544. * @param parsedAnimationGroup defines the source
  42545. * @param scene defines the scene that will receive the animationGroup
  42546. * @returns a new AnimationGroup
  42547. */
  42548. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42549. /**
  42550. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42551. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42552. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42553. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42554. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42555. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42556. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42557. */
  42558. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42559. /**
  42560. * Returns the string "AnimationGroup"
  42561. * @returns "AnimationGroup"
  42562. */
  42563. getClassName(): string;
  42564. /**
  42565. * Creates a detailled string about the object
  42566. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42567. * @returns a string representing the object
  42568. */
  42569. toString(fullDetails?: boolean): string;
  42570. }
  42571. }
  42572. declare module BABYLON {
  42573. /**
  42574. * Define an interface for all classes that will hold resources
  42575. */
  42576. export interface IDisposable {
  42577. /**
  42578. * Releases all held resources
  42579. */
  42580. dispose(): void;
  42581. }
  42582. /** Interface defining initialization parameters for Scene class */
  42583. export interface SceneOptions {
  42584. /**
  42585. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42586. * It will improve performance when the number of geometries becomes important.
  42587. */
  42588. useGeometryUniqueIdsMap?: boolean;
  42589. /**
  42590. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42591. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42592. */
  42593. useMaterialMeshMap?: boolean;
  42594. /**
  42595. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42596. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42597. */
  42598. useClonedMeshMap?: boolean;
  42599. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42600. virtual?: boolean;
  42601. }
  42602. /**
  42603. * Represents a scene to be rendered by the engine.
  42604. * @see https://doc.babylonjs.com/features/scene
  42605. */
  42606. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42607. /** The fog is deactivated */
  42608. static readonly FOGMODE_NONE: number;
  42609. /** The fog density is following an exponential function */
  42610. static readonly FOGMODE_EXP: number;
  42611. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42612. static readonly FOGMODE_EXP2: number;
  42613. /** The fog density is following a linear function. */
  42614. static readonly FOGMODE_LINEAR: number;
  42615. /**
  42616. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42617. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42618. */
  42619. static MinDeltaTime: number;
  42620. /**
  42621. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42623. */
  42624. static MaxDeltaTime: number;
  42625. /**
  42626. * Factory used to create the default material.
  42627. * @param name The name of the material to create
  42628. * @param scene The scene to create the material for
  42629. * @returns The default material
  42630. */
  42631. static DefaultMaterialFactory(scene: Scene): Material;
  42632. /**
  42633. * Factory used to create the a collision coordinator.
  42634. * @returns The collision coordinator
  42635. */
  42636. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42637. /** @hidden */
  42638. _inputManager: InputManager;
  42639. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42640. cameraToUseForPointers: Nullable<Camera>;
  42641. /** @hidden */
  42642. readonly _isScene: boolean;
  42643. /** @hidden */
  42644. _blockEntityCollection: boolean;
  42645. /**
  42646. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42647. */
  42648. autoClear: boolean;
  42649. /**
  42650. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42651. */
  42652. autoClearDepthAndStencil: boolean;
  42653. /**
  42654. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42655. */
  42656. clearColor: Color4;
  42657. /**
  42658. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42659. */
  42660. ambientColor: Color3;
  42661. /**
  42662. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42663. * It should only be one of the following (if not the default embedded one):
  42664. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42665. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42666. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42667. * The material properties need to be setup according to the type of texture in use.
  42668. */
  42669. environmentBRDFTexture: BaseTexture;
  42670. /**
  42671. * Texture used in all pbr material as the reflection texture.
  42672. * As in the majority of the scene they are the same (exception for multi room and so on),
  42673. * this is easier to reference from here than from all the materials.
  42674. */
  42675. get environmentTexture(): Nullable<BaseTexture>;
  42676. /**
  42677. * Texture used in all pbr material as the reflection texture.
  42678. * As in the majority of the scene they are the same (exception for multi room and so on),
  42679. * this is easier to set here than in all the materials.
  42680. */
  42681. set environmentTexture(value: Nullable<BaseTexture>);
  42682. /** @hidden */
  42683. protected _environmentIntensity: number;
  42684. /**
  42685. * Intensity of the environment in all pbr material.
  42686. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42687. * As in the majority of the scene they are the same (exception for multi room and so on),
  42688. * this is easier to reference from here than from all the materials.
  42689. */
  42690. get environmentIntensity(): number;
  42691. /**
  42692. * Intensity of the environment in all pbr material.
  42693. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42694. * As in the majority of the scene they are the same (exception for multi room and so on),
  42695. * this is easier to set here than in all the materials.
  42696. */
  42697. set environmentIntensity(value: number);
  42698. /** @hidden */
  42699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42700. /**
  42701. * Default image processing configuration used either in the rendering
  42702. * Forward main pass or through the imageProcessingPostProcess if present.
  42703. * As in the majority of the scene they are the same (exception for multi camera),
  42704. * this is easier to reference from here than from all the materials and post process.
  42705. *
  42706. * No setter as we it is a shared configuration, you can set the values instead.
  42707. */
  42708. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42709. private _forceWireframe;
  42710. /**
  42711. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42712. */
  42713. set forceWireframe(value: boolean);
  42714. get forceWireframe(): boolean;
  42715. private _skipFrustumClipping;
  42716. /**
  42717. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42718. */
  42719. set skipFrustumClipping(value: boolean);
  42720. get skipFrustumClipping(): boolean;
  42721. private _forcePointsCloud;
  42722. /**
  42723. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42724. */
  42725. set forcePointsCloud(value: boolean);
  42726. get forcePointsCloud(): boolean;
  42727. /**
  42728. * Gets or sets the active clipplane 1
  42729. */
  42730. clipPlane: Nullable<Plane>;
  42731. /**
  42732. * Gets or sets the active clipplane 2
  42733. */
  42734. clipPlane2: Nullable<Plane>;
  42735. /**
  42736. * Gets or sets the active clipplane 3
  42737. */
  42738. clipPlane3: Nullable<Plane>;
  42739. /**
  42740. * Gets or sets the active clipplane 4
  42741. */
  42742. clipPlane4: Nullable<Plane>;
  42743. /**
  42744. * Gets or sets the active clipplane 5
  42745. */
  42746. clipPlane5: Nullable<Plane>;
  42747. /**
  42748. * Gets or sets the active clipplane 6
  42749. */
  42750. clipPlane6: Nullable<Plane>;
  42751. /**
  42752. * Gets or sets a boolean indicating if animations are enabled
  42753. */
  42754. animationsEnabled: boolean;
  42755. private _animationPropertiesOverride;
  42756. /**
  42757. * Gets or sets the animation properties override
  42758. */
  42759. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42760. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42761. /**
  42762. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42763. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42764. */
  42765. useConstantAnimationDeltaTime: boolean;
  42766. /**
  42767. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42768. * Please note that it requires to run a ray cast through the scene on every frame
  42769. */
  42770. constantlyUpdateMeshUnderPointer: boolean;
  42771. /**
  42772. * Defines the HTML cursor to use when hovering over interactive elements
  42773. */
  42774. hoverCursor: string;
  42775. /**
  42776. * Defines the HTML default cursor to use (empty by default)
  42777. */
  42778. defaultCursor: string;
  42779. /**
  42780. * Defines whether cursors are handled by the scene.
  42781. */
  42782. doNotHandleCursors: boolean;
  42783. /**
  42784. * This is used to call preventDefault() on pointer down
  42785. * in order to block unwanted artifacts like system double clicks
  42786. */
  42787. preventDefaultOnPointerDown: boolean;
  42788. /**
  42789. * This is used to call preventDefault() on pointer up
  42790. * in order to block unwanted artifacts like system double clicks
  42791. */
  42792. preventDefaultOnPointerUp: boolean;
  42793. /**
  42794. * Gets or sets user defined metadata
  42795. */
  42796. metadata: any;
  42797. /**
  42798. * For internal use only. Please do not use.
  42799. */
  42800. reservedDataStore: any;
  42801. /**
  42802. * Gets the name of the plugin used to load this scene (null by default)
  42803. */
  42804. loadingPluginName: string;
  42805. /**
  42806. * Use this array to add regular expressions used to disable offline support for specific urls
  42807. */
  42808. disableOfflineSupportExceptionRules: RegExp[];
  42809. /**
  42810. * An event triggered when the scene is disposed.
  42811. */
  42812. onDisposeObservable: Observable<Scene>;
  42813. private _onDisposeObserver;
  42814. /** Sets a function to be executed when this scene is disposed. */
  42815. set onDispose(callback: () => void);
  42816. /**
  42817. * An event triggered before rendering the scene (right after animations and physics)
  42818. */
  42819. onBeforeRenderObservable: Observable<Scene>;
  42820. private _onBeforeRenderObserver;
  42821. /** Sets a function to be executed before rendering this scene */
  42822. set beforeRender(callback: Nullable<() => void>);
  42823. /**
  42824. * An event triggered after rendering the scene
  42825. */
  42826. onAfterRenderObservable: Observable<Scene>;
  42827. /**
  42828. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42829. */
  42830. onAfterRenderCameraObservable: Observable<Camera>;
  42831. private _onAfterRenderObserver;
  42832. /** Sets a function to be executed after rendering this scene */
  42833. set afterRender(callback: Nullable<() => void>);
  42834. /**
  42835. * An event triggered before animating the scene
  42836. */
  42837. onBeforeAnimationsObservable: Observable<Scene>;
  42838. /**
  42839. * An event triggered after animations processing
  42840. */
  42841. onAfterAnimationsObservable: Observable<Scene>;
  42842. /**
  42843. * An event triggered before draw calls are ready to be sent
  42844. */
  42845. onBeforeDrawPhaseObservable: Observable<Scene>;
  42846. /**
  42847. * An event triggered after draw calls have been sent
  42848. */
  42849. onAfterDrawPhaseObservable: Observable<Scene>;
  42850. /**
  42851. * An event triggered when the scene is ready
  42852. */
  42853. onReadyObservable: Observable<Scene>;
  42854. /**
  42855. * An event triggered before rendering a camera
  42856. */
  42857. onBeforeCameraRenderObservable: Observable<Camera>;
  42858. private _onBeforeCameraRenderObserver;
  42859. /** Sets a function to be executed before rendering a camera*/
  42860. set beforeCameraRender(callback: () => void);
  42861. /**
  42862. * An event triggered after rendering a camera
  42863. */
  42864. onAfterCameraRenderObservable: Observable<Camera>;
  42865. private _onAfterCameraRenderObserver;
  42866. /** Sets a function to be executed after rendering a camera*/
  42867. set afterCameraRender(callback: () => void);
  42868. /**
  42869. * An event triggered when active meshes evaluation is about to start
  42870. */
  42871. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42872. /**
  42873. * An event triggered when active meshes evaluation is done
  42874. */
  42875. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42876. /**
  42877. * An event triggered when particles rendering is about to start
  42878. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42879. */
  42880. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42881. /**
  42882. * An event triggered when particles rendering is done
  42883. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42884. */
  42885. onAfterParticlesRenderingObservable: Observable<Scene>;
  42886. /**
  42887. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42888. */
  42889. onDataLoadedObservable: Observable<Scene>;
  42890. /**
  42891. * An event triggered when a camera is created
  42892. */
  42893. onNewCameraAddedObservable: Observable<Camera>;
  42894. /**
  42895. * An event triggered when a camera is removed
  42896. */
  42897. onCameraRemovedObservable: Observable<Camera>;
  42898. /**
  42899. * An event triggered when a light is created
  42900. */
  42901. onNewLightAddedObservable: Observable<Light>;
  42902. /**
  42903. * An event triggered when a light is removed
  42904. */
  42905. onLightRemovedObservable: Observable<Light>;
  42906. /**
  42907. * An event triggered when a geometry is created
  42908. */
  42909. onNewGeometryAddedObservable: Observable<Geometry>;
  42910. /**
  42911. * An event triggered when a geometry is removed
  42912. */
  42913. onGeometryRemovedObservable: Observable<Geometry>;
  42914. /**
  42915. * An event triggered when a transform node is created
  42916. */
  42917. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42918. /**
  42919. * An event triggered when a transform node is removed
  42920. */
  42921. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42922. /**
  42923. * An event triggered when a mesh is created
  42924. */
  42925. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42926. /**
  42927. * An event triggered when a mesh is removed
  42928. */
  42929. onMeshRemovedObservable: Observable<AbstractMesh>;
  42930. /**
  42931. * An event triggered when a skeleton is created
  42932. */
  42933. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42934. /**
  42935. * An event triggered when a skeleton is removed
  42936. */
  42937. onSkeletonRemovedObservable: Observable<Skeleton>;
  42938. /**
  42939. * An event triggered when a material is created
  42940. */
  42941. onNewMaterialAddedObservable: Observable<Material>;
  42942. /**
  42943. * An event triggered when a material is removed
  42944. */
  42945. onMaterialRemovedObservable: Observable<Material>;
  42946. /**
  42947. * An event triggered when a texture is created
  42948. */
  42949. onNewTextureAddedObservable: Observable<BaseTexture>;
  42950. /**
  42951. * An event triggered when a texture is removed
  42952. */
  42953. onTextureRemovedObservable: Observable<BaseTexture>;
  42954. /**
  42955. * An event triggered when render targets are about to be rendered
  42956. * Can happen multiple times per frame.
  42957. */
  42958. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42959. /**
  42960. * An event triggered when render targets were rendered.
  42961. * Can happen multiple times per frame.
  42962. */
  42963. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42964. /**
  42965. * An event triggered before calculating deterministic simulation step
  42966. */
  42967. onBeforeStepObservable: Observable<Scene>;
  42968. /**
  42969. * An event triggered after calculating deterministic simulation step
  42970. */
  42971. onAfterStepObservable: Observable<Scene>;
  42972. /**
  42973. * An event triggered when the activeCamera property is updated
  42974. */
  42975. onActiveCameraChanged: Observable<Scene>;
  42976. /**
  42977. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42979. * 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)
  42980. */
  42981. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42982. /**
  42983. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42984. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42985. * 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)
  42986. */
  42987. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42988. /**
  42989. * This Observable will when a mesh has been imported into the scene.
  42990. */
  42991. onMeshImportedObservable: Observable<AbstractMesh>;
  42992. /**
  42993. * This Observable will when an animation file has been imported into the scene.
  42994. */
  42995. onAnimationFileImportedObservable: Observable<Scene>;
  42996. /**
  42997. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42998. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42999. */
  43000. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43001. /** @hidden */
  43002. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43003. /**
  43004. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43005. */
  43006. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43007. /**
  43008. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43009. */
  43010. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43011. /**
  43012. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43013. */
  43014. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43015. /** Callback called when a pointer move is detected */
  43016. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43017. /** Callback called when a pointer down is detected */
  43018. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43019. /** Callback called when a pointer up is detected */
  43020. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43021. /** Callback called when a pointer pick is detected */
  43022. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43023. /**
  43024. * 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).
  43025. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43026. */
  43027. onPrePointerObservable: Observable<PointerInfoPre>;
  43028. /**
  43029. * Observable event triggered each time an input event is received from the rendering canvas
  43030. */
  43031. onPointerObservable: Observable<PointerInfo>;
  43032. /**
  43033. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43034. */
  43035. get unTranslatedPointer(): Vector2;
  43036. /**
  43037. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43038. */
  43039. static get DragMovementThreshold(): number;
  43040. static set DragMovementThreshold(value: number);
  43041. /**
  43042. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43043. */
  43044. static get LongPressDelay(): number;
  43045. static set LongPressDelay(value: number);
  43046. /**
  43047. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43048. */
  43049. static get DoubleClickDelay(): number;
  43050. static set DoubleClickDelay(value: number);
  43051. /** If you need to check double click without raising a single click at first click, enable this flag */
  43052. static get ExclusiveDoubleClickMode(): boolean;
  43053. static set ExclusiveDoubleClickMode(value: boolean);
  43054. /** @hidden */
  43055. _mirroredCameraPosition: Nullable<Vector3>;
  43056. /**
  43057. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43058. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43059. */
  43060. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43061. /**
  43062. * Observable event triggered each time an keyboard event is received from the hosting window
  43063. */
  43064. onKeyboardObservable: Observable<KeyboardInfo>;
  43065. private _useRightHandedSystem;
  43066. /**
  43067. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43068. */
  43069. set useRightHandedSystem(value: boolean);
  43070. get useRightHandedSystem(): boolean;
  43071. private _timeAccumulator;
  43072. private _currentStepId;
  43073. private _currentInternalStep;
  43074. /**
  43075. * Sets the step Id used by deterministic lock step
  43076. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43077. * @param newStepId defines the step Id
  43078. */
  43079. setStepId(newStepId: number): void;
  43080. /**
  43081. * Gets the step Id used by deterministic lock step
  43082. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43083. * @returns the step Id
  43084. */
  43085. getStepId(): number;
  43086. /**
  43087. * Gets the internal step used by deterministic lock step
  43088. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43089. * @returns the internal step
  43090. */
  43091. getInternalStep(): number;
  43092. private _fogEnabled;
  43093. /**
  43094. * Gets or sets a boolean indicating if fog is enabled on this scene
  43095. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43096. * (Default is true)
  43097. */
  43098. set fogEnabled(value: boolean);
  43099. get fogEnabled(): boolean;
  43100. private _fogMode;
  43101. /**
  43102. * Gets or sets the fog mode to use
  43103. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43104. * | mode | value |
  43105. * | --- | --- |
  43106. * | FOGMODE_NONE | 0 |
  43107. * | FOGMODE_EXP | 1 |
  43108. * | FOGMODE_EXP2 | 2 |
  43109. * | FOGMODE_LINEAR | 3 |
  43110. */
  43111. set fogMode(value: number);
  43112. get fogMode(): number;
  43113. /**
  43114. * Gets or sets the fog color to use
  43115. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43116. * (Default is Color3(0.2, 0.2, 0.3))
  43117. */
  43118. fogColor: Color3;
  43119. /**
  43120. * Gets or sets the fog density to use
  43121. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43122. * (Default is 0.1)
  43123. */
  43124. fogDensity: number;
  43125. /**
  43126. * Gets or sets the fog start distance to use
  43127. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43128. * (Default is 0)
  43129. */
  43130. fogStart: number;
  43131. /**
  43132. * Gets or sets the fog end distance to use
  43133. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43134. * (Default is 1000)
  43135. */
  43136. fogEnd: number;
  43137. /**
  43138. * Flag indicating that the frame buffer binding is handled by another component
  43139. */
  43140. prePass: boolean;
  43141. private _shadowsEnabled;
  43142. /**
  43143. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43144. */
  43145. set shadowsEnabled(value: boolean);
  43146. get shadowsEnabled(): boolean;
  43147. private _lightsEnabled;
  43148. /**
  43149. * Gets or sets a boolean indicating if lights are enabled on this scene
  43150. */
  43151. set lightsEnabled(value: boolean);
  43152. get lightsEnabled(): boolean;
  43153. /** All of the active cameras added to this scene. */
  43154. activeCameras: Camera[];
  43155. /** @hidden */
  43156. _activeCamera: Nullable<Camera>;
  43157. /** Gets or sets the current active camera */
  43158. get activeCamera(): Nullable<Camera>;
  43159. set activeCamera(value: Nullable<Camera>);
  43160. private _defaultMaterial;
  43161. /** The default material used on meshes when no material is affected */
  43162. get defaultMaterial(): Material;
  43163. /** The default material used on meshes when no material is affected */
  43164. set defaultMaterial(value: Material);
  43165. private _texturesEnabled;
  43166. /**
  43167. * Gets or sets a boolean indicating if textures are enabled on this scene
  43168. */
  43169. set texturesEnabled(value: boolean);
  43170. get texturesEnabled(): boolean;
  43171. /**
  43172. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43173. */
  43174. physicsEnabled: boolean;
  43175. /**
  43176. * Gets or sets a boolean indicating if particles are enabled on this scene
  43177. */
  43178. particlesEnabled: boolean;
  43179. /**
  43180. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43181. */
  43182. spritesEnabled: boolean;
  43183. private _skeletonsEnabled;
  43184. /**
  43185. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43186. */
  43187. set skeletonsEnabled(value: boolean);
  43188. get skeletonsEnabled(): boolean;
  43189. /**
  43190. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43191. */
  43192. lensFlaresEnabled: boolean;
  43193. /**
  43194. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43195. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43196. */
  43197. collisionsEnabled: boolean;
  43198. private _collisionCoordinator;
  43199. /** @hidden */
  43200. get collisionCoordinator(): ICollisionCoordinator;
  43201. /**
  43202. * Defines the gravity applied to this scene (used only for collisions)
  43203. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43204. */
  43205. gravity: Vector3;
  43206. /**
  43207. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43208. */
  43209. postProcessesEnabled: boolean;
  43210. /**
  43211. * Gets the current postprocess manager
  43212. */
  43213. postProcessManager: PostProcessManager;
  43214. /**
  43215. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43216. */
  43217. renderTargetsEnabled: boolean;
  43218. /**
  43219. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43220. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43221. */
  43222. dumpNextRenderTargets: boolean;
  43223. /**
  43224. * The list of user defined render targets added to the scene
  43225. */
  43226. customRenderTargets: RenderTargetTexture[];
  43227. /**
  43228. * Defines if texture loading must be delayed
  43229. * If true, textures will only be loaded when they need to be rendered
  43230. */
  43231. useDelayedTextureLoading: boolean;
  43232. /**
  43233. * Gets the list of meshes imported to the scene through SceneLoader
  43234. */
  43235. importedMeshesFiles: String[];
  43236. /**
  43237. * Gets or sets a boolean indicating if probes are enabled on this scene
  43238. */
  43239. probesEnabled: boolean;
  43240. /**
  43241. * Gets or sets the current offline provider to use to store scene data
  43242. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43243. */
  43244. offlineProvider: IOfflineProvider;
  43245. /**
  43246. * Gets or sets the action manager associated with the scene
  43247. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43248. */
  43249. actionManager: AbstractActionManager;
  43250. private _meshesForIntersections;
  43251. /**
  43252. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43253. */
  43254. proceduralTexturesEnabled: boolean;
  43255. private _engine;
  43256. private _totalVertices;
  43257. /** @hidden */
  43258. _activeIndices: PerfCounter;
  43259. /** @hidden */
  43260. _activeParticles: PerfCounter;
  43261. /** @hidden */
  43262. _activeBones: PerfCounter;
  43263. private _animationRatio;
  43264. /** @hidden */
  43265. _animationTimeLast: number;
  43266. /** @hidden */
  43267. _animationTime: number;
  43268. /**
  43269. * Gets or sets a general scale for animation speed
  43270. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43271. */
  43272. animationTimeScale: number;
  43273. /** @hidden */
  43274. _cachedMaterial: Nullable<Material>;
  43275. /** @hidden */
  43276. _cachedEffect: Nullable<Effect>;
  43277. /** @hidden */
  43278. _cachedVisibility: Nullable<number>;
  43279. private _renderId;
  43280. private _frameId;
  43281. private _executeWhenReadyTimeoutId;
  43282. private _intermediateRendering;
  43283. private _viewUpdateFlag;
  43284. private _projectionUpdateFlag;
  43285. /** @hidden */
  43286. _toBeDisposed: Nullable<IDisposable>[];
  43287. private _activeRequests;
  43288. /** @hidden */
  43289. _pendingData: any[];
  43290. private _isDisposed;
  43291. /**
  43292. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43293. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43294. */
  43295. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43296. private _activeMeshes;
  43297. private _processedMaterials;
  43298. private _renderTargets;
  43299. /** @hidden */
  43300. _activeParticleSystems: SmartArray<IParticleSystem>;
  43301. private _activeSkeletons;
  43302. private _softwareSkinnedMeshes;
  43303. private _renderingManager;
  43304. /** @hidden */
  43305. _activeAnimatables: Animatable[];
  43306. private _transformMatrix;
  43307. private _sceneUbo;
  43308. /** @hidden */
  43309. _viewMatrix: Matrix;
  43310. private _projectionMatrix;
  43311. /** @hidden */
  43312. _forcedViewPosition: Nullable<Vector3>;
  43313. /** @hidden */
  43314. _frustumPlanes: Plane[];
  43315. /**
  43316. * Gets the list of frustum planes (built from the active camera)
  43317. */
  43318. get frustumPlanes(): Plane[];
  43319. /**
  43320. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43321. * This is useful if there are more lights that the maximum simulteanous authorized
  43322. */
  43323. requireLightSorting: boolean;
  43324. /** @hidden */
  43325. readonly useMaterialMeshMap: boolean;
  43326. /** @hidden */
  43327. readonly useClonedMeshMap: boolean;
  43328. private _externalData;
  43329. private _uid;
  43330. /**
  43331. * @hidden
  43332. * Backing store of defined scene components.
  43333. */
  43334. _components: ISceneComponent[];
  43335. /**
  43336. * @hidden
  43337. * Backing store of defined scene components.
  43338. */
  43339. _serializableComponents: ISceneSerializableComponent[];
  43340. /**
  43341. * List of components to register on the next registration step.
  43342. */
  43343. private _transientComponents;
  43344. /**
  43345. * Registers the transient components if needed.
  43346. */
  43347. private _registerTransientComponents;
  43348. /**
  43349. * @hidden
  43350. * Add a component to the scene.
  43351. * Note that the ccomponent could be registered on th next frame if this is called after
  43352. * the register component stage.
  43353. * @param component Defines the component to add to the scene
  43354. */
  43355. _addComponent(component: ISceneComponent): void;
  43356. /**
  43357. * @hidden
  43358. * Gets a component from the scene.
  43359. * @param name defines the name of the component to retrieve
  43360. * @returns the component or null if not present
  43361. */
  43362. _getComponent(name: string): Nullable<ISceneComponent>;
  43363. /**
  43364. * @hidden
  43365. * Defines the actions happening before camera updates.
  43366. */
  43367. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43368. /**
  43369. * @hidden
  43370. * Defines the actions happening before clear the canvas.
  43371. */
  43372. _beforeClearStage: Stage<SimpleStageAction>;
  43373. /**
  43374. * @hidden
  43375. * Defines the actions when collecting render targets for the frame.
  43376. */
  43377. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43378. /**
  43379. * @hidden
  43380. * Defines the actions happening for one camera in the frame.
  43381. */
  43382. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43383. /**
  43384. * @hidden
  43385. * Defines the actions happening during the per mesh ready checks.
  43386. */
  43387. _isReadyForMeshStage: Stage<MeshStageAction>;
  43388. /**
  43389. * @hidden
  43390. * Defines the actions happening before evaluate active mesh checks.
  43391. */
  43392. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43393. /**
  43394. * @hidden
  43395. * Defines the actions happening during the evaluate sub mesh checks.
  43396. */
  43397. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43398. /**
  43399. * @hidden
  43400. * Defines the actions happening during the active mesh stage.
  43401. */
  43402. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43403. /**
  43404. * @hidden
  43405. * Defines the actions happening during the per camera render target step.
  43406. */
  43407. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43408. /**
  43409. * @hidden
  43410. * Defines the actions happening just before the active camera is drawing.
  43411. */
  43412. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43413. /**
  43414. * @hidden
  43415. * Defines the actions happening just before a render target is drawing.
  43416. */
  43417. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43418. /**
  43419. * @hidden
  43420. * Defines the actions happening just before a rendering group is drawing.
  43421. */
  43422. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43423. /**
  43424. * @hidden
  43425. * Defines the actions happening just before a mesh is drawing.
  43426. */
  43427. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43428. /**
  43429. * @hidden
  43430. * Defines the actions happening just after a mesh has been drawn.
  43431. */
  43432. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43433. /**
  43434. * @hidden
  43435. * Defines the actions happening just after a rendering group has been drawn.
  43436. */
  43437. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43438. /**
  43439. * @hidden
  43440. * Defines the actions happening just after the active camera has been drawn.
  43441. */
  43442. _afterCameraDrawStage: Stage<CameraStageAction>;
  43443. /**
  43444. * @hidden
  43445. * Defines the actions happening just after a render target has been drawn.
  43446. */
  43447. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43448. /**
  43449. * @hidden
  43450. * Defines the actions happening just after rendering all cameras and computing intersections.
  43451. */
  43452. _afterRenderStage: Stage<SimpleStageAction>;
  43453. /**
  43454. * @hidden
  43455. * Defines the actions happening when a pointer move event happens.
  43456. */
  43457. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43458. /**
  43459. * @hidden
  43460. * Defines the actions happening when a pointer down event happens.
  43461. */
  43462. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43463. /**
  43464. * @hidden
  43465. * Defines the actions happening when a pointer up event happens.
  43466. */
  43467. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43468. /**
  43469. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43470. */
  43471. private geometriesByUniqueId;
  43472. /**
  43473. * Creates a new Scene
  43474. * @param engine defines the engine to use to render this scene
  43475. * @param options defines the scene options
  43476. */
  43477. constructor(engine: Engine, options?: SceneOptions);
  43478. /**
  43479. * Gets a string identifying the name of the class
  43480. * @returns "Scene" string
  43481. */
  43482. getClassName(): string;
  43483. private _defaultMeshCandidates;
  43484. /**
  43485. * @hidden
  43486. */
  43487. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43488. private _defaultSubMeshCandidates;
  43489. /**
  43490. * @hidden
  43491. */
  43492. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43493. /**
  43494. * Sets the default candidate providers for the scene.
  43495. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43496. * and getCollidingSubMeshCandidates to their default function
  43497. */
  43498. setDefaultCandidateProviders(): void;
  43499. /**
  43500. * Gets the mesh that is currently under the pointer
  43501. */
  43502. get meshUnderPointer(): Nullable<AbstractMesh>;
  43503. /**
  43504. * Gets or sets the current on-screen X position of the pointer
  43505. */
  43506. get pointerX(): number;
  43507. set pointerX(value: number);
  43508. /**
  43509. * Gets or sets the current on-screen Y position of the pointer
  43510. */
  43511. get pointerY(): number;
  43512. set pointerY(value: number);
  43513. /**
  43514. * Gets the cached material (ie. the latest rendered one)
  43515. * @returns the cached material
  43516. */
  43517. getCachedMaterial(): Nullable<Material>;
  43518. /**
  43519. * Gets the cached effect (ie. the latest rendered one)
  43520. * @returns the cached effect
  43521. */
  43522. getCachedEffect(): Nullable<Effect>;
  43523. /**
  43524. * Gets the cached visibility state (ie. the latest rendered one)
  43525. * @returns the cached visibility state
  43526. */
  43527. getCachedVisibility(): Nullable<number>;
  43528. /**
  43529. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43530. * @param material defines the current material
  43531. * @param effect defines the current effect
  43532. * @param visibility defines the current visibility state
  43533. * @returns true if one parameter is not cached
  43534. */
  43535. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43536. /**
  43537. * Gets the engine associated with the scene
  43538. * @returns an Engine
  43539. */
  43540. getEngine(): Engine;
  43541. /**
  43542. * Gets the total number of vertices rendered per frame
  43543. * @returns the total number of vertices rendered per frame
  43544. */
  43545. getTotalVertices(): number;
  43546. /**
  43547. * Gets the performance counter for total vertices
  43548. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43549. */
  43550. get totalVerticesPerfCounter(): PerfCounter;
  43551. /**
  43552. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43553. * @returns the total number of active indices rendered per frame
  43554. */
  43555. getActiveIndices(): number;
  43556. /**
  43557. * Gets the performance counter for active indices
  43558. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43559. */
  43560. get totalActiveIndicesPerfCounter(): PerfCounter;
  43561. /**
  43562. * Gets the total number of active particles rendered per frame
  43563. * @returns the total number of active particles rendered per frame
  43564. */
  43565. getActiveParticles(): number;
  43566. /**
  43567. * Gets the performance counter for active particles
  43568. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43569. */
  43570. get activeParticlesPerfCounter(): PerfCounter;
  43571. /**
  43572. * Gets the total number of active bones rendered per frame
  43573. * @returns the total number of active bones rendered per frame
  43574. */
  43575. getActiveBones(): number;
  43576. /**
  43577. * Gets the performance counter for active bones
  43578. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43579. */
  43580. get activeBonesPerfCounter(): PerfCounter;
  43581. /**
  43582. * Gets the array of active meshes
  43583. * @returns an array of AbstractMesh
  43584. */
  43585. getActiveMeshes(): SmartArray<AbstractMesh>;
  43586. /**
  43587. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43588. * @returns a number
  43589. */
  43590. getAnimationRatio(): number;
  43591. /**
  43592. * Gets an unique Id for the current render phase
  43593. * @returns a number
  43594. */
  43595. getRenderId(): number;
  43596. /**
  43597. * Gets an unique Id for the current frame
  43598. * @returns a number
  43599. */
  43600. getFrameId(): number;
  43601. /** Call this function if you want to manually increment the render Id*/
  43602. incrementRenderId(): void;
  43603. private _createUbo;
  43604. /**
  43605. * Use this method to simulate a pointer move on a mesh
  43606. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43607. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43608. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43609. * @returns the current scene
  43610. */
  43611. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43612. /**
  43613. * Use this method to simulate a pointer down on a mesh
  43614. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43615. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43616. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43617. * @returns the current scene
  43618. */
  43619. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43620. /**
  43621. * Use this method to simulate a pointer up on a mesh
  43622. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43623. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43624. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43625. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43626. * @returns the current scene
  43627. */
  43628. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43629. /**
  43630. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43631. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43632. * @returns true if the pointer was captured
  43633. */
  43634. isPointerCaptured(pointerId?: number): boolean;
  43635. /**
  43636. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43637. * @param attachUp defines if you want to attach events to pointerup
  43638. * @param attachDown defines if you want to attach events to pointerdown
  43639. * @param attachMove defines if you want to attach events to pointermove
  43640. */
  43641. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43642. /** Detaches all event handlers*/
  43643. detachControl(): void;
  43644. /**
  43645. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43646. * Delay loaded resources are not taking in account
  43647. * @return true if all required resources are ready
  43648. */
  43649. isReady(): boolean;
  43650. /** Resets all cached information relative to material (including effect and visibility) */
  43651. resetCachedMaterial(): void;
  43652. /**
  43653. * Registers a function to be called before every frame render
  43654. * @param func defines the function to register
  43655. */
  43656. registerBeforeRender(func: () => void): void;
  43657. /**
  43658. * Unregisters a function called before every frame render
  43659. * @param func defines the function to unregister
  43660. */
  43661. unregisterBeforeRender(func: () => void): void;
  43662. /**
  43663. * Registers a function to be called after every frame render
  43664. * @param func defines the function to register
  43665. */
  43666. registerAfterRender(func: () => void): void;
  43667. /**
  43668. * Unregisters a function called after every frame render
  43669. * @param func defines the function to unregister
  43670. */
  43671. unregisterAfterRender(func: () => void): void;
  43672. private _executeOnceBeforeRender;
  43673. /**
  43674. * The provided function will run before render once and will be disposed afterwards.
  43675. * A timeout delay can be provided so that the function will be executed in N ms.
  43676. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43677. * @param func The function to be executed.
  43678. * @param timeout optional delay in ms
  43679. */
  43680. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43681. /** @hidden */
  43682. _addPendingData(data: any): void;
  43683. /** @hidden */
  43684. _removePendingData(data: any): void;
  43685. /**
  43686. * Returns the number of items waiting to be loaded
  43687. * @returns the number of items waiting to be loaded
  43688. */
  43689. getWaitingItemsCount(): number;
  43690. /**
  43691. * Returns a boolean indicating if the scene is still loading data
  43692. */
  43693. get isLoading(): boolean;
  43694. /**
  43695. * Registers a function to be executed when the scene is ready
  43696. * @param {Function} func - the function to be executed
  43697. */
  43698. executeWhenReady(func: () => void): void;
  43699. /**
  43700. * Returns a promise that resolves when the scene is ready
  43701. * @returns A promise that resolves when the scene is ready
  43702. */
  43703. whenReadyAsync(): Promise<void>;
  43704. /** @hidden */
  43705. _checkIsReady(): void;
  43706. /**
  43707. * Gets all animatable attached to the scene
  43708. */
  43709. get animatables(): Animatable[];
  43710. /**
  43711. * Resets the last animation time frame.
  43712. * Useful to override when animations start running when loading a scene for the first time.
  43713. */
  43714. resetLastAnimationTimeFrame(): void;
  43715. /**
  43716. * Gets the current view matrix
  43717. * @returns a Matrix
  43718. */
  43719. getViewMatrix(): Matrix;
  43720. /**
  43721. * Gets the current projection matrix
  43722. * @returns a Matrix
  43723. */
  43724. getProjectionMatrix(): Matrix;
  43725. /**
  43726. * Gets the current transform matrix
  43727. * @returns a Matrix made of View * Projection
  43728. */
  43729. getTransformMatrix(): Matrix;
  43730. /**
  43731. * Sets the current transform matrix
  43732. * @param viewL defines the View matrix to use
  43733. * @param projectionL defines the Projection matrix to use
  43734. * @param viewR defines the right View matrix to use (if provided)
  43735. * @param projectionR defines the right Projection matrix to use (if provided)
  43736. */
  43737. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43738. /**
  43739. * Gets the uniform buffer used to store scene data
  43740. * @returns a UniformBuffer
  43741. */
  43742. getSceneUniformBuffer(): UniformBuffer;
  43743. /**
  43744. * Gets an unique (relatively to the current scene) Id
  43745. * @returns an unique number for the scene
  43746. */
  43747. getUniqueId(): number;
  43748. /**
  43749. * Add a mesh to the list of scene's meshes
  43750. * @param newMesh defines the mesh to add
  43751. * @param recursive if all child meshes should also be added to the scene
  43752. */
  43753. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43754. /**
  43755. * Remove a mesh for the list of scene's meshes
  43756. * @param toRemove defines the mesh to remove
  43757. * @param recursive if all child meshes should also be removed from the scene
  43758. * @returns the index where the mesh was in the mesh list
  43759. */
  43760. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43761. /**
  43762. * Add a transform node to the list of scene's transform nodes
  43763. * @param newTransformNode defines the transform node to add
  43764. */
  43765. addTransformNode(newTransformNode: TransformNode): void;
  43766. /**
  43767. * Remove a transform node for the list of scene's transform nodes
  43768. * @param toRemove defines the transform node to remove
  43769. * @returns the index where the transform node was in the transform node list
  43770. */
  43771. removeTransformNode(toRemove: TransformNode): number;
  43772. /**
  43773. * Remove a skeleton for the list of scene's skeletons
  43774. * @param toRemove defines the skeleton to remove
  43775. * @returns the index where the skeleton was in the skeleton list
  43776. */
  43777. removeSkeleton(toRemove: Skeleton): number;
  43778. /**
  43779. * Remove a morph target for the list of scene's morph targets
  43780. * @param toRemove defines the morph target to remove
  43781. * @returns the index where the morph target was in the morph target list
  43782. */
  43783. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43784. /**
  43785. * Remove a light for the list of scene's lights
  43786. * @param toRemove defines the light to remove
  43787. * @returns the index where the light was in the light list
  43788. */
  43789. removeLight(toRemove: Light): number;
  43790. /**
  43791. * Remove a camera for the list of scene's cameras
  43792. * @param toRemove defines the camera to remove
  43793. * @returns the index where the camera was in the camera list
  43794. */
  43795. removeCamera(toRemove: Camera): number;
  43796. /**
  43797. * Remove a particle system for the list of scene's particle systems
  43798. * @param toRemove defines the particle system to remove
  43799. * @returns the index where the particle system was in the particle system list
  43800. */
  43801. removeParticleSystem(toRemove: IParticleSystem): number;
  43802. /**
  43803. * Remove a animation for the list of scene's animations
  43804. * @param toRemove defines the animation to remove
  43805. * @returns the index where the animation was in the animation list
  43806. */
  43807. removeAnimation(toRemove: Animation): number;
  43808. /**
  43809. * Will stop the animation of the given target
  43810. * @param target - the target
  43811. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43812. * @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)
  43813. */
  43814. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43815. /**
  43816. * Removes the given animation group from this scene.
  43817. * @param toRemove The animation group to remove
  43818. * @returns The index of the removed animation group
  43819. */
  43820. removeAnimationGroup(toRemove: AnimationGroup): number;
  43821. /**
  43822. * Removes the given multi-material from this scene.
  43823. * @param toRemove The multi-material to remove
  43824. * @returns The index of the removed multi-material
  43825. */
  43826. removeMultiMaterial(toRemove: MultiMaterial): number;
  43827. /**
  43828. * Removes the given material from this scene.
  43829. * @param toRemove The material to remove
  43830. * @returns The index of the removed material
  43831. */
  43832. removeMaterial(toRemove: Material): number;
  43833. /**
  43834. * Removes the given action manager from this scene.
  43835. * @param toRemove The action manager to remove
  43836. * @returns The index of the removed action manager
  43837. */
  43838. removeActionManager(toRemove: AbstractActionManager): number;
  43839. /**
  43840. * Removes the given texture from this scene.
  43841. * @param toRemove The texture to remove
  43842. * @returns The index of the removed texture
  43843. */
  43844. removeTexture(toRemove: BaseTexture): number;
  43845. /**
  43846. * Adds the given light to this scene
  43847. * @param newLight The light to add
  43848. */
  43849. addLight(newLight: Light): void;
  43850. /**
  43851. * Sorts the list list based on light priorities
  43852. */
  43853. sortLightsByPriority(): void;
  43854. /**
  43855. * Adds the given camera to this scene
  43856. * @param newCamera The camera to add
  43857. */
  43858. addCamera(newCamera: Camera): void;
  43859. /**
  43860. * Adds the given skeleton to this scene
  43861. * @param newSkeleton The skeleton to add
  43862. */
  43863. addSkeleton(newSkeleton: Skeleton): void;
  43864. /**
  43865. * Adds the given particle system to this scene
  43866. * @param newParticleSystem The particle system to add
  43867. */
  43868. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43869. /**
  43870. * Adds the given animation to this scene
  43871. * @param newAnimation The animation to add
  43872. */
  43873. addAnimation(newAnimation: Animation): void;
  43874. /**
  43875. * Adds the given animation group to this scene.
  43876. * @param newAnimationGroup The animation group to add
  43877. */
  43878. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43879. /**
  43880. * Adds the given multi-material to this scene
  43881. * @param newMultiMaterial The multi-material to add
  43882. */
  43883. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43884. /**
  43885. * Adds the given material to this scene
  43886. * @param newMaterial The material to add
  43887. */
  43888. addMaterial(newMaterial: Material): void;
  43889. /**
  43890. * Adds the given morph target to this scene
  43891. * @param newMorphTargetManager The morph target to add
  43892. */
  43893. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43894. /**
  43895. * Adds the given geometry to this scene
  43896. * @param newGeometry The geometry to add
  43897. */
  43898. addGeometry(newGeometry: Geometry): void;
  43899. /**
  43900. * Adds the given action manager to this scene
  43901. * @param newActionManager The action manager to add
  43902. */
  43903. addActionManager(newActionManager: AbstractActionManager): void;
  43904. /**
  43905. * Adds the given texture to this scene.
  43906. * @param newTexture The texture to add
  43907. */
  43908. addTexture(newTexture: BaseTexture): void;
  43909. /**
  43910. * Switch active camera
  43911. * @param newCamera defines the new active camera
  43912. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43913. */
  43914. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43915. /**
  43916. * sets the active camera of the scene using its ID
  43917. * @param id defines the camera's ID
  43918. * @return the new active camera or null if none found.
  43919. */
  43920. setActiveCameraByID(id: string): Nullable<Camera>;
  43921. /**
  43922. * sets the active camera of the scene using its name
  43923. * @param name defines the camera's name
  43924. * @returns the new active camera or null if none found.
  43925. */
  43926. setActiveCameraByName(name: string): Nullable<Camera>;
  43927. /**
  43928. * get an animation group using its name
  43929. * @param name defines the material's name
  43930. * @return the animation group or null if none found.
  43931. */
  43932. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43933. /**
  43934. * Get a material using its unique id
  43935. * @param uniqueId defines the material's unique id
  43936. * @return the material or null if none found.
  43937. */
  43938. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43939. /**
  43940. * get a material using its id
  43941. * @param id defines the material's ID
  43942. * @return the material or null if none found.
  43943. */
  43944. getMaterialByID(id: string): Nullable<Material>;
  43945. /**
  43946. * Gets a the last added material using a given id
  43947. * @param id defines the material's ID
  43948. * @return the last material with the given id or null if none found.
  43949. */
  43950. getLastMaterialByID(id: string): Nullable<Material>;
  43951. /**
  43952. * Gets a material using its name
  43953. * @param name defines the material's name
  43954. * @return the material or null if none found.
  43955. */
  43956. getMaterialByName(name: string): Nullable<Material>;
  43957. /**
  43958. * Get a texture using its unique id
  43959. * @param uniqueId defines the texture's unique id
  43960. * @return the texture or null if none found.
  43961. */
  43962. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43963. /**
  43964. * Gets a camera using its id
  43965. * @param id defines the id to look for
  43966. * @returns the camera or null if not found
  43967. */
  43968. getCameraByID(id: string): Nullable<Camera>;
  43969. /**
  43970. * Gets a camera using its unique id
  43971. * @param uniqueId defines the unique id to look for
  43972. * @returns the camera or null if not found
  43973. */
  43974. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43975. /**
  43976. * Gets a camera using its name
  43977. * @param name defines the camera's name
  43978. * @return the camera or null if none found.
  43979. */
  43980. getCameraByName(name: string): Nullable<Camera>;
  43981. /**
  43982. * Gets a bone using its id
  43983. * @param id defines the bone's id
  43984. * @return the bone or null if not found
  43985. */
  43986. getBoneByID(id: string): Nullable<Bone>;
  43987. /**
  43988. * Gets a bone using its id
  43989. * @param name defines the bone's name
  43990. * @return the bone or null if not found
  43991. */
  43992. getBoneByName(name: string): Nullable<Bone>;
  43993. /**
  43994. * Gets a light node using its name
  43995. * @param name defines the the light's name
  43996. * @return the light or null if none found.
  43997. */
  43998. getLightByName(name: string): Nullable<Light>;
  43999. /**
  44000. * Gets a light node using its id
  44001. * @param id defines the light's id
  44002. * @return the light or null if none found.
  44003. */
  44004. getLightByID(id: string): Nullable<Light>;
  44005. /**
  44006. * Gets a light node using its scene-generated unique ID
  44007. * @param uniqueId defines the light's unique id
  44008. * @return the light or null if none found.
  44009. */
  44010. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44011. /**
  44012. * Gets a particle system by id
  44013. * @param id defines the particle system id
  44014. * @return the corresponding system or null if none found
  44015. */
  44016. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44017. /**
  44018. * Gets a geometry using its ID
  44019. * @param id defines the geometry's id
  44020. * @return the geometry or null if none found.
  44021. */
  44022. getGeometryByID(id: string): Nullable<Geometry>;
  44023. private _getGeometryByUniqueID;
  44024. /**
  44025. * Add a new geometry to this scene
  44026. * @param geometry defines the geometry to be added to the scene.
  44027. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44028. * @return a boolean defining if the geometry was added or not
  44029. */
  44030. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44031. /**
  44032. * Removes an existing geometry
  44033. * @param geometry defines the geometry to be removed from the scene
  44034. * @return a boolean defining if the geometry was removed or not
  44035. */
  44036. removeGeometry(geometry: Geometry): boolean;
  44037. /**
  44038. * Gets the list of geometries attached to the scene
  44039. * @returns an array of Geometry
  44040. */
  44041. getGeometries(): Geometry[];
  44042. /**
  44043. * Gets the first added mesh found of a given ID
  44044. * @param id defines the id to search for
  44045. * @return the mesh found or null if not found at all
  44046. */
  44047. getMeshByID(id: string): Nullable<AbstractMesh>;
  44048. /**
  44049. * Gets a list of meshes using their id
  44050. * @param id defines the id to search for
  44051. * @returns a list of meshes
  44052. */
  44053. getMeshesByID(id: string): Array<AbstractMesh>;
  44054. /**
  44055. * Gets the first added transform node found of a given ID
  44056. * @param id defines the id to search for
  44057. * @return the found transform node or null if not found at all.
  44058. */
  44059. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44060. /**
  44061. * Gets a transform node with its auto-generated unique id
  44062. * @param uniqueId efines the unique id to search for
  44063. * @return the found transform node or null if not found at all.
  44064. */
  44065. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44066. /**
  44067. * Gets a list of transform nodes using their id
  44068. * @param id defines the id to search for
  44069. * @returns a list of transform nodes
  44070. */
  44071. getTransformNodesByID(id: string): Array<TransformNode>;
  44072. /**
  44073. * Gets a mesh with its auto-generated unique id
  44074. * @param uniqueId defines the unique id to search for
  44075. * @return the found mesh or null if not found at all.
  44076. */
  44077. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44078. /**
  44079. * Gets a the last added mesh using a given id
  44080. * @param id defines the id to search for
  44081. * @return the found mesh or null if not found at all.
  44082. */
  44083. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44084. /**
  44085. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44086. * @param id defines the id to search for
  44087. * @return the found node or null if not found at all
  44088. */
  44089. getLastEntryByID(id: string): Nullable<Node>;
  44090. /**
  44091. * Gets a node (Mesh, Camera, Light) using a given id
  44092. * @param id defines the id to search for
  44093. * @return the found node or null if not found at all
  44094. */
  44095. getNodeByID(id: string): Nullable<Node>;
  44096. /**
  44097. * Gets a node (Mesh, Camera, Light) using a given name
  44098. * @param name defines the name to search for
  44099. * @return the found node or null if not found at all.
  44100. */
  44101. getNodeByName(name: string): Nullable<Node>;
  44102. /**
  44103. * Gets a mesh using a given name
  44104. * @param name defines the name to search for
  44105. * @return the found mesh or null if not found at all.
  44106. */
  44107. getMeshByName(name: string): Nullable<AbstractMesh>;
  44108. /**
  44109. * Gets a transform node using a given name
  44110. * @param name defines the name to search for
  44111. * @return the found transform node or null if not found at all.
  44112. */
  44113. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44114. /**
  44115. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44116. * @param id defines the id to search for
  44117. * @return the found skeleton or null if not found at all.
  44118. */
  44119. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44120. /**
  44121. * Gets a skeleton using a given auto generated unique id
  44122. * @param uniqueId defines the unique id to search for
  44123. * @return the found skeleton or null if not found at all.
  44124. */
  44125. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44126. /**
  44127. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44128. * @param id defines the id to search for
  44129. * @return the found skeleton or null if not found at all.
  44130. */
  44131. getSkeletonById(id: string): Nullable<Skeleton>;
  44132. /**
  44133. * Gets a skeleton using a given name
  44134. * @param name defines the name to search for
  44135. * @return the found skeleton or null if not found at all.
  44136. */
  44137. getSkeletonByName(name: string): Nullable<Skeleton>;
  44138. /**
  44139. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44140. * @param id defines the id to search for
  44141. * @return the found morph target manager or null if not found at all.
  44142. */
  44143. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44144. /**
  44145. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44146. * @param id defines the id to search for
  44147. * @return the found morph target or null if not found at all.
  44148. */
  44149. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44150. /**
  44151. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44152. * @param name defines the name to search for
  44153. * @return the found morph target or null if not found at all.
  44154. */
  44155. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44156. /**
  44157. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44158. * @param name defines the name to search for
  44159. * @return the found post process or null if not found at all.
  44160. */
  44161. getPostProcessByName(name: string): Nullable<PostProcess>;
  44162. /**
  44163. * Gets a boolean indicating if the given mesh is active
  44164. * @param mesh defines the mesh to look for
  44165. * @returns true if the mesh is in the active list
  44166. */
  44167. isActiveMesh(mesh: AbstractMesh): boolean;
  44168. /**
  44169. * Return a unique id as a string which can serve as an identifier for the scene
  44170. */
  44171. get uid(): string;
  44172. /**
  44173. * Add an externaly attached data from its key.
  44174. * This method call will fail and return false, if such key already exists.
  44175. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44176. * @param key the unique key that identifies the data
  44177. * @param data the data object to associate to the key for this Engine instance
  44178. * @return true if no such key were already present and the data was added successfully, false otherwise
  44179. */
  44180. addExternalData<T>(key: string, data: T): boolean;
  44181. /**
  44182. * Get an externaly attached data from its key
  44183. * @param key the unique key that identifies the data
  44184. * @return the associated data, if present (can be null), or undefined if not present
  44185. */
  44186. getExternalData<T>(key: string): Nullable<T>;
  44187. /**
  44188. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44189. * @param key the unique key that identifies the data
  44190. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44191. * @return the associated data, can be null if the factory returned null.
  44192. */
  44193. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44194. /**
  44195. * Remove an externaly attached data from the Engine instance
  44196. * @param key the unique key that identifies the data
  44197. * @return true if the data was successfully removed, false if it doesn't exist
  44198. */
  44199. removeExternalData(key: string): boolean;
  44200. private _evaluateSubMesh;
  44201. /**
  44202. * Clear the processed materials smart array preventing retention point in material dispose.
  44203. */
  44204. freeProcessedMaterials(): void;
  44205. private _preventFreeActiveMeshesAndRenderingGroups;
  44206. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44207. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44208. * when disposing several meshes in a row or a hierarchy of meshes.
  44209. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44210. */
  44211. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44212. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44213. /**
  44214. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44215. */
  44216. freeActiveMeshes(): void;
  44217. /**
  44218. * Clear the info related to rendering groups preventing retention points during dispose.
  44219. */
  44220. freeRenderingGroups(): void;
  44221. /** @hidden */
  44222. _isInIntermediateRendering(): boolean;
  44223. /**
  44224. * Lambda returning the list of potentially active meshes.
  44225. */
  44226. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44227. /**
  44228. * Lambda returning the list of potentially active sub meshes.
  44229. */
  44230. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44231. /**
  44232. * Lambda returning the list of potentially intersecting sub meshes.
  44233. */
  44234. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44235. /**
  44236. * Lambda returning the list of potentially colliding sub meshes.
  44237. */
  44238. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44239. private _activeMeshesFrozen;
  44240. private _skipEvaluateActiveMeshesCompletely;
  44241. /**
  44242. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44243. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44244. * @param onSuccess optional success callback
  44245. * @param onError optional error callback
  44246. * @returns the current scene
  44247. */
  44248. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44249. /**
  44250. * Use this function to restart evaluating active meshes on every frame
  44251. * @returns the current scene
  44252. */
  44253. unfreezeActiveMeshes(): Scene;
  44254. private _evaluateActiveMeshes;
  44255. private _activeMesh;
  44256. /**
  44257. * Update the transform matrix to update from the current active camera
  44258. * @param force defines a boolean used to force the update even if cache is up to date
  44259. */
  44260. updateTransformMatrix(force?: boolean): void;
  44261. private _bindFrameBuffer;
  44262. /** @hidden */
  44263. _allowPostProcessClearColor: boolean;
  44264. /** @hidden */
  44265. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44266. private _processSubCameras;
  44267. private _checkIntersections;
  44268. /** @hidden */
  44269. _advancePhysicsEngineStep(step: number): void;
  44270. /**
  44271. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44272. */
  44273. getDeterministicFrameTime: () => number;
  44274. /** @hidden */
  44275. _animate(): void;
  44276. /** Execute all animations (for a frame) */
  44277. animate(): void;
  44278. /**
  44279. * Render the scene
  44280. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44281. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44282. */
  44283. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44284. /**
  44285. * Freeze all materials
  44286. * A frozen material will not be updatable but should be faster to render
  44287. */
  44288. freezeMaterials(): void;
  44289. /**
  44290. * Unfreeze all materials
  44291. * A frozen material will not be updatable but should be faster to render
  44292. */
  44293. unfreezeMaterials(): void;
  44294. /**
  44295. * Releases all held ressources
  44296. */
  44297. dispose(): void;
  44298. /**
  44299. * Gets if the scene is already disposed
  44300. */
  44301. get isDisposed(): boolean;
  44302. /**
  44303. * Call this function to reduce memory footprint of the scene.
  44304. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44305. */
  44306. clearCachedVertexData(): void;
  44307. /**
  44308. * This function will remove the local cached buffer data from texture.
  44309. * It will save memory but will prevent the texture from being rebuilt
  44310. */
  44311. cleanCachedTextureBuffer(): void;
  44312. /**
  44313. * Get the world extend vectors with an optional filter
  44314. *
  44315. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44316. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44317. */
  44318. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44319. min: Vector3;
  44320. max: Vector3;
  44321. };
  44322. /**
  44323. * Creates a ray that can be used to pick in the scene
  44324. * @param x defines the x coordinate of the origin (on-screen)
  44325. * @param y defines the y coordinate of the origin (on-screen)
  44326. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44327. * @param camera defines the camera to use for the picking
  44328. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44329. * @returns a Ray
  44330. */
  44331. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44332. /**
  44333. * Creates a ray that can be used to pick in the scene
  44334. * @param x defines the x coordinate of the origin (on-screen)
  44335. * @param y defines the y coordinate of the origin (on-screen)
  44336. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44337. * @param result defines the ray where to store the picking ray
  44338. * @param camera defines the camera to use for the picking
  44339. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44340. * @returns the current scene
  44341. */
  44342. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44343. /**
  44344. * Creates a ray that can be used to pick in the scene
  44345. * @param x defines the x coordinate of the origin (on-screen)
  44346. * @param y defines the y coordinate of the origin (on-screen)
  44347. * @param camera defines the camera to use for the picking
  44348. * @returns a Ray
  44349. */
  44350. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44351. /**
  44352. * Creates a ray that can be used to pick in the scene
  44353. * @param x defines the x coordinate of the origin (on-screen)
  44354. * @param y defines the y coordinate of the origin (on-screen)
  44355. * @param result defines the ray where to store the picking ray
  44356. * @param camera defines the camera to use for the picking
  44357. * @returns the current scene
  44358. */
  44359. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44360. /** Launch a ray to try to pick a mesh in the scene
  44361. * @param x position on screen
  44362. * @param y position on screen
  44363. * @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
  44364. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44365. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44366. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44367. * @returns a PickingInfo
  44368. */
  44369. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44370. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44371. * @param x position on screen
  44372. * @param y position on screen
  44373. * @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
  44374. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44375. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44376. * @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)
  44377. */
  44378. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44379. /** Use the given ray to pick a mesh in the scene
  44380. * @param ray The ray to use to pick meshes
  44381. * @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
  44382. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44384. * @returns a PickingInfo
  44385. */
  44386. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44387. /**
  44388. * Launch a ray to try to pick a mesh in the scene
  44389. * @param x X position on screen
  44390. * @param y Y position on screen
  44391. * @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
  44392. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44393. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44394. * @returns an array of PickingInfo
  44395. */
  44396. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44397. /**
  44398. * Launch a ray to try to pick a mesh in the scene
  44399. * @param ray Ray to use
  44400. * @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
  44401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44402. * @returns an array of PickingInfo
  44403. */
  44404. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44405. /**
  44406. * Force the value of meshUnderPointer
  44407. * @param mesh defines the mesh to use
  44408. * @param pointerId optional pointer id when using more than one pointer
  44409. */
  44410. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44411. /**
  44412. * Gets the mesh under the pointer
  44413. * @returns a Mesh or null if no mesh is under the pointer
  44414. */
  44415. getPointerOverMesh(): Nullable<AbstractMesh>;
  44416. /** @hidden */
  44417. _rebuildGeometries(): void;
  44418. /** @hidden */
  44419. _rebuildTextures(): void;
  44420. private _getByTags;
  44421. /**
  44422. * Get a list of meshes by tags
  44423. * @param tagsQuery defines the tags query to use
  44424. * @param forEach defines a predicate used to filter results
  44425. * @returns an array of Mesh
  44426. */
  44427. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44428. /**
  44429. * Get a list of cameras by tags
  44430. * @param tagsQuery defines the tags query to use
  44431. * @param forEach defines a predicate used to filter results
  44432. * @returns an array of Camera
  44433. */
  44434. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44435. /**
  44436. * Get a list of lights by tags
  44437. * @param tagsQuery defines the tags query to use
  44438. * @param forEach defines a predicate used to filter results
  44439. * @returns an array of Light
  44440. */
  44441. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44442. /**
  44443. * Get a list of materials by tags
  44444. * @param tagsQuery defines the tags query to use
  44445. * @param forEach defines a predicate used to filter results
  44446. * @returns an array of Material
  44447. */
  44448. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44449. /**
  44450. * Get a list of transform nodes by tags
  44451. * @param tagsQuery defines the tags query to use
  44452. * @param forEach defines a predicate used to filter results
  44453. * @returns an array of TransformNode
  44454. */
  44455. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44456. /**
  44457. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44458. * This allowed control for front to back rendering or reversly depending of the special needs.
  44459. *
  44460. * @param renderingGroupId The rendering group id corresponding to its index
  44461. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44462. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44463. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44464. */
  44465. 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;
  44466. /**
  44467. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44468. *
  44469. * @param renderingGroupId The rendering group id corresponding to its index
  44470. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44471. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44472. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44473. */
  44474. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44475. /**
  44476. * Gets the current auto clear configuration for one rendering group of the rendering
  44477. * manager.
  44478. * @param index the rendering group index to get the information for
  44479. * @returns The auto clear setup for the requested rendering group
  44480. */
  44481. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44482. private _blockMaterialDirtyMechanism;
  44483. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44484. get blockMaterialDirtyMechanism(): boolean;
  44485. set blockMaterialDirtyMechanism(value: boolean);
  44486. /**
  44487. * Will flag all materials as dirty to trigger new shader compilation
  44488. * @param flag defines the flag used to specify which material part must be marked as dirty
  44489. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44490. */
  44491. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44492. /** @hidden */
  44493. _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;
  44494. /** @hidden */
  44495. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44496. /** @hidden */
  44497. _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;
  44498. /** @hidden */
  44499. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44500. /** @hidden */
  44501. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44502. /** @hidden */
  44503. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44504. }
  44505. }
  44506. declare module BABYLON {
  44507. /**
  44508. * Set of assets to keep when moving a scene into an asset container.
  44509. */
  44510. export class KeepAssets extends AbstractScene {
  44511. }
  44512. /**
  44513. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44514. */
  44515. export class InstantiatedEntries {
  44516. /**
  44517. * List of new root nodes (eg. nodes with no parent)
  44518. */
  44519. rootNodes: TransformNode[];
  44520. /**
  44521. * List of new skeletons
  44522. */
  44523. skeletons: Skeleton[];
  44524. /**
  44525. * List of new animation groups
  44526. */
  44527. animationGroups: AnimationGroup[];
  44528. }
  44529. /**
  44530. * Container with a set of assets that can be added or removed from a scene.
  44531. */
  44532. export class AssetContainer extends AbstractScene {
  44533. private _wasAddedToScene;
  44534. /**
  44535. * The scene the AssetContainer belongs to.
  44536. */
  44537. scene: Scene;
  44538. /**
  44539. * Instantiates an AssetContainer.
  44540. * @param scene The scene the AssetContainer belongs to.
  44541. */
  44542. constructor(scene: Scene);
  44543. /**
  44544. * Instantiate or clone all meshes and add the new ones to the scene.
  44545. * Skeletons and animation groups will all be cloned
  44546. * @param nameFunction defines an optional function used to get new names for clones
  44547. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44548. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44549. */
  44550. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44551. /**
  44552. * Adds all the assets from the container to the scene.
  44553. */
  44554. addAllToScene(): void;
  44555. /**
  44556. * Removes all the assets in the container from the scene
  44557. */
  44558. removeAllFromScene(): void;
  44559. /**
  44560. * Disposes all the assets in the container
  44561. */
  44562. dispose(): void;
  44563. private _moveAssets;
  44564. /**
  44565. * Removes all the assets contained in the scene and adds them to the container.
  44566. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44567. */
  44568. moveAllFromScene(keepAssets?: KeepAssets): void;
  44569. /**
  44570. * 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.
  44571. * @returns the root mesh
  44572. */
  44573. createRootMesh(): Mesh;
  44574. /**
  44575. * Merge animations (direct and animation groups) from this asset container into a scene
  44576. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44577. * @param animatables set of animatables to retarget to a node from the scene
  44578. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44579. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44580. */
  44581. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44582. }
  44583. }
  44584. declare module BABYLON {
  44585. /**
  44586. * Defines how the parser contract is defined.
  44587. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44588. */
  44589. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44590. /**
  44591. * Defines how the individual parser contract is defined.
  44592. * These parser can parse an individual asset
  44593. */
  44594. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44595. /**
  44596. * Base class of the scene acting as a container for the different elements composing a scene.
  44597. * This class is dynamically extended by the different components of the scene increasing
  44598. * flexibility and reducing coupling
  44599. */
  44600. export abstract class AbstractScene {
  44601. /**
  44602. * Stores the list of available parsers in the application.
  44603. */
  44604. private static _BabylonFileParsers;
  44605. /**
  44606. * Stores the list of available individual parsers in the application.
  44607. */
  44608. private static _IndividualBabylonFileParsers;
  44609. /**
  44610. * Adds a parser in the list of available ones
  44611. * @param name Defines the name of the parser
  44612. * @param parser Defines the parser to add
  44613. */
  44614. static AddParser(name: string, parser: BabylonFileParser): void;
  44615. /**
  44616. * Gets a general parser from the list of avaialble ones
  44617. * @param name Defines the name of the parser
  44618. * @returns the requested parser or null
  44619. */
  44620. static GetParser(name: string): Nullable<BabylonFileParser>;
  44621. /**
  44622. * Adds n individual parser in the list of available ones
  44623. * @param name Defines the name of the parser
  44624. * @param parser Defines the parser to add
  44625. */
  44626. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44627. /**
  44628. * Gets an individual parser from the list of avaialble ones
  44629. * @param name Defines the name of the parser
  44630. * @returns the requested parser or null
  44631. */
  44632. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44633. /**
  44634. * Parser json data and populate both a scene and its associated container object
  44635. * @param jsonData Defines the data to parse
  44636. * @param scene Defines the scene to parse the data for
  44637. * @param container Defines the container attached to the parsing sequence
  44638. * @param rootUrl Defines the root url of the data
  44639. */
  44640. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44641. /**
  44642. * Gets the list of root nodes (ie. nodes with no parent)
  44643. */
  44644. rootNodes: Node[];
  44645. /** All of the cameras added to this scene
  44646. * @see https://doc.babylonjs.com/babylon101/cameras
  44647. */
  44648. cameras: Camera[];
  44649. /**
  44650. * All of the lights added to this scene
  44651. * @see https://doc.babylonjs.com/babylon101/lights
  44652. */
  44653. lights: Light[];
  44654. /**
  44655. * All of the (abstract) meshes added to this scene
  44656. */
  44657. meshes: AbstractMesh[];
  44658. /**
  44659. * The list of skeletons added to the scene
  44660. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44661. */
  44662. skeletons: Skeleton[];
  44663. /**
  44664. * All of the particle systems added to this scene
  44665. * @see https://doc.babylonjs.com/babylon101/particles
  44666. */
  44667. particleSystems: IParticleSystem[];
  44668. /**
  44669. * Gets a list of Animations associated with the scene
  44670. */
  44671. animations: Animation[];
  44672. /**
  44673. * All of the animation groups added to this scene
  44674. * @see https://doc.babylonjs.com/how_to/group
  44675. */
  44676. animationGroups: AnimationGroup[];
  44677. /**
  44678. * All of the multi-materials added to this scene
  44679. * @see https://doc.babylonjs.com/how_to/multi_materials
  44680. */
  44681. multiMaterials: MultiMaterial[];
  44682. /**
  44683. * All of the materials added to this scene
  44684. * In the context of a Scene, it is not supposed to be modified manually.
  44685. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44686. * Note also that the order of the Material within the array is not significant and might change.
  44687. * @see https://doc.babylonjs.com/babylon101/materials
  44688. */
  44689. materials: Material[];
  44690. /**
  44691. * The list of morph target managers added to the scene
  44692. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44693. */
  44694. morphTargetManagers: MorphTargetManager[];
  44695. /**
  44696. * The list of geometries used in the scene.
  44697. */
  44698. geometries: Geometry[];
  44699. /**
  44700. * All of the tranform nodes added to this scene
  44701. * In the context of a Scene, it is not supposed to be modified manually.
  44702. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44703. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44704. * @see https://doc.babylonjs.com/how_to/transformnode
  44705. */
  44706. transformNodes: TransformNode[];
  44707. /**
  44708. * ActionManagers available on the scene.
  44709. */
  44710. actionManagers: AbstractActionManager[];
  44711. /**
  44712. * Textures to keep.
  44713. */
  44714. textures: BaseTexture[];
  44715. /** @hidden */
  44716. protected _environmentTexture: Nullable<BaseTexture>;
  44717. /**
  44718. * Texture used in all pbr material as the reflection texture.
  44719. * As in the majority of the scene they are the same (exception for multi room and so on),
  44720. * this is easier to reference from here than from all the materials.
  44721. */
  44722. get environmentTexture(): Nullable<BaseTexture>;
  44723. set environmentTexture(value: Nullable<BaseTexture>);
  44724. /**
  44725. * The list of postprocesses added to the scene
  44726. */
  44727. postProcesses: PostProcess[];
  44728. /**
  44729. * @returns all meshes, lights, cameras, transformNodes and bones
  44730. */
  44731. getNodes(): Array<Node>;
  44732. }
  44733. }
  44734. declare module BABYLON {
  44735. /**
  44736. * Interface used to define options for Sound class
  44737. */
  44738. export interface ISoundOptions {
  44739. /**
  44740. * Does the sound autoplay once loaded.
  44741. */
  44742. autoplay?: boolean;
  44743. /**
  44744. * Does the sound loop after it finishes playing once.
  44745. */
  44746. loop?: boolean;
  44747. /**
  44748. * Sound's volume
  44749. */
  44750. volume?: number;
  44751. /**
  44752. * Is it a spatial sound?
  44753. */
  44754. spatialSound?: boolean;
  44755. /**
  44756. * Maximum distance to hear that sound
  44757. */
  44758. maxDistance?: number;
  44759. /**
  44760. * Uses user defined attenuation function
  44761. */
  44762. useCustomAttenuation?: boolean;
  44763. /**
  44764. * Define the roll off factor of spatial sounds.
  44765. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44766. */
  44767. rolloffFactor?: number;
  44768. /**
  44769. * Define the reference distance the sound should be heard perfectly.
  44770. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44771. */
  44772. refDistance?: number;
  44773. /**
  44774. * Define the distance attenuation model the sound will follow.
  44775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44776. */
  44777. distanceModel?: string;
  44778. /**
  44779. * Defines the playback speed (1 by default)
  44780. */
  44781. playbackRate?: number;
  44782. /**
  44783. * Defines if the sound is from a streaming source
  44784. */
  44785. streaming?: boolean;
  44786. /**
  44787. * Defines an optional length (in seconds) inside the sound file
  44788. */
  44789. length?: number;
  44790. /**
  44791. * Defines an optional offset (in seconds) inside the sound file
  44792. */
  44793. offset?: number;
  44794. /**
  44795. * If true, URLs will not be required to state the audio file codec to use.
  44796. */
  44797. skipCodecCheck?: boolean;
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. /**
  44802. * Defines a sound that can be played in the application.
  44803. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44804. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44805. */
  44806. export class Sound {
  44807. /**
  44808. * The name of the sound in the scene.
  44809. */
  44810. name: string;
  44811. /**
  44812. * Does the sound autoplay once loaded.
  44813. */
  44814. autoplay: boolean;
  44815. /**
  44816. * Does the sound loop after it finishes playing once.
  44817. */
  44818. loop: boolean;
  44819. /**
  44820. * Does the sound use a custom attenuation curve to simulate the falloff
  44821. * happening when the source gets further away from the camera.
  44822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44823. */
  44824. useCustomAttenuation: boolean;
  44825. /**
  44826. * The sound track id this sound belongs to.
  44827. */
  44828. soundTrackId: number;
  44829. /**
  44830. * Is this sound currently played.
  44831. */
  44832. isPlaying: boolean;
  44833. /**
  44834. * Is this sound currently paused.
  44835. */
  44836. isPaused: boolean;
  44837. /**
  44838. * Does this sound enables spatial sound.
  44839. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44840. */
  44841. spatialSound: boolean;
  44842. /**
  44843. * Define the reference distance the sound should be heard perfectly.
  44844. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44845. */
  44846. refDistance: number;
  44847. /**
  44848. * Define the roll off factor of spatial sounds.
  44849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44850. */
  44851. rolloffFactor: number;
  44852. /**
  44853. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44855. */
  44856. maxDistance: number;
  44857. /**
  44858. * Define the distance attenuation model the sound will follow.
  44859. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44860. */
  44861. distanceModel: string;
  44862. /**
  44863. * @hidden
  44864. * Back Compat
  44865. **/
  44866. onended: () => any;
  44867. /**
  44868. * Gets or sets an object used to store user defined information for the sound.
  44869. */
  44870. metadata: any;
  44871. /**
  44872. * Observable event when the current playing sound finishes.
  44873. */
  44874. onEndedObservable: Observable<Sound>;
  44875. /**
  44876. * Gets the current time for the sound.
  44877. */
  44878. get currentTime(): number;
  44879. private _panningModel;
  44880. private _playbackRate;
  44881. private _streaming;
  44882. private _startTime;
  44883. private _startOffset;
  44884. private _position;
  44885. /** @hidden */
  44886. _positionInEmitterSpace: boolean;
  44887. private _localDirection;
  44888. private _volume;
  44889. private _isReadyToPlay;
  44890. private _isDirectional;
  44891. private _readyToPlayCallback;
  44892. private _audioBuffer;
  44893. private _soundSource;
  44894. private _streamingSource;
  44895. private _soundPanner;
  44896. private _soundGain;
  44897. private _inputAudioNode;
  44898. private _outputAudioNode;
  44899. private _coneInnerAngle;
  44900. private _coneOuterAngle;
  44901. private _coneOuterGain;
  44902. private _scene;
  44903. private _connectedTransformNode;
  44904. private _customAttenuationFunction;
  44905. private _registerFunc;
  44906. private _isOutputConnected;
  44907. private _htmlAudioElement;
  44908. private _urlType;
  44909. private _length?;
  44910. private _offset?;
  44911. /** @hidden */
  44912. static _SceneComponentInitialization: (scene: Scene) => void;
  44913. /**
  44914. * Create a sound and attach it to a scene
  44915. * @param name Name of your sound
  44916. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44917. * @param scene defines the scene the sound belongs to
  44918. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44919. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44920. */
  44921. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44922. /**
  44923. * Release the sound and its associated resources
  44924. */
  44925. dispose(): void;
  44926. /**
  44927. * Gets if the sounds is ready to be played or not.
  44928. * @returns true if ready, otherwise false
  44929. */
  44930. isReady(): boolean;
  44931. private _soundLoaded;
  44932. /**
  44933. * Sets the data of the sound from an audiobuffer
  44934. * @param audioBuffer The audioBuffer containing the data
  44935. */
  44936. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44937. /**
  44938. * Updates the current sounds options such as maxdistance, loop...
  44939. * @param options A JSON object containing values named as the object properties
  44940. */
  44941. updateOptions(options: ISoundOptions): void;
  44942. private _createSpatialParameters;
  44943. private _updateSpatialParameters;
  44944. /**
  44945. * Switch the panning model to HRTF:
  44946. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44948. */
  44949. switchPanningModelToHRTF(): void;
  44950. /**
  44951. * Switch the panning model to Equal Power:
  44952. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44954. */
  44955. switchPanningModelToEqualPower(): void;
  44956. private _switchPanningModel;
  44957. /**
  44958. * Connect this sound to a sound track audio node like gain...
  44959. * @param soundTrackAudioNode the sound track audio node to connect to
  44960. */
  44961. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44962. /**
  44963. * Transform this sound into a directional source
  44964. * @param coneInnerAngle Size of the inner cone in degree
  44965. * @param coneOuterAngle Size of the outer cone in degree
  44966. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44967. */
  44968. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44969. /**
  44970. * Gets or sets the inner angle for the directional cone.
  44971. */
  44972. get directionalConeInnerAngle(): number;
  44973. /**
  44974. * Gets or sets the inner angle for the directional cone.
  44975. */
  44976. set directionalConeInnerAngle(value: number);
  44977. /**
  44978. * Gets or sets the outer angle for the directional cone.
  44979. */
  44980. get directionalConeOuterAngle(): number;
  44981. /**
  44982. * Gets or sets the outer angle for the directional cone.
  44983. */
  44984. set directionalConeOuterAngle(value: number);
  44985. /**
  44986. * Sets the position of the emitter if spatial sound is enabled
  44987. * @param newPosition Defines the new posisiton
  44988. */
  44989. setPosition(newPosition: Vector3): void;
  44990. /**
  44991. * Sets the local direction of the emitter if spatial sound is enabled
  44992. * @param newLocalDirection Defines the new local direction
  44993. */
  44994. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44995. private _updateDirection;
  44996. /** @hidden */
  44997. updateDistanceFromListener(): void;
  44998. /**
  44999. * Sets a new custom attenuation function for the sound.
  45000. * @param callback Defines the function used for the attenuation
  45001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45002. */
  45003. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45004. /**
  45005. * Play the sound
  45006. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45007. * @param offset (optional) Start the sound at a specific time in seconds
  45008. * @param length (optional) Sound duration (in seconds)
  45009. */
  45010. play(time?: number, offset?: number, length?: number): void;
  45011. private _onended;
  45012. /**
  45013. * Stop the sound
  45014. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45015. */
  45016. stop(time?: number): void;
  45017. /**
  45018. * Put the sound in pause
  45019. */
  45020. pause(): void;
  45021. /**
  45022. * Sets a dedicated volume for this sounds
  45023. * @param newVolume Define the new volume of the sound
  45024. * @param time Define time for gradual change to new volume
  45025. */
  45026. setVolume(newVolume: number, time?: number): void;
  45027. /**
  45028. * Set the sound play back rate
  45029. * @param newPlaybackRate Define the playback rate the sound should be played at
  45030. */
  45031. setPlaybackRate(newPlaybackRate: number): void;
  45032. /**
  45033. * Gets the volume of the sound.
  45034. * @returns the volume of the sound
  45035. */
  45036. getVolume(): number;
  45037. /**
  45038. * Attach the sound to a dedicated mesh
  45039. * @param transformNode The transform node to connect the sound with
  45040. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45041. */
  45042. attachToMesh(transformNode: TransformNode): void;
  45043. /**
  45044. * Detach the sound from the previously attached mesh
  45045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45046. */
  45047. detachFromMesh(): void;
  45048. private _onRegisterAfterWorldMatrixUpdate;
  45049. /**
  45050. * Clone the current sound in the scene.
  45051. * @returns the new sound clone
  45052. */
  45053. clone(): Nullable<Sound>;
  45054. /**
  45055. * Gets the current underlying audio buffer containing the data
  45056. * @returns the audio buffer
  45057. */
  45058. getAudioBuffer(): Nullable<AudioBuffer>;
  45059. /**
  45060. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45061. * @returns the source node
  45062. */
  45063. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45064. /**
  45065. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45066. * @returns the gain node
  45067. */
  45068. getSoundGain(): Nullable<GainNode>;
  45069. /**
  45070. * Serializes the Sound in a JSON representation
  45071. * @returns the JSON representation of the sound
  45072. */
  45073. serialize(): any;
  45074. /**
  45075. * Parse a JSON representation of a sound to innstantiate in a given scene
  45076. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45077. * @param scene Define the scene the new parsed sound should be created in
  45078. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45079. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45080. * @returns the newly parsed sound
  45081. */
  45082. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /**
  45087. * This defines an action helpful to play a defined sound on a triggered action.
  45088. */
  45089. export class PlaySoundAction extends Action {
  45090. private _sound;
  45091. /**
  45092. * Instantiate the action
  45093. * @param triggerOptions defines the trigger options
  45094. * @param sound defines the sound to play
  45095. * @param condition defines the trigger related conditions
  45096. */
  45097. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45098. /** @hidden */
  45099. _prepare(): void;
  45100. /**
  45101. * Execute the action and play the sound.
  45102. */
  45103. execute(): void;
  45104. /**
  45105. * Serializes the actions and its related information.
  45106. * @param parent defines the object to serialize in
  45107. * @returns the serialized object
  45108. */
  45109. serialize(parent: any): any;
  45110. }
  45111. /**
  45112. * This defines an action helpful to stop a defined sound on a triggered action.
  45113. */
  45114. export class StopSoundAction extends Action {
  45115. private _sound;
  45116. /**
  45117. * Instantiate the action
  45118. * @param triggerOptions defines the trigger options
  45119. * @param sound defines the sound to stop
  45120. * @param condition defines the trigger related conditions
  45121. */
  45122. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45123. /** @hidden */
  45124. _prepare(): void;
  45125. /**
  45126. * Execute the action and stop the sound.
  45127. */
  45128. execute(): void;
  45129. /**
  45130. * Serializes the actions and its related information.
  45131. * @param parent defines the object to serialize in
  45132. * @returns the serialized object
  45133. */
  45134. serialize(parent: any): any;
  45135. }
  45136. }
  45137. declare module BABYLON {
  45138. /**
  45139. * This defines an action responsible to change the value of a property
  45140. * by interpolating between its current value and the newly set one once triggered.
  45141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45142. */
  45143. export class InterpolateValueAction extends Action {
  45144. /**
  45145. * Defines the path of the property where the value should be interpolated
  45146. */
  45147. propertyPath: string;
  45148. /**
  45149. * Defines the target value at the end of the interpolation.
  45150. */
  45151. value: any;
  45152. /**
  45153. * Defines the time it will take for the property to interpolate to the value.
  45154. */
  45155. duration: number;
  45156. /**
  45157. * Defines if the other scene animations should be stopped when the action has been triggered
  45158. */
  45159. stopOtherAnimations?: boolean;
  45160. /**
  45161. * Defines a callback raised once the interpolation animation has been done.
  45162. */
  45163. onInterpolationDone?: () => void;
  45164. /**
  45165. * Observable triggered once the interpolation animation has been done.
  45166. */
  45167. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45168. private _target;
  45169. private _effectiveTarget;
  45170. private _property;
  45171. /**
  45172. * Instantiate the action
  45173. * @param triggerOptions defines the trigger options
  45174. * @param target defines the object containing the value to interpolate
  45175. * @param propertyPath defines the path to the property in the target object
  45176. * @param value defines the target value at the end of the interpolation
  45177. * @param duration deines the time it will take for the property to interpolate to the value.
  45178. * @param condition defines the trigger related conditions
  45179. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45180. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45181. */
  45182. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45183. /** @hidden */
  45184. _prepare(): void;
  45185. /**
  45186. * Execute the action starts the value interpolation.
  45187. */
  45188. execute(): void;
  45189. /**
  45190. * Serializes the actions and its related information.
  45191. * @param parent defines the object to serialize in
  45192. * @returns the serialized object
  45193. */
  45194. serialize(parent: any): any;
  45195. }
  45196. }
  45197. declare module BABYLON {
  45198. /**
  45199. * This represents the default audio engine used in babylon.
  45200. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45202. */
  45203. export class AudioEngine implements IAudioEngine {
  45204. private _audioContext;
  45205. private _audioContextInitialized;
  45206. private _muteButton;
  45207. private _hostElement;
  45208. /**
  45209. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45210. */
  45211. canUseWebAudio: boolean;
  45212. /**
  45213. * The master gain node defines the global audio volume of your audio engine.
  45214. */
  45215. masterGain: GainNode;
  45216. /**
  45217. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45218. * @ignoreNaming
  45219. */
  45220. WarnedWebAudioUnsupported: boolean;
  45221. /**
  45222. * Gets whether or not mp3 are supported by your browser.
  45223. */
  45224. isMP3supported: boolean;
  45225. /**
  45226. * Gets whether or not ogg are supported by your browser.
  45227. */
  45228. isOGGsupported: boolean;
  45229. /**
  45230. * Gets whether audio has been unlocked on the device.
  45231. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45232. * a user interaction has happened.
  45233. */
  45234. unlocked: boolean;
  45235. /**
  45236. * Defines if the audio engine relies on a custom unlocked button.
  45237. * In this case, the embedded button will not be displayed.
  45238. */
  45239. useCustomUnlockedButton: boolean;
  45240. /**
  45241. * Event raised when audio has been unlocked on the browser.
  45242. */
  45243. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45244. /**
  45245. * Event raised when audio has been locked on the browser.
  45246. */
  45247. onAudioLockedObservable: Observable<IAudioEngine>;
  45248. /**
  45249. * Gets the current AudioContext if available.
  45250. */
  45251. get audioContext(): Nullable<AudioContext>;
  45252. private _connectedAnalyser;
  45253. /**
  45254. * Instantiates a new audio engine.
  45255. *
  45256. * There should be only one per page as some browsers restrict the number
  45257. * of audio contexts you can create.
  45258. * @param hostElement defines the host element where to display the mute icon if necessary
  45259. */
  45260. constructor(hostElement?: Nullable<HTMLElement>);
  45261. /**
  45262. * Flags the audio engine in Locked state.
  45263. * This happens due to new browser policies preventing audio to autoplay.
  45264. */
  45265. lock(): void;
  45266. /**
  45267. * Unlocks the audio engine once a user action has been done on the dom.
  45268. * This is helpful to resume play once browser policies have been satisfied.
  45269. */
  45270. unlock(): void;
  45271. private _resumeAudioContext;
  45272. private _initializeAudioContext;
  45273. private _tryToRun;
  45274. private _triggerRunningState;
  45275. private _triggerSuspendedState;
  45276. private _displayMuteButton;
  45277. private _moveButtonToTopLeft;
  45278. private _onResize;
  45279. private _hideMuteButton;
  45280. /**
  45281. * Destroy and release the resources associated with the audio ccontext.
  45282. */
  45283. dispose(): void;
  45284. /**
  45285. * Gets the global volume sets on the master gain.
  45286. * @returns the global volume if set or -1 otherwise
  45287. */
  45288. getGlobalVolume(): number;
  45289. /**
  45290. * Sets the global volume of your experience (sets on the master gain).
  45291. * @param newVolume Defines the new global volume of the application
  45292. */
  45293. setGlobalVolume(newVolume: number): void;
  45294. /**
  45295. * Connect the audio engine to an audio analyser allowing some amazing
  45296. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45298. * @param analyser The analyser to connect to the engine
  45299. */
  45300. connectToAnalyser(analyser: Analyser): void;
  45301. }
  45302. }
  45303. declare module BABYLON {
  45304. /**
  45305. * Options allowed during the creation of a sound track.
  45306. */
  45307. export interface ISoundTrackOptions {
  45308. /**
  45309. * The volume the sound track should take during creation
  45310. */
  45311. volume?: number;
  45312. /**
  45313. * Define if the sound track is the main sound track of the scene
  45314. */
  45315. mainTrack?: boolean;
  45316. }
  45317. /**
  45318. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45319. * It will be also used in a future release to apply effects on a specific track.
  45320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45321. */
  45322. export class SoundTrack {
  45323. /**
  45324. * The unique identifier of the sound track in the scene.
  45325. */
  45326. id: number;
  45327. /**
  45328. * The list of sounds included in the sound track.
  45329. */
  45330. soundCollection: Array<Sound>;
  45331. private _outputAudioNode;
  45332. private _scene;
  45333. private _connectedAnalyser;
  45334. private _options;
  45335. private _isInitialized;
  45336. /**
  45337. * Creates a new sound track.
  45338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45339. * @param scene Define the scene the sound track belongs to
  45340. * @param options
  45341. */
  45342. constructor(scene: Scene, options?: ISoundTrackOptions);
  45343. private _initializeSoundTrackAudioGraph;
  45344. /**
  45345. * Release the sound track and its associated resources
  45346. */
  45347. dispose(): void;
  45348. /**
  45349. * Adds a sound to this sound track
  45350. * @param sound define the cound to add
  45351. * @ignoreNaming
  45352. */
  45353. addSound(sound: Sound): void;
  45354. /**
  45355. * Removes a sound to this sound track
  45356. * @param sound define the cound to remove
  45357. * @ignoreNaming
  45358. */
  45359. removeSound(sound: Sound): void;
  45360. /**
  45361. * Set a global volume for the full sound track.
  45362. * @param newVolume Define the new volume of the sound track
  45363. */
  45364. setVolume(newVolume: number): void;
  45365. /**
  45366. * Switch the panning model to HRTF:
  45367. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45368. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45369. */
  45370. switchPanningModelToHRTF(): void;
  45371. /**
  45372. * Switch the panning model to Equal Power:
  45373. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45375. */
  45376. switchPanningModelToEqualPower(): void;
  45377. /**
  45378. * Connect the sound track to an audio analyser allowing some amazing
  45379. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45381. * @param analyser The analyser to connect to the engine
  45382. */
  45383. connectToAnalyser(analyser: Analyser): void;
  45384. }
  45385. }
  45386. declare module BABYLON {
  45387. interface AbstractScene {
  45388. /**
  45389. * The list of sounds used in the scene.
  45390. */
  45391. sounds: Nullable<Array<Sound>>;
  45392. }
  45393. interface Scene {
  45394. /**
  45395. * @hidden
  45396. * Backing field
  45397. */
  45398. _mainSoundTrack: SoundTrack;
  45399. /**
  45400. * The main sound track played by the scene.
  45401. * It cotains your primary collection of sounds.
  45402. */
  45403. mainSoundTrack: SoundTrack;
  45404. /**
  45405. * The list of sound tracks added to the scene
  45406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45407. */
  45408. soundTracks: Nullable<Array<SoundTrack>>;
  45409. /**
  45410. * Gets a sound using a given name
  45411. * @param name defines the name to search for
  45412. * @return the found sound or null if not found at all.
  45413. */
  45414. getSoundByName(name: string): Nullable<Sound>;
  45415. /**
  45416. * Gets or sets if audio support is enabled
  45417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45418. */
  45419. audioEnabled: boolean;
  45420. /**
  45421. * Gets or sets if audio will be output to headphones
  45422. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45423. */
  45424. headphone: boolean;
  45425. /**
  45426. * Gets or sets custom audio listener position provider
  45427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45428. */
  45429. audioListenerPositionProvider: Nullable<() => Vector3>;
  45430. /**
  45431. * Gets or sets a refresh rate when using 3D audio positioning
  45432. */
  45433. audioPositioningRefreshRate: number;
  45434. }
  45435. /**
  45436. * Defines the sound scene component responsible to manage any sounds
  45437. * in a given scene.
  45438. */
  45439. export class AudioSceneComponent implements ISceneSerializableComponent {
  45440. private static _CameraDirectionLH;
  45441. private static _CameraDirectionRH;
  45442. /**
  45443. * The component name helpfull to identify the component in the list of scene components.
  45444. */
  45445. readonly name: string;
  45446. /**
  45447. * The scene the component belongs to.
  45448. */
  45449. scene: Scene;
  45450. private _audioEnabled;
  45451. /**
  45452. * Gets whether audio is enabled or not.
  45453. * Please use related enable/disable method to switch state.
  45454. */
  45455. get audioEnabled(): boolean;
  45456. private _headphone;
  45457. /**
  45458. * Gets whether audio is outputing to headphone or not.
  45459. * Please use the according Switch methods to change output.
  45460. */
  45461. get headphone(): boolean;
  45462. /**
  45463. * Gets or sets a refresh rate when using 3D audio positioning
  45464. */
  45465. audioPositioningRefreshRate: number;
  45466. private _audioListenerPositionProvider;
  45467. /**
  45468. * Gets the current audio listener position provider
  45469. */
  45470. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45471. /**
  45472. * Sets a custom listener position for all sounds in the scene
  45473. * By default, this is the position of the first active camera
  45474. */
  45475. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45476. /**
  45477. * Creates a new instance of the component for the given scene
  45478. * @param scene Defines the scene to register the component in
  45479. */
  45480. constructor(scene: Scene);
  45481. /**
  45482. * Registers the component in a given scene
  45483. */
  45484. register(): void;
  45485. /**
  45486. * Rebuilds the elements related to this component in case of
  45487. * context lost for instance.
  45488. */
  45489. rebuild(): void;
  45490. /**
  45491. * Serializes the component data to the specified json object
  45492. * @param serializationObject The object to serialize to
  45493. */
  45494. serialize(serializationObject: any): void;
  45495. /**
  45496. * Adds all the elements from the container to the scene
  45497. * @param container the container holding the elements
  45498. */
  45499. addFromContainer(container: AbstractScene): void;
  45500. /**
  45501. * Removes all the elements in the container from the scene
  45502. * @param container contains the elements to remove
  45503. * @param dispose if the removed element should be disposed (default: false)
  45504. */
  45505. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45506. /**
  45507. * Disposes the component and the associated ressources.
  45508. */
  45509. dispose(): void;
  45510. /**
  45511. * Disables audio in the associated scene.
  45512. */
  45513. disableAudio(): void;
  45514. /**
  45515. * Enables audio in the associated scene.
  45516. */
  45517. enableAudio(): void;
  45518. /**
  45519. * Switch audio to headphone output.
  45520. */
  45521. switchAudioModeForHeadphones(): void;
  45522. /**
  45523. * Switch audio to normal speakers.
  45524. */
  45525. switchAudioModeForNormalSpeakers(): void;
  45526. private _cachedCameraDirection;
  45527. private _cachedCameraPosition;
  45528. private _lastCheck;
  45529. private _afterRender;
  45530. }
  45531. }
  45532. declare module BABYLON {
  45533. /**
  45534. * Wraps one or more Sound objects and selects one with random weight for playback.
  45535. */
  45536. export class WeightedSound {
  45537. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45538. loop: boolean;
  45539. private _coneInnerAngle;
  45540. private _coneOuterAngle;
  45541. private _volume;
  45542. /** A Sound is currently playing. */
  45543. isPlaying: boolean;
  45544. /** A Sound is currently paused. */
  45545. isPaused: boolean;
  45546. private _sounds;
  45547. private _weights;
  45548. private _currentIndex?;
  45549. /**
  45550. * Creates a new WeightedSound from the list of sounds given.
  45551. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45552. * @param sounds Array of Sounds that will be selected from.
  45553. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45554. */
  45555. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45556. /**
  45557. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45558. */
  45559. get directionalConeInnerAngle(): number;
  45560. /**
  45561. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45562. */
  45563. set directionalConeInnerAngle(value: number);
  45564. /**
  45565. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45566. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45567. */
  45568. get directionalConeOuterAngle(): number;
  45569. /**
  45570. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45571. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45572. */
  45573. set directionalConeOuterAngle(value: number);
  45574. /**
  45575. * Playback volume.
  45576. */
  45577. get volume(): number;
  45578. /**
  45579. * Playback volume.
  45580. */
  45581. set volume(value: number);
  45582. private _onended;
  45583. /**
  45584. * Suspend playback
  45585. */
  45586. pause(): void;
  45587. /**
  45588. * Stop playback
  45589. */
  45590. stop(): void;
  45591. /**
  45592. * Start playback.
  45593. * @param startOffset Position the clip head at a specific time in seconds.
  45594. */
  45595. play(startOffset?: number): void;
  45596. }
  45597. }
  45598. declare module BABYLON {
  45599. /**
  45600. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45601. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45602. */
  45603. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45604. /**
  45605. * Gets the name of the behavior.
  45606. */
  45607. get name(): string;
  45608. /**
  45609. * The easing function used by animations
  45610. */
  45611. static EasingFunction: BackEase;
  45612. /**
  45613. * The easing mode used by animations
  45614. */
  45615. static EasingMode: number;
  45616. /**
  45617. * The duration of the animation, in milliseconds
  45618. */
  45619. transitionDuration: number;
  45620. /**
  45621. * Length of the distance animated by the transition when lower radius is reached
  45622. */
  45623. lowerRadiusTransitionRange: number;
  45624. /**
  45625. * Length of the distance animated by the transition when upper radius is reached
  45626. */
  45627. upperRadiusTransitionRange: number;
  45628. private _autoTransitionRange;
  45629. /**
  45630. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45631. */
  45632. get autoTransitionRange(): boolean;
  45633. /**
  45634. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45635. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45636. */
  45637. set autoTransitionRange(value: boolean);
  45638. private _attachedCamera;
  45639. private _onAfterCheckInputsObserver;
  45640. private _onMeshTargetChangedObserver;
  45641. /**
  45642. * Initializes the behavior.
  45643. */
  45644. init(): void;
  45645. /**
  45646. * Attaches the behavior to its arc rotate camera.
  45647. * @param camera Defines the camera to attach the behavior to
  45648. */
  45649. attach(camera: ArcRotateCamera): void;
  45650. /**
  45651. * Detaches the behavior from its current arc rotate camera.
  45652. */
  45653. detach(): void;
  45654. private _radiusIsAnimating;
  45655. private _radiusBounceTransition;
  45656. private _animatables;
  45657. private _cachedWheelPrecision;
  45658. /**
  45659. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45660. * @param radiusLimit The limit to check against.
  45661. * @return Bool to indicate if at limit.
  45662. */
  45663. private _isRadiusAtLimit;
  45664. /**
  45665. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45666. * @param radiusDelta The delta by which to animate to. Can be negative.
  45667. */
  45668. private _applyBoundRadiusAnimation;
  45669. /**
  45670. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45671. */
  45672. protected _clearAnimationLocks(): void;
  45673. /**
  45674. * Stops and removes all animations that have been applied to the camera
  45675. */
  45676. stopAllAnimations(): void;
  45677. }
  45678. }
  45679. declare module BABYLON {
  45680. /**
  45681. * 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.
  45682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45683. */
  45684. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45685. /**
  45686. * Gets the name of the behavior.
  45687. */
  45688. get name(): string;
  45689. private _mode;
  45690. private _radiusScale;
  45691. private _positionScale;
  45692. private _defaultElevation;
  45693. private _elevationReturnTime;
  45694. private _elevationReturnWaitTime;
  45695. private _zoomStopsAnimation;
  45696. private _framingTime;
  45697. /**
  45698. * The easing function used by animations
  45699. */
  45700. static EasingFunction: ExponentialEase;
  45701. /**
  45702. * The easing mode used by animations
  45703. */
  45704. static EasingMode: number;
  45705. /**
  45706. * Sets the current mode used by the behavior
  45707. */
  45708. set mode(mode: number);
  45709. /**
  45710. * Gets current mode used by the behavior.
  45711. */
  45712. get mode(): number;
  45713. /**
  45714. * Sets the scale applied to the radius (1 by default)
  45715. */
  45716. set radiusScale(radius: number);
  45717. /**
  45718. * Gets the scale applied to the radius
  45719. */
  45720. get radiusScale(): number;
  45721. /**
  45722. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45723. */
  45724. set positionScale(scale: number);
  45725. /**
  45726. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45727. */
  45728. get positionScale(): number;
  45729. /**
  45730. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45731. * behaviour is triggered, in radians.
  45732. */
  45733. set defaultElevation(elevation: number);
  45734. /**
  45735. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45736. * behaviour is triggered, in radians.
  45737. */
  45738. get defaultElevation(): number;
  45739. /**
  45740. * Sets the time (in milliseconds) taken to return to the default beta position.
  45741. * Negative value indicates camera should not return to default.
  45742. */
  45743. set elevationReturnTime(speed: number);
  45744. /**
  45745. * Gets the time (in milliseconds) taken to return to the default beta position.
  45746. * Negative value indicates camera should not return to default.
  45747. */
  45748. get elevationReturnTime(): number;
  45749. /**
  45750. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45751. */
  45752. set elevationReturnWaitTime(time: number);
  45753. /**
  45754. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45755. */
  45756. get elevationReturnWaitTime(): number;
  45757. /**
  45758. * Sets the flag that indicates if user zooming should stop animation.
  45759. */
  45760. set zoomStopsAnimation(flag: boolean);
  45761. /**
  45762. * Gets the flag that indicates if user zooming should stop animation.
  45763. */
  45764. get zoomStopsAnimation(): boolean;
  45765. /**
  45766. * Sets the transition time when framing the mesh, in milliseconds
  45767. */
  45768. set framingTime(time: number);
  45769. /**
  45770. * Gets the transition time when framing the mesh, in milliseconds
  45771. */
  45772. get framingTime(): number;
  45773. /**
  45774. * Define if the behavior should automatically change the configured
  45775. * camera limits and sensibilities.
  45776. */
  45777. autoCorrectCameraLimitsAndSensibility: boolean;
  45778. private _onPrePointerObservableObserver;
  45779. private _onAfterCheckInputsObserver;
  45780. private _onMeshTargetChangedObserver;
  45781. private _attachedCamera;
  45782. private _isPointerDown;
  45783. private _lastInteractionTime;
  45784. /**
  45785. * Initializes the behavior.
  45786. */
  45787. init(): void;
  45788. /**
  45789. * Attaches the behavior to its arc rotate camera.
  45790. * @param camera Defines the camera to attach the behavior to
  45791. */
  45792. attach(camera: ArcRotateCamera): void;
  45793. /**
  45794. * Detaches the behavior from its current arc rotate camera.
  45795. */
  45796. detach(): void;
  45797. private _animatables;
  45798. private _betaIsAnimating;
  45799. private _betaTransition;
  45800. private _radiusTransition;
  45801. private _vectorTransition;
  45802. /**
  45803. * Targets the given mesh and updates zoom level accordingly.
  45804. * @param mesh The mesh to target.
  45805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45807. */
  45808. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45809. /**
  45810. * Targets the given mesh with its children and updates zoom level accordingly.
  45811. * @param mesh The mesh to target.
  45812. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45813. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45814. */
  45815. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45816. /**
  45817. * Targets the given meshes with their children and updates zoom level accordingly.
  45818. * @param meshes The mesh to target.
  45819. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45820. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45821. */
  45822. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45823. /**
  45824. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45825. * @param minimumWorld Determines the smaller position of the bounding box extend
  45826. * @param maximumWorld Determines the bigger position of the bounding box extend
  45827. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45828. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45829. */
  45830. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45831. /**
  45832. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45833. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45834. * frustum width.
  45835. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45836. * to fully enclose the mesh in the viewing frustum.
  45837. */
  45838. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45839. /**
  45840. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45841. * is automatically returned to its default position (expected to be above ground plane).
  45842. */
  45843. private _maintainCameraAboveGround;
  45844. /**
  45845. * Returns the frustum slope based on the canvas ratio and camera FOV
  45846. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45847. */
  45848. private _getFrustumSlope;
  45849. /**
  45850. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45851. */
  45852. private _clearAnimationLocks;
  45853. /**
  45854. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45855. */
  45856. private _applyUserInteraction;
  45857. /**
  45858. * Stops and removes all animations that have been applied to the camera
  45859. */
  45860. stopAllAnimations(): void;
  45861. /**
  45862. * Gets a value indicating if the user is moving the camera
  45863. */
  45864. get isUserIsMoving(): boolean;
  45865. /**
  45866. * The camera can move all the way towards the mesh.
  45867. */
  45868. static IgnoreBoundsSizeMode: number;
  45869. /**
  45870. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45871. */
  45872. static FitFrustumSidesMode: number;
  45873. }
  45874. }
  45875. declare module BABYLON {
  45876. /**
  45877. * Base class for Camera Pointer Inputs.
  45878. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45879. * for example usage.
  45880. */
  45881. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45882. /**
  45883. * Defines the camera the input is attached to.
  45884. */
  45885. abstract camera: Camera;
  45886. /**
  45887. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45888. */
  45889. protected _altKey: boolean;
  45890. protected _ctrlKey: boolean;
  45891. protected _metaKey: boolean;
  45892. protected _shiftKey: boolean;
  45893. /**
  45894. * Which mouse buttons were pressed at time of last mouse event.
  45895. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45896. */
  45897. protected _buttonsPressed: number;
  45898. /**
  45899. * Defines the buttons associated with the input to handle camera move.
  45900. */
  45901. buttons: number[];
  45902. /**
  45903. * Attach the input controls to a specific dom element to get the input from.
  45904. * @param element Defines the element the controls should be listened from
  45905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45906. */
  45907. attachControl(noPreventDefault?: boolean): void;
  45908. /**
  45909. * Detach the current controls from the specified dom element.
  45910. */
  45911. detachControl(): void;
  45912. /**
  45913. * Gets the class name of the current input.
  45914. * @returns the class name
  45915. */
  45916. getClassName(): string;
  45917. /**
  45918. * Get the friendly name associated with the input class.
  45919. * @returns the input friendly name
  45920. */
  45921. getSimpleName(): string;
  45922. /**
  45923. * Called on pointer POINTERDOUBLETAP event.
  45924. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45925. */
  45926. protected onDoubleTap(type: string): void;
  45927. /**
  45928. * Called on pointer POINTERMOVE event if only a single touch is active.
  45929. * Override this method to provide functionality.
  45930. */
  45931. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45932. /**
  45933. * Called on pointer POINTERMOVE event if multiple touches are active.
  45934. * Override this method to provide functionality.
  45935. */
  45936. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45937. /**
  45938. * Called on JS contextmenu event.
  45939. * Override this method to provide functionality.
  45940. */
  45941. protected onContextMenu(evt: PointerEvent): void;
  45942. /**
  45943. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45944. * press.
  45945. * Override this method to provide functionality.
  45946. */
  45947. protected onButtonDown(evt: PointerEvent): void;
  45948. /**
  45949. * Called each time a new POINTERUP event occurs. Ie, for each button
  45950. * release.
  45951. * Override this method to provide functionality.
  45952. */
  45953. protected onButtonUp(evt: PointerEvent): void;
  45954. /**
  45955. * Called when window becomes inactive.
  45956. * Override this method to provide functionality.
  45957. */
  45958. protected onLostFocus(): void;
  45959. private _pointerInput;
  45960. private _observer;
  45961. private _onLostFocus;
  45962. private pointA;
  45963. private pointB;
  45964. }
  45965. }
  45966. declare module BABYLON {
  45967. /**
  45968. * Manage the pointers inputs to control an arc rotate camera.
  45969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45970. */
  45971. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45972. /**
  45973. * Defines the camera the input is attached to.
  45974. */
  45975. camera: ArcRotateCamera;
  45976. /**
  45977. * Gets the class name of the current input.
  45978. * @returns the class name
  45979. */
  45980. getClassName(): string;
  45981. /**
  45982. * Defines the buttons associated with the input to handle camera move.
  45983. */
  45984. buttons: number[];
  45985. /**
  45986. * Defines the pointer angular sensibility along the X axis or how fast is
  45987. * the camera rotating.
  45988. */
  45989. angularSensibilityX: number;
  45990. /**
  45991. * Defines the pointer angular sensibility along the Y axis or how fast is
  45992. * the camera rotating.
  45993. */
  45994. angularSensibilityY: number;
  45995. /**
  45996. * Defines the pointer pinch precision or how fast is the camera zooming.
  45997. */
  45998. pinchPrecision: number;
  45999. /**
  46000. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46001. * from 0.
  46002. * It defines the percentage of current camera.radius to use as delta when
  46003. * pinch zoom is used.
  46004. */
  46005. pinchDeltaPercentage: number;
  46006. /**
  46007. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46008. * that any object in the plane at the camera's target point will scale
  46009. * perfectly with finger motion.
  46010. * Overrides pinchDeltaPercentage and pinchPrecision.
  46011. */
  46012. useNaturalPinchZoom: boolean;
  46013. /**
  46014. * Defines the pointer panning sensibility or how fast is the camera moving.
  46015. */
  46016. panningSensibility: number;
  46017. /**
  46018. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46019. */
  46020. multiTouchPanning: boolean;
  46021. /**
  46022. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46023. * zoom (pinch) through multitouch.
  46024. */
  46025. multiTouchPanAndZoom: boolean;
  46026. /**
  46027. * Revers pinch action direction.
  46028. */
  46029. pinchInwards: boolean;
  46030. private _isPanClick;
  46031. private _twoFingerActivityCount;
  46032. private _isPinching;
  46033. /**
  46034. * Called on pointer POINTERMOVE event if only a single touch is active.
  46035. */
  46036. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46037. /**
  46038. * Called on pointer POINTERDOUBLETAP event.
  46039. */
  46040. protected onDoubleTap(type: string): void;
  46041. /**
  46042. * Called on pointer POINTERMOVE event if multiple touches are active.
  46043. */
  46044. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46045. /**
  46046. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46047. * press.
  46048. */
  46049. protected onButtonDown(evt: PointerEvent): void;
  46050. /**
  46051. * Called each time a new POINTERUP event occurs. Ie, for each button
  46052. * release.
  46053. */
  46054. protected onButtonUp(evt: PointerEvent): void;
  46055. /**
  46056. * Called when window becomes inactive.
  46057. */
  46058. protected onLostFocus(): void;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /**
  46063. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46064. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46065. */
  46066. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46067. /**
  46068. * Defines the camera the input is attached to.
  46069. */
  46070. camera: ArcRotateCamera;
  46071. /**
  46072. * Defines the list of key codes associated with the up action (increase alpha)
  46073. */
  46074. keysUp: number[];
  46075. /**
  46076. * Defines the list of key codes associated with the down action (decrease alpha)
  46077. */
  46078. keysDown: number[];
  46079. /**
  46080. * Defines the list of key codes associated with the left action (increase beta)
  46081. */
  46082. keysLeft: number[];
  46083. /**
  46084. * Defines the list of key codes associated with the right action (decrease beta)
  46085. */
  46086. keysRight: number[];
  46087. /**
  46088. * Defines the list of key codes associated with the reset action.
  46089. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46090. */
  46091. keysReset: number[];
  46092. /**
  46093. * Defines the panning sensibility of the inputs.
  46094. * (How fast is the camera panning)
  46095. */
  46096. panningSensibility: number;
  46097. /**
  46098. * Defines the zooming sensibility of the inputs.
  46099. * (How fast is the camera zooming)
  46100. */
  46101. zoomingSensibility: number;
  46102. /**
  46103. * Defines whether maintaining the alt key down switch the movement mode from
  46104. * orientation to zoom.
  46105. */
  46106. useAltToZoom: boolean;
  46107. /**
  46108. * Rotation speed of the camera
  46109. */
  46110. angularSpeed: number;
  46111. private _keys;
  46112. private _ctrlPressed;
  46113. private _altPressed;
  46114. private _onCanvasBlurObserver;
  46115. private _onKeyboardObserver;
  46116. private _engine;
  46117. private _scene;
  46118. /**
  46119. * Attach the input controls to a specific dom element to get the input from.
  46120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46121. */
  46122. attachControl(noPreventDefault?: boolean): void;
  46123. /**
  46124. * Detach the current controls from the specified dom element.
  46125. */
  46126. detachControl(): void;
  46127. /**
  46128. * Update the current camera state depending on the inputs that have been used this frame.
  46129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46130. */
  46131. checkInputs(): void;
  46132. /**
  46133. * Gets the class name of the current intput.
  46134. * @returns the class name
  46135. */
  46136. getClassName(): string;
  46137. /**
  46138. * Get the friendly name associated with the input class.
  46139. * @returns the input friendly name
  46140. */
  46141. getSimpleName(): string;
  46142. }
  46143. }
  46144. declare module BABYLON {
  46145. /**
  46146. * Manage the mouse wheel inputs to control an arc rotate camera.
  46147. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46148. */
  46149. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46150. /**
  46151. * Defines the camera the input is attached to.
  46152. */
  46153. camera: ArcRotateCamera;
  46154. /**
  46155. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46156. */
  46157. wheelPrecision: number;
  46158. /**
  46159. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46160. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46161. */
  46162. wheelDeltaPercentage: number;
  46163. private _wheel;
  46164. private _observer;
  46165. private computeDeltaFromMouseWheelLegacyEvent;
  46166. /**
  46167. * Attach the input controls to a specific dom element to get the input from.
  46168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46169. */
  46170. attachControl(noPreventDefault?: boolean): void;
  46171. /**
  46172. * Detach the current controls from the specified dom element.
  46173. */
  46174. detachControl(): void;
  46175. /**
  46176. * Gets the class name of the current intput.
  46177. * @returns the class name
  46178. */
  46179. getClassName(): string;
  46180. /**
  46181. * Get the friendly name associated with the input class.
  46182. * @returns the input friendly name
  46183. */
  46184. getSimpleName(): string;
  46185. }
  46186. }
  46187. declare module BABYLON {
  46188. /**
  46189. * Default Inputs manager for the ArcRotateCamera.
  46190. * It groups all the default supported inputs for ease of use.
  46191. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46192. */
  46193. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46194. /**
  46195. * Instantiates a new ArcRotateCameraInputsManager.
  46196. * @param camera Defines the camera the inputs belong to
  46197. */
  46198. constructor(camera: ArcRotateCamera);
  46199. /**
  46200. * Add mouse wheel input support to the input manager.
  46201. * @returns the current input manager
  46202. */
  46203. addMouseWheel(): ArcRotateCameraInputsManager;
  46204. /**
  46205. * Add pointers input support to the input manager.
  46206. * @returns the current input manager
  46207. */
  46208. addPointers(): ArcRotateCameraInputsManager;
  46209. /**
  46210. * Add keyboard input support to the input manager.
  46211. * @returns the current input manager
  46212. */
  46213. addKeyboard(): ArcRotateCameraInputsManager;
  46214. }
  46215. }
  46216. declare module BABYLON {
  46217. /**
  46218. * This represents an orbital type of camera.
  46219. *
  46220. * 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.
  46221. * 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.
  46222. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46223. */
  46224. export class ArcRotateCamera extends TargetCamera {
  46225. /**
  46226. * Defines the rotation angle of the camera along the longitudinal axis.
  46227. */
  46228. alpha: number;
  46229. /**
  46230. * Defines the rotation angle of the camera along the latitudinal axis.
  46231. */
  46232. beta: number;
  46233. /**
  46234. * Defines the radius of the camera from it s target point.
  46235. */
  46236. radius: number;
  46237. protected _target: Vector3;
  46238. protected _targetHost: Nullable<AbstractMesh>;
  46239. /**
  46240. * Defines the target point of the camera.
  46241. * The camera looks towards it form the radius distance.
  46242. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46243. */
  46244. get target(): Vector3;
  46245. set target(value: Vector3);
  46246. /**
  46247. * Define the current local position of the camera in the scene
  46248. */
  46249. get position(): Vector3;
  46250. set position(newPosition: Vector3);
  46251. protected _upToYMatrix: Matrix;
  46252. protected _YToUpMatrix: Matrix;
  46253. /**
  46254. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46255. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46256. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46257. */
  46258. set upVector(vec: Vector3);
  46259. get upVector(): Vector3;
  46260. /**
  46261. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46262. */
  46263. setMatUp(): void;
  46264. /**
  46265. * Current inertia value on the longitudinal axis.
  46266. * The bigger this number the longer it will take for the camera to stop.
  46267. */
  46268. inertialAlphaOffset: number;
  46269. /**
  46270. * Current inertia value on the latitudinal axis.
  46271. * The bigger this number the longer it will take for the camera to stop.
  46272. */
  46273. inertialBetaOffset: number;
  46274. /**
  46275. * Current inertia value on the radius axis.
  46276. * The bigger this number the longer it will take for the camera to stop.
  46277. */
  46278. inertialRadiusOffset: number;
  46279. /**
  46280. * Minimum allowed angle on the longitudinal axis.
  46281. * This can help limiting how the Camera is able to move in the scene.
  46282. */
  46283. lowerAlphaLimit: Nullable<number>;
  46284. /**
  46285. * Maximum allowed angle on the longitudinal axis.
  46286. * This can help limiting how the Camera is able to move in the scene.
  46287. */
  46288. upperAlphaLimit: Nullable<number>;
  46289. /**
  46290. * Minimum allowed angle on the latitudinal axis.
  46291. * This can help limiting how the Camera is able to move in the scene.
  46292. */
  46293. lowerBetaLimit: number;
  46294. /**
  46295. * Maximum allowed angle on the latitudinal axis.
  46296. * This can help limiting how the Camera is able to move in the scene.
  46297. */
  46298. upperBetaLimit: number;
  46299. /**
  46300. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46301. * This can help limiting how the Camera is able to move in the scene.
  46302. */
  46303. lowerRadiusLimit: Nullable<number>;
  46304. /**
  46305. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46306. * This can help limiting how the Camera is able to move in the scene.
  46307. */
  46308. upperRadiusLimit: Nullable<number>;
  46309. /**
  46310. * Defines the current inertia value used during panning of the camera along the X axis.
  46311. */
  46312. inertialPanningX: number;
  46313. /**
  46314. * Defines the current inertia value used during panning of the camera along the Y axis.
  46315. */
  46316. inertialPanningY: number;
  46317. /**
  46318. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46319. * Basically if your fingers moves away from more than this distance you will be considered
  46320. * in pinch mode.
  46321. */
  46322. pinchToPanMaxDistance: number;
  46323. /**
  46324. * Defines the maximum distance the camera can pan.
  46325. * This could help keeping the cammera always in your scene.
  46326. */
  46327. panningDistanceLimit: Nullable<number>;
  46328. /**
  46329. * Defines the target of the camera before paning.
  46330. */
  46331. panningOriginTarget: Vector3;
  46332. /**
  46333. * Defines the value of the inertia used during panning.
  46334. * 0 would mean stop inertia and one would mean no decelleration at all.
  46335. */
  46336. panningInertia: number;
  46337. /**
  46338. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46339. */
  46340. get angularSensibilityX(): number;
  46341. set angularSensibilityX(value: number);
  46342. /**
  46343. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46344. */
  46345. get angularSensibilityY(): number;
  46346. set angularSensibilityY(value: number);
  46347. /**
  46348. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46349. */
  46350. get pinchPrecision(): number;
  46351. set pinchPrecision(value: number);
  46352. /**
  46353. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46354. * It will be used instead of pinchDeltaPrecision if different from 0.
  46355. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46356. */
  46357. get pinchDeltaPercentage(): number;
  46358. set pinchDeltaPercentage(value: number);
  46359. /**
  46360. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46361. * and pinch delta percentage.
  46362. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46363. * that any object in the plane at the camera's target point will scale
  46364. * perfectly with finger motion.
  46365. */
  46366. get useNaturalPinchZoom(): boolean;
  46367. set useNaturalPinchZoom(value: boolean);
  46368. /**
  46369. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46370. */
  46371. get panningSensibility(): number;
  46372. set panningSensibility(value: number);
  46373. /**
  46374. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46375. */
  46376. get keysUp(): number[];
  46377. set keysUp(value: number[]);
  46378. /**
  46379. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46380. */
  46381. get keysDown(): number[];
  46382. set keysDown(value: number[]);
  46383. /**
  46384. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46385. */
  46386. get keysLeft(): number[];
  46387. set keysLeft(value: number[]);
  46388. /**
  46389. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46390. */
  46391. get keysRight(): number[];
  46392. set keysRight(value: number[]);
  46393. /**
  46394. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46395. */
  46396. get wheelPrecision(): number;
  46397. set wheelPrecision(value: number);
  46398. /**
  46399. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46400. * It will be used instead of pinchDeltaPrecision if different from 0.
  46401. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46402. */
  46403. get wheelDeltaPercentage(): number;
  46404. set wheelDeltaPercentage(value: number);
  46405. /**
  46406. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46407. */
  46408. zoomOnFactor: number;
  46409. /**
  46410. * Defines a screen offset for the camera position.
  46411. */
  46412. targetScreenOffset: Vector2;
  46413. /**
  46414. * Allows the camera to be completely reversed.
  46415. * If false the camera can not arrive upside down.
  46416. */
  46417. allowUpsideDown: boolean;
  46418. /**
  46419. * Define if double tap/click is used to restore the previously saved state of the camera.
  46420. */
  46421. useInputToRestoreState: boolean;
  46422. /** @hidden */
  46423. _viewMatrix: Matrix;
  46424. /** @hidden */
  46425. _useCtrlForPanning: boolean;
  46426. /** @hidden */
  46427. _panningMouseButton: number;
  46428. /**
  46429. * Defines the input associated to the camera.
  46430. */
  46431. inputs: ArcRotateCameraInputsManager;
  46432. /** @hidden */
  46433. _reset: () => void;
  46434. /**
  46435. * Defines the allowed panning axis.
  46436. */
  46437. panningAxis: Vector3;
  46438. protected _localDirection: Vector3;
  46439. protected _transformedDirection: Vector3;
  46440. private _bouncingBehavior;
  46441. /**
  46442. * Gets the bouncing behavior of the camera if it has been enabled.
  46443. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46444. */
  46445. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46446. /**
  46447. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46449. */
  46450. get useBouncingBehavior(): boolean;
  46451. set useBouncingBehavior(value: boolean);
  46452. private _framingBehavior;
  46453. /**
  46454. * Gets the framing behavior of the camera if it has been enabled.
  46455. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46456. */
  46457. get framingBehavior(): Nullable<FramingBehavior>;
  46458. /**
  46459. * Defines if the framing behavior of the camera is enabled on the camera.
  46460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46461. */
  46462. get useFramingBehavior(): boolean;
  46463. set useFramingBehavior(value: boolean);
  46464. private _autoRotationBehavior;
  46465. /**
  46466. * Gets the auto rotation behavior of the camera if it has been enabled.
  46467. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46468. */
  46469. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46470. /**
  46471. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46472. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46473. */
  46474. get useAutoRotationBehavior(): boolean;
  46475. set useAutoRotationBehavior(value: boolean);
  46476. /**
  46477. * Observable triggered when the mesh target has been changed on the camera.
  46478. */
  46479. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46480. /**
  46481. * Event raised when the camera is colliding with a mesh.
  46482. */
  46483. onCollide: (collidedMesh: AbstractMesh) => void;
  46484. /**
  46485. * Defines whether the camera should check collision with the objects oh the scene.
  46486. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46487. */
  46488. checkCollisions: boolean;
  46489. /**
  46490. * Defines the collision radius of the camera.
  46491. * This simulates a sphere around the camera.
  46492. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46493. */
  46494. collisionRadius: Vector3;
  46495. protected _collider: Collider;
  46496. protected _previousPosition: Vector3;
  46497. protected _collisionVelocity: Vector3;
  46498. protected _newPosition: Vector3;
  46499. protected _previousAlpha: number;
  46500. protected _previousBeta: number;
  46501. protected _previousRadius: number;
  46502. protected _collisionTriggered: boolean;
  46503. protected _targetBoundingCenter: Nullable<Vector3>;
  46504. private _computationVector;
  46505. /**
  46506. * Instantiates a new ArcRotateCamera in a given scene
  46507. * @param name Defines the name of the camera
  46508. * @param alpha Defines the camera rotation along the logitudinal axis
  46509. * @param beta Defines the camera rotation along the latitudinal axis
  46510. * @param radius Defines the camera distance from its target
  46511. * @param target Defines the camera target
  46512. * @param scene Defines the scene the camera belongs to
  46513. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46514. */
  46515. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46516. /** @hidden */
  46517. _initCache(): void;
  46518. /** @hidden */
  46519. _updateCache(ignoreParentClass?: boolean): void;
  46520. protected _getTargetPosition(): Vector3;
  46521. private _storedAlpha;
  46522. private _storedBeta;
  46523. private _storedRadius;
  46524. private _storedTarget;
  46525. private _storedTargetScreenOffset;
  46526. /**
  46527. * Stores the current state of the camera (alpha, beta, radius and target)
  46528. * @returns the camera itself
  46529. */
  46530. storeState(): Camera;
  46531. /**
  46532. * @hidden
  46533. * Restored camera state. You must call storeState() first
  46534. */
  46535. _restoreStateValues(): boolean;
  46536. /** @hidden */
  46537. _isSynchronizedViewMatrix(): boolean;
  46538. /**
  46539. * Attach the input controls to a specific dom element to get the input from.
  46540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46541. */
  46542. attachControl(noPreventDefault?: boolean): void;
  46543. /**
  46544. * Attach the input controls to a specific dom element to get the input from.
  46545. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46547. */
  46548. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46549. /**
  46550. * Attached controls to the current camera.
  46551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46552. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46553. */
  46554. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46555. /**
  46556. * Attached controls to the current camera.
  46557. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46559. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46560. */
  46561. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46562. /**
  46563. * Attached controls to the current camera.
  46564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46565. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46566. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46567. */
  46568. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46569. /**
  46570. * Detach the current controls from the specified dom element.
  46571. */
  46572. detachControl(): void;
  46573. /** @hidden */
  46574. _checkInputs(): void;
  46575. protected _checkLimits(): void;
  46576. /**
  46577. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46578. */
  46579. rebuildAnglesAndRadius(): void;
  46580. /**
  46581. * Use a position to define the current camera related information like alpha, beta and radius
  46582. * @param position Defines the position to set the camera at
  46583. */
  46584. setPosition(position: Vector3): void;
  46585. /**
  46586. * Defines the target the camera should look at.
  46587. * This will automatically adapt alpha beta and radius to fit within the new target.
  46588. * @param target Defines the new target as a Vector or a mesh
  46589. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46590. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46591. */
  46592. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46593. /** @hidden */
  46594. _getViewMatrix(): Matrix;
  46595. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46596. /**
  46597. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46598. * @param meshes Defines the mesh to zoom on
  46599. * @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)
  46600. */
  46601. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46602. /**
  46603. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46604. * The target will be changed but the radius
  46605. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46606. * @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)
  46607. */
  46608. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46609. min: Vector3;
  46610. max: Vector3;
  46611. distance: number;
  46612. }, doNotUpdateMaxZ?: boolean): void;
  46613. /**
  46614. * @override
  46615. * Override Camera.createRigCamera
  46616. */
  46617. createRigCamera(name: string, cameraIndex: number): Camera;
  46618. /**
  46619. * @hidden
  46620. * @override
  46621. * Override Camera._updateRigCameras
  46622. */
  46623. _updateRigCameras(): void;
  46624. /**
  46625. * Destroy the camera and release the current resources hold by it.
  46626. */
  46627. dispose(): void;
  46628. /**
  46629. * Gets the current object class name.
  46630. * @return the class name
  46631. */
  46632. getClassName(): string;
  46633. }
  46634. }
  46635. declare module BABYLON {
  46636. /**
  46637. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46638. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46639. */
  46640. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46641. /**
  46642. * Gets the name of the behavior.
  46643. */
  46644. get name(): string;
  46645. private _zoomStopsAnimation;
  46646. private _idleRotationSpeed;
  46647. private _idleRotationWaitTime;
  46648. private _idleRotationSpinupTime;
  46649. /**
  46650. * Sets the flag that indicates if user zooming should stop animation.
  46651. */
  46652. set zoomStopsAnimation(flag: boolean);
  46653. /**
  46654. * Gets the flag that indicates if user zooming should stop animation.
  46655. */
  46656. get zoomStopsAnimation(): boolean;
  46657. /**
  46658. * Sets the default speed at which the camera rotates around the model.
  46659. */
  46660. set idleRotationSpeed(speed: number);
  46661. /**
  46662. * Gets the default speed at which the camera rotates around the model.
  46663. */
  46664. get idleRotationSpeed(): number;
  46665. /**
  46666. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46667. */
  46668. set idleRotationWaitTime(time: number);
  46669. /**
  46670. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46671. */
  46672. get idleRotationWaitTime(): number;
  46673. /**
  46674. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46675. */
  46676. set idleRotationSpinupTime(time: number);
  46677. /**
  46678. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46679. */
  46680. get idleRotationSpinupTime(): number;
  46681. /**
  46682. * Gets a value indicating if the camera is currently rotating because of this behavior
  46683. */
  46684. get rotationInProgress(): boolean;
  46685. private _onPrePointerObservableObserver;
  46686. private _onAfterCheckInputsObserver;
  46687. private _attachedCamera;
  46688. private _isPointerDown;
  46689. private _lastFrameTime;
  46690. private _lastInteractionTime;
  46691. private _cameraRotationSpeed;
  46692. /**
  46693. * Initializes the behavior.
  46694. */
  46695. init(): void;
  46696. /**
  46697. * Attaches the behavior to its arc rotate camera.
  46698. * @param camera Defines the camera to attach the behavior to
  46699. */
  46700. attach(camera: ArcRotateCamera): void;
  46701. /**
  46702. * Detaches the behavior from its current arc rotate camera.
  46703. */
  46704. detach(): void;
  46705. /**
  46706. * Returns true if user is scrolling.
  46707. * @return true if user is scrolling.
  46708. */
  46709. private _userIsZooming;
  46710. private _lastFrameRadius;
  46711. private _shouldAnimationStopForInteraction;
  46712. /**
  46713. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46714. */
  46715. private _applyUserInteraction;
  46716. private _userIsMoving;
  46717. }
  46718. }
  46719. declare module BABYLON {
  46720. /**
  46721. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46722. */
  46723. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46724. private ui;
  46725. /**
  46726. * The name of the behavior
  46727. */
  46728. name: string;
  46729. /**
  46730. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46731. */
  46732. distanceAwayFromFace: number;
  46733. /**
  46734. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46735. */
  46736. distanceAwayFromBottomOfFace: number;
  46737. private _faceVectors;
  46738. private _target;
  46739. private _scene;
  46740. private _onRenderObserver;
  46741. private _tmpMatrix;
  46742. private _tmpVector;
  46743. /**
  46744. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46745. * @param ui The transform node that should be attched to the mesh
  46746. */
  46747. constructor(ui: TransformNode);
  46748. /**
  46749. * Initializes the behavior
  46750. */
  46751. init(): void;
  46752. private _closestFace;
  46753. private _zeroVector;
  46754. private _lookAtTmpMatrix;
  46755. private _lookAtToRef;
  46756. /**
  46757. * Attaches the AttachToBoxBehavior to the passed in mesh
  46758. * @param target The mesh that the specified node will be attached to
  46759. */
  46760. attach(target: Mesh): void;
  46761. /**
  46762. * Detaches the behavior from the mesh
  46763. */
  46764. detach(): void;
  46765. }
  46766. }
  46767. declare module BABYLON {
  46768. /**
  46769. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46770. */
  46771. export class FadeInOutBehavior implements Behavior<Mesh> {
  46772. /**
  46773. * Time in milliseconds to delay before fading in (Default: 0)
  46774. */
  46775. delay: number;
  46776. /**
  46777. * Time in milliseconds for the mesh to fade in (Default: 300)
  46778. */
  46779. fadeInTime: number;
  46780. private _millisecondsPerFrame;
  46781. private _hovered;
  46782. private _hoverValue;
  46783. private _ownerNode;
  46784. /**
  46785. * Instatiates the FadeInOutBehavior
  46786. */
  46787. constructor();
  46788. /**
  46789. * The name of the behavior
  46790. */
  46791. get name(): string;
  46792. /**
  46793. * Initializes the behavior
  46794. */
  46795. init(): void;
  46796. /**
  46797. * Attaches the fade behavior on the passed in mesh
  46798. * @param ownerNode The mesh that will be faded in/out once attached
  46799. */
  46800. attach(ownerNode: Mesh): void;
  46801. /**
  46802. * Detaches the behavior from the mesh
  46803. */
  46804. detach(): void;
  46805. /**
  46806. * Triggers the mesh to begin fading in or out
  46807. * @param value if the object should fade in or out (true to fade in)
  46808. */
  46809. fadeIn(value: boolean): void;
  46810. private _update;
  46811. private _setAllVisibility;
  46812. }
  46813. }
  46814. declare module BABYLON {
  46815. /**
  46816. * Class containing a set of static utilities functions for managing Pivots
  46817. * @hidden
  46818. */
  46819. export class PivotTools {
  46820. private static _PivotCached;
  46821. private static _OldPivotPoint;
  46822. private static _PivotTranslation;
  46823. private static _PivotTmpVector;
  46824. private static _PivotPostMultiplyPivotMatrix;
  46825. /** @hidden */
  46826. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46827. /** @hidden */
  46828. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46829. }
  46830. }
  46831. declare module BABYLON {
  46832. /**
  46833. * Class containing static functions to help procedurally build meshes
  46834. */
  46835. export class PlaneBuilder {
  46836. /**
  46837. * Creates a plane mesh
  46838. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46839. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46840. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46842. * * 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
  46843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46844. * @param name defines the name of the mesh
  46845. * @param options defines the options used to create the mesh
  46846. * @param scene defines the hosting scene
  46847. * @returns the plane mesh
  46848. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46849. */
  46850. static CreatePlane(name: string, options: {
  46851. size?: number;
  46852. width?: number;
  46853. height?: number;
  46854. sideOrientation?: number;
  46855. frontUVs?: Vector4;
  46856. backUVs?: Vector4;
  46857. updatable?: boolean;
  46858. sourcePlane?: Plane;
  46859. }, scene?: Nullable<Scene>): Mesh;
  46860. }
  46861. }
  46862. declare module BABYLON {
  46863. /**
  46864. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46865. */
  46866. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46867. private static _AnyMouseID;
  46868. /**
  46869. * Abstract mesh the behavior is set on
  46870. */
  46871. attachedNode: AbstractMesh;
  46872. private _dragPlane;
  46873. private _scene;
  46874. private _pointerObserver;
  46875. private _beforeRenderObserver;
  46876. private static _planeScene;
  46877. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46878. /**
  46879. * 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)
  46880. */
  46881. maxDragAngle: number;
  46882. /**
  46883. * @hidden
  46884. */
  46885. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46886. /**
  46887. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46888. */
  46889. currentDraggingPointerID: number;
  46890. /**
  46891. * The last position where the pointer hit the drag plane in world space
  46892. */
  46893. lastDragPosition: Vector3;
  46894. /**
  46895. * If the behavior is currently in a dragging state
  46896. */
  46897. dragging: boolean;
  46898. /**
  46899. * 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)
  46900. */
  46901. dragDeltaRatio: number;
  46902. /**
  46903. * If the drag plane orientation should be updated during the dragging (Default: true)
  46904. */
  46905. updateDragPlane: boolean;
  46906. private _debugMode;
  46907. private _moving;
  46908. /**
  46909. * Fires each time the attached mesh is dragged with the pointer
  46910. * * delta between last drag position and current drag position in world space
  46911. * * dragDistance along the drag axis
  46912. * * dragPlaneNormal normal of the current drag plane used during the drag
  46913. * * dragPlanePoint in world space where the drag intersects the drag plane
  46914. */
  46915. onDragObservable: Observable<{
  46916. delta: Vector3;
  46917. dragPlanePoint: Vector3;
  46918. dragPlaneNormal: Vector3;
  46919. dragDistance: number;
  46920. pointerId: number;
  46921. }>;
  46922. /**
  46923. * Fires each time a drag begins (eg. mouse down on mesh)
  46924. */
  46925. onDragStartObservable: Observable<{
  46926. dragPlanePoint: Vector3;
  46927. pointerId: number;
  46928. }>;
  46929. /**
  46930. * Fires each time a drag ends (eg. mouse release after drag)
  46931. */
  46932. onDragEndObservable: Observable<{
  46933. dragPlanePoint: Vector3;
  46934. pointerId: number;
  46935. }>;
  46936. /**
  46937. * If the attached mesh should be moved when dragged
  46938. */
  46939. moveAttached: boolean;
  46940. /**
  46941. * If the drag behavior will react to drag events (Default: true)
  46942. */
  46943. enabled: boolean;
  46944. /**
  46945. * If pointer events should start and release the drag (Default: true)
  46946. */
  46947. startAndReleaseDragOnPointerEvents: boolean;
  46948. /**
  46949. * If camera controls should be detached during the drag
  46950. */
  46951. detachCameraControls: boolean;
  46952. /**
  46953. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46954. */
  46955. useObjectOrientationForDragging: boolean;
  46956. private _options;
  46957. /**
  46958. * Gets the options used by the behavior
  46959. */
  46960. get options(): {
  46961. dragAxis?: Vector3;
  46962. dragPlaneNormal?: Vector3;
  46963. };
  46964. /**
  46965. * Sets the options used by the behavior
  46966. */
  46967. set options(options: {
  46968. dragAxis?: Vector3;
  46969. dragPlaneNormal?: Vector3;
  46970. });
  46971. /**
  46972. * Creates a pointer drag behavior that can be attached to a mesh
  46973. * @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)
  46974. */
  46975. constructor(options?: {
  46976. dragAxis?: Vector3;
  46977. dragPlaneNormal?: Vector3;
  46978. });
  46979. /**
  46980. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46981. */
  46982. validateDrag: (targetPosition: Vector3) => boolean;
  46983. /**
  46984. * The name of the behavior
  46985. */
  46986. get name(): string;
  46987. /**
  46988. * Initializes the behavior
  46989. */
  46990. init(): void;
  46991. private _tmpVector;
  46992. private _alternatePickedPoint;
  46993. private _worldDragAxis;
  46994. private _targetPosition;
  46995. private _attachedToElement;
  46996. /**
  46997. * Attaches the drag behavior the passed in mesh
  46998. * @param ownerNode The mesh that will be dragged around once attached
  46999. * @param predicate Predicate to use for pick filtering
  47000. */
  47001. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47002. /**
  47003. * Force relase the drag action by code.
  47004. */
  47005. releaseDrag(): void;
  47006. private _startDragRay;
  47007. private _lastPointerRay;
  47008. /**
  47009. * Simulates the start of a pointer drag event on the behavior
  47010. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47011. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47012. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47013. */
  47014. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47015. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47016. private _dragDelta;
  47017. protected _moveDrag(ray: Ray): void;
  47018. private _pickWithRayOnDragPlane;
  47019. private _pointA;
  47020. private _pointC;
  47021. private _localAxis;
  47022. private _lookAt;
  47023. private _updateDragPlanePosition;
  47024. /**
  47025. * Detaches the behavior from the mesh
  47026. */
  47027. detach(): void;
  47028. }
  47029. }
  47030. declare module BABYLON {
  47031. /**
  47032. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47033. */
  47034. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47035. private _dragBehaviorA;
  47036. private _dragBehaviorB;
  47037. private _startDistance;
  47038. private _initialScale;
  47039. private _targetScale;
  47040. private _ownerNode;
  47041. private _sceneRenderObserver;
  47042. /**
  47043. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47044. */
  47045. constructor();
  47046. /**
  47047. * The name of the behavior
  47048. */
  47049. get name(): string;
  47050. /**
  47051. * Initializes the behavior
  47052. */
  47053. init(): void;
  47054. private _getCurrentDistance;
  47055. /**
  47056. * Attaches the scale behavior the passed in mesh
  47057. * @param ownerNode The mesh that will be scaled around once attached
  47058. */
  47059. attach(ownerNode: Mesh): void;
  47060. /**
  47061. * Detaches the behavior from the mesh
  47062. */
  47063. detach(): void;
  47064. }
  47065. }
  47066. declare module BABYLON {
  47067. /**
  47068. * 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
  47069. */
  47070. export class SixDofDragBehavior implements Behavior<Mesh> {
  47071. private static _virtualScene;
  47072. private _ownerNode;
  47073. private _sceneRenderObserver;
  47074. private _scene;
  47075. private _targetPosition;
  47076. private _virtualOriginMesh;
  47077. private _virtualDragMesh;
  47078. private _pointerObserver;
  47079. private _moving;
  47080. private _startingOrientation;
  47081. private _attachedToElement;
  47082. /**
  47083. * 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)
  47084. */
  47085. private zDragFactor;
  47086. /**
  47087. * If the object should rotate to face the drag origin
  47088. */
  47089. rotateDraggedObject: boolean;
  47090. /**
  47091. * If the behavior is currently in a dragging state
  47092. */
  47093. dragging: boolean;
  47094. /**
  47095. * 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)
  47096. */
  47097. dragDeltaRatio: number;
  47098. /**
  47099. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47100. */
  47101. currentDraggingPointerID: number;
  47102. /**
  47103. * If camera controls should be detached during the drag
  47104. */
  47105. detachCameraControls: boolean;
  47106. /**
  47107. * Fires each time a drag starts
  47108. */
  47109. onDragStartObservable: Observable<{}>;
  47110. /**
  47111. * Fires each time a drag ends (eg. mouse release after drag)
  47112. */
  47113. onDragEndObservable: Observable<{}>;
  47114. /**
  47115. * 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
  47116. */
  47117. constructor();
  47118. /**
  47119. * The name of the behavior
  47120. */
  47121. get name(): string;
  47122. /**
  47123. * Initializes the behavior
  47124. */
  47125. init(): void;
  47126. /**
  47127. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47128. */
  47129. private get _pointerCamera();
  47130. /**
  47131. * Attaches the scale behavior the passed in mesh
  47132. * @param ownerNode The mesh that will be scaled around once attached
  47133. */
  47134. attach(ownerNode: Mesh): void;
  47135. /**
  47136. * Detaches the behavior from the mesh
  47137. */
  47138. detach(): void;
  47139. }
  47140. }
  47141. declare module BABYLON {
  47142. /**
  47143. * Class used to apply inverse kinematics to bones
  47144. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47145. */
  47146. export class BoneIKController {
  47147. private static _tmpVecs;
  47148. private static _tmpQuat;
  47149. private static _tmpMats;
  47150. /**
  47151. * Gets or sets the target mesh
  47152. */
  47153. targetMesh: AbstractMesh;
  47154. /** Gets or sets the mesh used as pole */
  47155. poleTargetMesh: AbstractMesh;
  47156. /**
  47157. * Gets or sets the bone used as pole
  47158. */
  47159. poleTargetBone: Nullable<Bone>;
  47160. /**
  47161. * Gets or sets the target position
  47162. */
  47163. targetPosition: Vector3;
  47164. /**
  47165. * Gets or sets the pole target position
  47166. */
  47167. poleTargetPosition: Vector3;
  47168. /**
  47169. * Gets or sets the pole target local offset
  47170. */
  47171. poleTargetLocalOffset: Vector3;
  47172. /**
  47173. * Gets or sets the pole angle
  47174. */
  47175. poleAngle: number;
  47176. /**
  47177. * Gets or sets the mesh associated with the controller
  47178. */
  47179. mesh: AbstractMesh;
  47180. /**
  47181. * 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)
  47182. */
  47183. slerpAmount: number;
  47184. private _bone1Quat;
  47185. private _bone1Mat;
  47186. private _bone2Ang;
  47187. private _bone1;
  47188. private _bone2;
  47189. private _bone1Length;
  47190. private _bone2Length;
  47191. private _maxAngle;
  47192. private _maxReach;
  47193. private _rightHandedSystem;
  47194. private _bendAxis;
  47195. private _slerping;
  47196. private _adjustRoll;
  47197. /**
  47198. * Gets or sets maximum allowed angle
  47199. */
  47200. get maxAngle(): number;
  47201. set maxAngle(value: number);
  47202. /**
  47203. * Creates a new BoneIKController
  47204. * @param mesh defines the mesh to control
  47205. * @param bone defines the bone to control
  47206. * @param options defines options to set up the controller
  47207. */
  47208. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47209. targetMesh?: AbstractMesh;
  47210. poleTargetMesh?: AbstractMesh;
  47211. poleTargetBone?: Bone;
  47212. poleTargetLocalOffset?: Vector3;
  47213. poleAngle?: number;
  47214. bendAxis?: Vector3;
  47215. maxAngle?: number;
  47216. slerpAmount?: number;
  47217. });
  47218. private _setMaxAngle;
  47219. /**
  47220. * Force the controller to update the bones
  47221. */
  47222. update(): void;
  47223. }
  47224. }
  47225. declare module BABYLON {
  47226. /**
  47227. * Class used to make a bone look toward a point in space
  47228. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47229. */
  47230. export class BoneLookController {
  47231. private static _tmpVecs;
  47232. private static _tmpQuat;
  47233. private static _tmpMats;
  47234. /**
  47235. * The target Vector3 that the bone will look at
  47236. */
  47237. target: Vector3;
  47238. /**
  47239. * The mesh that the bone is attached to
  47240. */
  47241. mesh: AbstractMesh;
  47242. /**
  47243. * The bone that will be looking to the target
  47244. */
  47245. bone: Bone;
  47246. /**
  47247. * The up axis of the coordinate system that is used when the bone is rotated
  47248. */
  47249. upAxis: Vector3;
  47250. /**
  47251. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47252. */
  47253. upAxisSpace: Space;
  47254. /**
  47255. * Used to make an adjustment to the yaw of the bone
  47256. */
  47257. adjustYaw: number;
  47258. /**
  47259. * Used to make an adjustment to the pitch of the bone
  47260. */
  47261. adjustPitch: number;
  47262. /**
  47263. * Used to make an adjustment to the roll of the bone
  47264. */
  47265. adjustRoll: number;
  47266. /**
  47267. * 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)
  47268. */
  47269. slerpAmount: number;
  47270. private _minYaw;
  47271. private _maxYaw;
  47272. private _minPitch;
  47273. private _maxPitch;
  47274. private _minYawSin;
  47275. private _minYawCos;
  47276. private _maxYawSin;
  47277. private _maxYawCos;
  47278. private _midYawConstraint;
  47279. private _minPitchTan;
  47280. private _maxPitchTan;
  47281. private _boneQuat;
  47282. private _slerping;
  47283. private _transformYawPitch;
  47284. private _transformYawPitchInv;
  47285. private _firstFrameSkipped;
  47286. private _yawRange;
  47287. private _fowardAxis;
  47288. /**
  47289. * Gets or sets the minimum yaw angle that the bone can look to
  47290. */
  47291. get minYaw(): number;
  47292. set minYaw(value: number);
  47293. /**
  47294. * Gets or sets the maximum yaw angle that the bone can look to
  47295. */
  47296. get maxYaw(): number;
  47297. set maxYaw(value: number);
  47298. /**
  47299. * Gets or sets the minimum pitch angle that the bone can look to
  47300. */
  47301. get minPitch(): number;
  47302. set minPitch(value: number);
  47303. /**
  47304. * Gets or sets the maximum pitch angle that the bone can look to
  47305. */
  47306. get maxPitch(): number;
  47307. set maxPitch(value: number);
  47308. /**
  47309. * Create a BoneLookController
  47310. * @param mesh the mesh that the bone belongs to
  47311. * @param bone the bone that will be looking to the target
  47312. * @param target the target Vector3 to look at
  47313. * @param options optional settings:
  47314. * * maxYaw: the maximum angle the bone will yaw to
  47315. * * minYaw: the minimum angle the bone will yaw to
  47316. * * maxPitch: the maximum angle the bone will pitch to
  47317. * * minPitch: the minimum angle the bone will yaw to
  47318. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47319. * * upAxis: the up axis of the coordinate system
  47320. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47321. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47322. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47323. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47324. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47325. * * adjustRoll: used to make an adjustment to the roll of the bone
  47326. **/
  47327. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47328. maxYaw?: number;
  47329. minYaw?: number;
  47330. maxPitch?: number;
  47331. minPitch?: number;
  47332. slerpAmount?: number;
  47333. upAxis?: Vector3;
  47334. upAxisSpace?: Space;
  47335. yawAxis?: Vector3;
  47336. pitchAxis?: Vector3;
  47337. adjustYaw?: number;
  47338. adjustPitch?: number;
  47339. adjustRoll?: number;
  47340. });
  47341. /**
  47342. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47343. */
  47344. update(): void;
  47345. private _getAngleDiff;
  47346. private _getAngleBetween;
  47347. private _isAngleBetween;
  47348. }
  47349. }
  47350. declare module BABYLON {
  47351. /**
  47352. * Manage the gamepad inputs to control an arc rotate camera.
  47353. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47354. */
  47355. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47356. /**
  47357. * Defines the camera the input is attached to.
  47358. */
  47359. camera: ArcRotateCamera;
  47360. /**
  47361. * Defines the gamepad the input is gathering event from.
  47362. */
  47363. gamepad: Nullable<Gamepad>;
  47364. /**
  47365. * Defines the gamepad rotation sensiblity.
  47366. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47367. */
  47368. gamepadRotationSensibility: number;
  47369. /**
  47370. * Defines the gamepad move sensiblity.
  47371. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47372. */
  47373. gamepadMoveSensibility: number;
  47374. private _yAxisScale;
  47375. /**
  47376. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47377. */
  47378. get invertYAxis(): boolean;
  47379. set invertYAxis(value: boolean);
  47380. private _onGamepadConnectedObserver;
  47381. private _onGamepadDisconnectedObserver;
  47382. /**
  47383. * Attach the input controls to a specific dom element to get the input from.
  47384. */
  47385. attachControl(): void;
  47386. /**
  47387. * Detach the current controls from the specified dom element.
  47388. */
  47389. detachControl(): void;
  47390. /**
  47391. * Update the current camera state depending on the inputs that have been used this frame.
  47392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47393. */
  47394. checkInputs(): void;
  47395. /**
  47396. * Gets the class name of the current intput.
  47397. * @returns the class name
  47398. */
  47399. getClassName(): string;
  47400. /**
  47401. * Get the friendly name associated with the input class.
  47402. * @returns the input friendly name
  47403. */
  47404. getSimpleName(): string;
  47405. }
  47406. }
  47407. declare module BABYLON {
  47408. interface ArcRotateCameraInputsManager {
  47409. /**
  47410. * Add orientation input support to the input manager.
  47411. * @returns the current input manager
  47412. */
  47413. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47414. }
  47415. /**
  47416. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47417. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47418. */
  47419. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47420. /**
  47421. * Defines the camera the input is attached to.
  47422. */
  47423. camera: ArcRotateCamera;
  47424. /**
  47425. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47426. */
  47427. alphaCorrection: number;
  47428. /**
  47429. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47430. */
  47431. gammaCorrection: number;
  47432. private _alpha;
  47433. private _gamma;
  47434. private _dirty;
  47435. private _deviceOrientationHandler;
  47436. /**
  47437. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47438. */
  47439. constructor();
  47440. /**
  47441. * Attach the input controls to a specific dom element to get the input from.
  47442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47443. */
  47444. attachControl(noPreventDefault?: boolean): void;
  47445. /** @hidden */
  47446. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47447. /**
  47448. * Update the current camera state depending on the inputs that have been used this frame.
  47449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47450. */
  47451. checkInputs(): void;
  47452. /**
  47453. * Detach the current controls from the specified dom element.
  47454. */
  47455. detachControl(): void;
  47456. /**
  47457. * Gets the class name of the current intput.
  47458. * @returns the class name
  47459. */
  47460. getClassName(): string;
  47461. /**
  47462. * Get the friendly name associated with the input class.
  47463. * @returns the input friendly name
  47464. */
  47465. getSimpleName(): string;
  47466. }
  47467. }
  47468. declare module BABYLON {
  47469. /**
  47470. * Listen to mouse events to control the camera.
  47471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47472. */
  47473. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47474. /**
  47475. * Defines the camera the input is attached to.
  47476. */
  47477. camera: FlyCamera;
  47478. /**
  47479. * Defines if touch is enabled. (Default is true.)
  47480. */
  47481. touchEnabled: boolean;
  47482. /**
  47483. * Defines the buttons associated with the input to handle camera rotation.
  47484. */
  47485. buttons: number[];
  47486. /**
  47487. * Assign buttons for Yaw control.
  47488. */
  47489. buttonsYaw: number[];
  47490. /**
  47491. * Assign buttons for Pitch control.
  47492. */
  47493. buttonsPitch: number[];
  47494. /**
  47495. * Assign buttons for Roll control.
  47496. */
  47497. buttonsRoll: number[];
  47498. /**
  47499. * Detect if any button is being pressed while mouse is moved.
  47500. * -1 = Mouse locked.
  47501. * 0 = Left button.
  47502. * 1 = Middle Button.
  47503. * 2 = Right Button.
  47504. */
  47505. activeButton: number;
  47506. /**
  47507. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47508. * Higher values reduce its sensitivity.
  47509. */
  47510. angularSensibility: number;
  47511. private _observer;
  47512. private _rollObserver;
  47513. private previousPosition;
  47514. private noPreventDefault;
  47515. private element;
  47516. /**
  47517. * Listen to mouse events to control the camera.
  47518. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47519. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47520. */
  47521. constructor(touchEnabled?: boolean);
  47522. /**
  47523. * Attach the mouse control to the HTML DOM element.
  47524. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47525. */
  47526. attachControl(noPreventDefault?: boolean): void;
  47527. /**
  47528. * Detach the current controls from the specified dom element.
  47529. */
  47530. detachControl(): void;
  47531. /**
  47532. * Gets the class name of the current input.
  47533. * @returns the class name.
  47534. */
  47535. getClassName(): string;
  47536. /**
  47537. * Get the friendly name associated with the input class.
  47538. * @returns the input's friendly name.
  47539. */
  47540. getSimpleName(): string;
  47541. private _pointerInput;
  47542. private _onMouseMove;
  47543. /**
  47544. * Rotate camera by mouse offset.
  47545. */
  47546. private rotateCamera;
  47547. }
  47548. }
  47549. declare module BABYLON {
  47550. /**
  47551. * Default Inputs manager for the FlyCamera.
  47552. * It groups all the default supported inputs for ease of use.
  47553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47554. */
  47555. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47556. /**
  47557. * Instantiates a new FlyCameraInputsManager.
  47558. * @param camera Defines the camera the inputs belong to.
  47559. */
  47560. constructor(camera: FlyCamera);
  47561. /**
  47562. * Add keyboard input support to the input manager.
  47563. * @returns the new FlyCameraKeyboardMoveInput().
  47564. */
  47565. addKeyboard(): FlyCameraInputsManager;
  47566. /**
  47567. * Add mouse input support to the input manager.
  47568. * @param touchEnabled Enable touch screen support.
  47569. * @returns the new FlyCameraMouseInput().
  47570. */
  47571. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47572. }
  47573. }
  47574. declare module BABYLON {
  47575. /**
  47576. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47577. * such as in a 3D Space Shooter or a Flight Simulator.
  47578. */
  47579. export class FlyCamera extends TargetCamera {
  47580. /**
  47581. * Define the collision ellipsoid of the camera.
  47582. * This is helpful for simulating a camera body, like a player's body.
  47583. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47584. */
  47585. ellipsoid: Vector3;
  47586. /**
  47587. * Define an offset for the position of the ellipsoid around the camera.
  47588. * This can be helpful if the camera is attached away from the player's body center,
  47589. * such as at its head.
  47590. */
  47591. ellipsoidOffset: Vector3;
  47592. /**
  47593. * Enable or disable collisions of the camera with the rest of the scene objects.
  47594. */
  47595. checkCollisions: boolean;
  47596. /**
  47597. * Enable or disable gravity on the camera.
  47598. */
  47599. applyGravity: boolean;
  47600. /**
  47601. * Define the current direction the camera is moving to.
  47602. */
  47603. cameraDirection: Vector3;
  47604. /**
  47605. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47606. * This overrides and empties cameraRotation.
  47607. */
  47608. rotationQuaternion: Quaternion;
  47609. /**
  47610. * Track Roll to maintain the wanted Rolling when looking around.
  47611. */
  47612. _trackRoll: number;
  47613. /**
  47614. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47615. */
  47616. rollCorrect: number;
  47617. /**
  47618. * Mimic a banked turn, Rolling the camera when Yawing.
  47619. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47620. */
  47621. bankedTurn: boolean;
  47622. /**
  47623. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47624. */
  47625. bankedTurnLimit: number;
  47626. /**
  47627. * Value of 0 disables the banked Roll.
  47628. * Value of 1 is equal to the Yaw angle in radians.
  47629. */
  47630. bankedTurnMultiplier: number;
  47631. /**
  47632. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47633. */
  47634. inputs: FlyCameraInputsManager;
  47635. /**
  47636. * Gets the input sensibility for mouse input.
  47637. * Higher values reduce sensitivity.
  47638. */
  47639. get angularSensibility(): number;
  47640. /**
  47641. * Sets the input sensibility for a mouse input.
  47642. * Higher values reduce sensitivity.
  47643. */
  47644. set angularSensibility(value: number);
  47645. /**
  47646. * Get the keys for camera movement forward.
  47647. */
  47648. get keysForward(): number[];
  47649. /**
  47650. * Set the keys for camera movement forward.
  47651. */
  47652. set keysForward(value: number[]);
  47653. /**
  47654. * Get the keys for camera movement backward.
  47655. */
  47656. get keysBackward(): number[];
  47657. set keysBackward(value: number[]);
  47658. /**
  47659. * Get the keys for camera movement up.
  47660. */
  47661. get keysUp(): number[];
  47662. /**
  47663. * Set the keys for camera movement up.
  47664. */
  47665. set keysUp(value: number[]);
  47666. /**
  47667. * Get the keys for camera movement down.
  47668. */
  47669. get keysDown(): number[];
  47670. /**
  47671. * Set the keys for camera movement down.
  47672. */
  47673. set keysDown(value: number[]);
  47674. /**
  47675. * Get the keys for camera movement left.
  47676. */
  47677. get keysLeft(): number[];
  47678. /**
  47679. * Set the keys for camera movement left.
  47680. */
  47681. set keysLeft(value: number[]);
  47682. /**
  47683. * Set the keys for camera movement right.
  47684. */
  47685. get keysRight(): number[];
  47686. /**
  47687. * Set the keys for camera movement right.
  47688. */
  47689. set keysRight(value: number[]);
  47690. /**
  47691. * Event raised when the camera collides with a mesh in the scene.
  47692. */
  47693. onCollide: (collidedMesh: AbstractMesh) => void;
  47694. private _collider;
  47695. private _needMoveForGravity;
  47696. private _oldPosition;
  47697. private _diffPosition;
  47698. private _newPosition;
  47699. /** @hidden */
  47700. _localDirection: Vector3;
  47701. /** @hidden */
  47702. _transformedDirection: Vector3;
  47703. /**
  47704. * Instantiates a FlyCamera.
  47705. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47706. * such as in a 3D Space Shooter or a Flight Simulator.
  47707. * @param name Define the name of the camera in the scene.
  47708. * @param position Define the starting position of the camera in the scene.
  47709. * @param scene Define the scene the camera belongs to.
  47710. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47711. */
  47712. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47713. /**
  47714. * Attach the input controls to a specific dom element to get the input from.
  47715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47716. */
  47717. attachControl(noPreventDefault?: boolean): void;
  47718. /**
  47719. * Detach a control from the HTML DOM element.
  47720. * The camera will stop reacting to that input.
  47721. */
  47722. detachControl(): void;
  47723. private _collisionMask;
  47724. /**
  47725. * Get the mask that the camera ignores in collision events.
  47726. */
  47727. get collisionMask(): number;
  47728. /**
  47729. * Set the mask that the camera ignores in collision events.
  47730. */
  47731. set collisionMask(mask: number);
  47732. /** @hidden */
  47733. _collideWithWorld(displacement: Vector3): void;
  47734. /** @hidden */
  47735. private _onCollisionPositionChange;
  47736. /** @hidden */
  47737. _checkInputs(): void;
  47738. /** @hidden */
  47739. _decideIfNeedsToMove(): boolean;
  47740. /** @hidden */
  47741. _updatePosition(): void;
  47742. /**
  47743. * Restore the Roll to its target value at the rate specified.
  47744. * @param rate - Higher means slower restoring.
  47745. * @hidden
  47746. */
  47747. restoreRoll(rate: number): void;
  47748. /**
  47749. * Destroy the camera and release the current resources held by it.
  47750. */
  47751. dispose(): void;
  47752. /**
  47753. * Get the current object class name.
  47754. * @returns the class name.
  47755. */
  47756. getClassName(): string;
  47757. }
  47758. }
  47759. declare module BABYLON {
  47760. /**
  47761. * Listen to keyboard events to control the camera.
  47762. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47763. */
  47764. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47765. /**
  47766. * Defines the camera the input is attached to.
  47767. */
  47768. camera: FlyCamera;
  47769. /**
  47770. * The list of keyboard keys used to control the forward move of the camera.
  47771. */
  47772. keysForward: number[];
  47773. /**
  47774. * The list of keyboard keys used to control the backward move of the camera.
  47775. */
  47776. keysBackward: number[];
  47777. /**
  47778. * The list of keyboard keys used to control the forward move of the camera.
  47779. */
  47780. keysUp: number[];
  47781. /**
  47782. * The list of keyboard keys used to control the backward move of the camera.
  47783. */
  47784. keysDown: number[];
  47785. /**
  47786. * The list of keyboard keys used to control the right strafe move of the camera.
  47787. */
  47788. keysRight: number[];
  47789. /**
  47790. * The list of keyboard keys used to control the left strafe move of the camera.
  47791. */
  47792. keysLeft: number[];
  47793. private _keys;
  47794. private _onCanvasBlurObserver;
  47795. private _onKeyboardObserver;
  47796. private _engine;
  47797. private _scene;
  47798. /**
  47799. * Attach the input controls to a specific dom element to get the input from.
  47800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47801. */
  47802. attachControl(noPreventDefault?: boolean): void;
  47803. /**
  47804. * Detach the current controls from the specified dom element.
  47805. */
  47806. detachControl(): void;
  47807. /**
  47808. * Gets the class name of the current intput.
  47809. * @returns the class name
  47810. */
  47811. getClassName(): string;
  47812. /** @hidden */
  47813. _onLostFocus(e: FocusEvent): void;
  47814. /**
  47815. * Get the friendly name associated with the input class.
  47816. * @returns the input friendly name
  47817. */
  47818. getSimpleName(): string;
  47819. /**
  47820. * Update the current camera state depending on the inputs that have been used this frame.
  47821. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47822. */
  47823. checkInputs(): void;
  47824. }
  47825. }
  47826. declare module BABYLON {
  47827. /**
  47828. * Manage the mouse wheel inputs to control a follow camera.
  47829. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47830. */
  47831. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47832. /**
  47833. * Defines the camera the input is attached to.
  47834. */
  47835. camera: FollowCamera;
  47836. /**
  47837. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47838. */
  47839. axisControlRadius: boolean;
  47840. /**
  47841. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47842. */
  47843. axisControlHeight: boolean;
  47844. /**
  47845. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47846. */
  47847. axisControlRotation: boolean;
  47848. /**
  47849. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47850. * relation to mouseWheel events.
  47851. */
  47852. wheelPrecision: number;
  47853. /**
  47854. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47855. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47856. */
  47857. wheelDeltaPercentage: number;
  47858. private _wheel;
  47859. private _observer;
  47860. /**
  47861. * Attach the input controls to a specific dom element to get the input from.
  47862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47863. */
  47864. attachControl(noPreventDefault?: boolean): void;
  47865. /**
  47866. * Detach the current controls from the specified dom element.
  47867. */
  47868. detachControl(): void;
  47869. /**
  47870. * Gets the class name of the current intput.
  47871. * @returns the class name
  47872. */
  47873. getClassName(): string;
  47874. /**
  47875. * Get the friendly name associated with the input class.
  47876. * @returns the input friendly name
  47877. */
  47878. getSimpleName(): string;
  47879. }
  47880. }
  47881. declare module BABYLON {
  47882. /**
  47883. * Manage the pointers inputs to control an follow camera.
  47884. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47885. */
  47886. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47887. /**
  47888. * Defines the camera the input is attached to.
  47889. */
  47890. camera: FollowCamera;
  47891. /**
  47892. * Gets the class name of the current input.
  47893. * @returns the class name
  47894. */
  47895. getClassName(): string;
  47896. /**
  47897. * Defines the pointer angular sensibility along the X axis or how fast is
  47898. * the camera rotating.
  47899. * A negative number will reverse the axis direction.
  47900. */
  47901. angularSensibilityX: number;
  47902. /**
  47903. * Defines the pointer angular sensibility along the Y axis or how fast is
  47904. * the camera rotating.
  47905. * A negative number will reverse the axis direction.
  47906. */
  47907. angularSensibilityY: number;
  47908. /**
  47909. * Defines the pointer pinch precision or how fast is the camera zooming.
  47910. * A negative number will reverse the axis direction.
  47911. */
  47912. pinchPrecision: number;
  47913. /**
  47914. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47915. * from 0.
  47916. * It defines the percentage of current camera.radius to use as delta when
  47917. * pinch zoom is used.
  47918. */
  47919. pinchDeltaPercentage: number;
  47920. /**
  47921. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47922. */
  47923. axisXControlRadius: boolean;
  47924. /**
  47925. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47926. */
  47927. axisXControlHeight: boolean;
  47928. /**
  47929. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47930. */
  47931. axisXControlRotation: boolean;
  47932. /**
  47933. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47934. */
  47935. axisYControlRadius: boolean;
  47936. /**
  47937. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47938. */
  47939. axisYControlHeight: boolean;
  47940. /**
  47941. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47942. */
  47943. axisYControlRotation: boolean;
  47944. /**
  47945. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47946. */
  47947. axisPinchControlRadius: boolean;
  47948. /**
  47949. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47950. */
  47951. axisPinchControlHeight: boolean;
  47952. /**
  47953. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47954. */
  47955. axisPinchControlRotation: boolean;
  47956. /**
  47957. * Log error messages if basic misconfiguration has occurred.
  47958. */
  47959. warningEnable: boolean;
  47960. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47961. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47962. private _warningCounter;
  47963. private _warning;
  47964. }
  47965. }
  47966. declare module BABYLON {
  47967. /**
  47968. * Default Inputs manager for the FollowCamera.
  47969. * It groups all the default supported inputs for ease of use.
  47970. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47971. */
  47972. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47973. /**
  47974. * Instantiates a new FollowCameraInputsManager.
  47975. * @param camera Defines the camera the inputs belong to
  47976. */
  47977. constructor(camera: FollowCamera);
  47978. /**
  47979. * Add keyboard input support to the input manager.
  47980. * @returns the current input manager
  47981. */
  47982. addKeyboard(): FollowCameraInputsManager;
  47983. /**
  47984. * Add mouse wheel input support to the input manager.
  47985. * @returns the current input manager
  47986. */
  47987. addMouseWheel(): FollowCameraInputsManager;
  47988. /**
  47989. * Add pointers input support to the input manager.
  47990. * @returns the current input manager
  47991. */
  47992. addPointers(): FollowCameraInputsManager;
  47993. /**
  47994. * Add orientation input support to the input manager.
  47995. * @returns the current input manager
  47996. */
  47997. addVRDeviceOrientation(): FollowCameraInputsManager;
  47998. }
  47999. }
  48000. declare module BABYLON {
  48001. /**
  48002. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48003. * an arc rotate version arcFollowCamera are available.
  48004. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48005. */
  48006. export class FollowCamera extends TargetCamera {
  48007. /**
  48008. * Distance the follow camera should follow an object at
  48009. */
  48010. radius: number;
  48011. /**
  48012. * Minimum allowed distance of the camera to the axis of rotation
  48013. * (The camera can not get closer).
  48014. * This can help limiting how the Camera is able to move in the scene.
  48015. */
  48016. lowerRadiusLimit: Nullable<number>;
  48017. /**
  48018. * Maximum allowed distance of the camera to the axis of rotation
  48019. * (The camera can not get further).
  48020. * This can help limiting how the Camera is able to move in the scene.
  48021. */
  48022. upperRadiusLimit: Nullable<number>;
  48023. /**
  48024. * Define a rotation offset between the camera and the object it follows
  48025. */
  48026. rotationOffset: number;
  48027. /**
  48028. * Minimum allowed angle to camera position relative to target object.
  48029. * This can help limiting how the Camera is able to move in the scene.
  48030. */
  48031. lowerRotationOffsetLimit: Nullable<number>;
  48032. /**
  48033. * Maximum allowed angle to camera position relative to target object.
  48034. * This can help limiting how the Camera is able to move in the scene.
  48035. */
  48036. upperRotationOffsetLimit: Nullable<number>;
  48037. /**
  48038. * Define a height offset between the camera and the object it follows.
  48039. * It can help following an object from the top (like a car chaing a plane)
  48040. */
  48041. heightOffset: number;
  48042. /**
  48043. * Minimum allowed height of camera position relative to target object.
  48044. * This can help limiting how the Camera is able to move in the scene.
  48045. */
  48046. lowerHeightOffsetLimit: Nullable<number>;
  48047. /**
  48048. * Maximum allowed height of camera position relative to target object.
  48049. * This can help limiting how the Camera is able to move in the scene.
  48050. */
  48051. upperHeightOffsetLimit: Nullable<number>;
  48052. /**
  48053. * Define how fast the camera can accelerate to follow it s target.
  48054. */
  48055. cameraAcceleration: number;
  48056. /**
  48057. * Define the speed limit of the camera following an object.
  48058. */
  48059. maxCameraSpeed: number;
  48060. /**
  48061. * Define the target of the camera.
  48062. */
  48063. lockedTarget: Nullable<AbstractMesh>;
  48064. /**
  48065. * Defines the input associated with the camera.
  48066. */
  48067. inputs: FollowCameraInputsManager;
  48068. /**
  48069. * Instantiates the follow camera.
  48070. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48071. * @param name Define the name of the camera in the scene
  48072. * @param position Define the position of the camera
  48073. * @param scene Define the scene the camera belong to
  48074. * @param lockedTarget Define the target of the camera
  48075. */
  48076. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48077. private _follow;
  48078. /**
  48079. * Attach the input controls to a specific dom element to get the input from.
  48080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48081. */
  48082. attachControl(noPreventDefault?: boolean): void;
  48083. /**
  48084. * Detach the current controls from the specified dom element.
  48085. */
  48086. detachControl(): void;
  48087. /** @hidden */
  48088. _checkInputs(): void;
  48089. private _checkLimits;
  48090. /**
  48091. * Gets the camera class name.
  48092. * @returns the class name
  48093. */
  48094. getClassName(): string;
  48095. }
  48096. /**
  48097. * Arc Rotate version of the follow camera.
  48098. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48099. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48100. */
  48101. export class ArcFollowCamera extends TargetCamera {
  48102. /** The longitudinal angle of the camera */
  48103. alpha: number;
  48104. /** The latitudinal angle of the camera */
  48105. beta: number;
  48106. /** The radius of the camera from its target */
  48107. radius: number;
  48108. private _cartesianCoordinates;
  48109. /** Define the camera target (the mesh it should follow) */
  48110. private _meshTarget;
  48111. /**
  48112. * Instantiates a new ArcFollowCamera
  48113. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48114. * @param name Define the name of the camera
  48115. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48116. * @param beta Define the rotation angle of the camera around the elevation axis
  48117. * @param radius Define the radius of the camera from its target point
  48118. * @param target Define the target of the camera
  48119. * @param scene Define the scene the camera belongs to
  48120. */
  48121. constructor(name: string,
  48122. /** The longitudinal angle of the camera */
  48123. alpha: number,
  48124. /** The latitudinal angle of the camera */
  48125. beta: number,
  48126. /** The radius of the camera from its target */
  48127. radius: number,
  48128. /** Define the camera target (the mesh it should follow) */
  48129. target: Nullable<AbstractMesh>, scene: Scene);
  48130. private _follow;
  48131. /** @hidden */
  48132. _checkInputs(): void;
  48133. /**
  48134. * Returns the class name of the object.
  48135. * It is mostly used internally for serialization purposes.
  48136. */
  48137. getClassName(): string;
  48138. }
  48139. }
  48140. declare module BABYLON {
  48141. /**
  48142. * Manage the keyboard inputs to control the movement of a follow camera.
  48143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48144. */
  48145. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48146. /**
  48147. * Defines the camera the input is attached to.
  48148. */
  48149. camera: FollowCamera;
  48150. /**
  48151. * Defines the list of key codes associated with the up action (increase heightOffset)
  48152. */
  48153. keysHeightOffsetIncr: number[];
  48154. /**
  48155. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48156. */
  48157. keysHeightOffsetDecr: number[];
  48158. /**
  48159. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48160. */
  48161. keysHeightOffsetModifierAlt: boolean;
  48162. /**
  48163. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48164. */
  48165. keysHeightOffsetModifierCtrl: boolean;
  48166. /**
  48167. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48168. */
  48169. keysHeightOffsetModifierShift: boolean;
  48170. /**
  48171. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48172. */
  48173. keysRotationOffsetIncr: number[];
  48174. /**
  48175. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48176. */
  48177. keysRotationOffsetDecr: number[];
  48178. /**
  48179. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48180. */
  48181. keysRotationOffsetModifierAlt: boolean;
  48182. /**
  48183. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48184. */
  48185. keysRotationOffsetModifierCtrl: boolean;
  48186. /**
  48187. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48188. */
  48189. keysRotationOffsetModifierShift: boolean;
  48190. /**
  48191. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48192. */
  48193. keysRadiusIncr: number[];
  48194. /**
  48195. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48196. */
  48197. keysRadiusDecr: number[];
  48198. /**
  48199. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48200. */
  48201. keysRadiusModifierAlt: boolean;
  48202. /**
  48203. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48204. */
  48205. keysRadiusModifierCtrl: boolean;
  48206. /**
  48207. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48208. */
  48209. keysRadiusModifierShift: boolean;
  48210. /**
  48211. * Defines the rate of change of heightOffset.
  48212. */
  48213. heightSensibility: number;
  48214. /**
  48215. * Defines the rate of change of rotationOffset.
  48216. */
  48217. rotationSensibility: number;
  48218. /**
  48219. * Defines the rate of change of radius.
  48220. */
  48221. radiusSensibility: number;
  48222. private _keys;
  48223. private _ctrlPressed;
  48224. private _altPressed;
  48225. private _shiftPressed;
  48226. private _onCanvasBlurObserver;
  48227. private _onKeyboardObserver;
  48228. private _engine;
  48229. private _scene;
  48230. /**
  48231. * Attach the input controls to a specific dom element to get the input from.
  48232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48233. */
  48234. attachControl(noPreventDefault?: boolean): void;
  48235. /**
  48236. * Detach the current controls from the specified dom element.
  48237. */
  48238. detachControl(): void;
  48239. /**
  48240. * Update the current camera state depending on the inputs that have been used this frame.
  48241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48242. */
  48243. checkInputs(): void;
  48244. /**
  48245. * Gets the class name of the current input.
  48246. * @returns the class name
  48247. */
  48248. getClassName(): string;
  48249. /**
  48250. * Get the friendly name associated with the input class.
  48251. * @returns the input friendly name
  48252. */
  48253. getSimpleName(): string;
  48254. /**
  48255. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48256. * allow modification of the heightOffset value.
  48257. */
  48258. private _modifierHeightOffset;
  48259. /**
  48260. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48261. * allow modification of the rotationOffset value.
  48262. */
  48263. private _modifierRotationOffset;
  48264. /**
  48265. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48266. * allow modification of the radius value.
  48267. */
  48268. private _modifierRadius;
  48269. }
  48270. }
  48271. declare module BABYLON {
  48272. interface FreeCameraInputsManager {
  48273. /**
  48274. * @hidden
  48275. */
  48276. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48277. /**
  48278. * Add orientation input support to the input manager.
  48279. * @returns the current input manager
  48280. */
  48281. addDeviceOrientation(): FreeCameraInputsManager;
  48282. }
  48283. /**
  48284. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48285. * Screen rotation is taken into account.
  48286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48287. */
  48288. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48289. private _camera;
  48290. private _screenOrientationAngle;
  48291. private _constantTranform;
  48292. private _screenQuaternion;
  48293. private _alpha;
  48294. private _beta;
  48295. private _gamma;
  48296. /**
  48297. * Can be used to detect if a device orientation sensor is available on a device
  48298. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48299. * @returns a promise that will resolve on orientation change
  48300. */
  48301. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48302. /**
  48303. * @hidden
  48304. */
  48305. _onDeviceOrientationChangedObservable: Observable<void>;
  48306. /**
  48307. * Instantiates a new input
  48308. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48309. */
  48310. constructor();
  48311. /**
  48312. * Define the camera controlled by the input.
  48313. */
  48314. get camera(): FreeCamera;
  48315. set camera(camera: FreeCamera);
  48316. /**
  48317. * Attach the input controls to a specific dom element to get the input from.
  48318. */
  48319. attachControl(): void;
  48320. private _orientationChanged;
  48321. private _deviceOrientation;
  48322. /**
  48323. * Detach the current controls from the specified dom element.
  48324. */
  48325. detachControl(): void;
  48326. /**
  48327. * Update the current camera state depending on the inputs that have been used this frame.
  48328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48329. */
  48330. checkInputs(): void;
  48331. /**
  48332. * Gets the class name of the current intput.
  48333. * @returns the class name
  48334. */
  48335. getClassName(): string;
  48336. /**
  48337. * Get the friendly name associated with the input class.
  48338. * @returns the input friendly name
  48339. */
  48340. getSimpleName(): string;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * Manage the gamepad inputs to control a free camera.
  48346. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48347. */
  48348. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48349. /**
  48350. * Define the camera the input is attached to.
  48351. */
  48352. camera: FreeCamera;
  48353. /**
  48354. * Define the Gamepad controlling the input
  48355. */
  48356. gamepad: Nullable<Gamepad>;
  48357. /**
  48358. * Defines the gamepad rotation sensiblity.
  48359. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48360. */
  48361. gamepadAngularSensibility: number;
  48362. /**
  48363. * Defines the gamepad move sensiblity.
  48364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48365. */
  48366. gamepadMoveSensibility: number;
  48367. private _yAxisScale;
  48368. /**
  48369. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48370. */
  48371. get invertYAxis(): boolean;
  48372. set invertYAxis(value: boolean);
  48373. private _onGamepadConnectedObserver;
  48374. private _onGamepadDisconnectedObserver;
  48375. private _cameraTransform;
  48376. private _deltaTransform;
  48377. private _vector3;
  48378. private _vector2;
  48379. /**
  48380. * Attach the input controls to a specific dom element to get the input from.
  48381. */
  48382. attachControl(): void;
  48383. /**
  48384. * Detach the current controls from the specified dom element.
  48385. */
  48386. detachControl(): void;
  48387. /**
  48388. * Update the current camera state depending on the inputs that have been used this frame.
  48389. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48390. */
  48391. checkInputs(): void;
  48392. /**
  48393. * Gets the class name of the current intput.
  48394. * @returns the class name
  48395. */
  48396. getClassName(): string;
  48397. /**
  48398. * Get the friendly name associated with the input class.
  48399. * @returns the input friendly name
  48400. */
  48401. getSimpleName(): string;
  48402. }
  48403. }
  48404. declare module BABYLON {
  48405. /**
  48406. * Defines the potential axis of a Joystick
  48407. */
  48408. export enum JoystickAxis {
  48409. /** X axis */
  48410. X = 0,
  48411. /** Y axis */
  48412. Y = 1,
  48413. /** Z axis */
  48414. Z = 2
  48415. }
  48416. /**
  48417. * Represents the different customization options available
  48418. * for VirtualJoystick
  48419. */
  48420. interface VirtualJoystickCustomizations {
  48421. /**
  48422. * Size of the joystick's puck
  48423. */
  48424. puckSize: number;
  48425. /**
  48426. * Size of the joystick's container
  48427. */
  48428. containerSize: number;
  48429. /**
  48430. * Color of the joystick && puck
  48431. */
  48432. color: string;
  48433. /**
  48434. * Image URL for the joystick's puck
  48435. */
  48436. puckImage?: string;
  48437. /**
  48438. * Image URL for the joystick's container
  48439. */
  48440. containerImage?: string;
  48441. /**
  48442. * Defines the unmoving position of the joystick container
  48443. */
  48444. position?: {
  48445. x: number;
  48446. y: number;
  48447. };
  48448. /**
  48449. * Defines whether or not the joystick container is always visible
  48450. */
  48451. alwaysVisible: boolean;
  48452. /**
  48453. * Defines whether or not to limit the movement of the puck to the joystick's container
  48454. */
  48455. limitToContainer: boolean;
  48456. }
  48457. /**
  48458. * Class used to define virtual joystick (used in touch mode)
  48459. */
  48460. export class VirtualJoystick {
  48461. /**
  48462. * Gets or sets a boolean indicating that left and right values must be inverted
  48463. */
  48464. reverseLeftRight: boolean;
  48465. /**
  48466. * Gets or sets a boolean indicating that up and down values must be inverted
  48467. */
  48468. reverseUpDown: boolean;
  48469. /**
  48470. * Gets the offset value for the position (ie. the change of the position value)
  48471. */
  48472. deltaPosition: Vector3;
  48473. /**
  48474. * Gets a boolean indicating if the virtual joystick was pressed
  48475. */
  48476. pressed: boolean;
  48477. /**
  48478. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48479. */
  48480. static Canvas: Nullable<HTMLCanvasElement>;
  48481. /**
  48482. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48483. */
  48484. limitToContainer: boolean;
  48485. private static _globalJoystickIndex;
  48486. private static _alwaysVisibleSticks;
  48487. private static vjCanvasContext;
  48488. private static vjCanvasWidth;
  48489. private static vjCanvasHeight;
  48490. private static halfWidth;
  48491. private static _GetDefaultOptions;
  48492. private _action;
  48493. private _axisTargetedByLeftAndRight;
  48494. private _axisTargetedByUpAndDown;
  48495. private _joystickSensibility;
  48496. private _inversedSensibility;
  48497. private _joystickPointerID;
  48498. private _joystickColor;
  48499. private _joystickPointerPos;
  48500. private _joystickPreviousPointerPos;
  48501. private _joystickPointerStartPos;
  48502. private _deltaJoystickVector;
  48503. private _leftJoystick;
  48504. private _touches;
  48505. private _joystickPosition;
  48506. private _alwaysVisible;
  48507. private _puckImage;
  48508. private _containerImage;
  48509. private _joystickPuckSize;
  48510. private _joystickContainerSize;
  48511. private _clearPuckSize;
  48512. private _clearContainerSize;
  48513. private _clearPuckSizeOffset;
  48514. private _clearContainerSizeOffset;
  48515. private _onPointerDownHandlerRef;
  48516. private _onPointerMoveHandlerRef;
  48517. private _onPointerUpHandlerRef;
  48518. private _onResize;
  48519. /**
  48520. * Creates a new virtual joystick
  48521. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48522. * @param customizations Defines the options we want to customize the VirtualJoystick
  48523. */
  48524. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48525. /**
  48526. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48527. * @param newJoystickSensibility defines the new sensibility
  48528. */
  48529. setJoystickSensibility(newJoystickSensibility: number): void;
  48530. private _onPointerDown;
  48531. private _onPointerMove;
  48532. private _onPointerUp;
  48533. /**
  48534. * Change the color of the virtual joystick
  48535. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48536. */
  48537. setJoystickColor(newColor: string): void;
  48538. /**
  48539. * Size of the joystick's container
  48540. */
  48541. set containerSize(newSize: number);
  48542. get containerSize(): number;
  48543. /**
  48544. * Size of the joystick's puck
  48545. */
  48546. set puckSize(newSize: number);
  48547. get puckSize(): number;
  48548. /**
  48549. * Clears the set position of the joystick
  48550. */
  48551. clearPosition(): void;
  48552. /**
  48553. * Defines whether or not the joystick container is always visible
  48554. */
  48555. set alwaysVisible(value: boolean);
  48556. get alwaysVisible(): boolean;
  48557. /**
  48558. * Sets the constant position of the Joystick container
  48559. * @param x X axis coordinate
  48560. * @param y Y axis coordinate
  48561. */
  48562. setPosition(x: number, y: number): void;
  48563. /**
  48564. * Defines a callback to call when the joystick is touched
  48565. * @param action defines the callback
  48566. */
  48567. setActionOnTouch(action: () => any): void;
  48568. /**
  48569. * Defines which axis you'd like to control for left & right
  48570. * @param axis defines the axis to use
  48571. */
  48572. setAxisForLeftRight(axis: JoystickAxis): void;
  48573. /**
  48574. * Defines which axis you'd like to control for up & down
  48575. * @param axis defines the axis to use
  48576. */
  48577. setAxisForUpDown(axis: JoystickAxis): void;
  48578. /**
  48579. * Clears the canvas from the previous puck / container draw
  48580. */
  48581. private _clearPreviousDraw;
  48582. /**
  48583. * Loads `urlPath` to be used for the container's image
  48584. * @param urlPath defines the urlPath of an image to use
  48585. */
  48586. setContainerImage(urlPath: string): void;
  48587. /**
  48588. * Loads `urlPath` to be used for the puck's image
  48589. * @param urlPath defines the urlPath of an image to use
  48590. */
  48591. setPuckImage(urlPath: string): void;
  48592. /**
  48593. * Draws the Virtual Joystick's container
  48594. */
  48595. private _drawContainer;
  48596. /**
  48597. * Draws the Virtual Joystick's puck
  48598. */
  48599. private _drawPuck;
  48600. private _drawVirtualJoystick;
  48601. /**
  48602. * Release internal HTML canvas
  48603. */
  48604. releaseCanvas(): void;
  48605. }
  48606. }
  48607. declare module BABYLON {
  48608. interface FreeCameraInputsManager {
  48609. /**
  48610. * Add virtual joystick input support to the input manager.
  48611. * @returns the current input manager
  48612. */
  48613. addVirtualJoystick(): FreeCameraInputsManager;
  48614. }
  48615. /**
  48616. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48618. */
  48619. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48620. /**
  48621. * Defines the camera the input is attached to.
  48622. */
  48623. camera: FreeCamera;
  48624. private _leftjoystick;
  48625. private _rightjoystick;
  48626. /**
  48627. * Gets the left stick of the virtual joystick.
  48628. * @returns The virtual Joystick
  48629. */
  48630. getLeftJoystick(): VirtualJoystick;
  48631. /**
  48632. * Gets the right stick of the virtual joystick.
  48633. * @returns The virtual Joystick
  48634. */
  48635. getRightJoystick(): VirtualJoystick;
  48636. /**
  48637. * Update the current camera state depending on the inputs that have been used this frame.
  48638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48639. */
  48640. checkInputs(): void;
  48641. /**
  48642. * Attach the input controls to a specific dom element to get the input from.
  48643. */
  48644. attachControl(): void;
  48645. /**
  48646. * Detach the current controls from the specified dom element.
  48647. */
  48648. detachControl(): void;
  48649. /**
  48650. * Gets the class name of the current intput.
  48651. * @returns the class name
  48652. */
  48653. getClassName(): string;
  48654. /**
  48655. * Get the friendly name associated with the input class.
  48656. * @returns the input friendly name
  48657. */
  48658. getSimpleName(): string;
  48659. }
  48660. }
  48661. declare module BABYLON {
  48662. /**
  48663. * This represents a FPS type of camera controlled by touch.
  48664. * This is like a universal camera minus the Gamepad controls.
  48665. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48666. */
  48667. export class TouchCamera extends FreeCamera {
  48668. /**
  48669. * Defines the touch sensibility for rotation.
  48670. * The higher the faster.
  48671. */
  48672. get touchAngularSensibility(): number;
  48673. set touchAngularSensibility(value: number);
  48674. /**
  48675. * Defines the touch sensibility for move.
  48676. * The higher the faster.
  48677. */
  48678. get touchMoveSensibility(): number;
  48679. set touchMoveSensibility(value: number);
  48680. /**
  48681. * Instantiates a new touch camera.
  48682. * This represents a FPS type of camera controlled by touch.
  48683. * This is like a universal camera minus the Gamepad controls.
  48684. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48685. * @param name Define the name of the camera in the scene
  48686. * @param position Define the start position of the camera in the scene
  48687. * @param scene Define the scene the camera belongs to
  48688. */
  48689. constructor(name: string, position: Vector3, scene: Scene);
  48690. /**
  48691. * Gets the current object class name.
  48692. * @return the class name
  48693. */
  48694. getClassName(): string;
  48695. /** @hidden */
  48696. _setupInputs(): void;
  48697. }
  48698. }
  48699. declare module BABYLON {
  48700. /**
  48701. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48702. * being tilted forward or back and left or right.
  48703. */
  48704. export class DeviceOrientationCamera extends FreeCamera {
  48705. private _initialQuaternion;
  48706. private _quaternionCache;
  48707. private _tmpDragQuaternion;
  48708. private _disablePointerInputWhenUsingDeviceOrientation;
  48709. /**
  48710. * Creates a new device orientation camera
  48711. * @param name The name of the camera
  48712. * @param position The start position camera
  48713. * @param scene The scene the camera belongs to
  48714. */
  48715. constructor(name: string, position: Vector3, scene: Scene);
  48716. /**
  48717. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48718. */
  48719. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48720. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48721. private _dragFactor;
  48722. /**
  48723. * Enabled turning on the y axis when the orientation sensor is active
  48724. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48725. */
  48726. enableHorizontalDragging(dragFactor?: number): void;
  48727. /**
  48728. * Gets the current instance class name ("DeviceOrientationCamera").
  48729. * This helps avoiding instanceof at run time.
  48730. * @returns the class name
  48731. */
  48732. getClassName(): string;
  48733. /**
  48734. * @hidden
  48735. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48736. */
  48737. _checkInputs(): void;
  48738. /**
  48739. * Reset the camera to its default orientation on the specified axis only.
  48740. * @param axis The axis to reset
  48741. */
  48742. resetToCurrentRotation(axis?: Axis): void;
  48743. }
  48744. }
  48745. declare module BABYLON {
  48746. /**
  48747. * Defines supported buttons for XBox360 compatible gamepads
  48748. */
  48749. export enum Xbox360Button {
  48750. /** A */
  48751. A = 0,
  48752. /** B */
  48753. B = 1,
  48754. /** X */
  48755. X = 2,
  48756. /** Y */
  48757. Y = 3,
  48758. /** Left button */
  48759. LB = 4,
  48760. /** Right button */
  48761. RB = 5,
  48762. /** Back */
  48763. Back = 8,
  48764. /** Start */
  48765. Start = 9,
  48766. /** Left stick */
  48767. LeftStick = 10,
  48768. /** Right stick */
  48769. RightStick = 11
  48770. }
  48771. /** Defines values for XBox360 DPad */
  48772. export enum Xbox360Dpad {
  48773. /** Up */
  48774. Up = 12,
  48775. /** Down */
  48776. Down = 13,
  48777. /** Left */
  48778. Left = 14,
  48779. /** Right */
  48780. Right = 15
  48781. }
  48782. /**
  48783. * Defines a XBox360 gamepad
  48784. */
  48785. export class Xbox360Pad extends Gamepad {
  48786. private _leftTrigger;
  48787. private _rightTrigger;
  48788. private _onlefttriggerchanged;
  48789. private _onrighttriggerchanged;
  48790. private _onbuttondown;
  48791. private _onbuttonup;
  48792. private _ondpaddown;
  48793. private _ondpadup;
  48794. /** Observable raised when a button is pressed */
  48795. onButtonDownObservable: Observable<Xbox360Button>;
  48796. /** Observable raised when a button is released */
  48797. onButtonUpObservable: Observable<Xbox360Button>;
  48798. /** Observable raised when a pad is pressed */
  48799. onPadDownObservable: Observable<Xbox360Dpad>;
  48800. /** Observable raised when a pad is released */
  48801. onPadUpObservable: Observable<Xbox360Dpad>;
  48802. private _buttonA;
  48803. private _buttonB;
  48804. private _buttonX;
  48805. private _buttonY;
  48806. private _buttonBack;
  48807. private _buttonStart;
  48808. private _buttonLB;
  48809. private _buttonRB;
  48810. private _buttonLeftStick;
  48811. private _buttonRightStick;
  48812. private _dPadUp;
  48813. private _dPadDown;
  48814. private _dPadLeft;
  48815. private _dPadRight;
  48816. private _isXboxOnePad;
  48817. /**
  48818. * Creates a new XBox360 gamepad object
  48819. * @param id defines the id of this gamepad
  48820. * @param index defines its index
  48821. * @param gamepad defines the internal HTML gamepad object
  48822. * @param xboxOne defines if it is a XBox One gamepad
  48823. */
  48824. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48825. /**
  48826. * Defines the callback to call when left trigger is pressed
  48827. * @param callback defines the callback to use
  48828. */
  48829. onlefttriggerchanged(callback: (value: number) => void): void;
  48830. /**
  48831. * Defines the callback to call when right trigger is pressed
  48832. * @param callback defines the callback to use
  48833. */
  48834. onrighttriggerchanged(callback: (value: number) => void): void;
  48835. /**
  48836. * Gets the left trigger value
  48837. */
  48838. get leftTrigger(): number;
  48839. /**
  48840. * Sets the left trigger value
  48841. */
  48842. set leftTrigger(newValue: number);
  48843. /**
  48844. * Gets the right trigger value
  48845. */
  48846. get rightTrigger(): number;
  48847. /**
  48848. * Sets the right trigger value
  48849. */
  48850. set rightTrigger(newValue: number);
  48851. /**
  48852. * Defines the callback to call when a button is pressed
  48853. * @param callback defines the callback to use
  48854. */
  48855. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48856. /**
  48857. * Defines the callback to call when a button is released
  48858. * @param callback defines the callback to use
  48859. */
  48860. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48861. /**
  48862. * Defines the callback to call when a pad is pressed
  48863. * @param callback defines the callback to use
  48864. */
  48865. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48866. /**
  48867. * Defines the callback to call when a pad is released
  48868. * @param callback defines the callback to use
  48869. */
  48870. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48871. private _setButtonValue;
  48872. private _setDPadValue;
  48873. /**
  48874. * Gets the value of the `A` button
  48875. */
  48876. get buttonA(): number;
  48877. /**
  48878. * Sets the value of the `A` button
  48879. */
  48880. set buttonA(value: number);
  48881. /**
  48882. * Gets the value of the `B` button
  48883. */
  48884. get buttonB(): number;
  48885. /**
  48886. * Sets the value of the `B` button
  48887. */
  48888. set buttonB(value: number);
  48889. /**
  48890. * Gets the value of the `X` button
  48891. */
  48892. get buttonX(): number;
  48893. /**
  48894. * Sets the value of the `X` button
  48895. */
  48896. set buttonX(value: number);
  48897. /**
  48898. * Gets the value of the `Y` button
  48899. */
  48900. get buttonY(): number;
  48901. /**
  48902. * Sets the value of the `Y` button
  48903. */
  48904. set buttonY(value: number);
  48905. /**
  48906. * Gets the value of the `Start` button
  48907. */
  48908. get buttonStart(): number;
  48909. /**
  48910. * Sets the value of the `Start` button
  48911. */
  48912. set buttonStart(value: number);
  48913. /**
  48914. * Gets the value of the `Back` button
  48915. */
  48916. get buttonBack(): number;
  48917. /**
  48918. * Sets the value of the `Back` button
  48919. */
  48920. set buttonBack(value: number);
  48921. /**
  48922. * Gets the value of the `Left` button
  48923. */
  48924. get buttonLB(): number;
  48925. /**
  48926. * Sets the value of the `Left` button
  48927. */
  48928. set buttonLB(value: number);
  48929. /**
  48930. * Gets the value of the `Right` button
  48931. */
  48932. get buttonRB(): number;
  48933. /**
  48934. * Sets the value of the `Right` button
  48935. */
  48936. set buttonRB(value: number);
  48937. /**
  48938. * Gets the value of the Left joystick
  48939. */
  48940. get buttonLeftStick(): number;
  48941. /**
  48942. * Sets the value of the Left joystick
  48943. */
  48944. set buttonLeftStick(value: number);
  48945. /**
  48946. * Gets the value of the Right joystick
  48947. */
  48948. get buttonRightStick(): number;
  48949. /**
  48950. * Sets the value of the Right joystick
  48951. */
  48952. set buttonRightStick(value: number);
  48953. /**
  48954. * Gets the value of D-pad up
  48955. */
  48956. get dPadUp(): number;
  48957. /**
  48958. * Sets the value of D-pad up
  48959. */
  48960. set dPadUp(value: number);
  48961. /**
  48962. * Gets the value of D-pad down
  48963. */
  48964. get dPadDown(): number;
  48965. /**
  48966. * Sets the value of D-pad down
  48967. */
  48968. set dPadDown(value: number);
  48969. /**
  48970. * Gets the value of D-pad left
  48971. */
  48972. get dPadLeft(): number;
  48973. /**
  48974. * Sets the value of D-pad left
  48975. */
  48976. set dPadLeft(value: number);
  48977. /**
  48978. * Gets the value of D-pad right
  48979. */
  48980. get dPadRight(): number;
  48981. /**
  48982. * Sets the value of D-pad right
  48983. */
  48984. set dPadRight(value: number);
  48985. /**
  48986. * Force the gamepad to synchronize with device values
  48987. */
  48988. update(): void;
  48989. /**
  48990. * Disposes the gamepad
  48991. */
  48992. dispose(): void;
  48993. }
  48994. }
  48995. declare module BABYLON {
  48996. /**
  48997. * Defines supported buttons for DualShock compatible gamepads
  48998. */
  48999. export enum DualShockButton {
  49000. /** Cross */
  49001. Cross = 0,
  49002. /** Circle */
  49003. Circle = 1,
  49004. /** Square */
  49005. Square = 2,
  49006. /** Triangle */
  49007. Triangle = 3,
  49008. /** L1 */
  49009. L1 = 4,
  49010. /** R1 */
  49011. R1 = 5,
  49012. /** Share */
  49013. Share = 8,
  49014. /** Options */
  49015. Options = 9,
  49016. /** Left stick */
  49017. LeftStick = 10,
  49018. /** Right stick */
  49019. RightStick = 11
  49020. }
  49021. /** Defines values for DualShock DPad */
  49022. export enum DualShockDpad {
  49023. /** Up */
  49024. Up = 12,
  49025. /** Down */
  49026. Down = 13,
  49027. /** Left */
  49028. Left = 14,
  49029. /** Right */
  49030. Right = 15
  49031. }
  49032. /**
  49033. * Defines a DualShock gamepad
  49034. */
  49035. export class DualShockPad extends Gamepad {
  49036. private _leftTrigger;
  49037. private _rightTrigger;
  49038. private _onlefttriggerchanged;
  49039. private _onrighttriggerchanged;
  49040. private _onbuttondown;
  49041. private _onbuttonup;
  49042. private _ondpaddown;
  49043. private _ondpadup;
  49044. /** Observable raised when a button is pressed */
  49045. onButtonDownObservable: Observable<DualShockButton>;
  49046. /** Observable raised when a button is released */
  49047. onButtonUpObservable: Observable<DualShockButton>;
  49048. /** Observable raised when a pad is pressed */
  49049. onPadDownObservable: Observable<DualShockDpad>;
  49050. /** Observable raised when a pad is released */
  49051. onPadUpObservable: Observable<DualShockDpad>;
  49052. private _buttonCross;
  49053. private _buttonCircle;
  49054. private _buttonSquare;
  49055. private _buttonTriangle;
  49056. private _buttonShare;
  49057. private _buttonOptions;
  49058. private _buttonL1;
  49059. private _buttonR1;
  49060. private _buttonLeftStick;
  49061. private _buttonRightStick;
  49062. private _dPadUp;
  49063. private _dPadDown;
  49064. private _dPadLeft;
  49065. private _dPadRight;
  49066. /**
  49067. * Creates a new DualShock gamepad object
  49068. * @param id defines the id of this gamepad
  49069. * @param index defines its index
  49070. * @param gamepad defines the internal HTML gamepad object
  49071. */
  49072. constructor(id: string, index: number, gamepad: any);
  49073. /**
  49074. * Defines the callback to call when left trigger is pressed
  49075. * @param callback defines the callback to use
  49076. */
  49077. onlefttriggerchanged(callback: (value: number) => void): void;
  49078. /**
  49079. * Defines the callback to call when right trigger is pressed
  49080. * @param callback defines the callback to use
  49081. */
  49082. onrighttriggerchanged(callback: (value: number) => void): void;
  49083. /**
  49084. * Gets the left trigger value
  49085. */
  49086. get leftTrigger(): number;
  49087. /**
  49088. * Sets the left trigger value
  49089. */
  49090. set leftTrigger(newValue: number);
  49091. /**
  49092. * Gets the right trigger value
  49093. */
  49094. get rightTrigger(): number;
  49095. /**
  49096. * Sets the right trigger value
  49097. */
  49098. set rightTrigger(newValue: number);
  49099. /**
  49100. * Defines the callback to call when a button is pressed
  49101. * @param callback defines the callback to use
  49102. */
  49103. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49104. /**
  49105. * Defines the callback to call when a button is released
  49106. * @param callback defines the callback to use
  49107. */
  49108. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49109. /**
  49110. * Defines the callback to call when a pad is pressed
  49111. * @param callback defines the callback to use
  49112. */
  49113. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49114. /**
  49115. * Defines the callback to call when a pad is released
  49116. * @param callback defines the callback to use
  49117. */
  49118. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49119. private _setButtonValue;
  49120. private _setDPadValue;
  49121. /**
  49122. * Gets the value of the `Cross` button
  49123. */
  49124. get buttonCross(): number;
  49125. /**
  49126. * Sets the value of the `Cross` button
  49127. */
  49128. set buttonCross(value: number);
  49129. /**
  49130. * Gets the value of the `Circle` button
  49131. */
  49132. get buttonCircle(): number;
  49133. /**
  49134. * Sets the value of the `Circle` button
  49135. */
  49136. set buttonCircle(value: number);
  49137. /**
  49138. * Gets the value of the `Square` button
  49139. */
  49140. get buttonSquare(): number;
  49141. /**
  49142. * Sets the value of the `Square` button
  49143. */
  49144. set buttonSquare(value: number);
  49145. /**
  49146. * Gets the value of the `Triangle` button
  49147. */
  49148. get buttonTriangle(): number;
  49149. /**
  49150. * Sets the value of the `Triangle` button
  49151. */
  49152. set buttonTriangle(value: number);
  49153. /**
  49154. * Gets the value of the `Options` button
  49155. */
  49156. get buttonOptions(): number;
  49157. /**
  49158. * Sets the value of the `Options` button
  49159. */
  49160. set buttonOptions(value: number);
  49161. /**
  49162. * Gets the value of the `Share` button
  49163. */
  49164. get buttonShare(): number;
  49165. /**
  49166. * Sets the value of the `Share` button
  49167. */
  49168. set buttonShare(value: number);
  49169. /**
  49170. * Gets the value of the `L1` button
  49171. */
  49172. get buttonL1(): number;
  49173. /**
  49174. * Sets the value of the `L1` button
  49175. */
  49176. set buttonL1(value: number);
  49177. /**
  49178. * Gets the value of the `R1` button
  49179. */
  49180. get buttonR1(): number;
  49181. /**
  49182. * Sets the value of the `R1` button
  49183. */
  49184. set buttonR1(value: number);
  49185. /**
  49186. * Gets the value of the Left joystick
  49187. */
  49188. get buttonLeftStick(): number;
  49189. /**
  49190. * Sets the value of the Left joystick
  49191. */
  49192. set buttonLeftStick(value: number);
  49193. /**
  49194. * Gets the value of the Right joystick
  49195. */
  49196. get buttonRightStick(): number;
  49197. /**
  49198. * Sets the value of the Right joystick
  49199. */
  49200. set buttonRightStick(value: number);
  49201. /**
  49202. * Gets the value of D-pad up
  49203. */
  49204. get dPadUp(): number;
  49205. /**
  49206. * Sets the value of D-pad up
  49207. */
  49208. set dPadUp(value: number);
  49209. /**
  49210. * Gets the value of D-pad down
  49211. */
  49212. get dPadDown(): number;
  49213. /**
  49214. * Sets the value of D-pad down
  49215. */
  49216. set dPadDown(value: number);
  49217. /**
  49218. * Gets the value of D-pad left
  49219. */
  49220. get dPadLeft(): number;
  49221. /**
  49222. * Sets the value of D-pad left
  49223. */
  49224. set dPadLeft(value: number);
  49225. /**
  49226. * Gets the value of D-pad right
  49227. */
  49228. get dPadRight(): number;
  49229. /**
  49230. * Sets the value of D-pad right
  49231. */
  49232. set dPadRight(value: number);
  49233. /**
  49234. * Force the gamepad to synchronize with device values
  49235. */
  49236. update(): void;
  49237. /**
  49238. * Disposes the gamepad
  49239. */
  49240. dispose(): void;
  49241. }
  49242. }
  49243. declare module BABYLON {
  49244. /**
  49245. * Manager for handling gamepads
  49246. */
  49247. export class GamepadManager {
  49248. private _scene?;
  49249. private _babylonGamepads;
  49250. private _oneGamepadConnected;
  49251. /** @hidden */
  49252. _isMonitoring: boolean;
  49253. private _gamepadEventSupported;
  49254. private _gamepadSupport?;
  49255. /**
  49256. * observable to be triggered when the gamepad controller has been connected
  49257. */
  49258. onGamepadConnectedObservable: Observable<Gamepad>;
  49259. /**
  49260. * observable to be triggered when the gamepad controller has been disconnected
  49261. */
  49262. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49263. private _onGamepadConnectedEvent;
  49264. private _onGamepadDisconnectedEvent;
  49265. /**
  49266. * Initializes the gamepad manager
  49267. * @param _scene BabylonJS scene
  49268. */
  49269. constructor(_scene?: Scene | undefined);
  49270. /**
  49271. * The gamepads in the game pad manager
  49272. */
  49273. get gamepads(): Gamepad[];
  49274. /**
  49275. * Get the gamepad controllers based on type
  49276. * @param type The type of gamepad controller
  49277. * @returns Nullable gamepad
  49278. */
  49279. getGamepadByType(type?: number): Nullable<Gamepad>;
  49280. /**
  49281. * Disposes the gamepad manager
  49282. */
  49283. dispose(): void;
  49284. private _addNewGamepad;
  49285. private _startMonitoringGamepads;
  49286. private _stopMonitoringGamepads;
  49287. /** @hidden */
  49288. _checkGamepadsStatus(): void;
  49289. private _updateGamepadObjects;
  49290. }
  49291. }
  49292. declare module BABYLON {
  49293. interface Scene {
  49294. /** @hidden */
  49295. _gamepadManager: Nullable<GamepadManager>;
  49296. /**
  49297. * Gets the gamepad manager associated with the scene
  49298. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49299. */
  49300. gamepadManager: GamepadManager;
  49301. }
  49302. /**
  49303. * Interface representing a free camera inputs manager
  49304. */
  49305. interface FreeCameraInputsManager {
  49306. /**
  49307. * Adds gamepad input support to the FreeCameraInputsManager.
  49308. * @returns the FreeCameraInputsManager
  49309. */
  49310. addGamepad(): FreeCameraInputsManager;
  49311. }
  49312. /**
  49313. * Interface representing an arc rotate camera inputs manager
  49314. */
  49315. interface ArcRotateCameraInputsManager {
  49316. /**
  49317. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49318. * @returns the camera inputs manager
  49319. */
  49320. addGamepad(): ArcRotateCameraInputsManager;
  49321. }
  49322. /**
  49323. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49324. */
  49325. export class GamepadSystemSceneComponent implements ISceneComponent {
  49326. /**
  49327. * The component name helpfull to identify the component in the list of scene components.
  49328. */
  49329. readonly name: string;
  49330. /**
  49331. * The scene the component belongs to.
  49332. */
  49333. scene: Scene;
  49334. /**
  49335. * Creates a new instance of the component for the given scene
  49336. * @param scene Defines the scene to register the component in
  49337. */
  49338. constructor(scene: Scene);
  49339. /**
  49340. * Registers the component in a given scene
  49341. */
  49342. register(): void;
  49343. /**
  49344. * Rebuilds the elements related to this component in case of
  49345. * context lost for instance.
  49346. */
  49347. rebuild(): void;
  49348. /**
  49349. * Disposes the component and the associated ressources
  49350. */
  49351. dispose(): void;
  49352. private _beforeCameraUpdate;
  49353. }
  49354. }
  49355. declare module BABYLON {
  49356. /**
  49357. * 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,
  49358. * which still works and will still be found in many Playgrounds.
  49359. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49360. */
  49361. export class UniversalCamera extends TouchCamera {
  49362. /**
  49363. * Defines the gamepad rotation sensiblity.
  49364. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49365. */
  49366. get gamepadAngularSensibility(): number;
  49367. set gamepadAngularSensibility(value: number);
  49368. /**
  49369. * Defines the gamepad move sensiblity.
  49370. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49371. */
  49372. get gamepadMoveSensibility(): number;
  49373. set gamepadMoveSensibility(value: number);
  49374. /**
  49375. * 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,
  49376. * which still works and will still be found in many Playgrounds.
  49377. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49378. * @param name Define the name of the camera in the scene
  49379. * @param position Define the start position of the camera in the scene
  49380. * @param scene Define the scene the camera belongs to
  49381. */
  49382. constructor(name: string, position: Vector3, scene: Scene);
  49383. /**
  49384. * Gets the current object class name.
  49385. * @return the class name
  49386. */
  49387. getClassName(): string;
  49388. }
  49389. }
  49390. declare module BABYLON {
  49391. /**
  49392. * This represents a FPS type of camera. This is only here for back compat purpose.
  49393. * Please use the UniversalCamera instead as both are identical.
  49394. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49395. */
  49396. export class GamepadCamera extends UniversalCamera {
  49397. /**
  49398. * Instantiates a new Gamepad Camera
  49399. * This represents a FPS type of camera. This is only here for back compat purpose.
  49400. * Please use the UniversalCamera instead as both are identical.
  49401. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49402. * @param name Define the name of the camera in the scene
  49403. * @param position Define the start position of the camera in the scene
  49404. * @param scene Define the scene the camera belongs to
  49405. */
  49406. constructor(name: string, position: Vector3, scene: Scene);
  49407. /**
  49408. * Gets the current object class name.
  49409. * @return the class name
  49410. */
  49411. getClassName(): string;
  49412. }
  49413. }
  49414. declare module BABYLON {
  49415. /** @hidden */
  49416. export var passPixelShader: {
  49417. name: string;
  49418. shader: string;
  49419. };
  49420. }
  49421. declare module BABYLON {
  49422. /** @hidden */
  49423. export var passCubePixelShader: {
  49424. name: string;
  49425. shader: string;
  49426. };
  49427. }
  49428. declare module BABYLON {
  49429. /**
  49430. * PassPostProcess which produces an output the same as it's input
  49431. */
  49432. export class PassPostProcess extends PostProcess {
  49433. /**
  49434. * Gets a string identifying the name of the class
  49435. * @returns "PassPostProcess" string
  49436. */
  49437. getClassName(): string;
  49438. /**
  49439. * Creates the PassPostProcess
  49440. * @param name The name of the effect.
  49441. * @param options The required width/height ratio to downsize to before computing the render pass.
  49442. * @param camera The camera to apply the render pass to.
  49443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49444. * @param engine The engine which the post process will be applied. (default: current engine)
  49445. * @param reusable If the post process can be reused on the same frame. (default: false)
  49446. * @param textureType The type of texture to be used when performing the post processing.
  49447. * @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)
  49448. */
  49449. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49450. /** @hidden */
  49451. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49452. }
  49453. /**
  49454. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49455. */
  49456. export class PassCubePostProcess extends PostProcess {
  49457. private _face;
  49458. /**
  49459. * Gets or sets the cube face to display.
  49460. * * 0 is +X
  49461. * * 1 is -X
  49462. * * 2 is +Y
  49463. * * 3 is -Y
  49464. * * 4 is +Z
  49465. * * 5 is -Z
  49466. */
  49467. get face(): number;
  49468. set face(value: number);
  49469. /**
  49470. * Gets a string identifying the name of the class
  49471. * @returns "PassCubePostProcess" string
  49472. */
  49473. getClassName(): string;
  49474. /**
  49475. * Creates the PassCubePostProcess
  49476. * @param name The name of the effect.
  49477. * @param options The required width/height ratio to downsize to before computing the render pass.
  49478. * @param camera The camera to apply the render pass to.
  49479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49480. * @param engine The engine which the post process will be applied. (default: current engine)
  49481. * @param reusable If the post process can be reused on the same frame. (default: false)
  49482. * @param textureType The type of texture to be used when performing the post processing.
  49483. * @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)
  49484. */
  49485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49486. /** @hidden */
  49487. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49488. }
  49489. }
  49490. declare module BABYLON {
  49491. /** @hidden */
  49492. export var anaglyphPixelShader: {
  49493. name: string;
  49494. shader: string;
  49495. };
  49496. }
  49497. declare module BABYLON {
  49498. /**
  49499. * Postprocess used to generate anaglyphic rendering
  49500. */
  49501. export class AnaglyphPostProcess extends PostProcess {
  49502. private _passedProcess;
  49503. /**
  49504. * Gets a string identifying the name of the class
  49505. * @returns "AnaglyphPostProcess" string
  49506. */
  49507. getClassName(): string;
  49508. /**
  49509. * Creates a new AnaglyphPostProcess
  49510. * @param name defines postprocess name
  49511. * @param options defines creation options or target ratio scale
  49512. * @param rigCameras defines cameras using this postprocess
  49513. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49514. * @param engine defines hosting engine
  49515. * @param reusable defines if the postprocess will be reused multiple times per frame
  49516. */
  49517. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49518. }
  49519. }
  49520. declare module BABYLON {
  49521. /**
  49522. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49523. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49524. */
  49525. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49526. /**
  49527. * Creates a new AnaglyphArcRotateCamera
  49528. * @param name defines camera name
  49529. * @param alpha defines alpha angle (in radians)
  49530. * @param beta defines beta angle (in radians)
  49531. * @param radius defines radius
  49532. * @param target defines camera target
  49533. * @param interaxialDistance defines distance between each color axis
  49534. * @param scene defines the hosting scene
  49535. */
  49536. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49537. /**
  49538. * Gets camera class name
  49539. * @returns AnaglyphArcRotateCamera
  49540. */
  49541. getClassName(): string;
  49542. }
  49543. }
  49544. declare module BABYLON {
  49545. /**
  49546. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49547. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49548. */
  49549. export class AnaglyphFreeCamera extends FreeCamera {
  49550. /**
  49551. * Creates a new AnaglyphFreeCamera
  49552. * @param name defines camera name
  49553. * @param position defines initial position
  49554. * @param interaxialDistance defines distance between each color axis
  49555. * @param scene defines the hosting scene
  49556. */
  49557. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49558. /**
  49559. * Gets camera class name
  49560. * @returns AnaglyphFreeCamera
  49561. */
  49562. getClassName(): string;
  49563. }
  49564. }
  49565. declare module BABYLON {
  49566. /**
  49567. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49568. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49569. */
  49570. export class AnaglyphGamepadCamera extends GamepadCamera {
  49571. /**
  49572. * Creates a new AnaglyphGamepadCamera
  49573. * @param name defines camera name
  49574. * @param position defines initial position
  49575. * @param interaxialDistance defines distance between each color axis
  49576. * @param scene defines the hosting scene
  49577. */
  49578. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49579. /**
  49580. * Gets camera class name
  49581. * @returns AnaglyphGamepadCamera
  49582. */
  49583. getClassName(): string;
  49584. }
  49585. }
  49586. declare module BABYLON {
  49587. /**
  49588. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49589. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49590. */
  49591. export class AnaglyphUniversalCamera extends UniversalCamera {
  49592. /**
  49593. * Creates a new AnaglyphUniversalCamera
  49594. * @param name defines camera name
  49595. * @param position defines initial position
  49596. * @param interaxialDistance defines distance between each color axis
  49597. * @param scene defines the hosting scene
  49598. */
  49599. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49600. /**
  49601. * Gets camera class name
  49602. * @returns AnaglyphUniversalCamera
  49603. */
  49604. getClassName(): string;
  49605. }
  49606. }
  49607. declare module BABYLON {
  49608. /**
  49609. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49610. * @see https://doc.babylonjs.com/features/cameras
  49611. */
  49612. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49613. /**
  49614. * Creates a new StereoscopicArcRotateCamera
  49615. * @param name defines camera name
  49616. * @param alpha defines alpha angle (in radians)
  49617. * @param beta defines beta angle (in radians)
  49618. * @param radius defines radius
  49619. * @param target defines camera target
  49620. * @param interaxialDistance defines distance between each color axis
  49621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49622. * @param scene defines the hosting scene
  49623. */
  49624. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49625. /**
  49626. * Gets camera class name
  49627. * @returns StereoscopicArcRotateCamera
  49628. */
  49629. getClassName(): string;
  49630. }
  49631. }
  49632. declare module BABYLON {
  49633. /**
  49634. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49635. * @see https://doc.babylonjs.com/features/cameras
  49636. */
  49637. export class StereoscopicFreeCamera extends FreeCamera {
  49638. /**
  49639. * Creates a new StereoscopicFreeCamera
  49640. * @param name defines camera name
  49641. * @param position defines initial position
  49642. * @param interaxialDistance defines distance between each color axis
  49643. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49644. * @param scene defines the hosting scene
  49645. */
  49646. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49647. /**
  49648. * Gets camera class name
  49649. * @returns StereoscopicFreeCamera
  49650. */
  49651. getClassName(): string;
  49652. }
  49653. }
  49654. declare module BABYLON {
  49655. /**
  49656. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49657. * @see https://doc.babylonjs.com/features/cameras
  49658. */
  49659. export class StereoscopicGamepadCamera extends GamepadCamera {
  49660. /**
  49661. * Creates a new StereoscopicGamepadCamera
  49662. * @param name defines camera name
  49663. * @param position defines initial position
  49664. * @param interaxialDistance defines distance between each color axis
  49665. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49666. * @param scene defines the hosting scene
  49667. */
  49668. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49669. /**
  49670. * Gets camera class name
  49671. * @returns StereoscopicGamepadCamera
  49672. */
  49673. getClassName(): string;
  49674. }
  49675. }
  49676. declare module BABYLON {
  49677. /**
  49678. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49679. * @see https://doc.babylonjs.com/features/cameras
  49680. */
  49681. export class StereoscopicUniversalCamera extends UniversalCamera {
  49682. /**
  49683. * Creates a new StereoscopicUniversalCamera
  49684. * @param name defines camera name
  49685. * @param position defines initial position
  49686. * @param interaxialDistance defines distance between each color axis
  49687. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49688. * @param scene defines the hosting scene
  49689. */
  49690. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49691. /**
  49692. * Gets camera class name
  49693. * @returns StereoscopicUniversalCamera
  49694. */
  49695. getClassName(): string;
  49696. }
  49697. }
  49698. declare module BABYLON {
  49699. /**
  49700. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49701. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49702. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49703. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49704. */
  49705. export class VirtualJoysticksCamera extends FreeCamera {
  49706. /**
  49707. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49708. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49709. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49710. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49711. * @param name Define the name of the camera in the scene
  49712. * @param position Define the start position of the camera in the scene
  49713. * @param scene Define the scene the camera belongs to
  49714. */
  49715. constructor(name: string, position: Vector3, scene: Scene);
  49716. /**
  49717. * Gets the current object class name.
  49718. * @return the class name
  49719. */
  49720. getClassName(): string;
  49721. }
  49722. }
  49723. declare module BABYLON {
  49724. /**
  49725. * This represents all the required metrics to create a VR camera.
  49726. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49727. */
  49728. export class VRCameraMetrics {
  49729. /**
  49730. * Define the horizontal resolution off the screen.
  49731. */
  49732. hResolution: number;
  49733. /**
  49734. * Define the vertical resolution off the screen.
  49735. */
  49736. vResolution: number;
  49737. /**
  49738. * Define the horizontal screen size.
  49739. */
  49740. hScreenSize: number;
  49741. /**
  49742. * Define the vertical screen size.
  49743. */
  49744. vScreenSize: number;
  49745. /**
  49746. * Define the vertical screen center position.
  49747. */
  49748. vScreenCenter: number;
  49749. /**
  49750. * Define the distance of the eyes to the screen.
  49751. */
  49752. eyeToScreenDistance: number;
  49753. /**
  49754. * Define the distance between both lenses
  49755. */
  49756. lensSeparationDistance: number;
  49757. /**
  49758. * Define the distance between both viewer's eyes.
  49759. */
  49760. interpupillaryDistance: number;
  49761. /**
  49762. * Define the distortion factor of the VR postprocess.
  49763. * Please, touch with care.
  49764. */
  49765. distortionK: number[];
  49766. /**
  49767. * Define the chromatic aberration correction factors for the VR post process.
  49768. */
  49769. chromaAbCorrection: number[];
  49770. /**
  49771. * Define the scale factor of the post process.
  49772. * The smaller the better but the slower.
  49773. */
  49774. postProcessScaleFactor: number;
  49775. /**
  49776. * Define an offset for the lens center.
  49777. */
  49778. lensCenterOffset: number;
  49779. /**
  49780. * Define if the current vr camera should compensate the distortion of the lense or not.
  49781. */
  49782. compensateDistortion: boolean;
  49783. /**
  49784. * Defines if multiview should be enabled when rendering (Default: false)
  49785. */
  49786. multiviewEnabled: boolean;
  49787. /**
  49788. * Gets the rendering aspect ratio based on the provided resolutions.
  49789. */
  49790. get aspectRatio(): number;
  49791. /**
  49792. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49793. */
  49794. get aspectRatioFov(): number;
  49795. /**
  49796. * @hidden
  49797. */
  49798. get leftHMatrix(): Matrix;
  49799. /**
  49800. * @hidden
  49801. */
  49802. get rightHMatrix(): Matrix;
  49803. /**
  49804. * @hidden
  49805. */
  49806. get leftPreViewMatrix(): Matrix;
  49807. /**
  49808. * @hidden
  49809. */
  49810. get rightPreViewMatrix(): Matrix;
  49811. /**
  49812. * Get the default VRMetrics based on the most generic setup.
  49813. * @returns the default vr metrics
  49814. */
  49815. static GetDefault(): VRCameraMetrics;
  49816. }
  49817. }
  49818. declare module BABYLON {
  49819. /** @hidden */
  49820. export var vrDistortionCorrectionPixelShader: {
  49821. name: string;
  49822. shader: string;
  49823. };
  49824. }
  49825. declare module BABYLON {
  49826. /**
  49827. * VRDistortionCorrectionPostProcess used for mobile VR
  49828. */
  49829. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49830. private _isRightEye;
  49831. private _distortionFactors;
  49832. private _postProcessScaleFactor;
  49833. private _lensCenterOffset;
  49834. private _scaleIn;
  49835. private _scaleFactor;
  49836. private _lensCenter;
  49837. /**
  49838. * Gets a string identifying the name of the class
  49839. * @returns "VRDistortionCorrectionPostProcess" string
  49840. */
  49841. getClassName(): string;
  49842. /**
  49843. * Initializes the VRDistortionCorrectionPostProcess
  49844. * @param name The name of the effect.
  49845. * @param camera The camera to apply the render pass to.
  49846. * @param isRightEye If this is for the right eye distortion
  49847. * @param vrMetrics All the required metrics for the VR camera
  49848. */
  49849. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /**
  49854. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49855. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49856. */
  49857. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49858. /**
  49859. * Creates a new VRDeviceOrientationArcRotateCamera
  49860. * @param name defines camera name
  49861. * @param alpha defines the camera rotation along the logitudinal axis
  49862. * @param beta defines the camera rotation along the latitudinal axis
  49863. * @param radius defines the camera distance from its target
  49864. * @param target defines the camera target
  49865. * @param scene defines the scene the camera belongs to
  49866. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49867. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49868. */
  49869. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49870. /**
  49871. * Gets camera class name
  49872. * @returns VRDeviceOrientationArcRotateCamera
  49873. */
  49874. getClassName(): string;
  49875. }
  49876. }
  49877. declare module BABYLON {
  49878. /**
  49879. * Camera used to simulate VR rendering (based on FreeCamera)
  49880. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49881. */
  49882. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49883. /**
  49884. * Creates a new VRDeviceOrientationFreeCamera
  49885. * @param name defines camera name
  49886. * @param position defines the start position of the camera
  49887. * @param scene defines the scene the camera belongs to
  49888. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49889. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49890. */
  49891. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49892. /**
  49893. * Gets camera class name
  49894. * @returns VRDeviceOrientationFreeCamera
  49895. */
  49896. getClassName(): string;
  49897. }
  49898. }
  49899. declare module BABYLON {
  49900. /**
  49901. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49902. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49903. */
  49904. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49905. /**
  49906. * Creates a new VRDeviceOrientationGamepadCamera
  49907. * @param name defines camera name
  49908. * @param position defines the start position of the camera
  49909. * @param scene defines the scene the camera belongs to
  49910. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49911. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49912. */
  49913. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49914. /**
  49915. * Gets camera class name
  49916. * @returns VRDeviceOrientationGamepadCamera
  49917. */
  49918. getClassName(): string;
  49919. }
  49920. }
  49921. declare module BABYLON {
  49922. /**
  49923. * A class extending Texture allowing drawing on a texture
  49924. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49925. */
  49926. export class DynamicTexture extends Texture {
  49927. private _generateMipMaps;
  49928. private _canvas;
  49929. private _context;
  49930. /**
  49931. * Creates a DynamicTexture
  49932. * @param name defines the name of the texture
  49933. * @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
  49934. * @param scene defines the scene where you want the texture
  49935. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49936. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49937. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49938. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49939. */
  49940. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49941. /**
  49942. * Get the current class name of the texture useful for serialization or dynamic coding.
  49943. * @returns "DynamicTexture"
  49944. */
  49945. getClassName(): string;
  49946. /**
  49947. * Gets the current state of canRescale
  49948. */
  49949. get canRescale(): boolean;
  49950. private _recreate;
  49951. /**
  49952. * Scales the texture
  49953. * @param ratio the scale factor to apply to both width and height
  49954. */
  49955. scale(ratio: number): void;
  49956. /**
  49957. * Resizes the texture
  49958. * @param width the new width
  49959. * @param height the new height
  49960. */
  49961. scaleTo(width: number, height: number): void;
  49962. /**
  49963. * Gets the context of the canvas used by the texture
  49964. * @returns the canvas context of the dynamic texture
  49965. */
  49966. getContext(): CanvasRenderingContext2D;
  49967. /**
  49968. * Clears the texture
  49969. */
  49970. clear(): void;
  49971. /**
  49972. * Updates the texture
  49973. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49974. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49975. */
  49976. update(invertY?: boolean, premulAlpha?: boolean): void;
  49977. /**
  49978. * Draws text onto the texture
  49979. * @param text defines the text to be drawn
  49980. * @param x defines the placement of the text from the left
  49981. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49982. * @param font defines the font to be used with font-style, font-size, font-name
  49983. * @param color defines the color used for the text
  49984. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49985. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49986. * @param update defines whether texture is immediately update (default is true)
  49987. */
  49988. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49989. /**
  49990. * Clones the texture
  49991. * @returns the clone of the texture.
  49992. */
  49993. clone(): DynamicTexture;
  49994. /**
  49995. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49996. * @returns a serialized dynamic texture object
  49997. */
  49998. serialize(): any;
  49999. private _IsCanvasElement;
  50000. /** @hidden */
  50001. _rebuild(): void;
  50002. }
  50003. }
  50004. declare module BABYLON {
  50005. /**
  50006. * Class containing static functions to help procedurally build meshes
  50007. */
  50008. export class GroundBuilder {
  50009. /**
  50010. * Creates a ground mesh
  50011. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50012. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50014. * @param name defines the name of the mesh
  50015. * @param options defines the options used to create the mesh
  50016. * @param scene defines the hosting scene
  50017. * @returns the ground mesh
  50018. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50019. */
  50020. static CreateGround(name: string, options: {
  50021. width?: number;
  50022. height?: number;
  50023. subdivisions?: number;
  50024. subdivisionsX?: number;
  50025. subdivisionsY?: number;
  50026. updatable?: boolean;
  50027. }, scene: any): Mesh;
  50028. /**
  50029. * Creates a tiled ground mesh
  50030. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50031. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50032. * * 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
  50033. * * 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
  50034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50035. * @param name defines the name of the mesh
  50036. * @param options defines the options used to create the mesh
  50037. * @param scene defines the hosting scene
  50038. * @returns the tiled ground mesh
  50039. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50040. */
  50041. static CreateTiledGround(name: string, options: {
  50042. xmin: number;
  50043. zmin: number;
  50044. xmax: number;
  50045. zmax: number;
  50046. subdivisions?: {
  50047. w: number;
  50048. h: number;
  50049. };
  50050. precision?: {
  50051. w: number;
  50052. h: number;
  50053. };
  50054. updatable?: boolean;
  50055. }, scene?: Nullable<Scene>): Mesh;
  50056. /**
  50057. * Creates a ground mesh from a height map
  50058. * * The parameter `url` sets the URL of the height map image resource.
  50059. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50060. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50061. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50062. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50063. * * 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.
  50064. * * 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).
  50065. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50067. * @param name defines the name of the mesh
  50068. * @param url defines the url to the height map
  50069. * @param options defines the options used to create the mesh
  50070. * @param scene defines the hosting scene
  50071. * @returns the ground mesh
  50072. * @see https://doc.babylonjs.com/babylon101/height_map
  50073. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50074. */
  50075. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50076. width?: number;
  50077. height?: number;
  50078. subdivisions?: number;
  50079. minHeight?: number;
  50080. maxHeight?: number;
  50081. colorFilter?: Color3;
  50082. alphaFilter?: number;
  50083. updatable?: boolean;
  50084. onReady?: (mesh: GroundMesh) => void;
  50085. }, scene?: Nullable<Scene>): GroundMesh;
  50086. }
  50087. }
  50088. declare module BABYLON {
  50089. /**
  50090. * Class containing static functions to help procedurally build meshes
  50091. */
  50092. export class TorusBuilder {
  50093. /**
  50094. * Creates a torus mesh
  50095. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50096. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50097. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50099. * * 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
  50100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50101. * @param name defines the name of the mesh
  50102. * @param options defines the options used to create the mesh
  50103. * @param scene defines the hosting scene
  50104. * @returns the torus mesh
  50105. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50106. */
  50107. static CreateTorus(name: string, options: {
  50108. diameter?: number;
  50109. thickness?: number;
  50110. tessellation?: number;
  50111. updatable?: boolean;
  50112. sideOrientation?: number;
  50113. frontUVs?: Vector4;
  50114. backUVs?: Vector4;
  50115. }, scene: any): Mesh;
  50116. }
  50117. }
  50118. declare module BABYLON {
  50119. /**
  50120. * Class containing static functions to help procedurally build meshes
  50121. */
  50122. export class CylinderBuilder {
  50123. /**
  50124. * Creates a cylinder or a cone mesh
  50125. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50126. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50127. * * 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.
  50128. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50129. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50130. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50131. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50132. * * 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).
  50133. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50134. * * 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).
  50135. * * 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
  50136. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50137. * * 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
  50138. * * 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.
  50139. * * If `enclose` is false, a ring surface is one element.
  50140. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50141. * * 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
  50142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50143. * * 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
  50144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50145. * @param name defines the name of the mesh
  50146. * @param options defines the options used to create the mesh
  50147. * @param scene defines the hosting scene
  50148. * @returns the cylinder mesh
  50149. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50150. */
  50151. static CreateCylinder(name: string, options: {
  50152. height?: number;
  50153. diameterTop?: number;
  50154. diameterBottom?: number;
  50155. diameter?: number;
  50156. tessellation?: number;
  50157. subdivisions?: number;
  50158. arc?: number;
  50159. faceColors?: Color4[];
  50160. faceUV?: Vector4[];
  50161. updatable?: boolean;
  50162. hasRings?: boolean;
  50163. enclose?: boolean;
  50164. cap?: number;
  50165. sideOrientation?: number;
  50166. frontUVs?: Vector4;
  50167. backUVs?: Vector4;
  50168. }, scene: any): Mesh;
  50169. }
  50170. }
  50171. declare module BABYLON {
  50172. /**
  50173. * States of the webXR experience
  50174. */
  50175. export enum WebXRState {
  50176. /**
  50177. * Transitioning to being in XR mode
  50178. */
  50179. ENTERING_XR = 0,
  50180. /**
  50181. * Transitioning to non XR mode
  50182. */
  50183. EXITING_XR = 1,
  50184. /**
  50185. * In XR mode and presenting
  50186. */
  50187. IN_XR = 2,
  50188. /**
  50189. * Not entered XR mode
  50190. */
  50191. NOT_IN_XR = 3
  50192. }
  50193. /**
  50194. * The state of the XR camera's tracking
  50195. */
  50196. export enum WebXRTrackingState {
  50197. /**
  50198. * No transformation received, device is not being tracked
  50199. */
  50200. NOT_TRACKING = 0,
  50201. /**
  50202. * Tracking lost - using emulated position
  50203. */
  50204. TRACKING_LOST = 1,
  50205. /**
  50206. * Transformation tracking works normally
  50207. */
  50208. TRACKING = 2
  50209. }
  50210. /**
  50211. * Abstraction of the XR render target
  50212. */
  50213. export interface WebXRRenderTarget extends IDisposable {
  50214. /**
  50215. * xrpresent context of the canvas which can be used to display/mirror xr content
  50216. */
  50217. canvasContext: WebGLRenderingContext;
  50218. /**
  50219. * xr layer for the canvas
  50220. */
  50221. xrLayer: Nullable<XRWebGLLayer>;
  50222. /**
  50223. * Initializes the xr layer for the session
  50224. * @param xrSession xr session
  50225. * @returns a promise that will resolve once the XR Layer has been created
  50226. */
  50227. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50228. }
  50229. }
  50230. declare module BABYLON {
  50231. /**
  50232. * COnfiguration object for WebXR output canvas
  50233. */
  50234. export class WebXRManagedOutputCanvasOptions {
  50235. /**
  50236. * An optional canvas in case you wish to create it yourself and provide it here.
  50237. * If not provided, a new canvas will be created
  50238. */
  50239. canvasElement?: HTMLCanvasElement;
  50240. /**
  50241. * Options for this XR Layer output
  50242. */
  50243. canvasOptions?: XRWebGLLayerInit;
  50244. /**
  50245. * CSS styling for a newly created canvas (if not provided)
  50246. */
  50247. newCanvasCssStyle?: string;
  50248. /**
  50249. * Get the default values of the configuration object
  50250. * @param engine defines the engine to use (can be null)
  50251. * @returns default values of this configuration object
  50252. */
  50253. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50254. }
  50255. /**
  50256. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50257. */
  50258. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50259. private _options;
  50260. private _canvas;
  50261. private _engine;
  50262. private _originalCanvasSize;
  50263. /**
  50264. * Rendering context of the canvas which can be used to display/mirror xr content
  50265. */
  50266. canvasContext: WebGLRenderingContext;
  50267. /**
  50268. * xr layer for the canvas
  50269. */
  50270. xrLayer: Nullable<XRWebGLLayer>;
  50271. /**
  50272. * Obseervers registered here will be triggered when the xr layer was initialized
  50273. */
  50274. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50275. /**
  50276. * Initializes the canvas to be added/removed upon entering/exiting xr
  50277. * @param _xrSessionManager The XR Session manager
  50278. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50279. */
  50280. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50281. /**
  50282. * Disposes of the object
  50283. */
  50284. dispose(): void;
  50285. /**
  50286. * Initializes the xr layer for the session
  50287. * @param xrSession xr session
  50288. * @returns a promise that will resolve once the XR Layer has been created
  50289. */
  50290. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50291. private _addCanvas;
  50292. private _removeCanvas;
  50293. private _setCanvasSize;
  50294. private _setManagedOutputCanvas;
  50295. }
  50296. }
  50297. declare module BABYLON {
  50298. /**
  50299. * Manages an XRSession to work with Babylon's engine
  50300. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50301. */
  50302. export class WebXRSessionManager implements IDisposable {
  50303. /** The scene which the session should be created for */
  50304. scene: Scene;
  50305. private _referenceSpace;
  50306. private _rttProvider;
  50307. private _sessionEnded;
  50308. private _xrNavigator;
  50309. private baseLayer;
  50310. /**
  50311. * The base reference space from which the session started. good if you want to reset your
  50312. * reference space
  50313. */
  50314. baseReferenceSpace: XRReferenceSpace;
  50315. /**
  50316. * Current XR frame
  50317. */
  50318. currentFrame: Nullable<XRFrame>;
  50319. /** WebXR timestamp updated every frame */
  50320. currentTimestamp: number;
  50321. /**
  50322. * Used just in case of a failure to initialize an immersive session.
  50323. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50324. */
  50325. defaultHeightCompensation: number;
  50326. /**
  50327. * Fires every time a new xrFrame arrives which can be used to update the camera
  50328. */
  50329. onXRFrameObservable: Observable<XRFrame>;
  50330. /**
  50331. * Fires when the reference space changed
  50332. */
  50333. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50334. /**
  50335. * Fires when the xr session is ended either by the device or manually done
  50336. */
  50337. onXRSessionEnded: Observable<any>;
  50338. /**
  50339. * Fires when the xr session is ended either by the device or manually done
  50340. */
  50341. onXRSessionInit: Observable<XRSession>;
  50342. /**
  50343. * Underlying xr session
  50344. */
  50345. session: XRSession;
  50346. /**
  50347. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50348. * or get the offset the player is currently at.
  50349. */
  50350. viewerReferenceSpace: XRReferenceSpace;
  50351. /**
  50352. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50353. * @param scene The scene which the session should be created for
  50354. */
  50355. constructor(
  50356. /** The scene which the session should be created for */
  50357. scene: Scene);
  50358. /**
  50359. * The current reference space used in this session. This reference space can constantly change!
  50360. * It is mainly used to offset the camera's position.
  50361. */
  50362. get referenceSpace(): XRReferenceSpace;
  50363. /**
  50364. * Set a new reference space and triggers the observable
  50365. */
  50366. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50367. /**
  50368. * Disposes of the session manager
  50369. */
  50370. dispose(): void;
  50371. /**
  50372. * Stops the xrSession and restores the render loop
  50373. * @returns Promise which resolves after it exits XR
  50374. */
  50375. exitXRAsync(): Promise<void>;
  50376. /**
  50377. * Gets the correct render target texture to be rendered this frame for this eye
  50378. * @param eye the eye for which to get the render target
  50379. * @returns the render target for the specified eye
  50380. */
  50381. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50382. /**
  50383. * Creates a WebXRRenderTarget object for the XR session
  50384. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50385. * @param options optional options to provide when creating a new render target
  50386. * @returns a WebXR render target to which the session can render
  50387. */
  50388. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50389. /**
  50390. * Initializes the manager
  50391. * After initialization enterXR can be called to start an XR session
  50392. * @returns Promise which resolves after it is initialized
  50393. */
  50394. initializeAsync(): Promise<void>;
  50395. /**
  50396. * Initializes an xr session
  50397. * @param xrSessionMode mode to initialize
  50398. * @param xrSessionInit defines optional and required values to pass to the session builder
  50399. * @returns a promise which will resolve once the session has been initialized
  50400. */
  50401. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50402. /**
  50403. * Checks if a session would be supported for the creation options specified
  50404. * @param sessionMode session mode to check if supported eg. immersive-vr
  50405. * @returns A Promise that resolves to true if supported and false if not
  50406. */
  50407. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50408. /**
  50409. * Resets the reference space to the one started the session
  50410. */
  50411. resetReferenceSpace(): void;
  50412. /**
  50413. * Starts rendering to the xr layer
  50414. */
  50415. runXRRenderLoop(): void;
  50416. /**
  50417. * Sets the reference space on the xr session
  50418. * @param referenceSpaceType space to set
  50419. * @returns a promise that will resolve once the reference space has been set
  50420. */
  50421. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50422. /**
  50423. * Updates the render state of the session
  50424. * @param state state to set
  50425. * @returns a promise that resolves once the render state has been updated
  50426. */
  50427. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50428. /**
  50429. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50430. * @param sessionMode defines the session to test
  50431. * @returns a promise with boolean as final value
  50432. */
  50433. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50434. private _createRenderTargetTexture;
  50435. }
  50436. }
  50437. declare module BABYLON {
  50438. /**
  50439. * WebXR Camera which holds the views for the xrSession
  50440. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50441. */
  50442. export class WebXRCamera extends FreeCamera {
  50443. private _xrSessionManager;
  50444. private _firstFrame;
  50445. private _referenceQuaternion;
  50446. private _referencedPosition;
  50447. private _xrInvPositionCache;
  50448. private _xrInvQuaternionCache;
  50449. private _trackingState;
  50450. /**
  50451. * Observable raised before camera teleportation
  50452. */
  50453. onBeforeCameraTeleport: Observable<Vector3>;
  50454. /**
  50455. * Observable raised after camera teleportation
  50456. */
  50457. onAfterCameraTeleport: Observable<Vector3>;
  50458. /**
  50459. * Notifies when the camera's tracking state has changed.
  50460. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50461. */
  50462. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50463. /**
  50464. * Should position compensation execute on first frame.
  50465. * This is used when copying the position from a native (non XR) camera
  50466. */
  50467. compensateOnFirstFrame: boolean;
  50468. /**
  50469. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50470. * @param name the name of the camera
  50471. * @param scene the scene to add the camera to
  50472. * @param _xrSessionManager a constructed xr session manager
  50473. */
  50474. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50475. /**
  50476. * Get the current XR tracking state of the camera
  50477. */
  50478. get trackingState(): WebXRTrackingState;
  50479. private _setTrackingState;
  50480. /**
  50481. * Return the user's height, unrelated to the current ground.
  50482. * This will be the y position of this camera, when ground level is 0.
  50483. */
  50484. get realWorldHeight(): number;
  50485. /** @hidden */
  50486. _updateForDualEyeDebugging(): void;
  50487. /**
  50488. * Sets this camera's transformation based on a non-vr camera
  50489. * @param otherCamera the non-vr camera to copy the transformation from
  50490. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50491. */
  50492. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50493. /**
  50494. * Gets the current instance class name ("WebXRCamera").
  50495. * @returns the class name
  50496. */
  50497. getClassName(): string;
  50498. private _rotate180;
  50499. private _updateFromXRSession;
  50500. private _updateNumberOfRigCameras;
  50501. private _updateReferenceSpace;
  50502. private _updateReferenceSpaceOffset;
  50503. }
  50504. }
  50505. declare module BABYLON {
  50506. /**
  50507. * Defining the interface required for a (webxr) feature
  50508. */
  50509. export interface IWebXRFeature extends IDisposable {
  50510. /**
  50511. * Is this feature attached
  50512. */
  50513. attached: boolean;
  50514. /**
  50515. * Should auto-attach be disabled?
  50516. */
  50517. disableAutoAttach: boolean;
  50518. /**
  50519. * Attach the feature to the session
  50520. * Will usually be called by the features manager
  50521. *
  50522. * @param force should attachment be forced (even when already attached)
  50523. * @returns true if successful.
  50524. */
  50525. attach(force?: boolean): boolean;
  50526. /**
  50527. * Detach the feature from the session
  50528. * Will usually be called by the features manager
  50529. *
  50530. * @returns true if successful.
  50531. */
  50532. detach(): boolean;
  50533. /**
  50534. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50535. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50536. *
  50537. * @returns whether or not the feature is compatible in this environment
  50538. */
  50539. isCompatible(): boolean;
  50540. /**
  50541. * Was this feature disposed;
  50542. */
  50543. isDisposed: boolean;
  50544. /**
  50545. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50546. */
  50547. xrNativeFeatureName?: string;
  50548. /**
  50549. * A list of (Babylon WebXR) features this feature depends on
  50550. */
  50551. dependsOn?: string[];
  50552. }
  50553. /**
  50554. * A list of the currently available features without referencing them
  50555. */
  50556. export class WebXRFeatureName {
  50557. /**
  50558. * The name of the anchor system feature
  50559. */
  50560. static readonly ANCHOR_SYSTEM: string;
  50561. /**
  50562. * The name of the background remover feature
  50563. */
  50564. static readonly BACKGROUND_REMOVER: string;
  50565. /**
  50566. * The name of the hit test feature
  50567. */
  50568. static readonly HIT_TEST: string;
  50569. /**
  50570. * physics impostors for xr controllers feature
  50571. */
  50572. static readonly PHYSICS_CONTROLLERS: string;
  50573. /**
  50574. * The name of the plane detection feature
  50575. */
  50576. static readonly PLANE_DETECTION: string;
  50577. /**
  50578. * The name of the pointer selection feature
  50579. */
  50580. static readonly POINTER_SELECTION: string;
  50581. /**
  50582. * The name of the teleportation feature
  50583. */
  50584. static readonly TELEPORTATION: string;
  50585. /**
  50586. * The name of the feature points feature.
  50587. */
  50588. static readonly FEATURE_POINTS: string;
  50589. /**
  50590. * The name of the hand tracking feature.
  50591. */
  50592. static readonly HAND_TRACKING: string;
  50593. }
  50594. /**
  50595. * Defining the constructor of a feature. Used to register the modules.
  50596. */
  50597. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50598. /**
  50599. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50600. * It is mainly used in AR sessions.
  50601. *
  50602. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50603. */
  50604. export class WebXRFeaturesManager implements IDisposable {
  50605. private _xrSessionManager;
  50606. private static readonly _AvailableFeatures;
  50607. private _features;
  50608. /**
  50609. * constructs a new features manages.
  50610. *
  50611. * @param _xrSessionManager an instance of WebXRSessionManager
  50612. */
  50613. constructor(_xrSessionManager: WebXRSessionManager);
  50614. /**
  50615. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50616. * Mainly used internally.
  50617. *
  50618. * @param featureName the name of the feature to register
  50619. * @param constructorFunction the function used to construct the module
  50620. * @param version the (babylon) version of the module
  50621. * @param stable is that a stable version of this module
  50622. */
  50623. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50624. /**
  50625. * Returns a constructor of a specific feature.
  50626. *
  50627. * @param featureName the name of the feature to construct
  50628. * @param version the version of the feature to load
  50629. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50630. * @param options optional options provided to the module.
  50631. * @returns a function that, when called, will return a new instance of this feature
  50632. */
  50633. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50634. /**
  50635. * Can be used to return the list of features currently registered
  50636. *
  50637. * @returns an Array of available features
  50638. */
  50639. static GetAvailableFeatures(): string[];
  50640. /**
  50641. * Gets the versions available for a specific feature
  50642. * @param featureName the name of the feature
  50643. * @returns an array with the available versions
  50644. */
  50645. static GetAvailableVersions(featureName: string): string[];
  50646. /**
  50647. * Return the latest unstable version of this feature
  50648. * @param featureName the name of the feature to search
  50649. * @returns the version number. if not found will return -1
  50650. */
  50651. static GetLatestVersionOfFeature(featureName: string): number;
  50652. /**
  50653. * Return the latest stable version of this feature
  50654. * @param featureName the name of the feature to search
  50655. * @returns the version number. if not found will return -1
  50656. */
  50657. static GetStableVersionOfFeature(featureName: string): number;
  50658. /**
  50659. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50660. * Can be used during a session to start a feature
  50661. * @param featureName the name of feature to attach
  50662. */
  50663. attachFeature(featureName: string): void;
  50664. /**
  50665. * Can be used inside a session or when the session ends to detach a specific feature
  50666. * @param featureName the name of the feature to detach
  50667. */
  50668. detachFeature(featureName: string): void;
  50669. /**
  50670. * Used to disable an already-enabled feature
  50671. * The feature will be disposed and will be recreated once enabled.
  50672. * @param featureName the feature to disable
  50673. * @returns true if disable was successful
  50674. */
  50675. disableFeature(featureName: string | {
  50676. Name: string;
  50677. }): boolean;
  50678. /**
  50679. * dispose this features manager
  50680. */
  50681. dispose(): void;
  50682. /**
  50683. * 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.
  50684. * 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.
  50685. *
  50686. * @param featureName the name of the feature to load or the class of the feature
  50687. * @param version optional version to load. if not provided the latest version will be enabled
  50688. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50689. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50690. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50691. * @returns a new constructed feature or throws an error if feature not found.
  50692. */
  50693. enableFeature(featureName: string | {
  50694. Name: string;
  50695. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50696. /**
  50697. * get the implementation of an enabled feature.
  50698. * @param featureName the name of the feature to load
  50699. * @returns the feature class, if found
  50700. */
  50701. getEnabledFeature(featureName: string): IWebXRFeature;
  50702. /**
  50703. * Get the list of enabled features
  50704. * @returns an array of enabled features
  50705. */
  50706. getEnabledFeatures(): string[];
  50707. /**
  50708. * This function will exten the session creation configuration object with enabled features.
  50709. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50710. * according to the defined "required" variable, provided during enableFeature call
  50711. * @param xrSessionInit the xr Session init object to extend
  50712. *
  50713. * @returns an extended XRSessionInit object
  50714. */
  50715. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50716. }
  50717. }
  50718. declare module BABYLON {
  50719. /**
  50720. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50721. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50722. */
  50723. export class WebXRExperienceHelper implements IDisposable {
  50724. private scene;
  50725. private _nonVRCamera;
  50726. private _originalSceneAutoClear;
  50727. private _supported;
  50728. /**
  50729. * Camera used to render xr content
  50730. */
  50731. camera: WebXRCamera;
  50732. /** A features manager for this xr session */
  50733. featuresManager: WebXRFeaturesManager;
  50734. /**
  50735. * Observers registered here will be triggered after the camera's initial transformation is set
  50736. * This can be used to set a different ground level or an extra rotation.
  50737. *
  50738. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50739. * to the position set after this observable is done executing.
  50740. */
  50741. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50742. /**
  50743. * Fires when the state of the experience helper has changed
  50744. */
  50745. onStateChangedObservable: Observable<WebXRState>;
  50746. /** Session manager used to keep track of xr session */
  50747. sessionManager: WebXRSessionManager;
  50748. /**
  50749. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50750. */
  50751. state: WebXRState;
  50752. /**
  50753. * Creates a WebXRExperienceHelper
  50754. * @param scene The scene the helper should be created in
  50755. */
  50756. private constructor();
  50757. /**
  50758. * Creates the experience helper
  50759. * @param scene the scene to attach the experience helper to
  50760. * @returns a promise for the experience helper
  50761. */
  50762. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50763. /**
  50764. * Disposes of the experience helper
  50765. */
  50766. dispose(): void;
  50767. /**
  50768. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50769. * @param sessionMode options for the XR session
  50770. * @param referenceSpaceType frame of reference of the XR session
  50771. * @param renderTarget the output canvas that will be used to enter XR mode
  50772. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50773. * @returns promise that resolves after xr mode has entered
  50774. */
  50775. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50776. /**
  50777. * Exits XR mode and returns the scene to its original state
  50778. * @returns promise that resolves after xr mode has exited
  50779. */
  50780. exitXRAsync(): Promise<void>;
  50781. private _nonXRToXRCamera;
  50782. private _setState;
  50783. }
  50784. }
  50785. declare module BABYLON {
  50786. /**
  50787. * X-Y values for axes in WebXR
  50788. */
  50789. export interface IWebXRMotionControllerAxesValue {
  50790. /**
  50791. * The value of the x axis
  50792. */
  50793. x: number;
  50794. /**
  50795. * The value of the y-axis
  50796. */
  50797. y: number;
  50798. }
  50799. /**
  50800. * changed / previous values for the values of this component
  50801. */
  50802. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50803. /**
  50804. * current (this frame) value
  50805. */
  50806. current: T;
  50807. /**
  50808. * previous (last change) value
  50809. */
  50810. previous: T;
  50811. }
  50812. /**
  50813. * Represents changes in the component between current frame and last values recorded
  50814. */
  50815. export interface IWebXRMotionControllerComponentChanges {
  50816. /**
  50817. * will be populated with previous and current values if axes changed
  50818. */
  50819. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50820. /**
  50821. * will be populated with previous and current values if pressed changed
  50822. */
  50823. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50824. /**
  50825. * will be populated with previous and current values if touched changed
  50826. */
  50827. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50828. /**
  50829. * will be populated with previous and current values if value changed
  50830. */
  50831. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50832. }
  50833. /**
  50834. * This class represents a single component (for example button or thumbstick) of a motion controller
  50835. */
  50836. export class WebXRControllerComponent implements IDisposable {
  50837. /**
  50838. * the id of this component
  50839. */
  50840. id: string;
  50841. /**
  50842. * the type of the component
  50843. */
  50844. type: MotionControllerComponentType;
  50845. private _buttonIndex;
  50846. private _axesIndices;
  50847. private _axes;
  50848. private _changes;
  50849. private _currentValue;
  50850. private _hasChanges;
  50851. private _pressed;
  50852. private _touched;
  50853. /**
  50854. * button component type
  50855. */
  50856. static BUTTON_TYPE: MotionControllerComponentType;
  50857. /**
  50858. * squeeze component type
  50859. */
  50860. static SQUEEZE_TYPE: MotionControllerComponentType;
  50861. /**
  50862. * Thumbstick component type
  50863. */
  50864. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50865. /**
  50866. * Touchpad component type
  50867. */
  50868. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50869. /**
  50870. * trigger component type
  50871. */
  50872. static TRIGGER_TYPE: MotionControllerComponentType;
  50873. /**
  50874. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50875. * the axes data changes
  50876. */
  50877. onAxisValueChangedObservable: Observable<{
  50878. x: number;
  50879. y: number;
  50880. }>;
  50881. /**
  50882. * Observers registered here will be triggered when the state of a button changes
  50883. * State change is either pressed / touched / value
  50884. */
  50885. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50886. /**
  50887. * Creates a new component for a motion controller.
  50888. * It is created by the motion controller itself
  50889. *
  50890. * @param id the id of this component
  50891. * @param type the type of the component
  50892. * @param _buttonIndex index in the buttons array of the gamepad
  50893. * @param _axesIndices indices of the values in the axes array of the gamepad
  50894. */
  50895. constructor(
  50896. /**
  50897. * the id of this component
  50898. */
  50899. id: string,
  50900. /**
  50901. * the type of the component
  50902. */
  50903. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50904. /**
  50905. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50906. */
  50907. get axes(): IWebXRMotionControllerAxesValue;
  50908. /**
  50909. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50910. */
  50911. get changes(): IWebXRMotionControllerComponentChanges;
  50912. /**
  50913. * Return whether or not the component changed the last frame
  50914. */
  50915. get hasChanges(): boolean;
  50916. /**
  50917. * is the button currently pressed
  50918. */
  50919. get pressed(): boolean;
  50920. /**
  50921. * is the button currently touched
  50922. */
  50923. get touched(): boolean;
  50924. /**
  50925. * Get the current value of this component
  50926. */
  50927. get value(): number;
  50928. /**
  50929. * Dispose this component
  50930. */
  50931. dispose(): void;
  50932. /**
  50933. * Are there axes correlating to this component
  50934. * @return true is axes data is available
  50935. */
  50936. isAxes(): boolean;
  50937. /**
  50938. * Is this component a button (hence - pressable)
  50939. * @returns true if can be pressed
  50940. */
  50941. isButton(): boolean;
  50942. /**
  50943. * update this component using the gamepad object it is in. Called on every frame
  50944. * @param nativeController the native gamepad controller object
  50945. */
  50946. update(nativeController: IMinimalMotionControllerObject): void;
  50947. }
  50948. }
  50949. declare module BABYLON {
  50950. /**
  50951. * Interface used to represent data loading progression
  50952. */
  50953. export interface ISceneLoaderProgressEvent {
  50954. /**
  50955. * Defines if data length to load can be evaluated
  50956. */
  50957. readonly lengthComputable: boolean;
  50958. /**
  50959. * Defines the loaded data length
  50960. */
  50961. readonly loaded: number;
  50962. /**
  50963. * Defines the data length to load
  50964. */
  50965. readonly total: number;
  50966. }
  50967. /**
  50968. * Interface used by SceneLoader plugins to define supported file extensions
  50969. */
  50970. export interface ISceneLoaderPluginExtensions {
  50971. /**
  50972. * Defines the list of supported extensions
  50973. */
  50974. [extension: string]: {
  50975. isBinary: boolean;
  50976. };
  50977. }
  50978. /**
  50979. * Interface used by SceneLoader plugin factory
  50980. */
  50981. export interface ISceneLoaderPluginFactory {
  50982. /**
  50983. * Defines the name of the factory
  50984. */
  50985. name: string;
  50986. /**
  50987. * Function called to create a new plugin
  50988. * @return the new plugin
  50989. */
  50990. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50991. /**
  50992. * The callback that returns true if the data can be directly loaded.
  50993. * @param data string containing the file data
  50994. * @returns if the data can be loaded directly
  50995. */
  50996. canDirectLoad?(data: string): boolean;
  50997. }
  50998. /**
  50999. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51000. */
  51001. export interface ISceneLoaderPluginBase {
  51002. /**
  51003. * The friendly name of this plugin.
  51004. */
  51005. name: string;
  51006. /**
  51007. * The file extensions supported by this plugin.
  51008. */
  51009. extensions: string | ISceneLoaderPluginExtensions;
  51010. /**
  51011. * The callback called when loading from a url.
  51012. * @param scene scene loading this url
  51013. * @param url url to load
  51014. * @param onSuccess callback called when the file successfully loads
  51015. * @param onProgress callback called while file is loading (if the server supports this mode)
  51016. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51017. * @param onError callback called when the file fails to load
  51018. * @returns a file request object
  51019. */
  51020. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51021. /**
  51022. * The callback called when loading from a file object.
  51023. * @param scene scene loading this file
  51024. * @param file defines the file to load
  51025. * @param onSuccess defines the callback to call when data is loaded
  51026. * @param onProgress defines the callback to call during loading process
  51027. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51028. * @param onError defines the callback to call when an error occurs
  51029. * @returns a file request object
  51030. */
  51031. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51032. /**
  51033. * The callback that returns true if the data can be directly loaded.
  51034. * @param data string containing the file data
  51035. * @returns if the data can be loaded directly
  51036. */
  51037. canDirectLoad?(data: string): boolean;
  51038. /**
  51039. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51040. * @param scene scene loading this data
  51041. * @param data string containing the data
  51042. * @returns data to pass to the plugin
  51043. */
  51044. directLoad?(scene: Scene, data: string): any;
  51045. /**
  51046. * The callback that allows custom handling of the root url based on the response url.
  51047. * @param rootUrl the original root url
  51048. * @param responseURL the response url if available
  51049. * @returns the new root url
  51050. */
  51051. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51052. }
  51053. /**
  51054. * Interface used to define a SceneLoader plugin
  51055. */
  51056. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51057. /**
  51058. * Import meshes into a scene.
  51059. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51060. * @param scene The scene to import into
  51061. * @param data The data to import
  51062. * @param rootUrl The root url for scene and resources
  51063. * @param meshes The meshes array to import into
  51064. * @param particleSystems The particle systems array to import into
  51065. * @param skeletons The skeletons array to import into
  51066. * @param onError The callback when import fails
  51067. * @returns True if successful or false otherwise
  51068. */
  51069. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51070. /**
  51071. * Load into a scene.
  51072. * @param scene The scene to load into
  51073. * @param data The data to import
  51074. * @param rootUrl The root url for scene and resources
  51075. * @param onError The callback when import fails
  51076. * @returns True if successful or false otherwise
  51077. */
  51078. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51079. /**
  51080. * Load into an asset container.
  51081. * @param scene The scene to load into
  51082. * @param data The data to import
  51083. * @param rootUrl The root url for scene and resources
  51084. * @param onError The callback when import fails
  51085. * @returns The loaded asset container
  51086. */
  51087. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51088. }
  51089. /**
  51090. * Interface used to define an async SceneLoader plugin
  51091. */
  51092. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51093. /**
  51094. * Import meshes into a scene.
  51095. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51096. * @param scene The scene to import into
  51097. * @param data The data to import
  51098. * @param rootUrl The root url for scene and resources
  51099. * @param onProgress The callback when the load progresses
  51100. * @param fileName Defines the name of the file to load
  51101. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51102. */
  51103. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51104. meshes: AbstractMesh[];
  51105. particleSystems: IParticleSystem[];
  51106. skeletons: Skeleton[];
  51107. animationGroups: AnimationGroup[];
  51108. }>;
  51109. /**
  51110. * Load into a scene.
  51111. * @param scene The scene to load into
  51112. * @param data The data to import
  51113. * @param rootUrl The root url for scene and resources
  51114. * @param onProgress The callback when the load progresses
  51115. * @param fileName Defines the name of the file to load
  51116. * @returns Nothing
  51117. */
  51118. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51119. /**
  51120. * Load into an asset container.
  51121. * @param scene The scene to load into
  51122. * @param data The data to import
  51123. * @param rootUrl The root url for scene and resources
  51124. * @param onProgress The callback when the load progresses
  51125. * @param fileName Defines the name of the file to load
  51126. * @returns The loaded asset container
  51127. */
  51128. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51129. }
  51130. /**
  51131. * Mode that determines how to handle old animation groups before loading new ones.
  51132. */
  51133. export enum SceneLoaderAnimationGroupLoadingMode {
  51134. /**
  51135. * Reset all old animations to initial state then dispose them.
  51136. */
  51137. Clean = 0,
  51138. /**
  51139. * Stop all old animations.
  51140. */
  51141. Stop = 1,
  51142. /**
  51143. * Restart old animations from first frame.
  51144. */
  51145. Sync = 2,
  51146. /**
  51147. * Old animations remains untouched.
  51148. */
  51149. NoSync = 3
  51150. }
  51151. /**
  51152. * Defines a plugin registered by the SceneLoader
  51153. */
  51154. interface IRegisteredPlugin {
  51155. /**
  51156. * Defines the plugin to use
  51157. */
  51158. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51159. /**
  51160. * Defines if the plugin supports binary data
  51161. */
  51162. isBinary: boolean;
  51163. }
  51164. /**
  51165. * Class used to load scene from various file formats using registered plugins
  51166. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51167. */
  51168. export class SceneLoader {
  51169. /**
  51170. * No logging while loading
  51171. */
  51172. static readonly NO_LOGGING: number;
  51173. /**
  51174. * Minimal logging while loading
  51175. */
  51176. static readonly MINIMAL_LOGGING: number;
  51177. /**
  51178. * Summary logging while loading
  51179. */
  51180. static readonly SUMMARY_LOGGING: number;
  51181. /**
  51182. * Detailled logging while loading
  51183. */
  51184. static readonly DETAILED_LOGGING: number;
  51185. /**
  51186. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51187. */
  51188. static get ForceFullSceneLoadingForIncremental(): boolean;
  51189. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51190. /**
  51191. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51192. */
  51193. static get ShowLoadingScreen(): boolean;
  51194. static set ShowLoadingScreen(value: boolean);
  51195. /**
  51196. * Defines the current logging level (while loading the scene)
  51197. * @ignorenaming
  51198. */
  51199. static get loggingLevel(): number;
  51200. static set loggingLevel(value: number);
  51201. /**
  51202. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51203. */
  51204. static get CleanBoneMatrixWeights(): boolean;
  51205. static set CleanBoneMatrixWeights(value: boolean);
  51206. /**
  51207. * Event raised when a plugin is used to load a scene
  51208. */
  51209. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51210. private static _registeredPlugins;
  51211. private static _showingLoadingScreen;
  51212. /**
  51213. * Gets the default plugin (used to load Babylon files)
  51214. * @returns the .babylon plugin
  51215. */
  51216. static GetDefaultPlugin(): IRegisteredPlugin;
  51217. private static _GetPluginForExtension;
  51218. private static _GetPluginForDirectLoad;
  51219. private static _GetPluginForFilename;
  51220. private static _GetDirectLoad;
  51221. private static _LoadData;
  51222. private static _GetFileInfo;
  51223. /**
  51224. * Gets a plugin that can load the given extension
  51225. * @param extension defines the extension to load
  51226. * @returns a plugin or null if none works
  51227. */
  51228. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51229. /**
  51230. * Gets a boolean indicating that the given extension can be loaded
  51231. * @param extension defines the extension to load
  51232. * @returns true if the extension is supported
  51233. */
  51234. static IsPluginForExtensionAvailable(extension: string): boolean;
  51235. /**
  51236. * Adds a new plugin to the list of registered plugins
  51237. * @param plugin defines the plugin to add
  51238. */
  51239. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51240. /**
  51241. * Import meshes into a scene
  51242. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 the instance of BABYLON.Scene to append to
  51246. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51247. * @param onProgress a callback with a progress event for each file being loaded
  51248. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51249. * @param pluginExtension the extension used to determine the plugin
  51250. * @returns The loaded plugin
  51251. */
  51252. static 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>;
  51253. /**
  51254. * Import meshes into a scene
  51255. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51256. * @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)
  51257. * @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)
  51258. * @param scene the instance of BABYLON.Scene to append to
  51259. * @param onProgress a callback with a progress event for each file being loaded
  51260. * @param pluginExtension the extension used to determine the plugin
  51261. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51262. */
  51263. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51264. meshes: AbstractMesh[];
  51265. particleSystems: IParticleSystem[];
  51266. skeletons: Skeleton[];
  51267. animationGroups: AnimationGroup[];
  51268. }>;
  51269. /**
  51270. * Load a scene
  51271. * @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)
  51272. * @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)
  51273. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51274. * @param onSuccess a callback with the scene when import succeeds
  51275. * @param onProgress a callback with a progress event for each file being loaded
  51276. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51277. * @param pluginExtension the extension used to determine the plugin
  51278. * @returns The loaded plugin
  51279. */
  51280. 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>;
  51281. /**
  51282. * Load a scene
  51283. * @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)
  51284. * @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)
  51285. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51286. * @param onProgress a callback with a progress event for each file being loaded
  51287. * @param pluginExtension the extension used to determine the plugin
  51288. * @returns The loaded scene
  51289. */
  51290. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51291. /**
  51292. * Append a scene
  51293. * @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)
  51294. * @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)
  51295. * @param scene is the instance of BABYLON.Scene to append to
  51296. * @param onSuccess a callback with the scene when import succeeds
  51297. * @param onProgress a callback with a progress event for each file being loaded
  51298. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51299. * @param pluginExtension the extension used to determine the plugin
  51300. * @returns The loaded plugin
  51301. */
  51302. 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>;
  51303. /**
  51304. * Append a scene
  51305. * @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)
  51306. * @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)
  51307. * @param scene is the instance of BABYLON.Scene to append to
  51308. * @param onProgress a callback with a progress event for each file being loaded
  51309. * @param pluginExtension the extension used to determine the plugin
  51310. * @returns The given scene
  51311. */
  51312. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51313. /**
  51314. * Load a scene into an asset container
  51315. * @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)
  51316. * @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)
  51317. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51318. * @param onSuccess a callback with the scene when import succeeds
  51319. * @param onProgress a callback with a progress event for each file being loaded
  51320. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51321. * @param pluginExtension the extension used to determine the plugin
  51322. * @returns The loaded plugin
  51323. */
  51324. 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>;
  51325. /**
  51326. * Load a scene into an asset container
  51327. * @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)
  51328. * @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)
  51329. * @param scene is the instance of Scene to append to
  51330. * @param onProgress a callback with a progress event for each file being loaded
  51331. * @param pluginExtension the extension used to determine the plugin
  51332. * @returns The loaded asset container
  51333. */
  51334. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51335. /**
  51336. * Import animations from a file into a scene
  51337. * @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)
  51338. * @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)
  51339. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51340. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51341. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51342. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51343. * @param onSuccess a callback with the scene when import succeeds
  51344. * @param onProgress a callback with a progress event for each file being loaded
  51345. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51346. * @param pluginExtension the extension used to determine the plugin
  51347. */
  51348. 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;
  51349. /**
  51350. * Import animations from a file into a scene
  51351. * @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)
  51352. * @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)
  51353. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51354. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51355. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51356. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51357. * @param onSuccess a callback with the scene when import succeeds
  51358. * @param onProgress a callback with a progress event for each file being loaded
  51359. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51360. * @param pluginExtension the extension used to determine the plugin
  51361. * @returns the updated scene with imported animations
  51362. */
  51363. 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>;
  51364. }
  51365. }
  51366. declare module BABYLON {
  51367. /**
  51368. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51369. */
  51370. export type MotionControllerHandedness = "none" | "left" | "right";
  51371. /**
  51372. * The type of components available in motion controllers.
  51373. * This is not the name of the component.
  51374. */
  51375. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51376. /**
  51377. * The state of a controller component
  51378. */
  51379. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51380. /**
  51381. * The schema of motion controller layout.
  51382. * No object will be initialized using this interface
  51383. * This is used just to define the profile.
  51384. */
  51385. export interface IMotionControllerLayout {
  51386. /**
  51387. * Path to load the assets. Usually relative to the base path
  51388. */
  51389. assetPath: string;
  51390. /**
  51391. * Available components (unsorted)
  51392. */
  51393. components: {
  51394. /**
  51395. * A map of component Ids
  51396. */
  51397. [componentId: string]: {
  51398. /**
  51399. * The type of input the component outputs
  51400. */
  51401. type: MotionControllerComponentType;
  51402. /**
  51403. * The indices of this component in the gamepad object
  51404. */
  51405. gamepadIndices: {
  51406. /**
  51407. * Index of button
  51408. */
  51409. button?: number;
  51410. /**
  51411. * If available, index of x-axis
  51412. */
  51413. xAxis?: number;
  51414. /**
  51415. * If available, index of y-axis
  51416. */
  51417. yAxis?: number;
  51418. };
  51419. /**
  51420. * The mesh's root node name
  51421. */
  51422. rootNodeName: string;
  51423. /**
  51424. * Animation definitions for this model
  51425. */
  51426. visualResponses: {
  51427. [stateKey: string]: {
  51428. /**
  51429. * What property will be animated
  51430. */
  51431. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51432. /**
  51433. * What states influence this visual response
  51434. */
  51435. states: MotionControllerComponentStateType[];
  51436. /**
  51437. * Type of animation - movement or visibility
  51438. */
  51439. valueNodeProperty: "transform" | "visibility";
  51440. /**
  51441. * Base node name to move. Its position will be calculated according to the min and max nodes
  51442. */
  51443. valueNodeName?: string;
  51444. /**
  51445. * Minimum movement node
  51446. */
  51447. minNodeName?: string;
  51448. /**
  51449. * Max movement node
  51450. */
  51451. maxNodeName?: string;
  51452. };
  51453. };
  51454. /**
  51455. * If touch enabled, what is the name of node to display user feedback
  51456. */
  51457. touchPointNodeName?: string;
  51458. };
  51459. };
  51460. /**
  51461. * Is it xr standard mapping or not
  51462. */
  51463. gamepadMapping: "" | "xr-standard";
  51464. /**
  51465. * Base root node of this entire model
  51466. */
  51467. rootNodeName: string;
  51468. /**
  51469. * Defines the main button component id
  51470. */
  51471. selectComponentId: string;
  51472. }
  51473. /**
  51474. * A definition for the layout map in the input profile
  51475. */
  51476. export interface IMotionControllerLayoutMap {
  51477. /**
  51478. * Layouts with handedness type as a key
  51479. */
  51480. [handedness: string]: IMotionControllerLayout;
  51481. }
  51482. /**
  51483. * The XR Input profile schema
  51484. * Profiles can be found here:
  51485. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51486. */
  51487. export interface IMotionControllerProfile {
  51488. /**
  51489. * fallback profiles for this profileId
  51490. */
  51491. fallbackProfileIds: string[];
  51492. /**
  51493. * The layout map, with handedness as key
  51494. */
  51495. layouts: IMotionControllerLayoutMap;
  51496. /**
  51497. * The id of this profile
  51498. * correlates to the profile(s) in the xrInput.profiles array
  51499. */
  51500. profileId: string;
  51501. }
  51502. /**
  51503. * A helper-interface for the 3 meshes needed for controller button animation
  51504. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51505. */
  51506. export interface IMotionControllerButtonMeshMap {
  51507. /**
  51508. * the mesh that defines the pressed value mesh position.
  51509. * This is used to find the max-position of this button
  51510. */
  51511. pressedMesh: AbstractMesh;
  51512. /**
  51513. * the mesh that defines the unpressed value mesh position.
  51514. * This is used to find the min (or initial) position of this button
  51515. */
  51516. unpressedMesh: AbstractMesh;
  51517. /**
  51518. * The mesh that will be changed when value changes
  51519. */
  51520. valueMesh: AbstractMesh;
  51521. }
  51522. /**
  51523. * A helper-interface for the 3 meshes needed for controller axis animation.
  51524. * This will be expanded when touchpad animations are fully supported
  51525. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51526. */
  51527. export interface IMotionControllerMeshMap {
  51528. /**
  51529. * the mesh that defines the maximum value mesh position.
  51530. */
  51531. maxMesh?: AbstractMesh;
  51532. /**
  51533. * the mesh that defines the minimum value mesh position.
  51534. */
  51535. minMesh?: AbstractMesh;
  51536. /**
  51537. * The mesh that will be changed when axis value changes
  51538. */
  51539. valueMesh?: AbstractMesh;
  51540. }
  51541. /**
  51542. * The elements needed for change-detection of the gamepad objects in motion controllers
  51543. */
  51544. export interface IMinimalMotionControllerObject {
  51545. /**
  51546. * Available axes of this controller
  51547. */
  51548. axes: number[];
  51549. /**
  51550. * An array of available buttons
  51551. */
  51552. buttons: Array<{
  51553. /**
  51554. * Value of the button/trigger
  51555. */
  51556. value: number;
  51557. /**
  51558. * If the button/trigger is currently touched
  51559. */
  51560. touched: boolean;
  51561. /**
  51562. * If the button/trigger is currently pressed
  51563. */
  51564. pressed: boolean;
  51565. }>;
  51566. /**
  51567. * EXPERIMENTAL haptic support.
  51568. */
  51569. hapticActuators?: Array<{
  51570. pulse: (value: number, duration: number) => Promise<boolean>;
  51571. }>;
  51572. }
  51573. /**
  51574. * An Abstract Motion controller
  51575. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51576. * Each component has an observable to check for changes in value and state
  51577. */
  51578. export abstract class WebXRAbstractMotionController implements IDisposable {
  51579. protected scene: Scene;
  51580. protected layout: IMotionControllerLayout;
  51581. /**
  51582. * The gamepad object correlating to this controller
  51583. */
  51584. gamepadObject: IMinimalMotionControllerObject;
  51585. /**
  51586. * handedness (left/right/none) of this controller
  51587. */
  51588. handedness: MotionControllerHandedness;
  51589. private _initComponent;
  51590. private _modelReady;
  51591. /**
  51592. * A map of components (WebXRControllerComponent) in this motion controller
  51593. * Components have a ComponentType and can also have both button and axis definitions
  51594. */
  51595. readonly components: {
  51596. [id: string]: WebXRControllerComponent;
  51597. };
  51598. /**
  51599. * Disable the model's animation. Can be set at any time.
  51600. */
  51601. disableAnimation: boolean;
  51602. /**
  51603. * Observers registered here will be triggered when the model of this controller is done loading
  51604. */
  51605. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51606. /**
  51607. * The profile id of this motion controller
  51608. */
  51609. abstract profileId: string;
  51610. /**
  51611. * The root mesh of the model. It is null if the model was not yet initialized
  51612. */
  51613. rootMesh: Nullable<AbstractMesh>;
  51614. /**
  51615. * constructs a new abstract motion controller
  51616. * @param scene the scene to which the model of the controller will be added
  51617. * @param layout The profile layout to load
  51618. * @param gamepadObject The gamepad object correlating to this controller
  51619. * @param handedness handedness (left/right/none) of this controller
  51620. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51621. */
  51622. constructor(scene: Scene, layout: IMotionControllerLayout,
  51623. /**
  51624. * The gamepad object correlating to this controller
  51625. */
  51626. gamepadObject: IMinimalMotionControllerObject,
  51627. /**
  51628. * handedness (left/right/none) of this controller
  51629. */
  51630. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51631. /**
  51632. * Dispose this controller, the model mesh and all its components
  51633. */
  51634. dispose(): void;
  51635. /**
  51636. * Returns all components of specific type
  51637. * @param type the type to search for
  51638. * @return an array of components with this type
  51639. */
  51640. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51641. /**
  51642. * get a component based an its component id as defined in layout.components
  51643. * @param id the id of the component
  51644. * @returns the component correlates to the id or undefined if not found
  51645. */
  51646. getComponent(id: string): WebXRControllerComponent;
  51647. /**
  51648. * Get the list of components available in this motion controller
  51649. * @returns an array of strings correlating to available components
  51650. */
  51651. getComponentIds(): string[];
  51652. /**
  51653. * Get the first component of specific type
  51654. * @param type type of component to find
  51655. * @return a controller component or null if not found
  51656. */
  51657. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51658. /**
  51659. * Get the main (Select) component of this controller as defined in the layout
  51660. * @returns the main component of this controller
  51661. */
  51662. getMainComponent(): WebXRControllerComponent;
  51663. /**
  51664. * Loads the model correlating to this controller
  51665. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51666. * @returns A promise fulfilled with the result of the model loading
  51667. */
  51668. loadModel(): Promise<boolean>;
  51669. /**
  51670. * Update this model using the current XRFrame
  51671. * @param xrFrame the current xr frame to use and update the model
  51672. */
  51673. updateFromXRFrame(xrFrame: XRFrame): void;
  51674. /**
  51675. * Backwards compatibility due to a deeply-integrated typo
  51676. */
  51677. get handness(): XREye;
  51678. /**
  51679. * Pulse (vibrate) this controller
  51680. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51681. * Consecutive calls to this function will cancel the last pulse call
  51682. *
  51683. * @param value the strength of the pulse in 0.0...1.0 range
  51684. * @param duration Duration of the pulse in milliseconds
  51685. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51686. * @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
  51687. */
  51688. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51689. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51690. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51691. /**
  51692. * Moves the axis on the controller mesh based on its current state
  51693. * @param axis the index of the axis
  51694. * @param axisValue the value of the axis which determines the meshes new position
  51695. * @hidden
  51696. */
  51697. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51698. /**
  51699. * Update the model itself with the current frame data
  51700. * @param xrFrame the frame to use for updating the model mesh
  51701. */
  51702. protected updateModel(xrFrame: XRFrame): void;
  51703. /**
  51704. * Get the filename and path for this controller's model
  51705. * @returns a map of filename and path
  51706. */
  51707. protected abstract _getFilenameAndPath(): {
  51708. filename: string;
  51709. path: string;
  51710. };
  51711. /**
  51712. * This function is called before the mesh is loaded. It checks for loading constraints.
  51713. * For example, this function can check if the GLB loader is available
  51714. * If this function returns false, the generic controller will be loaded instead
  51715. * @returns Is the client ready to load the mesh
  51716. */
  51717. protected abstract _getModelLoadingConstraints(): boolean;
  51718. /**
  51719. * This function will be called after the model was successfully loaded and can be used
  51720. * for mesh transformations before it is available for the user
  51721. * @param meshes the loaded meshes
  51722. */
  51723. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51724. /**
  51725. * Set the root mesh for this controller. Important for the WebXR controller class
  51726. * @param meshes the loaded meshes
  51727. */
  51728. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51729. /**
  51730. * A function executed each frame that updates the mesh (if needed)
  51731. * @param xrFrame the current xrFrame
  51732. */
  51733. protected abstract _updateModel(xrFrame: XRFrame): void;
  51734. private _getGenericFilenameAndPath;
  51735. private _getGenericParentMesh;
  51736. }
  51737. }
  51738. declare module BABYLON {
  51739. /**
  51740. * A generic trigger-only motion controller for WebXR
  51741. */
  51742. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51743. /**
  51744. * Static version of the profile id of this controller
  51745. */
  51746. static ProfileId: string;
  51747. profileId: string;
  51748. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51749. protected _getFilenameAndPath(): {
  51750. filename: string;
  51751. path: string;
  51752. };
  51753. protected _getModelLoadingConstraints(): boolean;
  51754. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51755. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51756. protected _updateModel(): void;
  51757. }
  51758. }
  51759. declare module BABYLON {
  51760. /**
  51761. * Class containing static functions to help procedurally build meshes
  51762. */
  51763. export class SphereBuilder {
  51764. /**
  51765. * Creates a sphere mesh
  51766. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51767. * * 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`)
  51768. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51769. * * 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
  51770. * * 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)
  51771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51772. * * 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
  51773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51774. * @param name defines the name of the mesh
  51775. * @param options defines the options used to create the mesh
  51776. * @param scene defines the hosting scene
  51777. * @returns the sphere mesh
  51778. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51779. */
  51780. static CreateSphere(name: string, options: {
  51781. segments?: number;
  51782. diameter?: number;
  51783. diameterX?: number;
  51784. diameterY?: number;
  51785. diameterZ?: number;
  51786. arc?: number;
  51787. slice?: number;
  51788. sideOrientation?: number;
  51789. frontUVs?: Vector4;
  51790. backUVs?: Vector4;
  51791. updatable?: boolean;
  51792. }, scene?: Nullable<Scene>): Mesh;
  51793. }
  51794. }
  51795. declare module BABYLON {
  51796. /**
  51797. * A profiled motion controller has its profile loaded from an online repository.
  51798. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51799. */
  51800. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51801. private _repositoryUrl;
  51802. private _buttonMeshMapping;
  51803. private _touchDots;
  51804. /**
  51805. * The profile ID of this controller. Will be populated when the controller initializes.
  51806. */
  51807. profileId: string;
  51808. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51809. dispose(): void;
  51810. protected _getFilenameAndPath(): {
  51811. filename: string;
  51812. path: string;
  51813. };
  51814. protected _getModelLoadingConstraints(): boolean;
  51815. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51816. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51817. protected _updateModel(_xrFrame: XRFrame): void;
  51818. }
  51819. }
  51820. declare module BABYLON {
  51821. /**
  51822. * A construction function type to create a new controller based on an xrInput object
  51823. */
  51824. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51825. /**
  51826. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51827. *
  51828. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51829. * it should be replaced with auto-loaded controllers.
  51830. *
  51831. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51832. */
  51833. export class WebXRMotionControllerManager {
  51834. private static _AvailableControllers;
  51835. private static _Fallbacks;
  51836. private static _ProfileLoadingPromises;
  51837. private static _ProfilesList;
  51838. /**
  51839. * The base URL of the online controller repository. Can be changed at any time.
  51840. */
  51841. static BaseRepositoryUrl: string;
  51842. /**
  51843. * Which repository gets priority - local or online
  51844. */
  51845. static PrioritizeOnlineRepository: boolean;
  51846. /**
  51847. * Use the online repository, or use only locally-defined controllers
  51848. */
  51849. static UseOnlineRepository: boolean;
  51850. /**
  51851. * Clear the cache used for profile loading and reload when requested again
  51852. */
  51853. static ClearProfilesCache(): void;
  51854. /**
  51855. * Register the default fallbacks.
  51856. * This function is called automatically when this file is imported.
  51857. */
  51858. static DefaultFallbacks(): void;
  51859. /**
  51860. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51861. * @param profileId the profile to which a fallback needs to be found
  51862. * @return an array with corresponding fallback profiles
  51863. */
  51864. static FindFallbackWithProfileId(profileId: string): string[];
  51865. /**
  51866. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51867. * The order of search:
  51868. *
  51869. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51870. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51871. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51872. * 4) return the generic trigger controller if none were found
  51873. *
  51874. * @param xrInput the xrInput to which a new controller is initialized
  51875. * @param scene the scene to which the model will be added
  51876. * @param forceProfile force a certain profile for this controller
  51877. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51878. */
  51879. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51880. /**
  51881. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51882. *
  51883. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51884. *
  51885. * @param type the profile type to register
  51886. * @param constructFunction the function to be called when loading this profile
  51887. */
  51888. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51889. /**
  51890. * Register a fallback to a specific profile.
  51891. * @param profileId the profileId that will receive the fallbacks
  51892. * @param fallbacks A list of fallback profiles
  51893. */
  51894. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51895. /**
  51896. * Will update the list of profiles available in the repository
  51897. * @return a promise that resolves to a map of profiles available online
  51898. */
  51899. static UpdateProfilesList(): Promise<{
  51900. [profile: string]: string;
  51901. }>;
  51902. private static _LoadProfileFromRepository;
  51903. private static _LoadProfilesFromAvailableControllers;
  51904. }
  51905. }
  51906. declare module BABYLON {
  51907. /**
  51908. * Configuration options for the WebXR controller creation
  51909. */
  51910. export interface IWebXRControllerOptions {
  51911. /**
  51912. * Should the controller mesh be animated when a user interacts with it
  51913. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51914. */
  51915. disableMotionControllerAnimation?: boolean;
  51916. /**
  51917. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51918. */
  51919. doNotLoadControllerMesh?: boolean;
  51920. /**
  51921. * Force a specific controller type for this controller.
  51922. * This can be used when creating your own profile or when testing different controllers
  51923. */
  51924. forceControllerProfile?: string;
  51925. /**
  51926. * Defines a rendering group ID for meshes that will be loaded.
  51927. * This is for the default controllers only.
  51928. */
  51929. renderingGroupId?: number;
  51930. }
  51931. /**
  51932. * Represents an XR controller
  51933. */
  51934. export class WebXRInputSource {
  51935. private _scene;
  51936. /** The underlying input source for the controller */
  51937. inputSource: XRInputSource;
  51938. private _options;
  51939. private _tmpVector;
  51940. private _uniqueId;
  51941. private _disposed;
  51942. /**
  51943. * 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
  51944. */
  51945. grip?: AbstractMesh;
  51946. /**
  51947. * If available, this is the gamepad object related to this controller.
  51948. * Using this object it is possible to get click events and trackpad changes of the
  51949. * webxr controller that is currently being used.
  51950. */
  51951. motionController?: WebXRAbstractMotionController;
  51952. /**
  51953. * Event that fires when the controller is removed/disposed.
  51954. * The object provided as event data is this controller, after associated assets were disposed.
  51955. * uniqueId is still available.
  51956. */
  51957. onDisposeObservable: Observable<WebXRInputSource>;
  51958. /**
  51959. * Will be triggered when the mesh associated with the motion controller is done loading.
  51960. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51961. * A shortened version of controller -> motion controller -> on mesh loaded.
  51962. */
  51963. onMeshLoadedObservable: Observable<AbstractMesh>;
  51964. /**
  51965. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51966. */
  51967. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51968. /**
  51969. * Pointer which can be used to select objects or attach a visible laser to
  51970. */
  51971. pointer: AbstractMesh;
  51972. /**
  51973. * Creates the input source object
  51974. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51975. * @param _scene the scene which the controller should be associated to
  51976. * @param inputSource the underlying input source for the controller
  51977. * @param _options options for this controller creation
  51978. */
  51979. constructor(_scene: Scene,
  51980. /** The underlying input source for the controller */
  51981. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51982. /**
  51983. * Get this controllers unique id
  51984. */
  51985. get uniqueId(): string;
  51986. /**
  51987. * Disposes of the object
  51988. */
  51989. dispose(): void;
  51990. /**
  51991. * Gets a world space ray coming from the pointer or grip
  51992. * @param result the resulting ray
  51993. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51994. */
  51995. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51996. /**
  51997. * Updates the controller pose based on the given XRFrame
  51998. * @param xrFrame xr frame to update the pose with
  51999. * @param referenceSpace reference space to use
  52000. */
  52001. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52002. }
  52003. }
  52004. declare module BABYLON {
  52005. /**
  52006. * The schema for initialization options of the XR Input class
  52007. */
  52008. export interface IWebXRInputOptions {
  52009. /**
  52010. * If set to true no model will be automatically loaded
  52011. */
  52012. doNotLoadControllerMeshes?: boolean;
  52013. /**
  52014. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52015. * If not found, the xr input profile data will be used.
  52016. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52017. */
  52018. forceInputProfile?: string;
  52019. /**
  52020. * Do not send a request to the controller repository to load the profile.
  52021. *
  52022. * Instead, use the controllers available in babylon itself.
  52023. */
  52024. disableOnlineControllerRepository?: boolean;
  52025. /**
  52026. * A custom URL for the controllers repository
  52027. */
  52028. customControllersRepositoryURL?: string;
  52029. /**
  52030. * Should the controller model's components not move according to the user input
  52031. */
  52032. disableControllerAnimation?: boolean;
  52033. /**
  52034. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52035. */
  52036. controllerOptions?: IWebXRControllerOptions;
  52037. }
  52038. /**
  52039. * XR input used to track XR inputs such as controllers/rays
  52040. */
  52041. export class WebXRInput implements IDisposable {
  52042. /**
  52043. * the xr session manager for this session
  52044. */
  52045. xrSessionManager: WebXRSessionManager;
  52046. /**
  52047. * the WebXR camera for this session. Mainly used for teleportation
  52048. */
  52049. xrCamera: WebXRCamera;
  52050. private readonly options;
  52051. /**
  52052. * XR controllers being tracked
  52053. */
  52054. controllers: Array<WebXRInputSource>;
  52055. private _frameObserver;
  52056. private _sessionEndedObserver;
  52057. private _sessionInitObserver;
  52058. /**
  52059. * Event when a controller has been connected/added
  52060. */
  52061. onControllerAddedObservable: Observable<WebXRInputSource>;
  52062. /**
  52063. * Event when a controller has been removed/disconnected
  52064. */
  52065. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52066. /**
  52067. * Initializes the WebXRInput
  52068. * @param xrSessionManager the xr session manager for this session
  52069. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52070. * @param options = initialization options for this xr input
  52071. */
  52072. constructor(
  52073. /**
  52074. * the xr session manager for this session
  52075. */
  52076. xrSessionManager: WebXRSessionManager,
  52077. /**
  52078. * the WebXR camera for this session. Mainly used for teleportation
  52079. */
  52080. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52081. private _onInputSourcesChange;
  52082. private _addAndRemoveControllers;
  52083. /**
  52084. * Disposes of the object
  52085. */
  52086. dispose(): void;
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. /**
  52091. * This is the base class for all WebXR features.
  52092. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52093. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52094. */
  52095. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52096. protected _xrSessionManager: WebXRSessionManager;
  52097. private _attached;
  52098. private _removeOnDetach;
  52099. /**
  52100. * Is this feature disposed?
  52101. */
  52102. isDisposed: boolean;
  52103. /**
  52104. * Should auto-attach be disabled?
  52105. */
  52106. disableAutoAttach: boolean;
  52107. /**
  52108. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52109. */
  52110. xrNativeFeatureName: string;
  52111. /**
  52112. * Construct a new (abstract) WebXR feature
  52113. * @param _xrSessionManager the xr session manager for this feature
  52114. */
  52115. constructor(_xrSessionManager: WebXRSessionManager);
  52116. /**
  52117. * Is this feature attached
  52118. */
  52119. get attached(): boolean;
  52120. /**
  52121. * attach this feature
  52122. *
  52123. * @param force should attachment be forced (even when already attached)
  52124. * @returns true if successful, false is failed or already attached
  52125. */
  52126. attach(force?: boolean): boolean;
  52127. /**
  52128. * detach this feature.
  52129. *
  52130. * @returns true if successful, false if failed or already detached
  52131. */
  52132. detach(): boolean;
  52133. /**
  52134. * Dispose this feature and all of the resources attached
  52135. */
  52136. dispose(): void;
  52137. /**
  52138. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52139. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52140. *
  52141. * @returns whether or not the feature is compatible in this environment
  52142. */
  52143. isCompatible(): boolean;
  52144. /**
  52145. * This is used to register callbacks that will automatically be removed when detach is called.
  52146. * @param observable the observable to which the observer will be attached
  52147. * @param callback the callback to register
  52148. */
  52149. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52150. /**
  52151. * Code in this function will be executed on each xrFrame received from the browser.
  52152. * This function will not execute after the feature is detached.
  52153. * @param _xrFrame the current frame
  52154. */
  52155. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52156. }
  52157. }
  52158. declare module BABYLON {
  52159. /**
  52160. * Renders a layer on top of an existing scene
  52161. */
  52162. export class UtilityLayerRenderer implements IDisposable {
  52163. /** the original scene that will be rendered on top of */
  52164. originalScene: Scene;
  52165. private _pointerCaptures;
  52166. private _lastPointerEvents;
  52167. private static _DefaultUtilityLayer;
  52168. private static _DefaultKeepDepthUtilityLayer;
  52169. private _sharedGizmoLight;
  52170. private _renderCamera;
  52171. /**
  52172. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52173. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52174. * @returns the camera that is used when rendering the utility layer
  52175. */
  52176. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52177. /**
  52178. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52179. * @param cam the camera that should be used when rendering the utility layer
  52180. */
  52181. setRenderCamera(cam: Nullable<Camera>): void;
  52182. /**
  52183. * @hidden
  52184. * Light which used by gizmos to get light shading
  52185. */
  52186. _getSharedGizmoLight(): HemisphericLight;
  52187. /**
  52188. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52189. */
  52190. pickUtilitySceneFirst: boolean;
  52191. /**
  52192. * 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)
  52193. */
  52194. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52195. /**
  52196. * 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)
  52197. */
  52198. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52199. /**
  52200. * The scene that is rendered on top of the original scene
  52201. */
  52202. utilityLayerScene: Scene;
  52203. /**
  52204. * If the utility layer should automatically be rendered on top of existing scene
  52205. */
  52206. shouldRender: boolean;
  52207. /**
  52208. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52209. */
  52210. onlyCheckPointerDownEvents: boolean;
  52211. /**
  52212. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52213. */
  52214. processAllEvents: boolean;
  52215. /**
  52216. * Observable raised when the pointer move from the utility layer scene to the main scene
  52217. */
  52218. onPointerOutObservable: Observable<number>;
  52219. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52220. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52221. private _afterRenderObserver;
  52222. private _sceneDisposeObserver;
  52223. private _originalPointerObserver;
  52224. /**
  52225. * Instantiates a UtilityLayerRenderer
  52226. * @param originalScene the original scene that will be rendered on top of
  52227. * @param handleEvents boolean indicating if the utility layer should handle events
  52228. */
  52229. constructor(
  52230. /** the original scene that will be rendered on top of */
  52231. originalScene: Scene, handleEvents?: boolean);
  52232. private _notifyObservers;
  52233. /**
  52234. * Renders the utility layers scene on top of the original scene
  52235. */
  52236. render(): void;
  52237. /**
  52238. * Disposes of the renderer
  52239. */
  52240. dispose(): void;
  52241. private _updateCamera;
  52242. }
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * Options interface for the pointer selection module
  52247. */
  52248. export interface IWebXRControllerPointerSelectionOptions {
  52249. /**
  52250. * if provided, this scene will be used to render meshes.
  52251. */
  52252. customUtilityLayerScene?: Scene;
  52253. /**
  52254. * 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)
  52255. * If not disabled, the last picked point will be used to execute a pointer up event
  52256. * If disabled, pointer up event will be triggered right after the pointer down event.
  52257. * Used in screen and gaze target ray mode only
  52258. */
  52259. disablePointerUpOnTouchOut: boolean;
  52260. /**
  52261. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52262. */
  52263. forceGazeMode: boolean;
  52264. /**
  52265. * 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
  52266. * to start a new countdown to the pointer down event.
  52267. * Defaults to 1.
  52268. */
  52269. gazeModePointerMovedFactor?: number;
  52270. /**
  52271. * Different button type to use instead of the main component
  52272. */
  52273. overrideButtonId?: string;
  52274. /**
  52275. * use this rendering group id for the meshes (optional)
  52276. */
  52277. renderingGroupId?: number;
  52278. /**
  52279. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52280. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52281. * 3000 means 3 seconds between pointing at something and selecting it
  52282. */
  52283. timeToSelect?: number;
  52284. /**
  52285. * Should meshes created here be added to a utility layer or the main scene
  52286. */
  52287. useUtilityLayer?: boolean;
  52288. /**
  52289. * Optional WebXR camera to be used for gaze selection
  52290. */
  52291. gazeCamera?: WebXRCamera;
  52292. /**
  52293. * the xr input to use with this pointer selection
  52294. */
  52295. xrInput: WebXRInput;
  52296. /**
  52297. * Should the scene pointerX and pointerY update be disabled
  52298. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52299. * Disable in VR, if not needed.
  52300. * The first rig camera (left eye) will be used to calculate the projection
  52301. */
  52302. disableScenePointerVectorUpdate: boolean;
  52303. /**
  52304. * Enable pointer selection on all controllers instead of switching between them
  52305. */
  52306. enablePointerSelectionOnAllControllers?: boolean;
  52307. /**
  52308. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52309. * If switch is enabled, it will still allow the user to switch between the different controllers
  52310. */
  52311. preferredHandedness?: XRHandedness;
  52312. /**
  52313. * Disable switching the pointer selection from one controller to the other.
  52314. * 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
  52315. */
  52316. disableSwitchOnClick?: boolean;
  52317. /**
  52318. * The maximum distance of the pointer selection feature. Defaults to 100.
  52319. */
  52320. maxPointerDistance?: number;
  52321. }
  52322. /**
  52323. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52324. */
  52325. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52326. private readonly _options;
  52327. private static _idCounter;
  52328. private _attachController;
  52329. private _controllers;
  52330. private _scene;
  52331. private _tmpVectorForPickCompare;
  52332. private _attachedController;
  52333. /**
  52334. * The module's name
  52335. */
  52336. static readonly Name: string;
  52337. /**
  52338. * The (Babylon) version of this module.
  52339. * This is an integer representing the implementation version.
  52340. * This number does not correspond to the WebXR specs version
  52341. */
  52342. static readonly Version: number;
  52343. /**
  52344. * Disable lighting on the laser pointer (so it will always be visible)
  52345. */
  52346. disablePointerLighting: boolean;
  52347. /**
  52348. * Disable lighting on the selection mesh (so it will always be visible)
  52349. */
  52350. disableSelectionMeshLighting: boolean;
  52351. /**
  52352. * Should the laser pointer be displayed
  52353. */
  52354. displayLaserPointer: boolean;
  52355. /**
  52356. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52357. */
  52358. displaySelectionMesh: boolean;
  52359. /**
  52360. * This color will be set to the laser pointer when selection is triggered
  52361. */
  52362. laserPointerPickedColor: Color3;
  52363. /**
  52364. * Default color of the laser pointer
  52365. */
  52366. laserPointerDefaultColor: Color3;
  52367. /**
  52368. * default color of the selection ring
  52369. */
  52370. selectionMeshDefaultColor: Color3;
  52371. /**
  52372. * This color will be applied to the selection ring when selection is triggered
  52373. */
  52374. selectionMeshPickedColor: Color3;
  52375. /**
  52376. * Optional filter to be used for ray selection. This predicate shares behavior with
  52377. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52378. */
  52379. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52380. /**
  52381. * constructs a new background remover module
  52382. * @param _xrSessionManager the session manager for this module
  52383. * @param _options read-only options to be used in this module
  52384. */
  52385. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52386. /**
  52387. * attach this feature
  52388. * Will usually be called by the features manager
  52389. *
  52390. * @returns true if successful.
  52391. */
  52392. attach(): boolean;
  52393. /**
  52394. * detach this feature.
  52395. * Will usually be called by the features manager
  52396. *
  52397. * @returns true if successful.
  52398. */
  52399. detach(): boolean;
  52400. /**
  52401. * Will get the mesh under a specific pointer.
  52402. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52403. * @param controllerId the controllerId to check
  52404. * @returns The mesh under pointer or null if no mesh is under the pointer
  52405. */
  52406. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52407. /**
  52408. * Get the xr controller that correlates to the pointer id in the pointer event
  52409. *
  52410. * @param id the pointer id to search for
  52411. * @returns the controller that correlates to this id or null if not found
  52412. */
  52413. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52414. private _identityMatrix;
  52415. private _screenCoordinatesRef;
  52416. private _viewportRef;
  52417. protected _onXRFrame(_xrFrame: XRFrame): void;
  52418. private _attachGazeMode;
  52419. private _attachScreenRayMode;
  52420. private _attachTrackedPointerRayMode;
  52421. private _convertNormalToDirectionOfRay;
  52422. private _detachController;
  52423. private _generateNewMeshPair;
  52424. private _pickingMoved;
  52425. private _updatePointerDistance;
  52426. /** @hidden */
  52427. get lasterPointerDefaultColor(): Color3;
  52428. }
  52429. }
  52430. declare module BABYLON {
  52431. /**
  52432. * Button which can be used to enter a different mode of XR
  52433. */
  52434. export class WebXREnterExitUIButton {
  52435. /** button element */
  52436. element: HTMLElement;
  52437. /** XR initialization options for the button */
  52438. sessionMode: XRSessionMode;
  52439. /** Reference space type */
  52440. referenceSpaceType: XRReferenceSpaceType;
  52441. /**
  52442. * Creates a WebXREnterExitUIButton
  52443. * @param element button element
  52444. * @param sessionMode XR initialization session mode
  52445. * @param referenceSpaceType the type of reference space to be used
  52446. */
  52447. constructor(
  52448. /** button element */
  52449. element: HTMLElement,
  52450. /** XR initialization options for the button */
  52451. sessionMode: XRSessionMode,
  52452. /** Reference space type */
  52453. referenceSpaceType: XRReferenceSpaceType);
  52454. /**
  52455. * Extendable function which can be used to update the button's visuals when the state changes
  52456. * @param activeButton the current active button in the UI
  52457. */
  52458. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52459. }
  52460. /**
  52461. * Options to create the webXR UI
  52462. */
  52463. export class WebXREnterExitUIOptions {
  52464. /**
  52465. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52466. */
  52467. customButtons?: Array<WebXREnterExitUIButton>;
  52468. /**
  52469. * A reference space type to use when creating the default button.
  52470. * Default is local-floor
  52471. */
  52472. referenceSpaceType?: XRReferenceSpaceType;
  52473. /**
  52474. * Context to enter xr with
  52475. */
  52476. renderTarget?: Nullable<WebXRRenderTarget>;
  52477. /**
  52478. * A session mode to use when creating the default button.
  52479. * Default is immersive-vr
  52480. */
  52481. sessionMode?: XRSessionMode;
  52482. /**
  52483. * A list of optional features to init the session with
  52484. */
  52485. optionalFeatures?: string[];
  52486. /**
  52487. * A list of optional features to init the session with
  52488. */
  52489. requiredFeatures?: string[];
  52490. /**
  52491. * If defined, this function will be executed if the UI encounters an error when entering XR
  52492. */
  52493. onError?: (error: any) => void;
  52494. }
  52495. /**
  52496. * UI to allow the user to enter/exit XR mode
  52497. */
  52498. export class WebXREnterExitUI implements IDisposable {
  52499. private scene;
  52500. /** version of the options passed to this UI */
  52501. options: WebXREnterExitUIOptions;
  52502. private _activeButton;
  52503. private _buttons;
  52504. /**
  52505. * The HTML Div Element to which buttons are added.
  52506. */
  52507. readonly overlay: HTMLDivElement;
  52508. /**
  52509. * Fired every time the active button is changed.
  52510. *
  52511. * When xr is entered via a button that launches xr that button will be the callback parameter
  52512. *
  52513. * When exiting xr the callback parameter will be null)
  52514. */
  52515. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52516. /**
  52517. *
  52518. * @param scene babylon scene object to use
  52519. * @param options (read-only) version of the options passed to this UI
  52520. */
  52521. private constructor();
  52522. /**
  52523. * Creates UI to allow the user to enter/exit XR mode
  52524. * @param scene the scene to add the ui to
  52525. * @param helper the xr experience helper to enter/exit xr with
  52526. * @param options options to configure the UI
  52527. * @returns the created ui
  52528. */
  52529. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52530. /**
  52531. * Disposes of the XR UI component
  52532. */
  52533. dispose(): void;
  52534. private _updateButtons;
  52535. }
  52536. }
  52537. declare module BABYLON {
  52538. /**
  52539. * Class containing static functions to help procedurally build meshes
  52540. */
  52541. export class LinesBuilder {
  52542. /**
  52543. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52544. * * 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
  52545. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52546. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52547. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52548. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52549. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52550. * * 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
  52551. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52554. * @param name defines the name of the new line system
  52555. * @param options defines the options used to create the line system
  52556. * @param scene defines the hosting scene
  52557. * @returns a new line system mesh
  52558. */
  52559. static CreateLineSystem(name: string, options: {
  52560. lines: Vector3[][];
  52561. updatable?: boolean;
  52562. instance?: Nullable<LinesMesh>;
  52563. colors?: Nullable<Color4[][]>;
  52564. useVertexAlpha?: boolean;
  52565. }, scene: Nullable<Scene>): LinesMesh;
  52566. /**
  52567. * Creates a line mesh
  52568. * 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
  52569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52570. * * The parameter `points` is an array successive Vector3
  52571. * * 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
  52572. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52573. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52574. * * When updating an instance, remember that only point positions can change, not the number of points
  52575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52577. * @param name defines the name of the new line system
  52578. * @param options defines the options used to create the line system
  52579. * @param scene defines the hosting scene
  52580. * @returns a new line mesh
  52581. */
  52582. static CreateLines(name: string, options: {
  52583. points: Vector3[];
  52584. updatable?: boolean;
  52585. instance?: Nullable<LinesMesh>;
  52586. colors?: Color4[];
  52587. useVertexAlpha?: boolean;
  52588. }, scene?: Nullable<Scene>): LinesMesh;
  52589. /**
  52590. * Creates a dashed line mesh
  52591. * * 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
  52592. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52593. * * The parameter `points` is an array successive Vector3
  52594. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52595. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52596. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52597. * * 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
  52598. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52599. * * When updating an instance, remember that only point positions can change, not the number of points
  52600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52601. * @param name defines the name of the mesh
  52602. * @param options defines the options used to create the mesh
  52603. * @param scene defines the hosting scene
  52604. * @returns the dashed line mesh
  52605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52606. */
  52607. static CreateDashedLines(name: string, options: {
  52608. points: Vector3[];
  52609. dashSize?: number;
  52610. gapSize?: number;
  52611. dashNb?: number;
  52612. updatable?: boolean;
  52613. instance?: LinesMesh;
  52614. useVertexAlpha?: boolean;
  52615. }, scene?: Nullable<Scene>): LinesMesh;
  52616. }
  52617. }
  52618. declare module BABYLON {
  52619. /**
  52620. * Construction options for a timer
  52621. */
  52622. export interface ITimerOptions<T> {
  52623. /**
  52624. * Time-to-end
  52625. */
  52626. timeout: number;
  52627. /**
  52628. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52629. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52630. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52631. */
  52632. contextObservable: Observable<T>;
  52633. /**
  52634. * Optional parameters when adding an observer to the observable
  52635. */
  52636. observableParameters?: {
  52637. mask?: number;
  52638. insertFirst?: boolean;
  52639. scope?: any;
  52640. };
  52641. /**
  52642. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52643. */
  52644. breakCondition?: (data?: ITimerData<T>) => boolean;
  52645. /**
  52646. * Will be triggered when the time condition has met
  52647. */
  52648. onEnded?: (data: ITimerData<any>) => void;
  52649. /**
  52650. * Will be triggered when the break condition has met (prematurely ended)
  52651. */
  52652. onAborted?: (data: ITimerData<any>) => void;
  52653. /**
  52654. * Optional function to execute on each tick (or count)
  52655. */
  52656. onTick?: (data: ITimerData<any>) => void;
  52657. }
  52658. /**
  52659. * An interface defining the data sent by the timer
  52660. */
  52661. export interface ITimerData<T> {
  52662. /**
  52663. * When did it start
  52664. */
  52665. startTime: number;
  52666. /**
  52667. * Time now
  52668. */
  52669. currentTime: number;
  52670. /**
  52671. * Time passed since started
  52672. */
  52673. deltaTime: number;
  52674. /**
  52675. * How much is completed, in [0.0...1.0].
  52676. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52677. */
  52678. completeRate: number;
  52679. /**
  52680. * What the registered observable sent in the last count
  52681. */
  52682. payload: T;
  52683. }
  52684. /**
  52685. * The current state of the timer
  52686. */
  52687. export enum TimerState {
  52688. /**
  52689. * Timer initialized, not yet started
  52690. */
  52691. INIT = 0,
  52692. /**
  52693. * Timer started and counting
  52694. */
  52695. STARTED = 1,
  52696. /**
  52697. * Timer ended (whether aborted or time reached)
  52698. */
  52699. ENDED = 2
  52700. }
  52701. /**
  52702. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52703. *
  52704. * @param options options with which to initialize this timer
  52705. */
  52706. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52707. /**
  52708. * An advanced implementation of a timer class
  52709. */
  52710. export class AdvancedTimer<T = any> implements IDisposable {
  52711. /**
  52712. * Will notify each time the timer calculates the remaining time
  52713. */
  52714. onEachCountObservable: Observable<ITimerData<T>>;
  52715. /**
  52716. * Will trigger when the timer was aborted due to the break condition
  52717. */
  52718. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52719. /**
  52720. * Will trigger when the timer ended successfully
  52721. */
  52722. onTimerEndedObservable: Observable<ITimerData<T>>;
  52723. /**
  52724. * Will trigger when the timer state has changed
  52725. */
  52726. onStateChangedObservable: Observable<TimerState>;
  52727. private _observer;
  52728. private _contextObservable;
  52729. private _observableParameters;
  52730. private _startTime;
  52731. private _timer;
  52732. private _state;
  52733. private _breakCondition;
  52734. private _timeToEnd;
  52735. private _breakOnNextTick;
  52736. /**
  52737. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52738. * @param options construction options for this advanced timer
  52739. */
  52740. constructor(options: ITimerOptions<T>);
  52741. /**
  52742. * set a breaking condition for this timer. Default is to never break during count
  52743. * @param predicate the new break condition. Returns true to break, false otherwise
  52744. */
  52745. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52746. /**
  52747. * Reset ALL associated observables in this advanced timer
  52748. */
  52749. clearObservables(): void;
  52750. /**
  52751. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52752. *
  52753. * @param timeToEnd how much time to measure until timer ended
  52754. */
  52755. start(timeToEnd?: number): void;
  52756. /**
  52757. * Will force a stop on the next tick.
  52758. */
  52759. stop(): void;
  52760. /**
  52761. * Dispose this timer, clearing all resources
  52762. */
  52763. dispose(): void;
  52764. private _setState;
  52765. private _tick;
  52766. private _stop;
  52767. }
  52768. }
  52769. declare module BABYLON {
  52770. /**
  52771. * The options container for the teleportation module
  52772. */
  52773. export interface IWebXRTeleportationOptions {
  52774. /**
  52775. * if provided, this scene will be used to render meshes.
  52776. */
  52777. customUtilityLayerScene?: Scene;
  52778. /**
  52779. * Values to configure the default target mesh
  52780. */
  52781. defaultTargetMeshOptions?: {
  52782. /**
  52783. * Fill color of the teleportation area
  52784. */
  52785. teleportationFillColor?: string;
  52786. /**
  52787. * Border color for the teleportation area
  52788. */
  52789. teleportationBorderColor?: string;
  52790. /**
  52791. * Disable the mesh's animation sequence
  52792. */
  52793. disableAnimation?: boolean;
  52794. /**
  52795. * Disable lighting on the material or the ring and arrow
  52796. */
  52797. disableLighting?: boolean;
  52798. /**
  52799. * Override the default material of the torus and arrow
  52800. */
  52801. torusArrowMaterial?: Material;
  52802. };
  52803. /**
  52804. * A list of meshes to use as floor meshes.
  52805. * Meshes can be added and removed after initializing the feature using the
  52806. * addFloorMesh and removeFloorMesh functions
  52807. * If empty, rotation will still work
  52808. */
  52809. floorMeshes?: AbstractMesh[];
  52810. /**
  52811. * use this rendering group id for the meshes (optional)
  52812. */
  52813. renderingGroupId?: number;
  52814. /**
  52815. * Should teleportation move only to snap points
  52816. */
  52817. snapPointsOnly?: boolean;
  52818. /**
  52819. * An array of points to which the teleportation will snap to.
  52820. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52821. */
  52822. snapPositions?: Vector3[];
  52823. /**
  52824. * How close should the teleportation ray be in order to snap to position.
  52825. * Default to 0.8 units (meters)
  52826. */
  52827. snapToPositionRadius?: number;
  52828. /**
  52829. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52830. * If you want to support rotation, make sure your mesh has a direction indicator.
  52831. *
  52832. * When left untouched, the default mesh will be initialized.
  52833. */
  52834. teleportationTargetMesh?: AbstractMesh;
  52835. /**
  52836. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52837. */
  52838. timeToTeleport?: number;
  52839. /**
  52840. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52841. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52842. */
  52843. useMainComponentOnly?: boolean;
  52844. /**
  52845. * Should meshes created here be added to a utility layer or the main scene
  52846. */
  52847. useUtilityLayer?: boolean;
  52848. /**
  52849. * Babylon XR Input class for controller
  52850. */
  52851. xrInput: WebXRInput;
  52852. /**
  52853. * Meshes that the teleportation ray cannot go through
  52854. */
  52855. pickBlockerMeshes?: AbstractMesh[];
  52856. }
  52857. /**
  52858. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52859. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52860. * the input of the attached controllers.
  52861. */
  52862. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52863. private _options;
  52864. private _controllers;
  52865. private _currentTeleportationControllerId;
  52866. private _floorMeshes;
  52867. private _quadraticBezierCurve;
  52868. private _selectionFeature;
  52869. private _snapToPositions;
  52870. private _snappedToPoint;
  52871. private _teleportationRingMaterial?;
  52872. private _tmpRay;
  52873. private _tmpVector;
  52874. private _tmpQuaternion;
  52875. /**
  52876. * The module's name
  52877. */
  52878. static readonly Name: string;
  52879. /**
  52880. * The (Babylon) version of this module.
  52881. * This is an integer representing the implementation version.
  52882. * This number does not correspond to the webxr specs version
  52883. */
  52884. static readonly Version: number;
  52885. /**
  52886. * Is movement backwards enabled
  52887. */
  52888. backwardsMovementEnabled: boolean;
  52889. /**
  52890. * Distance to travel when moving backwards
  52891. */
  52892. backwardsTeleportationDistance: number;
  52893. /**
  52894. * The distance from the user to the inspection point in the direction of the controller
  52895. * A higher number will allow the user to move further
  52896. * defaults to 5 (meters, in xr units)
  52897. */
  52898. parabolicCheckRadius: number;
  52899. /**
  52900. * Should the module support parabolic ray on top of direct ray
  52901. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52902. * Very helpful when moving between floors / different heights
  52903. */
  52904. parabolicRayEnabled: boolean;
  52905. /**
  52906. * How much rotation should be applied when rotating right and left
  52907. */
  52908. rotationAngle: number;
  52909. /**
  52910. * Is rotation enabled when moving forward?
  52911. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52912. */
  52913. rotationEnabled: boolean;
  52914. /**
  52915. * constructs a new anchor system
  52916. * @param _xrSessionManager an instance of WebXRSessionManager
  52917. * @param _options configuration object for this feature
  52918. */
  52919. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52920. /**
  52921. * Get the snapPointsOnly flag
  52922. */
  52923. get snapPointsOnly(): boolean;
  52924. /**
  52925. * Sets the snapPointsOnly flag
  52926. * @param snapToPoints should teleportation be exclusively to snap points
  52927. */
  52928. set snapPointsOnly(snapToPoints: boolean);
  52929. /**
  52930. * Add a new mesh to the floor meshes array
  52931. * @param mesh the mesh to use as floor mesh
  52932. */
  52933. addFloorMesh(mesh: AbstractMesh): void;
  52934. /**
  52935. * Add a new snap-to point to fix teleportation to this position
  52936. * @param newSnapPoint The new Snap-To point
  52937. */
  52938. addSnapPoint(newSnapPoint: Vector3): void;
  52939. attach(): boolean;
  52940. detach(): boolean;
  52941. dispose(): void;
  52942. /**
  52943. * Remove a mesh from the floor meshes array
  52944. * @param mesh the mesh to remove
  52945. */
  52946. removeFloorMesh(mesh: AbstractMesh): void;
  52947. /**
  52948. * Remove a mesh from the floor meshes array using its name
  52949. * @param name the mesh name to remove
  52950. */
  52951. removeFloorMeshByName(name: string): void;
  52952. /**
  52953. * 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
  52954. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52955. * @returns was the point found and removed or not
  52956. */
  52957. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52958. /**
  52959. * This function sets a selection feature that will be disabled when
  52960. * the forward ray is shown and will be reattached when hidden.
  52961. * This is used to remove the selection rays when moving.
  52962. * @param selectionFeature the feature to disable when forward movement is enabled
  52963. */
  52964. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52965. protected _onXRFrame(_xrFrame: XRFrame): void;
  52966. private _attachController;
  52967. private _createDefaultTargetMesh;
  52968. private _detachController;
  52969. private _findClosestSnapPointWithRadius;
  52970. private _setTargetMeshPosition;
  52971. private _setTargetMeshVisibility;
  52972. private _showParabolicPath;
  52973. private _teleportForward;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /**
  52978. * Options for the default xr helper
  52979. */
  52980. export class WebXRDefaultExperienceOptions {
  52981. /**
  52982. * Enable or disable default UI to enter XR
  52983. */
  52984. disableDefaultUI?: boolean;
  52985. /**
  52986. * Should teleportation not initialize. defaults to false.
  52987. */
  52988. disableTeleportation?: boolean;
  52989. /**
  52990. * Floor meshes that will be used for teleport
  52991. */
  52992. floorMeshes?: Array<AbstractMesh>;
  52993. /**
  52994. * If set to true, the first frame will not be used to reset position
  52995. * The first frame is mainly used when copying transformation from the old camera
  52996. * Mainly used in AR
  52997. */
  52998. ignoreNativeCameraTransformation?: boolean;
  52999. /**
  53000. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53001. */
  53002. inputOptions?: IWebXRInputOptions;
  53003. /**
  53004. * optional configuration for the output canvas
  53005. */
  53006. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53007. /**
  53008. * optional UI options. This can be used among other to change session mode and reference space type
  53009. */
  53010. uiOptions?: WebXREnterExitUIOptions;
  53011. /**
  53012. * When loading teleportation and pointer select, use stable versions instead of latest.
  53013. */
  53014. useStablePlugins?: boolean;
  53015. /**
  53016. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53017. */
  53018. renderingGroupId?: number;
  53019. /**
  53020. * A list of optional features to init the session with
  53021. * If set to true, all features we support will be added
  53022. */
  53023. optionalFeatures?: boolean | string[];
  53024. }
  53025. /**
  53026. * Default experience which provides a similar setup to the previous webVRExperience
  53027. */
  53028. export class WebXRDefaultExperience {
  53029. /**
  53030. * Base experience
  53031. */
  53032. baseExperience: WebXRExperienceHelper;
  53033. /**
  53034. * Enables ui for entering/exiting xr
  53035. */
  53036. enterExitUI: WebXREnterExitUI;
  53037. /**
  53038. * Input experience extension
  53039. */
  53040. input: WebXRInput;
  53041. /**
  53042. * Enables laser pointer and selection
  53043. */
  53044. pointerSelection: WebXRControllerPointerSelection;
  53045. /**
  53046. * Default target xr should render to
  53047. */
  53048. renderTarget: WebXRRenderTarget;
  53049. /**
  53050. * Enables teleportation
  53051. */
  53052. teleportation: WebXRMotionControllerTeleportation;
  53053. private constructor();
  53054. /**
  53055. * Creates the default xr experience
  53056. * @param scene scene
  53057. * @param options options for basic configuration
  53058. * @returns resulting WebXRDefaultExperience
  53059. */
  53060. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53061. /**
  53062. * DIsposes of the experience helper
  53063. */
  53064. dispose(): void;
  53065. }
  53066. }
  53067. declare module BABYLON {
  53068. /**
  53069. * Options to modify the vr teleportation behavior.
  53070. */
  53071. export interface VRTeleportationOptions {
  53072. /**
  53073. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53074. */
  53075. floorMeshName?: string;
  53076. /**
  53077. * A list of meshes to be used as the teleportation floor. (default: empty)
  53078. */
  53079. floorMeshes?: Mesh[];
  53080. /**
  53081. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53082. */
  53083. teleportationMode?: number;
  53084. /**
  53085. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53086. */
  53087. teleportationTime?: number;
  53088. /**
  53089. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53090. */
  53091. teleportationSpeed?: number;
  53092. /**
  53093. * The easing function used in the animation or null for Linear. (default CircleEase)
  53094. */
  53095. easingFunction?: EasingFunction;
  53096. }
  53097. /**
  53098. * Options to modify the vr experience helper's behavior.
  53099. */
  53100. export interface VRExperienceHelperOptions extends WebVROptions {
  53101. /**
  53102. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53103. */
  53104. createDeviceOrientationCamera?: boolean;
  53105. /**
  53106. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53107. */
  53108. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53109. /**
  53110. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53111. */
  53112. laserToggle?: boolean;
  53113. /**
  53114. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53115. */
  53116. floorMeshes?: Mesh[];
  53117. /**
  53118. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53119. */
  53120. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53121. /**
  53122. * Defines if WebXR should be used instead of WebVR (if available)
  53123. */
  53124. useXR?: boolean;
  53125. }
  53126. /**
  53127. * Event containing information after VR has been entered
  53128. */
  53129. export class OnAfterEnteringVRObservableEvent {
  53130. /**
  53131. * If entering vr was successful
  53132. */
  53133. success: boolean;
  53134. }
  53135. /**
  53136. * Helps to quickly add VR support to an existing scene.
  53137. * See https://doc.babylonjs.com/how_to/webvr_helper
  53138. */
  53139. export class VRExperienceHelper {
  53140. /** Options to modify the vr experience helper's behavior. */
  53141. webVROptions: VRExperienceHelperOptions;
  53142. private _scene;
  53143. private _position;
  53144. private _btnVR;
  53145. private _btnVRDisplayed;
  53146. private _webVRsupported;
  53147. private _webVRready;
  53148. private _webVRrequesting;
  53149. private _webVRpresenting;
  53150. private _hasEnteredVR;
  53151. private _fullscreenVRpresenting;
  53152. private _inputElement;
  53153. private _webVRCamera;
  53154. private _vrDeviceOrientationCamera;
  53155. private _deviceOrientationCamera;
  53156. private _existingCamera;
  53157. private _onKeyDown;
  53158. private _onVrDisplayPresentChange;
  53159. private _onVRDisplayChanged;
  53160. private _onVRRequestPresentStart;
  53161. private _onVRRequestPresentComplete;
  53162. /**
  53163. * 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)
  53164. */
  53165. enableGazeEvenWhenNoPointerLock: boolean;
  53166. /**
  53167. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53168. */
  53169. exitVROnDoubleTap: boolean;
  53170. /**
  53171. * Observable raised right before entering VR.
  53172. */
  53173. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53174. /**
  53175. * Observable raised when entering VR has completed.
  53176. */
  53177. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53178. /**
  53179. * Observable raised when exiting VR.
  53180. */
  53181. onExitingVRObservable: Observable<VRExperienceHelper>;
  53182. /**
  53183. * Observable raised when controller mesh is loaded.
  53184. */
  53185. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53186. /** Return this.onEnteringVRObservable
  53187. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53188. */
  53189. get onEnteringVR(): Observable<VRExperienceHelper>;
  53190. /** Return this.onExitingVRObservable
  53191. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53192. */
  53193. get onExitingVR(): Observable<VRExperienceHelper>;
  53194. /** Return this.onControllerMeshLoadedObservable
  53195. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53196. */
  53197. get onControllerMeshLoaded(): Observable<WebVRController>;
  53198. private _rayLength;
  53199. private _useCustomVRButton;
  53200. private _teleportationRequested;
  53201. private _teleportActive;
  53202. private _floorMeshName;
  53203. private _floorMeshesCollection;
  53204. private _teleportationMode;
  53205. private _teleportationTime;
  53206. private _teleportationSpeed;
  53207. private _teleportationEasing;
  53208. private _rotationAllowed;
  53209. private _teleportBackwardsVector;
  53210. private _teleportationTarget;
  53211. private _isDefaultTeleportationTarget;
  53212. private _postProcessMove;
  53213. private _teleportationFillColor;
  53214. private _teleportationBorderColor;
  53215. private _rotationAngle;
  53216. private _haloCenter;
  53217. private _cameraGazer;
  53218. private _padSensibilityUp;
  53219. private _padSensibilityDown;
  53220. private _leftController;
  53221. private _rightController;
  53222. private _gazeColor;
  53223. private _laserColor;
  53224. private _pickedLaserColor;
  53225. private _pickedGazeColor;
  53226. /**
  53227. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53228. */
  53229. onNewMeshSelected: Observable<AbstractMesh>;
  53230. /**
  53231. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53232. * This observable will provide the mesh and the controller used to select the mesh
  53233. */
  53234. onMeshSelectedWithController: Observable<{
  53235. mesh: AbstractMesh;
  53236. controller: WebVRController;
  53237. }>;
  53238. /**
  53239. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53240. */
  53241. onNewMeshPicked: Observable<PickingInfo>;
  53242. private _circleEase;
  53243. /**
  53244. * Observable raised before camera teleportation
  53245. */
  53246. onBeforeCameraTeleport: Observable<Vector3>;
  53247. /**
  53248. * Observable raised after camera teleportation
  53249. */
  53250. onAfterCameraTeleport: Observable<Vector3>;
  53251. /**
  53252. * Observable raised when current selected mesh gets unselected
  53253. */
  53254. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53255. private _raySelectionPredicate;
  53256. /**
  53257. * To be optionaly changed by user to define custom ray selection
  53258. */
  53259. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53260. /**
  53261. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53262. */
  53263. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53264. /**
  53265. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53266. */
  53267. teleportationEnabled: boolean;
  53268. private _defaultHeight;
  53269. private _teleportationInitialized;
  53270. private _interactionsEnabled;
  53271. private _interactionsRequested;
  53272. private _displayGaze;
  53273. private _displayLaserPointer;
  53274. /**
  53275. * The mesh used to display where the user is going to teleport.
  53276. */
  53277. get teleportationTarget(): Mesh;
  53278. /**
  53279. * Sets the mesh to be used to display where the user is going to teleport.
  53280. */
  53281. set teleportationTarget(value: Mesh);
  53282. /**
  53283. * 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
  53284. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53285. * See https://doc.babylonjs.com/resources/baking_transformations
  53286. */
  53287. get gazeTrackerMesh(): Mesh;
  53288. set gazeTrackerMesh(value: Mesh);
  53289. /**
  53290. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53291. */
  53292. updateGazeTrackerScale: boolean;
  53293. /**
  53294. * If the gaze trackers color should be updated when selecting meshes
  53295. */
  53296. updateGazeTrackerColor: boolean;
  53297. /**
  53298. * If the controller laser color should be updated when selecting meshes
  53299. */
  53300. updateControllerLaserColor: boolean;
  53301. /**
  53302. * The gaze tracking mesh corresponding to the left controller
  53303. */
  53304. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53305. /**
  53306. * The gaze tracking mesh corresponding to the right controller
  53307. */
  53308. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53309. /**
  53310. * If the ray of the gaze should be displayed.
  53311. */
  53312. get displayGaze(): boolean;
  53313. /**
  53314. * Sets if the ray of the gaze should be displayed.
  53315. */
  53316. set displayGaze(value: boolean);
  53317. /**
  53318. * If the ray of the LaserPointer should be displayed.
  53319. */
  53320. get displayLaserPointer(): boolean;
  53321. /**
  53322. * Sets if the ray of the LaserPointer should be displayed.
  53323. */
  53324. set displayLaserPointer(value: boolean);
  53325. /**
  53326. * The deviceOrientationCamera used as the camera when not in VR.
  53327. */
  53328. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53329. /**
  53330. * Based on the current WebVR support, returns the current VR camera used.
  53331. */
  53332. get currentVRCamera(): Nullable<Camera>;
  53333. /**
  53334. * The webVRCamera which is used when in VR.
  53335. */
  53336. get webVRCamera(): WebVRFreeCamera;
  53337. /**
  53338. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53339. */
  53340. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53341. /**
  53342. * The html button that is used to trigger entering into VR.
  53343. */
  53344. get vrButton(): Nullable<HTMLButtonElement>;
  53345. private get _teleportationRequestInitiated();
  53346. /**
  53347. * Defines whether or not Pointer lock should be requested when switching to
  53348. * full screen.
  53349. */
  53350. requestPointerLockOnFullScreen: boolean;
  53351. /**
  53352. * If asking to force XR, this will be populated with the default xr experience
  53353. */
  53354. xr: WebXRDefaultExperience;
  53355. /**
  53356. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53357. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53358. */
  53359. xrTestDone: boolean;
  53360. /**
  53361. * Instantiates a VRExperienceHelper.
  53362. * Helps to quickly add VR support to an existing scene.
  53363. * @param scene The scene the VRExperienceHelper belongs to.
  53364. * @param webVROptions Options to modify the vr experience helper's behavior.
  53365. */
  53366. constructor(scene: Scene,
  53367. /** Options to modify the vr experience helper's behavior. */
  53368. webVROptions?: VRExperienceHelperOptions);
  53369. private completeVRInit;
  53370. private _onDefaultMeshLoaded;
  53371. private _onResize;
  53372. private _onFullscreenChange;
  53373. /**
  53374. * Gets a value indicating if we are currently in VR mode.
  53375. */
  53376. get isInVRMode(): boolean;
  53377. private onVrDisplayPresentChange;
  53378. private onVRDisplayChanged;
  53379. private moveButtonToBottomRight;
  53380. private displayVRButton;
  53381. private updateButtonVisibility;
  53382. private _cachedAngularSensibility;
  53383. /**
  53384. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53385. * Otherwise, will use the fullscreen API.
  53386. */
  53387. enterVR(): void;
  53388. /**
  53389. * Attempt to exit VR, or fullscreen.
  53390. */
  53391. exitVR(): void;
  53392. /**
  53393. * The position of the vr experience helper.
  53394. */
  53395. get position(): Vector3;
  53396. /**
  53397. * Sets the position of the vr experience helper.
  53398. */
  53399. set position(value: Vector3);
  53400. /**
  53401. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53402. */
  53403. enableInteractions(): void;
  53404. private get _noControllerIsActive();
  53405. private beforeRender;
  53406. private _isTeleportationFloor;
  53407. /**
  53408. * Adds a floor mesh to be used for teleportation.
  53409. * @param floorMesh the mesh to be used for teleportation.
  53410. */
  53411. addFloorMesh(floorMesh: Mesh): void;
  53412. /**
  53413. * Removes a floor mesh from being used for teleportation.
  53414. * @param floorMesh the mesh to be removed.
  53415. */
  53416. removeFloorMesh(floorMesh: Mesh): void;
  53417. /**
  53418. * Enables interactions and teleportation using the VR controllers and gaze.
  53419. * @param vrTeleportationOptions options to modify teleportation behavior.
  53420. */
  53421. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53422. private _onNewGamepadConnected;
  53423. private _tryEnableInteractionOnController;
  53424. private _onNewGamepadDisconnected;
  53425. private _enableInteractionOnController;
  53426. private _checkTeleportWithRay;
  53427. private _checkRotate;
  53428. private _checkTeleportBackwards;
  53429. private _enableTeleportationOnController;
  53430. private _createTeleportationCircles;
  53431. private _displayTeleportationTarget;
  53432. private _hideTeleportationTarget;
  53433. private _rotateCamera;
  53434. private _moveTeleportationSelectorTo;
  53435. private _workingVector;
  53436. private _workingQuaternion;
  53437. private _workingMatrix;
  53438. /**
  53439. * Time Constant Teleportation Mode
  53440. */
  53441. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53442. /**
  53443. * Speed Constant Teleportation Mode
  53444. */
  53445. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53446. /**
  53447. * Teleports the users feet to the desired location
  53448. * @param location The location where the user's feet should be placed
  53449. */
  53450. teleportCamera(location: Vector3): void;
  53451. private _convertNormalToDirectionOfRay;
  53452. private _castRayAndSelectObject;
  53453. private _notifySelectedMeshUnselected;
  53454. /**
  53455. * Permanently set new colors for the laser pointer
  53456. * @param color the new laser color
  53457. * @param pickedColor the new laser color when picked mesh detected
  53458. */
  53459. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53460. /**
  53461. * Set lighting enabled / disabled on the laser pointer of both controllers
  53462. * @param enabled should the lighting be enabled on the laser pointer
  53463. */
  53464. setLaserLightingState(enabled?: boolean): void;
  53465. /**
  53466. * Permanently set new colors for the gaze pointer
  53467. * @param color the new gaze color
  53468. * @param pickedColor the new gaze color when picked mesh detected
  53469. */
  53470. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53471. /**
  53472. * Sets the color of the laser ray from the vr controllers.
  53473. * @param color new color for the ray.
  53474. */
  53475. changeLaserColor(color: Color3): void;
  53476. /**
  53477. * Sets the color of the ray from the vr headsets gaze.
  53478. * @param color new color for the ray.
  53479. */
  53480. changeGazeColor(color: Color3): void;
  53481. /**
  53482. * Exits VR and disposes of the vr experience helper
  53483. */
  53484. dispose(): void;
  53485. /**
  53486. * Gets the name of the VRExperienceHelper class
  53487. * @returns "VRExperienceHelper"
  53488. */
  53489. getClassName(): string;
  53490. }
  53491. }
  53492. declare module BABYLON {
  53493. /**
  53494. * Contains an array of blocks representing the octree
  53495. */
  53496. export interface IOctreeContainer<T> {
  53497. /**
  53498. * Blocks within the octree
  53499. */
  53500. blocks: Array<OctreeBlock<T>>;
  53501. }
  53502. /**
  53503. * Class used to store a cell in an octree
  53504. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53505. */
  53506. export class OctreeBlock<T> {
  53507. /**
  53508. * Gets the content of the current block
  53509. */
  53510. entries: T[];
  53511. /**
  53512. * Gets the list of block children
  53513. */
  53514. blocks: Array<OctreeBlock<T>>;
  53515. private _depth;
  53516. private _maxDepth;
  53517. private _capacity;
  53518. private _minPoint;
  53519. private _maxPoint;
  53520. private _boundingVectors;
  53521. private _creationFunc;
  53522. /**
  53523. * Creates a new block
  53524. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53525. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53526. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53527. * @param depth defines the current depth of this block in the octree
  53528. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53529. * @param creationFunc defines a callback to call when an element is added to the block
  53530. */
  53531. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53532. /**
  53533. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53534. */
  53535. get capacity(): number;
  53536. /**
  53537. * Gets the minimum vector (in world space) of the block's bounding box
  53538. */
  53539. get minPoint(): Vector3;
  53540. /**
  53541. * Gets the maximum vector (in world space) of the block's bounding box
  53542. */
  53543. get maxPoint(): Vector3;
  53544. /**
  53545. * Add a new element to this block
  53546. * @param entry defines the element to add
  53547. */
  53548. addEntry(entry: T): void;
  53549. /**
  53550. * Remove an element from this block
  53551. * @param entry defines the element to remove
  53552. */
  53553. removeEntry(entry: T): void;
  53554. /**
  53555. * Add an array of elements to this block
  53556. * @param entries defines the array of elements to add
  53557. */
  53558. addEntries(entries: T[]): void;
  53559. /**
  53560. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53561. * @param frustumPlanes defines the frustum planes to test
  53562. * @param selection defines the array to store current content if selection is positive
  53563. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53564. */
  53565. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53566. /**
  53567. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53568. * @param sphereCenter defines the bounding sphere center
  53569. * @param sphereRadius defines the bounding sphere radius
  53570. * @param selection defines the array to store current content if selection is positive
  53571. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53572. */
  53573. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53574. /**
  53575. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53576. * @param ray defines the ray to test with
  53577. * @param selection defines the array to store current content if selection is positive
  53578. */
  53579. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53580. /**
  53581. * Subdivide the content into child blocks (this block will then be empty)
  53582. */
  53583. createInnerBlocks(): void;
  53584. /**
  53585. * @hidden
  53586. */
  53587. 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;
  53588. }
  53589. }
  53590. declare module BABYLON {
  53591. /**
  53592. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53593. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53594. */
  53595. export class Octree<T> {
  53596. /** 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.) */
  53597. maxDepth: number;
  53598. /**
  53599. * Blocks within the octree containing objects
  53600. */
  53601. blocks: Array<OctreeBlock<T>>;
  53602. /**
  53603. * Content stored in the octree
  53604. */
  53605. dynamicContent: T[];
  53606. private _maxBlockCapacity;
  53607. private _selectionContent;
  53608. private _creationFunc;
  53609. /**
  53610. * Creates a octree
  53611. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53612. * @param creationFunc function to be used to instatiate the octree
  53613. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53614. * @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.)
  53615. */
  53616. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53617. /** 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.) */
  53618. maxDepth?: number);
  53619. /**
  53620. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53621. * @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);
  53622. * @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);
  53623. * @param entries meshes to be added to the octree blocks
  53624. */
  53625. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53626. /**
  53627. * Adds a mesh to the octree
  53628. * @param entry Mesh to add to the octree
  53629. */
  53630. addMesh(entry: T): void;
  53631. /**
  53632. * Remove an element from the octree
  53633. * @param entry defines the element to remove
  53634. */
  53635. removeMesh(entry: T): void;
  53636. /**
  53637. * Selects an array of meshes within the frustum
  53638. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53639. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53640. * @returns array of meshes within the frustum
  53641. */
  53642. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53643. /**
  53644. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53645. * @param sphereCenter defines the bounding sphere center
  53646. * @param sphereRadius defines the bounding sphere radius
  53647. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53648. * @returns an array of objects that intersect the sphere
  53649. */
  53650. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53651. /**
  53652. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53653. * @param ray defines the ray to test with
  53654. * @returns array of intersected objects
  53655. */
  53656. intersectsRay(ray: Ray): SmartArray<T>;
  53657. /**
  53658. * Adds a mesh into the octree block if it intersects the block
  53659. */
  53660. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53661. /**
  53662. * Adds a submesh into the octree block if it intersects the block
  53663. */
  53664. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53665. }
  53666. }
  53667. declare module BABYLON {
  53668. interface Scene {
  53669. /**
  53670. * @hidden
  53671. * Backing Filed
  53672. */
  53673. _selectionOctree: Octree<AbstractMesh>;
  53674. /**
  53675. * Gets the octree used to boost mesh selection (picking)
  53676. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53677. */
  53678. selectionOctree: Octree<AbstractMesh>;
  53679. /**
  53680. * Creates or updates the octree used to boost selection (picking)
  53681. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53682. * @param maxCapacity defines the maximum capacity per leaf
  53683. * @param maxDepth defines the maximum depth of the octree
  53684. * @returns an octree of AbstractMesh
  53685. */
  53686. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53687. }
  53688. interface AbstractMesh {
  53689. /**
  53690. * @hidden
  53691. * Backing Field
  53692. */
  53693. _submeshesOctree: Octree<SubMesh>;
  53694. /**
  53695. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53696. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53697. * @param maxCapacity defines the maximum size of each block (64 by default)
  53698. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53699. * @returns the new octree
  53700. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53702. */
  53703. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53704. }
  53705. /**
  53706. * Defines the octree scene component responsible to manage any octrees
  53707. * in a given scene.
  53708. */
  53709. export class OctreeSceneComponent {
  53710. /**
  53711. * The component name help to identify the component in the list of scene components.
  53712. */
  53713. readonly name: string;
  53714. /**
  53715. * The scene the component belongs to.
  53716. */
  53717. scene: Scene;
  53718. /**
  53719. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53720. */
  53721. readonly checksIsEnabled: boolean;
  53722. /**
  53723. * Creates a new instance of the component for the given scene
  53724. * @param scene Defines the scene to register the component in
  53725. */
  53726. constructor(scene: Scene);
  53727. /**
  53728. * Registers the component in a given scene
  53729. */
  53730. register(): void;
  53731. /**
  53732. * Return the list of active meshes
  53733. * @returns the list of active meshes
  53734. */
  53735. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53736. /**
  53737. * Return the list of active sub meshes
  53738. * @param mesh The mesh to get the candidates sub meshes from
  53739. * @returns the list of active sub meshes
  53740. */
  53741. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53742. private _tempRay;
  53743. /**
  53744. * Return the list of sub meshes intersecting with a given local ray
  53745. * @param mesh defines the mesh to find the submesh for
  53746. * @param localRay defines the ray in local space
  53747. * @returns the list of intersecting sub meshes
  53748. */
  53749. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53750. /**
  53751. * Return the list of sub meshes colliding with a collider
  53752. * @param mesh defines the mesh to find the submesh for
  53753. * @param collider defines the collider to evaluate the collision against
  53754. * @returns the list of colliding sub meshes
  53755. */
  53756. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53757. /**
  53758. * Rebuilds the elements related to this component in case of
  53759. * context lost for instance.
  53760. */
  53761. rebuild(): void;
  53762. /**
  53763. * Disposes the component and the associated ressources.
  53764. */
  53765. dispose(): void;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /**
  53770. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53771. */
  53772. export class Gizmo implements IDisposable {
  53773. /** The utility layer the gizmo will be added to */
  53774. gizmoLayer: UtilityLayerRenderer;
  53775. /**
  53776. * The root mesh of the gizmo
  53777. */
  53778. _rootMesh: Mesh;
  53779. private _attachedMesh;
  53780. private _attachedNode;
  53781. /**
  53782. * Ratio for the scale of the gizmo (Default: 1)
  53783. */
  53784. protected _scaleRatio: number;
  53785. /**
  53786. * boolean updated by pointermove when a gizmo mesh is hovered
  53787. */
  53788. protected _isHovered: boolean;
  53789. /**
  53790. * Ratio for the scale of the gizmo (Default: 1)
  53791. */
  53792. set scaleRatio(value: number);
  53793. get scaleRatio(): number;
  53794. /**
  53795. * True when the mouse pointer is hovered a gizmo mesh
  53796. */
  53797. get isHovered(): boolean;
  53798. /**
  53799. * If a custom mesh has been set (Default: false)
  53800. */
  53801. protected _customMeshSet: boolean;
  53802. /**
  53803. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53804. * * When set, interactions will be enabled
  53805. */
  53806. get attachedMesh(): Nullable<AbstractMesh>;
  53807. set attachedMesh(value: Nullable<AbstractMesh>);
  53808. /**
  53809. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53810. * * When set, interactions will be enabled
  53811. */
  53812. get attachedNode(): Nullable<Node>;
  53813. set attachedNode(value: Nullable<Node>);
  53814. /**
  53815. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53816. * @param mesh The mesh to replace the default mesh of the gizmo
  53817. */
  53818. setCustomMesh(mesh: Mesh): void;
  53819. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53820. /**
  53821. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53822. */
  53823. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53824. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53825. /**
  53826. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53827. */
  53828. updateGizmoPositionToMatchAttachedMesh: boolean;
  53829. /**
  53830. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53831. */
  53832. updateScale: boolean;
  53833. protected _interactionsEnabled: boolean;
  53834. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53835. private _beforeRenderObserver;
  53836. private _tempQuaternion;
  53837. private _tempVector;
  53838. private _tempVector2;
  53839. private _tempMatrix1;
  53840. private _tempMatrix2;
  53841. private _rightHandtoLeftHandMatrix;
  53842. /**
  53843. * Creates a gizmo
  53844. * @param gizmoLayer The utility layer the gizmo will be added to
  53845. */
  53846. constructor(
  53847. /** The utility layer the gizmo will be added to */
  53848. gizmoLayer?: UtilityLayerRenderer);
  53849. /**
  53850. * Updates the gizmo to match the attached mesh's position/rotation
  53851. */
  53852. protected _update(): void;
  53853. /**
  53854. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53855. * @param value Node, TransformNode or mesh
  53856. */
  53857. protected _matrixChanged(): void;
  53858. /**
  53859. * Disposes of the gizmo
  53860. */
  53861. dispose(): void;
  53862. }
  53863. }
  53864. declare module BABYLON {
  53865. /**
  53866. * Single plane drag gizmo
  53867. */
  53868. export class PlaneDragGizmo extends Gizmo {
  53869. /**
  53870. * Drag behavior responsible for the gizmos dragging interactions
  53871. */
  53872. dragBehavior: PointerDragBehavior;
  53873. private _pointerObserver;
  53874. /**
  53875. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53876. */
  53877. snapDistance: number;
  53878. /**
  53879. * Event that fires each time the gizmo snaps to a new location.
  53880. * * snapDistance is the the change in distance
  53881. */
  53882. onSnapObservable: Observable<{
  53883. snapDistance: number;
  53884. }>;
  53885. private _plane;
  53886. private _coloredMaterial;
  53887. private _hoverMaterial;
  53888. private _isEnabled;
  53889. private _parent;
  53890. /** @hidden */
  53891. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53892. /** @hidden */
  53893. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53894. /**
  53895. * Creates a PlaneDragGizmo
  53896. * @param gizmoLayer The utility layer the gizmo will be added to
  53897. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53898. * @param color The color of the gizmo
  53899. */
  53900. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53901. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53902. /**
  53903. * If the gizmo is enabled
  53904. */
  53905. set isEnabled(value: boolean);
  53906. get isEnabled(): boolean;
  53907. /**
  53908. * Disposes of the gizmo
  53909. */
  53910. dispose(): void;
  53911. }
  53912. }
  53913. declare module BABYLON {
  53914. /**
  53915. * Gizmo that enables dragging a mesh along 3 axis
  53916. */
  53917. export class PositionGizmo extends Gizmo {
  53918. /**
  53919. * Internal gizmo used for interactions on the x axis
  53920. */
  53921. xGizmo: AxisDragGizmo;
  53922. /**
  53923. * Internal gizmo used for interactions on the y axis
  53924. */
  53925. yGizmo: AxisDragGizmo;
  53926. /**
  53927. * Internal gizmo used for interactions on the z axis
  53928. */
  53929. zGizmo: AxisDragGizmo;
  53930. /**
  53931. * Internal gizmo used for interactions on the yz plane
  53932. */
  53933. xPlaneGizmo: PlaneDragGizmo;
  53934. /**
  53935. * Internal gizmo used for interactions on the xz plane
  53936. */
  53937. yPlaneGizmo: PlaneDragGizmo;
  53938. /**
  53939. * Internal gizmo used for interactions on the xy plane
  53940. */
  53941. zPlaneGizmo: PlaneDragGizmo;
  53942. /**
  53943. * private variables
  53944. */
  53945. private _meshAttached;
  53946. private _nodeAttached;
  53947. private _snapDistance;
  53948. /** Fires an event when any of it's sub gizmos are dragged */
  53949. onDragStartObservable: Observable<unknown>;
  53950. /** Fires an event when any of it's sub gizmos are released from dragging */
  53951. onDragEndObservable: Observable<unknown>;
  53952. /**
  53953. * If set to true, planar drag is enabled
  53954. */
  53955. private _planarGizmoEnabled;
  53956. get attachedMesh(): Nullable<AbstractMesh>;
  53957. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53958. get attachedNode(): Nullable<Node>;
  53959. set attachedNode(node: Nullable<Node>);
  53960. /**
  53961. * True when the mouse pointer is hovering a gizmo mesh
  53962. */
  53963. get isHovered(): boolean;
  53964. /**
  53965. * Creates a PositionGizmo
  53966. * @param gizmoLayer The utility layer the gizmo will be added to
  53967. @param thickness display gizmo axis thickness
  53968. */
  53969. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53970. /**
  53971. * If the planar drag gizmo is enabled
  53972. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53973. */
  53974. set planarGizmoEnabled(value: boolean);
  53975. get planarGizmoEnabled(): boolean;
  53976. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53977. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53978. /**
  53979. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53980. */
  53981. set snapDistance(value: number);
  53982. get snapDistance(): number;
  53983. /**
  53984. * Ratio for the scale of the gizmo (Default: 1)
  53985. */
  53986. set scaleRatio(value: number);
  53987. get scaleRatio(): number;
  53988. /**
  53989. * Disposes of the gizmo
  53990. */
  53991. dispose(): void;
  53992. /**
  53993. * CustomMeshes are not supported by this gizmo
  53994. * @param mesh The mesh to replace the default mesh of the gizmo
  53995. */
  53996. setCustomMesh(mesh: Mesh): void;
  53997. }
  53998. }
  53999. declare module BABYLON {
  54000. /**
  54001. * Single axis drag gizmo
  54002. */
  54003. export class AxisDragGizmo extends Gizmo {
  54004. /**
  54005. * Drag behavior responsible for the gizmos dragging interactions
  54006. */
  54007. dragBehavior: PointerDragBehavior;
  54008. private _pointerObserver;
  54009. /**
  54010. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54011. */
  54012. snapDistance: number;
  54013. /**
  54014. * Event that fires each time the gizmo snaps to a new location.
  54015. * * snapDistance is the the change in distance
  54016. */
  54017. onSnapObservable: Observable<{
  54018. snapDistance: number;
  54019. }>;
  54020. private _isEnabled;
  54021. private _parent;
  54022. private _arrow;
  54023. private _coloredMaterial;
  54024. private _hoverMaterial;
  54025. /** @hidden */
  54026. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  54027. /** @hidden */
  54028. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54029. /**
  54030. * Creates an AxisDragGizmo
  54031. * @param gizmoLayer The utility layer the gizmo will be added to
  54032. * @param dragAxis The axis which the gizmo will be able to drag on
  54033. * @param color The color of the gizmo
  54034. * @param thickness display gizmo axis thickness
  54035. */
  54036. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54037. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54038. /**
  54039. * If the gizmo is enabled
  54040. */
  54041. set isEnabled(value: boolean);
  54042. get isEnabled(): boolean;
  54043. /**
  54044. * Disposes of the gizmo
  54045. */
  54046. dispose(): void;
  54047. }
  54048. }
  54049. declare module BABYLON.Debug {
  54050. /**
  54051. * The Axes viewer will show 3 axes in a specific point in space
  54052. */
  54053. export class AxesViewer {
  54054. private _xAxis;
  54055. private _yAxis;
  54056. private _zAxis;
  54057. private _scaleLinesFactor;
  54058. private _instanced;
  54059. /**
  54060. * Gets the hosting scene
  54061. */
  54062. scene: Nullable<Scene>;
  54063. /**
  54064. * Gets or sets a number used to scale line length
  54065. */
  54066. scaleLines: number;
  54067. /** Gets the node hierarchy used to render x-axis */
  54068. get xAxis(): TransformNode;
  54069. /** Gets the node hierarchy used to render y-axis */
  54070. get yAxis(): TransformNode;
  54071. /** Gets the node hierarchy used to render z-axis */
  54072. get zAxis(): TransformNode;
  54073. /**
  54074. * Creates a new AxesViewer
  54075. * @param scene defines the hosting scene
  54076. * @param scaleLines defines a number used to scale line length (1 by default)
  54077. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54078. * @param xAxis defines the node hierarchy used to render the x-axis
  54079. * @param yAxis defines the node hierarchy used to render the y-axis
  54080. * @param zAxis defines the node hierarchy used to render the z-axis
  54081. */
  54082. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54083. /**
  54084. * Force the viewer to update
  54085. * @param position defines the position of the viewer
  54086. * @param xaxis defines the x axis of the viewer
  54087. * @param yaxis defines the y axis of the viewer
  54088. * @param zaxis defines the z axis of the viewer
  54089. */
  54090. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54091. /**
  54092. * Creates an instance of this axes viewer.
  54093. * @returns a new axes viewer with instanced meshes
  54094. */
  54095. createInstance(): AxesViewer;
  54096. /** Releases resources */
  54097. dispose(): void;
  54098. private static _SetRenderingGroupId;
  54099. }
  54100. }
  54101. declare module BABYLON.Debug {
  54102. /**
  54103. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54104. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54105. */
  54106. export class BoneAxesViewer extends AxesViewer {
  54107. /**
  54108. * Gets or sets the target mesh where to display the axes viewer
  54109. */
  54110. mesh: Nullable<Mesh>;
  54111. /**
  54112. * Gets or sets the target bone where to display the axes viewer
  54113. */
  54114. bone: Nullable<Bone>;
  54115. /** Gets current position */
  54116. pos: Vector3;
  54117. /** Gets direction of X axis */
  54118. xaxis: Vector3;
  54119. /** Gets direction of Y axis */
  54120. yaxis: Vector3;
  54121. /** Gets direction of Z axis */
  54122. zaxis: Vector3;
  54123. /**
  54124. * Creates a new BoneAxesViewer
  54125. * @param scene defines the hosting scene
  54126. * @param bone defines the target bone
  54127. * @param mesh defines the target mesh
  54128. * @param scaleLines defines a scaling factor for line length (1 by default)
  54129. */
  54130. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54131. /**
  54132. * Force the viewer to update
  54133. */
  54134. update(): void;
  54135. /** Releases resources */
  54136. dispose(): void;
  54137. }
  54138. }
  54139. declare module BABYLON {
  54140. /**
  54141. * Interface used to define scene explorer extensibility option
  54142. */
  54143. export interface IExplorerExtensibilityOption {
  54144. /**
  54145. * Define the option label
  54146. */
  54147. label: string;
  54148. /**
  54149. * Defines the action to execute on click
  54150. */
  54151. action: (entity: any) => void;
  54152. }
  54153. /**
  54154. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54155. */
  54156. export interface IExplorerExtensibilityGroup {
  54157. /**
  54158. * Defines a predicate to test if a given type mut be extended
  54159. */
  54160. predicate: (entity: any) => boolean;
  54161. /**
  54162. * Gets the list of options added to a type
  54163. */
  54164. entries: IExplorerExtensibilityOption[];
  54165. }
  54166. /**
  54167. * Interface used to define the options to use to create the Inspector
  54168. */
  54169. export interface IInspectorOptions {
  54170. /**
  54171. * Display in overlay mode (default: false)
  54172. */
  54173. overlay?: boolean;
  54174. /**
  54175. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54176. */
  54177. globalRoot?: HTMLElement;
  54178. /**
  54179. * Display the Scene explorer
  54180. */
  54181. showExplorer?: boolean;
  54182. /**
  54183. * Display the property inspector
  54184. */
  54185. showInspector?: boolean;
  54186. /**
  54187. * Display in embed mode (both panes on the right)
  54188. */
  54189. embedMode?: boolean;
  54190. /**
  54191. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54192. */
  54193. handleResize?: boolean;
  54194. /**
  54195. * Allow the panes to popup (default: true)
  54196. */
  54197. enablePopup?: boolean;
  54198. /**
  54199. * Allow the panes to be closed by users (default: true)
  54200. */
  54201. enableClose?: boolean;
  54202. /**
  54203. * Optional list of extensibility entries
  54204. */
  54205. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54206. /**
  54207. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54208. */
  54209. inspectorURL?: string;
  54210. /**
  54211. * Optional initial tab (default to DebugLayerTab.Properties)
  54212. */
  54213. initialTab?: DebugLayerTab;
  54214. }
  54215. interface Scene {
  54216. /**
  54217. * @hidden
  54218. * Backing field
  54219. */
  54220. _debugLayer: DebugLayer;
  54221. /**
  54222. * Gets the debug layer (aka Inspector) associated with the scene
  54223. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54224. */
  54225. debugLayer: DebugLayer;
  54226. }
  54227. /**
  54228. * Enum of inspector action tab
  54229. */
  54230. export enum DebugLayerTab {
  54231. /**
  54232. * Properties tag (default)
  54233. */
  54234. Properties = 0,
  54235. /**
  54236. * Debug tab
  54237. */
  54238. Debug = 1,
  54239. /**
  54240. * Statistics tab
  54241. */
  54242. Statistics = 2,
  54243. /**
  54244. * Tools tab
  54245. */
  54246. Tools = 3,
  54247. /**
  54248. * Settings tab
  54249. */
  54250. Settings = 4
  54251. }
  54252. /**
  54253. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54254. * what is happening in your scene
  54255. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54256. */
  54257. export class DebugLayer {
  54258. /**
  54259. * Define the url to get the inspector script from.
  54260. * By default it uses the babylonjs CDN.
  54261. * @ignoreNaming
  54262. */
  54263. static InspectorURL: string;
  54264. private _scene;
  54265. private BJSINSPECTOR;
  54266. private _onPropertyChangedObservable?;
  54267. /**
  54268. * Observable triggered when a property is changed through the inspector.
  54269. */
  54270. get onPropertyChangedObservable(): any;
  54271. /**
  54272. * Instantiates a new debug layer.
  54273. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54274. * what is happening in your scene
  54275. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54276. * @param scene Defines the scene to inspect
  54277. */
  54278. constructor(scene: Scene);
  54279. /** Creates the inspector window. */
  54280. private _createInspector;
  54281. /**
  54282. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54283. * @param entity defines the entity to select
  54284. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54285. */
  54286. select(entity: any, lineContainerTitles?: string | string[]): void;
  54287. /** Get the inspector from bundle or global */
  54288. private _getGlobalInspector;
  54289. /**
  54290. * Get if the inspector is visible or not.
  54291. * @returns true if visible otherwise, false
  54292. */
  54293. isVisible(): boolean;
  54294. /**
  54295. * Hide the inspector and close its window.
  54296. */
  54297. hide(): void;
  54298. /**
  54299. * Update the scene in the inspector
  54300. */
  54301. setAsActiveScene(): void;
  54302. /**
  54303. * Launch the debugLayer.
  54304. * @param config Define the configuration of the inspector
  54305. * @return a promise fulfilled when the debug layer is visible
  54306. */
  54307. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54308. }
  54309. }
  54310. declare module BABYLON {
  54311. /**
  54312. * Class containing static functions to help procedurally build meshes
  54313. */
  54314. export class BoxBuilder {
  54315. /**
  54316. * Creates a box mesh
  54317. * * The parameter `size` sets the size (float) of each box side (default 1)
  54318. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54319. * * 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)
  54320. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54322. * * 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
  54323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54324. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54325. * @param name defines the name of the mesh
  54326. * @param options defines the options used to create the mesh
  54327. * @param scene defines the hosting scene
  54328. * @returns the box mesh
  54329. */
  54330. static CreateBox(name: string, options: {
  54331. size?: number;
  54332. width?: number;
  54333. height?: number;
  54334. depth?: number;
  54335. faceUV?: Vector4[];
  54336. faceColors?: Color4[];
  54337. sideOrientation?: number;
  54338. frontUVs?: Vector4;
  54339. backUVs?: Vector4;
  54340. wrap?: boolean;
  54341. topBaseAt?: number;
  54342. bottomBaseAt?: number;
  54343. updatable?: boolean;
  54344. }, scene?: Nullable<Scene>): Mesh;
  54345. }
  54346. }
  54347. declare module BABYLON.Debug {
  54348. /**
  54349. * Used to show the physics impostor around the specific mesh
  54350. */
  54351. export class PhysicsViewer {
  54352. /** @hidden */
  54353. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54354. /** @hidden */
  54355. protected _meshes: Array<Nullable<AbstractMesh>>;
  54356. /** @hidden */
  54357. protected _scene: Nullable<Scene>;
  54358. /** @hidden */
  54359. protected _numMeshes: number;
  54360. /** @hidden */
  54361. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54362. private _renderFunction;
  54363. private _utilityLayer;
  54364. private _debugBoxMesh;
  54365. private _debugSphereMesh;
  54366. private _debugCylinderMesh;
  54367. private _debugMaterial;
  54368. private _debugMeshMeshes;
  54369. /**
  54370. * Creates a new PhysicsViewer
  54371. * @param scene defines the hosting scene
  54372. */
  54373. constructor(scene: Scene);
  54374. /** @hidden */
  54375. protected _updateDebugMeshes(): void;
  54376. /**
  54377. * Renders a specified physic impostor
  54378. * @param impostor defines the impostor to render
  54379. * @param targetMesh defines the mesh represented by the impostor
  54380. * @returns the new debug mesh used to render the impostor
  54381. */
  54382. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54383. /**
  54384. * Hides a specified physic impostor
  54385. * @param impostor defines the impostor to hide
  54386. */
  54387. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54388. private _getDebugMaterial;
  54389. private _getDebugBoxMesh;
  54390. private _getDebugSphereMesh;
  54391. private _getDebugCylinderMesh;
  54392. private _getDebugMeshMesh;
  54393. private _getDebugMesh;
  54394. /** Releases all resources */
  54395. dispose(): void;
  54396. }
  54397. }
  54398. declare module BABYLON {
  54399. /**
  54400. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54401. * in order to better appreciate the issue one might have.
  54402. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54403. */
  54404. export class RayHelper {
  54405. /**
  54406. * Defines the ray we are currently tryin to visualize.
  54407. */
  54408. ray: Nullable<Ray>;
  54409. private _renderPoints;
  54410. private _renderLine;
  54411. private _renderFunction;
  54412. private _scene;
  54413. private _onAfterRenderObserver;
  54414. private _onAfterStepObserver;
  54415. private _attachedToMesh;
  54416. private _meshSpaceDirection;
  54417. private _meshSpaceOrigin;
  54418. /**
  54419. * Helper function to create a colored helper in a scene in one line.
  54420. * @param ray Defines the ray we are currently tryin to visualize
  54421. * @param scene Defines the scene the ray is used in
  54422. * @param color Defines the color we want to see the ray in
  54423. * @returns The newly created ray helper.
  54424. */
  54425. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54426. /**
  54427. * Instantiate a new ray helper.
  54428. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54429. * in order to better appreciate the issue one might have.
  54430. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54431. * @param ray Defines the ray we are currently tryin to visualize
  54432. */
  54433. constructor(ray: Ray);
  54434. /**
  54435. * Shows the ray we are willing to debug.
  54436. * @param scene Defines the scene the ray needs to be rendered in
  54437. * @param color Defines the color the ray needs to be rendered in
  54438. */
  54439. show(scene: Scene, color?: Color3): void;
  54440. /**
  54441. * Hides the ray we are debugging.
  54442. */
  54443. hide(): void;
  54444. private _render;
  54445. /**
  54446. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54447. * @param mesh Defines the mesh we want the helper attached to
  54448. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54449. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54450. * @param length Defines the length of the ray
  54451. */
  54452. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54453. /**
  54454. * Detach the ray helper from the mesh it has previously been attached to.
  54455. */
  54456. detachFromMesh(): void;
  54457. private _updateToMesh;
  54458. /**
  54459. * Dispose the helper and release its associated resources.
  54460. */
  54461. dispose(): void;
  54462. }
  54463. }
  54464. declare module BABYLON {
  54465. /**
  54466. * Defines the options associated with the creation of a SkeletonViewer.
  54467. */
  54468. export interface ISkeletonViewerOptions {
  54469. /** Should the system pause animations before building the Viewer? */
  54470. pauseAnimations: boolean;
  54471. /** Should the system return the skeleton to rest before building? */
  54472. returnToRest: boolean;
  54473. /** public Display Mode of the Viewer */
  54474. displayMode: number;
  54475. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54476. displayOptions: ISkeletonViewerDisplayOptions;
  54477. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54478. computeBonesUsingShaders: boolean;
  54479. /** Flag ignore non weighted bones */
  54480. useAllBones: boolean;
  54481. }
  54482. /**
  54483. * Defines how to display the various bone meshes for the viewer.
  54484. */
  54485. export interface ISkeletonViewerDisplayOptions {
  54486. /** How far down to start tapering the bone spurs */
  54487. midStep?: number;
  54488. /** How big is the midStep? */
  54489. midStepFactor?: number;
  54490. /** Base for the Sphere Size */
  54491. sphereBaseSize?: number;
  54492. /** The ratio of the sphere to the longest bone in units */
  54493. sphereScaleUnit?: number;
  54494. /** Ratio for the Sphere Size */
  54495. sphereFactor?: number;
  54496. /** Whether a spur should attach its far end to the child bone position */
  54497. spurFollowsChild?: boolean;
  54498. /** Whether to show local axes or not */
  54499. showLocalAxes?: boolean;
  54500. /** Length of each local axis */
  54501. localAxesSize?: number;
  54502. }
  54503. /**
  54504. * Defines the constructor options for the BoneWeight Shader.
  54505. */
  54506. export interface IBoneWeightShaderOptions {
  54507. /** Skeleton to Map */
  54508. skeleton: Skeleton;
  54509. /** Colors for Uninfluenced bones */
  54510. colorBase?: Color3;
  54511. /** Colors for 0.0-0.25 Weight bones */
  54512. colorZero?: Color3;
  54513. /** Color for 0.25-0.5 Weight Influence */
  54514. colorQuarter?: Color3;
  54515. /** Color for 0.5-0.75 Weight Influence */
  54516. colorHalf?: Color3;
  54517. /** Color for 0.75-1 Weight Influence */
  54518. colorFull?: Color3;
  54519. /** Color for Zero Weight Influence */
  54520. targetBoneIndex?: number;
  54521. }
  54522. /**
  54523. * Simple structure of the gradient steps for the Color Map.
  54524. */
  54525. export interface ISkeletonMapShaderColorMapKnot {
  54526. /** Color of the Knot */
  54527. color: Color3;
  54528. /** Location of the Knot */
  54529. location: number;
  54530. }
  54531. /**
  54532. * Defines the constructor options for the SkeletonMap Shader.
  54533. */
  54534. export interface ISkeletonMapShaderOptions {
  54535. /** Skeleton to Map */
  54536. skeleton: Skeleton;
  54537. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54538. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54539. }
  54540. }
  54541. declare module BABYLON {
  54542. /**
  54543. * Class containing static functions to help procedurally build meshes
  54544. */
  54545. export class RibbonBuilder {
  54546. /**
  54547. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54548. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54549. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54550. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54551. * * 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
  54552. * * 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
  54553. * * 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
  54554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54555. * * 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
  54556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54557. * * 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
  54558. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54559. * * 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
  54560. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54562. * @param name defines the name of the mesh
  54563. * @param options defines the options used to create the mesh
  54564. * @param scene defines the hosting scene
  54565. * @returns the ribbon mesh
  54566. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54567. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54568. */
  54569. static CreateRibbon(name: string, options: {
  54570. pathArray: Vector3[][];
  54571. closeArray?: boolean;
  54572. closePath?: boolean;
  54573. offset?: number;
  54574. updatable?: boolean;
  54575. sideOrientation?: number;
  54576. frontUVs?: Vector4;
  54577. backUVs?: Vector4;
  54578. instance?: Mesh;
  54579. invertUV?: boolean;
  54580. uvs?: Vector2[];
  54581. colors?: Color4[];
  54582. }, scene?: Nullable<Scene>): Mesh;
  54583. }
  54584. }
  54585. declare module BABYLON {
  54586. /**
  54587. * Class containing static functions to help procedurally build meshes
  54588. */
  54589. export class ShapeBuilder {
  54590. /**
  54591. * 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.
  54592. * * 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.
  54593. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54594. * * 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.
  54595. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54596. * * 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
  54597. * * 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
  54598. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54600. * * 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
  54601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54603. * @param name defines the name of the mesh
  54604. * @param options defines the options used to create the mesh
  54605. * @param scene defines the hosting scene
  54606. * @returns the extruded shape mesh
  54607. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54609. */
  54610. static ExtrudeShape(name: string, options: {
  54611. shape: Vector3[];
  54612. path: Vector3[];
  54613. scale?: number;
  54614. rotation?: number;
  54615. cap?: number;
  54616. updatable?: boolean;
  54617. sideOrientation?: number;
  54618. frontUVs?: Vector4;
  54619. backUVs?: Vector4;
  54620. instance?: Mesh;
  54621. invertUV?: boolean;
  54622. }, scene?: Nullable<Scene>): Mesh;
  54623. /**
  54624. * Creates an custom extruded shape mesh.
  54625. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54626. * * 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.
  54627. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54628. * * 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
  54629. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54630. * * 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
  54631. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54632. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54633. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54634. * * 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
  54635. * * 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
  54636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54638. * * 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
  54639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54641. * @param name defines the name of the mesh
  54642. * @param options defines the options used to create the mesh
  54643. * @param scene defines the hosting scene
  54644. * @returns the custom extruded shape mesh
  54645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54648. */
  54649. static ExtrudeShapeCustom(name: string, options: {
  54650. shape: Vector3[];
  54651. path: Vector3[];
  54652. scaleFunction?: any;
  54653. rotationFunction?: any;
  54654. ribbonCloseArray?: boolean;
  54655. ribbonClosePath?: boolean;
  54656. cap?: number;
  54657. updatable?: boolean;
  54658. sideOrientation?: number;
  54659. frontUVs?: Vector4;
  54660. backUVs?: Vector4;
  54661. instance?: Mesh;
  54662. invertUV?: boolean;
  54663. }, scene?: Nullable<Scene>): Mesh;
  54664. private static _ExtrudeShapeGeneric;
  54665. }
  54666. }
  54667. declare module BABYLON.Debug {
  54668. /**
  54669. * Class used to render a debug view of a given skeleton
  54670. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54671. */
  54672. export class SkeletonViewer {
  54673. /** defines the skeleton to render */
  54674. skeleton: Skeleton;
  54675. /** defines the mesh attached to the skeleton */
  54676. mesh: AbstractMesh;
  54677. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54678. autoUpdateBonesMatrices: boolean;
  54679. /** defines the rendering group id to use with the viewer */
  54680. renderingGroupId: number;
  54681. /** is the options for the viewer */
  54682. options: Partial<ISkeletonViewerOptions>;
  54683. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54684. static readonly DISPLAY_LINES: number;
  54685. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54686. static readonly DISPLAY_SPHERES: number;
  54687. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54688. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54689. /** public static method to create a BoneWeight Shader
  54690. * @param options The constructor options
  54691. * @param scene The scene that the shader is scoped to
  54692. * @returns The created ShaderMaterial
  54693. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54694. */
  54695. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54696. /** public static method to create a BoneWeight Shader
  54697. * @param options The constructor options
  54698. * @param scene The scene that the shader is scoped to
  54699. * @returns The created ShaderMaterial
  54700. */
  54701. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54702. /** private static method to create a BoneWeight Shader
  54703. * @param size The size of the buffer to create (usually the bone count)
  54704. * @param colorMap The gradient data to generate
  54705. * @param scene The scene that the shader is scoped to
  54706. * @returns an Array of floats from the color gradient values
  54707. */
  54708. private static _CreateBoneMapColorBuffer;
  54709. /** If SkeletonViewer scene scope. */
  54710. private _scene;
  54711. /** Gets or sets the color used to render the skeleton */
  54712. color: Color3;
  54713. /** Array of the points of the skeleton fo the line view. */
  54714. private _debugLines;
  54715. /** The SkeletonViewers Mesh. */
  54716. private _debugMesh;
  54717. /** The local axes Meshes. */
  54718. private _localAxes;
  54719. /** If SkeletonViewer is enabled. */
  54720. private _isEnabled;
  54721. /** If SkeletonViewer is ready. */
  54722. private _ready;
  54723. /** SkeletonViewer render observable. */
  54724. private _obs;
  54725. /** The Utility Layer to render the gizmos in. */
  54726. private _utilityLayer;
  54727. private _boneIndices;
  54728. /** Gets the Scene. */
  54729. get scene(): Scene;
  54730. /** Gets the utilityLayer. */
  54731. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54732. /** Checks Ready Status. */
  54733. get isReady(): Boolean;
  54734. /** Sets Ready Status. */
  54735. set ready(value: boolean);
  54736. /** Gets the debugMesh */
  54737. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54738. /** Sets the debugMesh */
  54739. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54740. /** Gets the displayMode */
  54741. get displayMode(): number;
  54742. /** Sets the displayMode */
  54743. set displayMode(value: number);
  54744. /**
  54745. * Creates a new SkeletonViewer
  54746. * @param skeleton defines the skeleton to render
  54747. * @param mesh defines the mesh attached to the skeleton
  54748. * @param scene defines the hosting scene
  54749. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54750. * @param renderingGroupId defines the rendering group id to use with the viewer
  54751. * @param options All of the extra constructor options for the SkeletonViewer
  54752. */
  54753. constructor(
  54754. /** defines the skeleton to render */
  54755. skeleton: Skeleton,
  54756. /** defines the mesh attached to the skeleton */
  54757. mesh: AbstractMesh,
  54758. /** The Scene scope*/
  54759. scene: Scene,
  54760. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54761. autoUpdateBonesMatrices?: boolean,
  54762. /** defines the rendering group id to use with the viewer */
  54763. renderingGroupId?: number,
  54764. /** is the options for the viewer */
  54765. options?: Partial<ISkeletonViewerOptions>);
  54766. /** The Dynamic bindings for the update functions */
  54767. private _bindObs;
  54768. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54769. update(): void;
  54770. /** Gets or sets a boolean indicating if the viewer is enabled */
  54771. set isEnabled(value: boolean);
  54772. get isEnabled(): boolean;
  54773. private _getBonePosition;
  54774. private _getLinesForBonesWithLength;
  54775. private _getLinesForBonesNoLength;
  54776. /** function to revert the mesh and scene back to the initial state. */
  54777. private _revert;
  54778. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54779. private _getAbsoluteBindPoseToRef;
  54780. /** function to build and bind sphere joint points and spur bone representations. */
  54781. private _buildSpheresAndSpurs;
  54782. private _buildLocalAxes;
  54783. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54784. private _displayLinesUpdate;
  54785. /** Changes the displayMode of the skeleton viewer
  54786. * @param mode The displayMode numerical value
  54787. */
  54788. changeDisplayMode(mode: number): void;
  54789. /** Sets a display option of the skeleton viewer
  54790. *
  54791. * | Option | Type | Default | Description |
  54792. * | ---------------- | ------- | ------- | ----------- |
  54793. * | 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`. |
  54794. * | 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`. |
  54795. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54796. * | 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`. |
  54797. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54798. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54799. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54800. *
  54801. * @param option String of the option name
  54802. * @param value The numerical option value
  54803. */
  54804. changeDisplayOptions(option: string, value: number): void;
  54805. /** Release associated resources */
  54806. dispose(): void;
  54807. }
  54808. }
  54809. declare module BABYLON {
  54810. /**
  54811. * Enum for Device Types
  54812. */
  54813. export enum DeviceType {
  54814. /** Generic */
  54815. Generic = 0,
  54816. /** Keyboard */
  54817. Keyboard = 1,
  54818. /** Mouse */
  54819. Mouse = 2,
  54820. /** Touch Pointers */
  54821. Touch = 3,
  54822. /** PS4 Dual Shock */
  54823. DualShock = 4,
  54824. /** Xbox */
  54825. Xbox = 5,
  54826. /** Switch Controller */
  54827. Switch = 6
  54828. }
  54829. /**
  54830. * Enum for All Pointers (Touch/Mouse)
  54831. */
  54832. export enum PointerInput {
  54833. /** Horizontal Axis */
  54834. Horizontal = 0,
  54835. /** Vertical Axis */
  54836. Vertical = 1,
  54837. /** Left Click or Touch */
  54838. LeftClick = 2,
  54839. /** Middle Click */
  54840. MiddleClick = 3,
  54841. /** Right Click */
  54842. RightClick = 4,
  54843. /** Browser Back */
  54844. BrowserBack = 5,
  54845. /** Browser Forward */
  54846. BrowserForward = 6
  54847. }
  54848. /**
  54849. * Enum for Dual Shock Gamepad
  54850. */
  54851. export enum DualShockInput {
  54852. /** Cross */
  54853. Cross = 0,
  54854. /** Circle */
  54855. Circle = 1,
  54856. /** Square */
  54857. Square = 2,
  54858. /** Triangle */
  54859. Triangle = 3,
  54860. /** L1 */
  54861. L1 = 4,
  54862. /** R1 */
  54863. R1 = 5,
  54864. /** L2 */
  54865. L2 = 6,
  54866. /** R2 */
  54867. R2 = 7,
  54868. /** Share */
  54869. Share = 8,
  54870. /** Options */
  54871. Options = 9,
  54872. /** L3 */
  54873. L3 = 10,
  54874. /** R3 */
  54875. R3 = 11,
  54876. /** DPadUp */
  54877. DPadUp = 12,
  54878. /** DPadDown */
  54879. DPadDown = 13,
  54880. /** DPadLeft */
  54881. DPadLeft = 14,
  54882. /** DRight */
  54883. DPadRight = 15,
  54884. /** Home */
  54885. Home = 16,
  54886. /** TouchPad */
  54887. TouchPad = 17,
  54888. /** LStickXAxis */
  54889. LStickXAxis = 18,
  54890. /** LStickYAxis */
  54891. LStickYAxis = 19,
  54892. /** RStickXAxis */
  54893. RStickXAxis = 20,
  54894. /** RStickYAxis */
  54895. RStickYAxis = 21
  54896. }
  54897. /**
  54898. * Enum for Xbox Gamepad
  54899. */
  54900. export enum XboxInput {
  54901. /** A */
  54902. A = 0,
  54903. /** B */
  54904. B = 1,
  54905. /** X */
  54906. X = 2,
  54907. /** Y */
  54908. Y = 3,
  54909. /** LB */
  54910. LB = 4,
  54911. /** RB */
  54912. RB = 5,
  54913. /** LT */
  54914. LT = 6,
  54915. /** RT */
  54916. RT = 7,
  54917. /** Back */
  54918. Back = 8,
  54919. /** Start */
  54920. Start = 9,
  54921. /** LS */
  54922. LS = 10,
  54923. /** RS */
  54924. RS = 11,
  54925. /** DPadUp */
  54926. DPadUp = 12,
  54927. /** DPadDown */
  54928. DPadDown = 13,
  54929. /** DPadLeft */
  54930. DPadLeft = 14,
  54931. /** DRight */
  54932. DPadRight = 15,
  54933. /** Home */
  54934. Home = 16,
  54935. /** LStickXAxis */
  54936. LStickXAxis = 17,
  54937. /** LStickYAxis */
  54938. LStickYAxis = 18,
  54939. /** RStickXAxis */
  54940. RStickXAxis = 19,
  54941. /** RStickYAxis */
  54942. RStickYAxis = 20
  54943. }
  54944. /**
  54945. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54946. */
  54947. export enum SwitchInput {
  54948. /** B */
  54949. B = 0,
  54950. /** A */
  54951. A = 1,
  54952. /** Y */
  54953. Y = 2,
  54954. /** X */
  54955. X = 3,
  54956. /** L */
  54957. L = 4,
  54958. /** R */
  54959. R = 5,
  54960. /** ZL */
  54961. ZL = 6,
  54962. /** ZR */
  54963. ZR = 7,
  54964. /** Minus */
  54965. Minus = 8,
  54966. /** Plus */
  54967. Plus = 9,
  54968. /** LS */
  54969. LS = 10,
  54970. /** RS */
  54971. RS = 11,
  54972. /** DPadUp */
  54973. DPadUp = 12,
  54974. /** DPadDown */
  54975. DPadDown = 13,
  54976. /** DPadLeft */
  54977. DPadLeft = 14,
  54978. /** DRight */
  54979. DPadRight = 15,
  54980. /** Home */
  54981. Home = 16,
  54982. /** Capture */
  54983. Capture = 17,
  54984. /** LStickXAxis */
  54985. LStickXAxis = 18,
  54986. /** LStickYAxis */
  54987. LStickYAxis = 19,
  54988. /** RStickXAxis */
  54989. RStickXAxis = 20,
  54990. /** RStickYAxis */
  54991. RStickYAxis = 21
  54992. }
  54993. }
  54994. declare module BABYLON {
  54995. /**
  54996. * This class will take all inputs from Keyboard, Pointer, and
  54997. * any Gamepads and provide a polling system that all devices
  54998. * will use. This class assumes that there will only be one
  54999. * pointer device and one keyboard.
  55000. */
  55001. export class DeviceInputSystem implements IDisposable {
  55002. /**
  55003. * Returns onDeviceConnected callback property
  55004. * @returns Callback with function to execute when a device is connected
  55005. */
  55006. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55007. /**
  55008. * Sets callback function when a device is connected and executes against all connected devices
  55009. * @param callback Function to execute when a device is connected
  55010. */
  55011. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55012. /**
  55013. * Callback to be triggered when a device is disconnected
  55014. */
  55015. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55016. /**
  55017. * Callback to be triggered when event driven input is updated
  55018. */
  55019. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55020. private _inputs;
  55021. private _gamepads;
  55022. private _keyboardActive;
  55023. private _pointerActive;
  55024. private _elementToAttachTo;
  55025. private _keyboardDownEvent;
  55026. private _keyboardUpEvent;
  55027. private _pointerMoveEvent;
  55028. private _pointerDownEvent;
  55029. private _pointerUpEvent;
  55030. private _gamepadConnectedEvent;
  55031. private _gamepadDisconnectedEvent;
  55032. private _onDeviceConnected;
  55033. private static _MAX_KEYCODES;
  55034. private static _MAX_POINTER_INPUTS;
  55035. private constructor();
  55036. /**
  55037. * Creates a new DeviceInputSystem instance
  55038. * @param engine Engine to pull input element from
  55039. * @returns The new instance
  55040. */
  55041. static Create(engine: Engine): DeviceInputSystem;
  55042. /**
  55043. * Checks for current device input value, given an id and input index
  55044. * @param deviceName Id of connected device
  55045. * @param inputIndex Index of device input
  55046. * @returns Current value of input
  55047. */
  55048. /**
  55049. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55050. * @param deviceType Enum specifiying device type
  55051. * @param deviceSlot "Slot" or index that device is referenced in
  55052. * @param inputIndex Id of input to be checked
  55053. * @returns Current value of input
  55054. */
  55055. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55056. /**
  55057. * Dispose of all the eventlisteners
  55058. */
  55059. dispose(): void;
  55060. /**
  55061. * Checks for existing connections to devices and register them, if necessary
  55062. * Currently handles gamepads and mouse
  55063. */
  55064. private _checkForConnectedDevices;
  55065. /**
  55066. * Add a gamepad to the DeviceInputSystem
  55067. * @param gamepad A single DOM Gamepad object
  55068. */
  55069. private _addGamePad;
  55070. /**
  55071. * Add pointer device to DeviceInputSystem
  55072. * @param deviceType Type of Pointer to add
  55073. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55074. * @param currentX Current X at point of adding
  55075. * @param currentY Current Y at point of adding
  55076. */
  55077. private _addPointerDevice;
  55078. /**
  55079. * Add device and inputs to device array
  55080. * @param deviceType Enum specifiying device type
  55081. * @param deviceSlot "Slot" or index that device is referenced in
  55082. * @param numberOfInputs Number of input entries to create for given device
  55083. */
  55084. private _registerDevice;
  55085. /**
  55086. * Given a specific device name, remove that device from the device map
  55087. * @param deviceType Enum specifiying device type
  55088. * @param deviceSlot "Slot" or index that device is referenced in
  55089. */
  55090. private _unregisterDevice;
  55091. /**
  55092. * Handle all actions that come from keyboard interaction
  55093. */
  55094. private _handleKeyActions;
  55095. /**
  55096. * Handle all actions that come from pointer interaction
  55097. */
  55098. private _handlePointerActions;
  55099. /**
  55100. * Handle all actions that come from gamepad interaction
  55101. */
  55102. private _handleGamepadActions;
  55103. /**
  55104. * Update all non-event based devices with each frame
  55105. * @param deviceType Enum specifiying device type
  55106. * @param deviceSlot "Slot" or index that device is referenced in
  55107. * @param inputIndex Id of input to be checked
  55108. */
  55109. private _updateDevice;
  55110. /**
  55111. * Gets DeviceType from the device name
  55112. * @param deviceName Name of Device from DeviceInputSystem
  55113. * @returns DeviceType enum value
  55114. */
  55115. private _getGamepadDeviceType;
  55116. }
  55117. }
  55118. declare module BABYLON {
  55119. /**
  55120. * Type to handle enforcement of inputs
  55121. */
  55122. 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;
  55123. }
  55124. declare module BABYLON {
  55125. /**
  55126. * Class that handles all input for a specific device
  55127. */
  55128. export class DeviceSource<T extends DeviceType> {
  55129. /** Type of device */
  55130. readonly deviceType: DeviceType;
  55131. /** "Slot" or index that device is referenced in */
  55132. readonly deviceSlot: number;
  55133. /**
  55134. * Observable to handle device input changes per device
  55135. */
  55136. readonly onInputChangedObservable: Observable<{
  55137. inputIndex: DeviceInput<T>;
  55138. previousState: Nullable<number>;
  55139. currentState: Nullable<number>;
  55140. }>;
  55141. private readonly _deviceInputSystem;
  55142. /**
  55143. * Default Constructor
  55144. * @param deviceInputSystem Reference to DeviceInputSystem
  55145. * @param deviceType Type of device
  55146. * @param deviceSlot "Slot" or index that device is referenced in
  55147. */
  55148. constructor(deviceInputSystem: DeviceInputSystem,
  55149. /** Type of device */
  55150. deviceType: DeviceType,
  55151. /** "Slot" or index that device is referenced in */
  55152. deviceSlot?: number);
  55153. /**
  55154. * Get input for specific input
  55155. * @param inputIndex index of specific input on device
  55156. * @returns Input value from DeviceInputSystem
  55157. */
  55158. getInput(inputIndex: DeviceInput<T>): number;
  55159. }
  55160. /**
  55161. * Class to keep track of devices
  55162. */
  55163. export class DeviceSourceManager implements IDisposable {
  55164. /**
  55165. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55166. */
  55167. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55168. /**
  55169. * Observable to be triggered when after a device is disconnected
  55170. */
  55171. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55172. private readonly _devices;
  55173. private readonly _firstDevice;
  55174. private readonly _deviceInputSystem;
  55175. /**
  55176. * Default Constructor
  55177. * @param engine engine to pull input element from
  55178. */
  55179. constructor(engine: Engine);
  55180. /**
  55181. * Gets a DeviceSource, given a type and slot
  55182. * @param deviceType Enum specifying device type
  55183. * @param deviceSlot "Slot" or index that device is referenced in
  55184. * @returns DeviceSource object
  55185. */
  55186. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55187. /**
  55188. * Gets an array of DeviceSource objects for a given device type
  55189. * @param deviceType Enum specifying device type
  55190. * @returns Array of DeviceSource objects
  55191. */
  55192. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55193. /**
  55194. * Returns a read-only list of all available devices
  55195. * @returns Read-only array with active devices
  55196. */
  55197. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55198. /**
  55199. * Dispose of DeviceInputSystem and other parts
  55200. */
  55201. dispose(): void;
  55202. /**
  55203. * Function to add device name to device list
  55204. * @param deviceType Enum specifying device type
  55205. * @param deviceSlot "Slot" or index that device is referenced in
  55206. */
  55207. private _addDevice;
  55208. /**
  55209. * Function to remove device name to device list
  55210. * @param deviceType Enum specifying device type
  55211. * @param deviceSlot "Slot" or index that device is referenced in
  55212. */
  55213. private _removeDevice;
  55214. /**
  55215. * Updates array storing first connected device of each type
  55216. * @param type Type of Device
  55217. */
  55218. private _updateFirstDevices;
  55219. }
  55220. }
  55221. declare module BABYLON {
  55222. /**
  55223. * Options to create the null engine
  55224. */
  55225. export class NullEngineOptions {
  55226. /**
  55227. * Render width (Default: 512)
  55228. */
  55229. renderWidth: number;
  55230. /**
  55231. * Render height (Default: 256)
  55232. */
  55233. renderHeight: number;
  55234. /**
  55235. * Texture size (Default: 512)
  55236. */
  55237. textureSize: number;
  55238. /**
  55239. * If delta time between frames should be constant
  55240. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55241. */
  55242. deterministicLockstep: boolean;
  55243. /**
  55244. * Maximum about of steps between frames (Default: 4)
  55245. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55246. */
  55247. lockstepMaxSteps: number;
  55248. /**
  55249. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55250. */
  55251. useHighPrecisionMatrix?: boolean;
  55252. }
  55253. /**
  55254. * The null engine class provides support for headless version of babylon.js.
  55255. * This can be used in server side scenario or for testing purposes
  55256. */
  55257. export class NullEngine extends Engine {
  55258. private _options;
  55259. /**
  55260. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55261. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55262. * @returns true if engine is in deterministic lock step mode
  55263. */
  55264. isDeterministicLockStep(): boolean;
  55265. /**
  55266. * Gets the max steps when engine is running in deterministic lock step
  55267. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55268. * @returns the max steps
  55269. */
  55270. getLockstepMaxSteps(): number;
  55271. /**
  55272. * Gets the current hardware scaling level.
  55273. * By default the hardware scaling level is computed from the window device ratio.
  55274. * 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.
  55275. * @returns a number indicating the current hardware scaling level
  55276. */
  55277. getHardwareScalingLevel(): number;
  55278. constructor(options?: NullEngineOptions);
  55279. /**
  55280. * Creates a vertex buffer
  55281. * @param vertices the data for the vertex buffer
  55282. * @returns the new WebGL static buffer
  55283. */
  55284. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55285. /**
  55286. * Creates a new index buffer
  55287. * @param indices defines the content of the index buffer
  55288. * @param updatable defines if the index buffer must be updatable
  55289. * @returns a new webGL buffer
  55290. */
  55291. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55292. /**
  55293. * Clear the current render buffer or the current render target (if any is set up)
  55294. * @param color defines the color to use
  55295. * @param backBuffer defines if the back buffer must be cleared
  55296. * @param depth defines if the depth buffer must be cleared
  55297. * @param stencil defines if the stencil buffer must be cleared
  55298. */
  55299. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55300. /**
  55301. * Gets the current render width
  55302. * @param useScreen defines if screen size must be used (or the current render target if any)
  55303. * @returns a number defining the current render width
  55304. */
  55305. getRenderWidth(useScreen?: boolean): number;
  55306. /**
  55307. * Gets the current render height
  55308. * @param useScreen defines if screen size must be used (or the current render target if any)
  55309. * @returns a number defining the current render height
  55310. */
  55311. getRenderHeight(useScreen?: boolean): number;
  55312. /**
  55313. * Set the WebGL's viewport
  55314. * @param viewport defines the viewport element to be used
  55315. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55316. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55317. */
  55318. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55319. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55320. /**
  55321. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55322. * @param pipelineContext defines the pipeline context to use
  55323. * @param uniformsNames defines the list of uniform names
  55324. * @returns an array of webGL uniform locations
  55325. */
  55326. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55327. /**
  55328. * Gets the lsit of active attributes for a given webGL program
  55329. * @param pipelineContext defines the pipeline context to use
  55330. * @param attributesNames defines the list of attribute names to get
  55331. * @returns an array of indices indicating the offset of each attribute
  55332. */
  55333. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55334. /**
  55335. * Binds an effect to the webGL context
  55336. * @param effect defines the effect to bind
  55337. */
  55338. bindSamplers(effect: Effect): void;
  55339. /**
  55340. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55341. * @param effect defines the effect to activate
  55342. */
  55343. enableEffect(effect: Effect): void;
  55344. /**
  55345. * Set various states to the webGL context
  55346. * @param culling defines backface culling state
  55347. * @param zOffset defines the value to apply to zOffset (0 by default)
  55348. * @param force defines if states must be applied even if cache is up to date
  55349. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55350. */
  55351. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55352. /**
  55353. * Set the value of an uniform to an array of int32
  55354. * @param uniform defines the webGL uniform location where to store the value
  55355. * @param array defines the array of int32 to store
  55356. * @returns true if value was set
  55357. */
  55358. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55359. /**
  55360. * Set the value of an uniform to an array of int32 (stored as vec2)
  55361. * @param uniform defines the webGL uniform location where to store the value
  55362. * @param array defines the array of int32 to store
  55363. * @returns true if value was set
  55364. */
  55365. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55366. /**
  55367. * Set the value of an uniform to an array of int32 (stored as vec3)
  55368. * @param uniform defines the webGL uniform location where to store the value
  55369. * @param array defines the array of int32 to store
  55370. * @returns true if value was set
  55371. */
  55372. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55373. /**
  55374. * Set the value of an uniform to an array of int32 (stored as vec4)
  55375. * @param uniform defines the webGL uniform location where to store the value
  55376. * @param array defines the array of int32 to store
  55377. * @returns true if value was set
  55378. */
  55379. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55380. /**
  55381. * Set the value of an uniform to an array of float32
  55382. * @param uniform defines the webGL uniform location where to store the value
  55383. * @param array defines the array of float32 to store
  55384. * @returns true if value was set
  55385. */
  55386. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55387. /**
  55388. * Set the value of an uniform to an array of float32 (stored as vec2)
  55389. * @param uniform defines the webGL uniform location where to store the value
  55390. * @param array defines the array of float32 to store
  55391. * @returns true if value was set
  55392. */
  55393. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55394. /**
  55395. * Set the value of an uniform to an array of float32 (stored as vec3)
  55396. * @param uniform defines the webGL uniform location where to store the value
  55397. * @param array defines the array of float32 to store
  55398. * @returns true if value was set
  55399. */
  55400. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55401. /**
  55402. * Set the value of an uniform to an array of float32 (stored as vec4)
  55403. * @param uniform defines the webGL uniform location where to store the value
  55404. * @param array defines the array of float32 to store
  55405. * @returns true if value was set
  55406. */
  55407. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55408. /**
  55409. * Set the value of an uniform to an array of number
  55410. * @param uniform defines the webGL uniform location where to store the value
  55411. * @param array defines the array of number to store
  55412. * @returns true if value was set
  55413. */
  55414. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55415. /**
  55416. * Set the value of an uniform to an array of number (stored as vec2)
  55417. * @param uniform defines the webGL uniform location where to store the value
  55418. * @param array defines the array of number to store
  55419. * @returns true if value was set
  55420. */
  55421. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55422. /**
  55423. * Set the value of an uniform to an array of number (stored as vec3)
  55424. * @param uniform defines the webGL uniform location where to store the value
  55425. * @param array defines the array of number to store
  55426. * @returns true if value was set
  55427. */
  55428. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55429. /**
  55430. * Set the value of an uniform to an array of number (stored as vec4)
  55431. * @param uniform defines the webGL uniform location where to store the value
  55432. * @param array defines the array of number to store
  55433. * @returns true if value was set
  55434. */
  55435. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55436. /**
  55437. * Set the value of an uniform to an array of float32 (stored as matrices)
  55438. * @param uniform defines the webGL uniform location where to store the value
  55439. * @param matrices defines the array of float32 to store
  55440. * @returns true if value was set
  55441. */
  55442. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55443. /**
  55444. * Set the value of an uniform to a matrix (3x3)
  55445. * @param uniform defines the webGL uniform location where to store the value
  55446. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55447. * @returns true if value was set
  55448. */
  55449. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55450. /**
  55451. * Set the value of an uniform to a matrix (2x2)
  55452. * @param uniform defines the webGL uniform location where to store the value
  55453. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55454. * @returns true if value was set
  55455. */
  55456. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55457. /**
  55458. * Set the value of an uniform to a number (float)
  55459. * @param uniform defines the webGL uniform location where to store the value
  55460. * @param value defines the float number to store
  55461. * @returns true if value was set
  55462. */
  55463. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55464. /**
  55465. * Set the value of an uniform to a vec2
  55466. * @param uniform defines the webGL uniform location where to store the value
  55467. * @param x defines the 1st component of the value
  55468. * @param y defines the 2nd component of the value
  55469. * @returns true if value was set
  55470. */
  55471. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55472. /**
  55473. * Set the value of an uniform to a vec3
  55474. * @param uniform defines the webGL uniform location where to store the value
  55475. * @param x defines the 1st component of the value
  55476. * @param y defines the 2nd component of the value
  55477. * @param z defines the 3rd component of the value
  55478. * @returns true if value was set
  55479. */
  55480. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55481. /**
  55482. * Set the value of an uniform to a boolean
  55483. * @param uniform defines the webGL uniform location where to store the value
  55484. * @param bool defines the boolean to store
  55485. * @returns true if value was set
  55486. */
  55487. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55488. /**
  55489. * Set the value of an uniform to a vec4
  55490. * @param uniform defines the webGL uniform location where to store the value
  55491. * @param x defines the 1st component of the value
  55492. * @param y defines the 2nd component of the value
  55493. * @param z defines the 3rd component of the value
  55494. * @param w defines the 4th component of the value
  55495. * @returns true if value was set
  55496. */
  55497. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55498. /**
  55499. * Sets the current alpha mode
  55500. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55501. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55502. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55503. */
  55504. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55505. /**
  55506. * Bind webGl buffers directly to the webGL context
  55507. * @param vertexBuffers defines the vertex buffer to bind
  55508. * @param indexBuffer defines the index buffer to bind
  55509. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55510. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55511. * @param effect defines the effect associated with the vertex buffer
  55512. */
  55513. bindBuffers(vertexBuffers: {
  55514. [key: string]: VertexBuffer;
  55515. }, indexBuffer: DataBuffer, effect: Effect): void;
  55516. /**
  55517. * Force the entire cache to be cleared
  55518. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55519. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55520. */
  55521. wipeCaches(bruteForce?: boolean): void;
  55522. /**
  55523. * Send a draw order
  55524. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55525. * @param indexStart defines the starting index
  55526. * @param indexCount defines the number of index to draw
  55527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55528. */
  55529. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55530. /**
  55531. * Draw a list of indexed primitives
  55532. * @param fillMode defines the primitive to use
  55533. * @param indexStart defines the starting index
  55534. * @param indexCount defines the number of index to draw
  55535. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55536. */
  55537. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55538. /**
  55539. * Draw a list of unindexed primitives
  55540. * @param fillMode defines the primitive to use
  55541. * @param verticesStart defines the index of first vertex to draw
  55542. * @param verticesCount defines the count of vertices to draw
  55543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55544. */
  55545. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55546. /** @hidden */
  55547. _createTexture(): WebGLTexture;
  55548. /** @hidden */
  55549. _releaseTexture(texture: InternalTexture): void;
  55550. /**
  55551. * Usually called from Texture.ts.
  55552. * Passed information to create a WebGLTexture
  55553. * @param urlArg defines a value which contains one of the following:
  55554. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55555. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55556. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55557. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55558. * @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)
  55559. * @param scene needed for loading to the correct scene
  55560. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55561. * @param onLoad optional callback to be called upon successful completion
  55562. * @param onError optional callback to be called upon failure
  55563. * @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
  55564. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55565. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55566. * @param forcedExtension defines the extension to use to pick the right loader
  55567. * @param mimeType defines an optional mime type
  55568. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55569. */
  55570. 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;
  55571. /**
  55572. * Creates a new render target texture
  55573. * @param size defines the size of the texture
  55574. * @param options defines the options used to create the texture
  55575. * @returns a new render target texture stored in an InternalTexture
  55576. */
  55577. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55578. /**
  55579. * Update the sampling mode of a given texture
  55580. * @param samplingMode defines the required sampling mode
  55581. * @param texture defines the texture to update
  55582. */
  55583. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55584. /**
  55585. * Binds the frame buffer to the specified texture.
  55586. * @param texture The texture to render to or null for the default canvas
  55587. * @param faceIndex The face of the texture to render to in case of cube texture
  55588. * @param requiredWidth The width of the target to render to
  55589. * @param requiredHeight The height of the target to render to
  55590. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55591. * @param lodLevel defines le lod level to bind to the frame buffer
  55592. */
  55593. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55594. /**
  55595. * Unbind the current render target texture from the webGL context
  55596. * @param texture defines the render target texture to unbind
  55597. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55598. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55599. */
  55600. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55601. /**
  55602. * Creates a dynamic vertex buffer
  55603. * @param vertices the data for the dynamic vertex buffer
  55604. * @returns the new WebGL dynamic buffer
  55605. */
  55606. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55607. /**
  55608. * Update the content of a dynamic texture
  55609. * @param texture defines the texture to update
  55610. * @param canvas defines the canvas containing the source
  55611. * @param invertY defines if data must be stored with Y axis inverted
  55612. * @param premulAlpha defines if alpha is stored as premultiplied
  55613. * @param format defines the format of the data
  55614. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55615. */
  55616. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55617. /**
  55618. * Gets a boolean indicating if all created effects are ready
  55619. * @returns true if all effects are ready
  55620. */
  55621. areAllEffectsReady(): boolean;
  55622. /**
  55623. * @hidden
  55624. * Get the current error code of the webGL context
  55625. * @returns the error code
  55626. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55627. */
  55628. getError(): number;
  55629. /** @hidden */
  55630. _getUnpackAlignement(): number;
  55631. /** @hidden */
  55632. _unpackFlipY(value: boolean): void;
  55633. /**
  55634. * Update a dynamic index buffer
  55635. * @param indexBuffer defines the target index buffer
  55636. * @param indices defines the data to update
  55637. * @param offset defines the offset in the target index buffer where update should start
  55638. */
  55639. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55640. /**
  55641. * Updates a dynamic vertex buffer.
  55642. * @param vertexBuffer the vertex buffer to update
  55643. * @param vertices the data used to update the vertex buffer
  55644. * @param byteOffset the byte offset of the data (optional)
  55645. * @param byteLength the byte length of the data (optional)
  55646. */
  55647. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55648. /** @hidden */
  55649. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55650. /** @hidden */
  55651. _bindTexture(channel: number, texture: InternalTexture): void;
  55652. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55653. /**
  55654. * 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
  55655. */
  55656. releaseEffects(): void;
  55657. displayLoadingUI(): void;
  55658. hideLoadingUI(): void;
  55659. /** @hidden */
  55660. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55661. /** @hidden */
  55662. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55663. /** @hidden */
  55664. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55665. /** @hidden */
  55666. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /**
  55671. * @hidden
  55672. **/
  55673. export class _TimeToken {
  55674. _startTimeQuery: Nullable<WebGLQuery>;
  55675. _endTimeQuery: Nullable<WebGLQuery>;
  55676. _timeElapsedQuery: Nullable<WebGLQuery>;
  55677. _timeElapsedQueryEnded: boolean;
  55678. }
  55679. }
  55680. declare module BABYLON {
  55681. /** @hidden */
  55682. export class _OcclusionDataStorage {
  55683. /** @hidden */
  55684. occlusionInternalRetryCounter: number;
  55685. /** @hidden */
  55686. isOcclusionQueryInProgress: boolean;
  55687. /** @hidden */
  55688. isOccluded: boolean;
  55689. /** @hidden */
  55690. occlusionRetryCount: number;
  55691. /** @hidden */
  55692. occlusionType: number;
  55693. /** @hidden */
  55694. occlusionQueryAlgorithmType: number;
  55695. }
  55696. interface Engine {
  55697. /**
  55698. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55699. * @return the new query
  55700. */
  55701. createQuery(): WebGLQuery;
  55702. /**
  55703. * Delete and release a webGL query
  55704. * @param query defines the query to delete
  55705. * @return the current engine
  55706. */
  55707. deleteQuery(query: WebGLQuery): Engine;
  55708. /**
  55709. * Check if a given query has resolved and got its value
  55710. * @param query defines the query to check
  55711. * @returns true if the query got its value
  55712. */
  55713. isQueryResultAvailable(query: WebGLQuery): boolean;
  55714. /**
  55715. * Gets the value of a given query
  55716. * @param query defines the query to check
  55717. * @returns the value of the query
  55718. */
  55719. getQueryResult(query: WebGLQuery): number;
  55720. /**
  55721. * Initiates an occlusion query
  55722. * @param algorithmType defines the algorithm to use
  55723. * @param query defines the query to use
  55724. * @returns the current engine
  55725. * @see https://doc.babylonjs.com/features/occlusionquery
  55726. */
  55727. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55728. /**
  55729. * Ends an occlusion query
  55730. * @see https://doc.babylonjs.com/features/occlusionquery
  55731. * @param algorithmType defines the algorithm to use
  55732. * @returns the current engine
  55733. */
  55734. endOcclusionQuery(algorithmType: number): Engine;
  55735. /**
  55736. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55737. * Please note that only one query can be issued at a time
  55738. * @returns a time token used to track the time span
  55739. */
  55740. startTimeQuery(): Nullable<_TimeToken>;
  55741. /**
  55742. * Ends a time query
  55743. * @param token defines the token used to measure the time span
  55744. * @returns the time spent (in ns)
  55745. */
  55746. endTimeQuery(token: _TimeToken): int;
  55747. /** @hidden */
  55748. _currentNonTimestampToken: Nullable<_TimeToken>;
  55749. /** @hidden */
  55750. _createTimeQuery(): WebGLQuery;
  55751. /** @hidden */
  55752. _deleteTimeQuery(query: WebGLQuery): void;
  55753. /** @hidden */
  55754. _getGlAlgorithmType(algorithmType: number): number;
  55755. /** @hidden */
  55756. _getTimeQueryResult(query: WebGLQuery): any;
  55757. /** @hidden */
  55758. _getTimeQueryAvailability(query: WebGLQuery): any;
  55759. }
  55760. interface AbstractMesh {
  55761. /**
  55762. * Backing filed
  55763. * @hidden
  55764. */
  55765. __occlusionDataStorage: _OcclusionDataStorage;
  55766. /**
  55767. * Access property
  55768. * @hidden
  55769. */
  55770. _occlusionDataStorage: _OcclusionDataStorage;
  55771. /**
  55772. * 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.
  55773. * The default value is -1 which means don't break the query and wait till the result
  55774. * @see https://doc.babylonjs.com/features/occlusionquery
  55775. */
  55776. occlusionRetryCount: number;
  55777. /**
  55778. * 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:
  55779. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55780. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55781. * * 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.
  55782. * @see https://doc.babylonjs.com/features/occlusionquery
  55783. */
  55784. occlusionType: number;
  55785. /**
  55786. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55787. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55788. * * 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.
  55789. * @see https://doc.babylonjs.com/features/occlusionquery
  55790. */
  55791. occlusionQueryAlgorithmType: number;
  55792. /**
  55793. * 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
  55794. * @see https://doc.babylonjs.com/features/occlusionquery
  55795. */
  55796. isOccluded: boolean;
  55797. /**
  55798. * Flag to check the progress status of the query
  55799. * @see https://doc.babylonjs.com/features/occlusionquery
  55800. */
  55801. isOcclusionQueryInProgress: boolean;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /** @hidden */
  55806. export var _forceTransformFeedbackToBundle: boolean;
  55807. interface Engine {
  55808. /**
  55809. * Creates a webGL transform feedback object
  55810. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55811. * @returns the webGL transform feedback object
  55812. */
  55813. createTransformFeedback(): WebGLTransformFeedback;
  55814. /**
  55815. * Delete a webGL transform feedback object
  55816. * @param value defines the webGL transform feedback object to delete
  55817. */
  55818. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55819. /**
  55820. * Bind a webGL transform feedback object to the webgl context
  55821. * @param value defines the webGL transform feedback object to bind
  55822. */
  55823. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55824. /**
  55825. * Begins a transform feedback operation
  55826. * @param usePoints defines if points or triangles must be used
  55827. */
  55828. beginTransformFeedback(usePoints: boolean): void;
  55829. /**
  55830. * Ends a transform feedback operation
  55831. */
  55832. endTransformFeedback(): void;
  55833. /**
  55834. * Specify the varyings to use with transform feedback
  55835. * @param program defines the associated webGL program
  55836. * @param value defines the list of strings representing the varying names
  55837. */
  55838. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55839. /**
  55840. * Bind a webGL buffer for a transform feedback operation
  55841. * @param value defines the webGL buffer to bind
  55842. */
  55843. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55844. }
  55845. }
  55846. declare module BABYLON {
  55847. /**
  55848. * Class used to define an additional view for the engine
  55849. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55850. */
  55851. export class EngineView {
  55852. /** Defines the canvas where to render the view */
  55853. target: HTMLCanvasElement;
  55854. /** Defines an optional camera used to render the view (will use active camera else) */
  55855. camera?: Camera;
  55856. }
  55857. interface Engine {
  55858. /**
  55859. * Gets or sets the HTML element to use for attaching events
  55860. */
  55861. inputElement: Nullable<HTMLElement>;
  55862. /**
  55863. * Gets the current engine view
  55864. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55865. */
  55866. activeView: Nullable<EngineView>;
  55867. /** Gets or sets the list of views */
  55868. views: EngineView[];
  55869. /**
  55870. * Register a new child canvas
  55871. * @param canvas defines the canvas to register
  55872. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55873. * @returns the associated view
  55874. */
  55875. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55876. /**
  55877. * Remove a registered child canvas
  55878. * @param canvas defines the canvas to remove
  55879. * @returns the current engine
  55880. */
  55881. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55882. }
  55883. }
  55884. declare module BABYLON {
  55885. interface Engine {
  55886. /** @hidden */
  55887. _excludedCompressedTextures: string[];
  55888. /** @hidden */
  55889. _textureFormatInUse: string;
  55890. /**
  55891. * Gets the list of texture formats supported
  55892. */
  55893. readonly texturesSupported: Array<string>;
  55894. /**
  55895. * Gets the texture format in use
  55896. */
  55897. readonly textureFormatInUse: Nullable<string>;
  55898. /**
  55899. * Set the compressed texture extensions or file names to skip.
  55900. *
  55901. * @param skippedFiles defines the list of those texture files you want to skip
  55902. * Example: [".dds", ".env", "myfile.png"]
  55903. */
  55904. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55905. /**
  55906. * Set the compressed texture format to use, based on the formats you have, and the formats
  55907. * supported by the hardware / browser.
  55908. *
  55909. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55910. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55911. * to API arguments needed to compressed textures. This puts the burden on the container
  55912. * generator to house the arcane code for determining these for current & future formats.
  55913. *
  55914. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55915. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55916. *
  55917. * Note: The result of this call is not taken into account when a texture is base64.
  55918. *
  55919. * @param formatsAvailable defines the list of those format families you have created
  55920. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55921. *
  55922. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55923. * @returns The extension selected.
  55924. */
  55925. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55926. }
  55927. }
  55928. declare module BABYLON {
  55929. /** @hidden */
  55930. export var rgbdEncodePixelShader: {
  55931. name: string;
  55932. shader: string;
  55933. };
  55934. }
  55935. declare module BABYLON {
  55936. /**
  55937. * Raw texture data and descriptor sufficient for WebGL texture upload
  55938. */
  55939. export interface EnvironmentTextureInfo {
  55940. /**
  55941. * Version of the environment map
  55942. */
  55943. version: number;
  55944. /**
  55945. * Width of image
  55946. */
  55947. width: number;
  55948. /**
  55949. * Irradiance information stored in the file.
  55950. */
  55951. irradiance: any;
  55952. /**
  55953. * Specular information stored in the file.
  55954. */
  55955. specular: any;
  55956. }
  55957. /**
  55958. * Defines One Image in the file. It requires only the position in the file
  55959. * as well as the length.
  55960. */
  55961. interface BufferImageData {
  55962. /**
  55963. * Length of the image data.
  55964. */
  55965. length: number;
  55966. /**
  55967. * Position of the data from the null terminator delimiting the end of the JSON.
  55968. */
  55969. position: number;
  55970. }
  55971. /**
  55972. * Defines the specular data enclosed in the file.
  55973. * This corresponds to the version 1 of the data.
  55974. */
  55975. export interface EnvironmentTextureSpecularInfoV1 {
  55976. /**
  55977. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55978. */
  55979. specularDataPosition?: number;
  55980. /**
  55981. * This contains all the images data needed to reconstruct the cubemap.
  55982. */
  55983. mipmaps: Array<BufferImageData>;
  55984. /**
  55985. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55986. */
  55987. lodGenerationScale: number;
  55988. }
  55989. /**
  55990. * Sets of helpers addressing the serialization and deserialization of environment texture
  55991. * stored in a BabylonJS env file.
  55992. * Those files are usually stored as .env files.
  55993. */
  55994. export class EnvironmentTextureTools {
  55995. /**
  55996. * Magic number identifying the env file.
  55997. */
  55998. private static _MagicBytes;
  55999. /**
  56000. * Gets the environment info from an env file.
  56001. * @param data The array buffer containing the .env bytes.
  56002. * @returns the environment file info (the json header) if successfully parsed.
  56003. */
  56004. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56005. /**
  56006. * Creates an environment texture from a loaded cube texture.
  56007. * @param texture defines the cube texture to convert in env file
  56008. * @return a promise containing the environment data if succesfull.
  56009. */
  56010. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56011. /**
  56012. * Creates a JSON representation of the spherical data.
  56013. * @param texture defines the texture containing the polynomials
  56014. * @return the JSON representation of the spherical info
  56015. */
  56016. private static _CreateEnvTextureIrradiance;
  56017. /**
  56018. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56019. * @param data the image data
  56020. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56021. * @return the views described by info providing access to the underlying buffer
  56022. */
  56023. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56024. /**
  56025. * Uploads the texture info contained in the env file to the GPU.
  56026. * @param texture defines the internal texture to upload to
  56027. * @param data defines the data to load
  56028. * @param info defines the texture info retrieved through the GetEnvInfo method
  56029. * @returns a promise
  56030. */
  56031. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56032. private static _OnImageReadyAsync;
  56033. /**
  56034. * Uploads the levels of image data to the GPU.
  56035. * @param texture defines the internal texture to upload to
  56036. * @param imageData defines the array buffer views of image data [mipmap][face]
  56037. * @returns a promise
  56038. */
  56039. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56040. /**
  56041. * Uploads spherical polynomials information to the texture.
  56042. * @param texture defines the texture we are trying to upload the information to
  56043. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56044. */
  56045. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56046. /** @hidden */
  56047. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56048. }
  56049. }
  56050. declare module BABYLON {
  56051. /**
  56052. * Class used to inline functions in shader code
  56053. */
  56054. export class ShaderCodeInliner {
  56055. private static readonly _RegexpFindFunctionNameAndType;
  56056. private _sourceCode;
  56057. private _functionDescr;
  56058. private _numMaxIterations;
  56059. /** Gets or sets the token used to mark the functions to inline */
  56060. inlineToken: string;
  56061. /** Gets or sets the debug mode */
  56062. debug: boolean;
  56063. /** Gets the code after the inlining process */
  56064. get code(): string;
  56065. /**
  56066. * Initializes the inliner
  56067. * @param sourceCode shader code source to inline
  56068. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56069. */
  56070. constructor(sourceCode: string, numMaxIterations?: number);
  56071. /**
  56072. * Start the processing of the shader code
  56073. */
  56074. processCode(): void;
  56075. private _collectFunctions;
  56076. private _processInlining;
  56077. private _extractBetweenMarkers;
  56078. private _skipWhitespaces;
  56079. private _removeComments;
  56080. private _replaceFunctionCallsByCode;
  56081. private _findBackward;
  56082. private _escapeRegExp;
  56083. private _replaceNames;
  56084. }
  56085. }
  56086. declare module BABYLON {
  56087. /**
  56088. * Container for accessors for natively-stored mesh data buffers.
  56089. */
  56090. class NativeDataBuffer extends DataBuffer {
  56091. /**
  56092. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56093. */
  56094. nativeIndexBuffer?: any;
  56095. /**
  56096. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56097. */
  56098. nativeVertexBuffer?: any;
  56099. }
  56100. /** @hidden */
  56101. class NativeTexture extends InternalTexture {
  56102. getInternalTexture(): InternalTexture;
  56103. getViewCount(): number;
  56104. }
  56105. /** @hidden */
  56106. export class NativeEngine extends Engine {
  56107. private readonly _native;
  56108. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56109. private readonly INVALID_HANDLE;
  56110. private _boundBuffersVertexArray;
  56111. private _currentDepthTest;
  56112. getHardwareScalingLevel(): number;
  56113. constructor();
  56114. dispose(): void;
  56115. /**
  56116. * Can be used to override the current requestAnimationFrame requester.
  56117. * @hidden
  56118. */
  56119. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56120. /**
  56121. * Override default engine behavior.
  56122. * @param color
  56123. * @param backBuffer
  56124. * @param depth
  56125. * @param stencil
  56126. */
  56127. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56128. /**
  56129. * Gets host document
  56130. * @returns the host document object
  56131. */
  56132. getHostDocument(): Nullable<Document>;
  56133. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56134. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56135. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56136. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56137. [key: string]: VertexBuffer;
  56138. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56139. bindBuffers(vertexBuffers: {
  56140. [key: string]: VertexBuffer;
  56141. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56142. recordVertexArrayObject(vertexBuffers: {
  56143. [key: string]: VertexBuffer;
  56144. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56145. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56146. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56147. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56148. /**
  56149. * Draw a list of indexed primitives
  56150. * @param fillMode defines the primitive to use
  56151. * @param indexStart defines the starting index
  56152. * @param indexCount defines the number of index to draw
  56153. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56154. */
  56155. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56156. /**
  56157. * Draw a list of unindexed primitives
  56158. * @param fillMode defines the primitive to use
  56159. * @param verticesStart defines the index of first vertex to draw
  56160. * @param verticesCount defines the count of vertices to draw
  56161. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56162. */
  56163. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56164. createPipelineContext(): IPipelineContext;
  56165. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56166. /** @hidden */
  56167. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56168. /** @hidden */
  56169. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56170. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56171. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56172. protected _setProgram(program: WebGLProgram): void;
  56173. _releaseEffect(effect: Effect): void;
  56174. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56175. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56176. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56177. bindSamplers(effect: Effect): void;
  56178. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56179. getRenderWidth(useScreen?: boolean): number;
  56180. getRenderHeight(useScreen?: boolean): number;
  56181. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56182. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56183. /**
  56184. * Set the z offset to apply to current rendering
  56185. * @param value defines the offset to apply
  56186. */
  56187. setZOffset(value: number): void;
  56188. /**
  56189. * Gets the current value of the zOffset
  56190. * @returns the current zOffset state
  56191. */
  56192. getZOffset(): number;
  56193. /**
  56194. * Enable or disable depth buffering
  56195. * @param enable defines the state to set
  56196. */
  56197. setDepthBuffer(enable: boolean): void;
  56198. /**
  56199. * Gets a boolean indicating if depth writing is enabled
  56200. * @returns the current depth writing state
  56201. */
  56202. getDepthWrite(): boolean;
  56203. setDepthFunctionToGreater(): void;
  56204. setDepthFunctionToGreaterOrEqual(): void;
  56205. setDepthFunctionToLess(): void;
  56206. setDepthFunctionToLessOrEqual(): void;
  56207. /**
  56208. * Enable or disable depth writing
  56209. * @param enable defines the state to set
  56210. */
  56211. setDepthWrite(enable: boolean): void;
  56212. /**
  56213. * Enable or disable color writing
  56214. * @param enable defines the state to set
  56215. */
  56216. setColorWrite(enable: boolean): void;
  56217. /**
  56218. * Gets a boolean indicating if color writing is enabled
  56219. * @returns the current color writing state
  56220. */
  56221. getColorWrite(): boolean;
  56222. /**
  56223. * Sets alpha constants used by some alpha blending modes
  56224. * @param r defines the red component
  56225. * @param g defines the green component
  56226. * @param b defines the blue component
  56227. * @param a defines the alpha component
  56228. */
  56229. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56230. /**
  56231. * Sets the current alpha mode
  56232. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56233. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56234. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56235. */
  56236. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56237. /**
  56238. * Gets the current alpha mode
  56239. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56240. * @returns the current alpha mode
  56241. */
  56242. getAlphaMode(): number;
  56243. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56244. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56245. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56246. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56247. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56248. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56249. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56250. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56251. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56252. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56253. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56254. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56255. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56256. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56257. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56258. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56259. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56260. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56261. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56262. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56263. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56264. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56265. wipeCaches(bruteForce?: boolean): void;
  56266. _createTexture(): WebGLTexture;
  56267. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56268. /**
  56269. * Update the content of a dynamic texture
  56270. * @param texture defines the texture to update
  56271. * @param canvas defines the canvas containing the source
  56272. * @param invertY defines if data must be stored with Y axis inverted
  56273. * @param premulAlpha defines if alpha is stored as premultiplied
  56274. * @param format defines the format of the data
  56275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56276. */
  56277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56278. /**
  56279. * Usually called from Texture.ts.
  56280. * Passed information to create a WebGLTexture
  56281. * @param url defines a value which contains one of the following:
  56282. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56283. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56284. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56286. * @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)
  56287. * @param scene needed for loading to the correct scene
  56288. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56289. * @param onLoad optional callback to be called upon successful completion
  56290. * @param onError optional callback to be called upon failure
  56291. * @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
  56292. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56293. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56294. * @param forcedExtension defines the extension to use to pick the right loader
  56295. * @param mimeType defines an optional mime type
  56296. * @param loaderOptions options to be passed to the loader
  56297. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56298. */
  56299. 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;
  56300. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56301. _releaseFramebufferObjects(texture: InternalTexture): void;
  56302. /**
  56303. * Creates a cube texture
  56304. * @param rootUrl defines the url where the files to load is located
  56305. * @param scene defines the current scene
  56306. * @param files defines the list of files to load (1 per face)
  56307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56308. * @param onLoad defines an optional callback raised when the texture is loaded
  56309. * @param onError defines an optional callback raised if there is an issue to load the texture
  56310. * @param format defines the format of the data
  56311. * @param forcedExtension defines the extension to use to pick the right loader
  56312. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56313. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56314. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56315. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56316. * @returns the cube texture as an InternalTexture
  56317. */
  56318. 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;
  56319. createRenderTargetTexture(size: number | {
  56320. width: number;
  56321. height: number;
  56322. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56323. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56324. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56325. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56326. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56327. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56328. /**
  56329. * Updates a dynamic vertex buffer.
  56330. * @param vertexBuffer the vertex buffer to update
  56331. * @param data the data used to update the vertex buffer
  56332. * @param byteOffset the byte offset of the data (optional)
  56333. * @param byteLength the byte length of the data (optional)
  56334. */
  56335. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56336. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56337. private _updateAnisotropicLevel;
  56338. private _getAddressMode;
  56339. /** @hidden */
  56340. _bindTexture(channel: number, texture: InternalTexture): void;
  56341. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56342. releaseEffects(): void;
  56343. /** @hidden */
  56344. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56345. /** @hidden */
  56346. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56347. /** @hidden */
  56348. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56349. /** @hidden */
  56350. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56351. private _getNativeSamplingMode;
  56352. private _getNativeTextureFormat;
  56353. private _getNativeAlphaMode;
  56354. private _getNativeAttribType;
  56355. }
  56356. }
  56357. declare module BABYLON {
  56358. /**
  56359. * Gather the list of clipboard event types as constants.
  56360. */
  56361. export class ClipboardEventTypes {
  56362. /**
  56363. * The clipboard event is fired when a copy command is active (pressed).
  56364. */
  56365. static readonly COPY: number;
  56366. /**
  56367. * The clipboard event is fired when a cut command is active (pressed).
  56368. */
  56369. static readonly CUT: number;
  56370. /**
  56371. * The clipboard event is fired when a paste command is active (pressed).
  56372. */
  56373. static readonly PASTE: number;
  56374. }
  56375. /**
  56376. * This class is used to store clipboard related info for the onClipboardObservable event.
  56377. */
  56378. export class ClipboardInfo {
  56379. /**
  56380. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56381. */
  56382. type: number;
  56383. /**
  56384. * Defines the related dom event
  56385. */
  56386. event: ClipboardEvent;
  56387. /**
  56388. *Creates an instance of ClipboardInfo.
  56389. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56390. * @param event Defines the related dom event
  56391. */
  56392. constructor(
  56393. /**
  56394. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56395. */
  56396. type: number,
  56397. /**
  56398. * Defines the related dom event
  56399. */
  56400. event: ClipboardEvent);
  56401. /**
  56402. * Get the clipboard event's type from the keycode.
  56403. * @param keyCode Defines the keyCode for the current keyboard event.
  56404. * @return {number}
  56405. */
  56406. static GetTypeFromCharacter(keyCode: number): number;
  56407. }
  56408. }
  56409. declare module BABYLON {
  56410. /**
  56411. * Google Daydream controller
  56412. */
  56413. export class DaydreamController extends WebVRController {
  56414. /**
  56415. * Base Url for the controller model.
  56416. */
  56417. static MODEL_BASE_URL: string;
  56418. /**
  56419. * File name for the controller model.
  56420. */
  56421. static MODEL_FILENAME: string;
  56422. /**
  56423. * Gamepad Id prefix used to identify Daydream Controller.
  56424. */
  56425. static readonly GAMEPAD_ID_PREFIX: string;
  56426. /**
  56427. * Creates a new DaydreamController from a gamepad
  56428. * @param vrGamepad the gamepad that the controller should be created from
  56429. */
  56430. constructor(vrGamepad: any);
  56431. /**
  56432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56433. * @param scene scene in which to add meshes
  56434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56435. */
  56436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56437. /**
  56438. * Called once for each button that changed state since the last frame
  56439. * @param buttonIdx Which button index changed
  56440. * @param state New state of the button
  56441. * @param changes Which properties on the state changed since last frame
  56442. */
  56443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56444. }
  56445. }
  56446. declare module BABYLON {
  56447. /**
  56448. * Gear VR Controller
  56449. */
  56450. export class GearVRController extends WebVRController {
  56451. /**
  56452. * Base Url for the controller model.
  56453. */
  56454. static MODEL_BASE_URL: string;
  56455. /**
  56456. * File name for the controller model.
  56457. */
  56458. static MODEL_FILENAME: string;
  56459. /**
  56460. * Gamepad Id prefix used to identify this controller.
  56461. */
  56462. static readonly GAMEPAD_ID_PREFIX: string;
  56463. private readonly _buttonIndexToObservableNameMap;
  56464. /**
  56465. * Creates a new GearVRController from a gamepad
  56466. * @param vrGamepad the gamepad that the controller should be created from
  56467. */
  56468. constructor(vrGamepad: any);
  56469. /**
  56470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56471. * @param scene scene in which to add meshes
  56472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56473. */
  56474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56475. /**
  56476. * Called once for each button that changed state since the last frame
  56477. * @param buttonIdx Which button index changed
  56478. * @param state New state of the button
  56479. * @param changes Which properties on the state changed since last frame
  56480. */
  56481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56482. }
  56483. }
  56484. declare module BABYLON {
  56485. /**
  56486. * Generic Controller
  56487. */
  56488. export class GenericController extends WebVRController {
  56489. /**
  56490. * Base Url for the controller model.
  56491. */
  56492. static readonly MODEL_BASE_URL: string;
  56493. /**
  56494. * File name for the controller model.
  56495. */
  56496. static readonly MODEL_FILENAME: string;
  56497. /**
  56498. * Creates a new GenericController from a gamepad
  56499. * @param vrGamepad the gamepad that the controller should be created from
  56500. */
  56501. constructor(vrGamepad: any);
  56502. /**
  56503. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56504. * @param scene scene in which to add meshes
  56505. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56506. */
  56507. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56508. /**
  56509. * Called once for each button that changed state since the last frame
  56510. * @param buttonIdx Which button index changed
  56511. * @param state New state of the button
  56512. * @param changes Which properties on the state changed since last frame
  56513. */
  56514. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56515. }
  56516. }
  56517. declare module BABYLON {
  56518. /**
  56519. * Oculus Touch Controller
  56520. */
  56521. export class OculusTouchController extends WebVRController {
  56522. /**
  56523. * Base Url for the controller model.
  56524. */
  56525. static MODEL_BASE_URL: string;
  56526. /**
  56527. * File name for the left controller model.
  56528. */
  56529. static MODEL_LEFT_FILENAME: string;
  56530. /**
  56531. * File name for the right controller model.
  56532. */
  56533. static MODEL_RIGHT_FILENAME: string;
  56534. /**
  56535. * Base Url for the Quest controller model.
  56536. */
  56537. static QUEST_MODEL_BASE_URL: string;
  56538. /**
  56539. * @hidden
  56540. * If the controllers are running on a device that needs the updated Quest controller models
  56541. */
  56542. static _IsQuest: boolean;
  56543. /**
  56544. * Fired when the secondary trigger on this controller is modified
  56545. */
  56546. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56547. /**
  56548. * Fired when the thumb rest on this controller is modified
  56549. */
  56550. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56551. /**
  56552. * Creates a new OculusTouchController from a gamepad
  56553. * @param vrGamepad the gamepad that the controller should be created from
  56554. */
  56555. constructor(vrGamepad: any);
  56556. /**
  56557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56558. * @param scene scene in which to add meshes
  56559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56560. */
  56561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56562. /**
  56563. * Fired when the A button on this controller is modified
  56564. */
  56565. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56566. /**
  56567. * Fired when the B button on this controller is modified
  56568. */
  56569. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56570. /**
  56571. * Fired when the X button on this controller is modified
  56572. */
  56573. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56574. /**
  56575. * Fired when the Y button on this controller is modified
  56576. */
  56577. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56578. /**
  56579. * Called once for each button that changed state since the last frame
  56580. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56581. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56582. * 2) secondary trigger (same)
  56583. * 3) A (right) X (left), touch, pressed = value
  56584. * 4) B / Y
  56585. * 5) thumb rest
  56586. * @param buttonIdx Which button index changed
  56587. * @param state New state of the button
  56588. * @param changes Which properties on the state changed since last frame
  56589. */
  56590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56591. }
  56592. }
  56593. declare module BABYLON {
  56594. /**
  56595. * Vive Controller
  56596. */
  56597. export class ViveController extends WebVRController {
  56598. /**
  56599. * Base Url for the controller model.
  56600. */
  56601. static MODEL_BASE_URL: string;
  56602. /**
  56603. * File name for the controller model.
  56604. */
  56605. static MODEL_FILENAME: string;
  56606. /**
  56607. * Creates a new ViveController from a gamepad
  56608. * @param vrGamepad the gamepad that the controller should be created from
  56609. */
  56610. constructor(vrGamepad: any);
  56611. /**
  56612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56613. * @param scene scene in which to add meshes
  56614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56615. */
  56616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56617. /**
  56618. * Fired when the left button on this controller is modified
  56619. */
  56620. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56621. /**
  56622. * Fired when the right button on this controller is modified
  56623. */
  56624. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56625. /**
  56626. * Fired when the menu button on this controller is modified
  56627. */
  56628. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56629. /**
  56630. * Called once for each button that changed state since the last frame
  56631. * Vive mapping:
  56632. * 0: touchpad
  56633. * 1: trigger
  56634. * 2: left AND right buttons
  56635. * 3: menu button
  56636. * @param buttonIdx Which button index changed
  56637. * @param state New state of the button
  56638. * @param changes Which properties on the state changed since last frame
  56639. */
  56640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56641. }
  56642. }
  56643. declare module BABYLON {
  56644. /**
  56645. * Defines the WindowsMotionController object that the state of the windows motion controller
  56646. */
  56647. export class WindowsMotionController extends WebVRController {
  56648. /**
  56649. * The base url used to load the left and right controller models
  56650. */
  56651. static MODEL_BASE_URL: string;
  56652. /**
  56653. * The name of the left controller model file
  56654. */
  56655. static MODEL_LEFT_FILENAME: string;
  56656. /**
  56657. * The name of the right controller model file
  56658. */
  56659. static MODEL_RIGHT_FILENAME: string;
  56660. /**
  56661. * The controller name prefix for this controller type
  56662. */
  56663. static readonly GAMEPAD_ID_PREFIX: string;
  56664. /**
  56665. * The controller id pattern for this controller type
  56666. */
  56667. private static readonly GAMEPAD_ID_PATTERN;
  56668. private _loadedMeshInfo;
  56669. protected readonly _mapping: {
  56670. buttons: string[];
  56671. buttonMeshNames: {
  56672. trigger: string;
  56673. menu: string;
  56674. grip: string;
  56675. thumbstick: string;
  56676. trackpad: string;
  56677. };
  56678. buttonObservableNames: {
  56679. trigger: string;
  56680. menu: string;
  56681. grip: string;
  56682. thumbstick: string;
  56683. trackpad: string;
  56684. };
  56685. axisMeshNames: string[];
  56686. pointingPoseMeshName: string;
  56687. };
  56688. /**
  56689. * Fired when the trackpad on this controller is clicked
  56690. */
  56691. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56692. /**
  56693. * Fired when the trackpad on this controller is modified
  56694. */
  56695. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56696. /**
  56697. * The current x and y values of this controller's trackpad
  56698. */
  56699. trackpad: StickValues;
  56700. /**
  56701. * Creates a new WindowsMotionController from a gamepad
  56702. * @param vrGamepad the gamepad that the controller should be created from
  56703. */
  56704. constructor(vrGamepad: any);
  56705. /**
  56706. * Fired when the trigger on this controller is modified
  56707. */
  56708. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56709. /**
  56710. * Fired when the menu button on this controller is modified
  56711. */
  56712. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56713. /**
  56714. * Fired when the grip button on this controller is modified
  56715. */
  56716. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56717. /**
  56718. * Fired when the thumbstick button on this controller is modified
  56719. */
  56720. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56721. /**
  56722. * Fired when the touchpad button on this controller is modified
  56723. */
  56724. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56725. /**
  56726. * Fired when the touchpad values on this controller are modified
  56727. */
  56728. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56729. protected _updateTrackpad(): void;
  56730. /**
  56731. * Called once per frame by the engine.
  56732. */
  56733. update(): void;
  56734. /**
  56735. * Called once for each button that changed state since the last frame
  56736. * @param buttonIdx Which button index changed
  56737. * @param state New state of the button
  56738. * @param changes Which properties on the state changed since last frame
  56739. */
  56740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56741. /**
  56742. * Moves the buttons on the controller mesh based on their current state
  56743. * @param buttonName the name of the button to move
  56744. * @param buttonValue the value of the button which determines the buttons new position
  56745. */
  56746. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56747. /**
  56748. * Moves the axis on the controller mesh based on its current state
  56749. * @param axis the index of the axis
  56750. * @param axisValue the value of the axis which determines the meshes new position
  56751. * @hidden
  56752. */
  56753. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56754. /**
  56755. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56756. * @param scene scene in which to add meshes
  56757. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56758. */
  56759. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56760. /**
  56761. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56762. * can be transformed by button presses and axes values, based on this._mapping.
  56763. *
  56764. * @param scene scene in which the meshes exist
  56765. * @param meshes list of meshes that make up the controller model to process
  56766. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56767. */
  56768. private processModel;
  56769. private createMeshInfo;
  56770. /**
  56771. * Gets the ray of the controller in the direction the controller is pointing
  56772. * @param length the length the resulting ray should be
  56773. * @returns a ray in the direction the controller is pointing
  56774. */
  56775. getForwardRay(length?: number): Ray;
  56776. /**
  56777. * Disposes of the controller
  56778. */
  56779. dispose(): void;
  56780. }
  56781. /**
  56782. * This class represents a new windows motion controller in XR.
  56783. */
  56784. export class XRWindowsMotionController extends WindowsMotionController {
  56785. /**
  56786. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56787. */
  56788. protected readonly _mapping: {
  56789. buttons: string[];
  56790. buttonMeshNames: {
  56791. trigger: string;
  56792. menu: string;
  56793. grip: string;
  56794. thumbstick: string;
  56795. trackpad: string;
  56796. };
  56797. buttonObservableNames: {
  56798. trigger: string;
  56799. menu: string;
  56800. grip: string;
  56801. thumbstick: string;
  56802. trackpad: string;
  56803. };
  56804. axisMeshNames: string[];
  56805. pointingPoseMeshName: string;
  56806. };
  56807. /**
  56808. * Construct a new XR-Based windows motion controller
  56809. *
  56810. * @param gamepadInfo the gamepad object from the browser
  56811. */
  56812. constructor(gamepadInfo: any);
  56813. /**
  56814. * holds the thumbstick values (X,Y)
  56815. */
  56816. thumbstickValues: StickValues;
  56817. /**
  56818. * Fired when the thumbstick on this controller is clicked
  56819. */
  56820. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56821. /**
  56822. * Fired when the thumbstick on this controller is modified
  56823. */
  56824. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56825. /**
  56826. * Fired when the touchpad button on this controller is modified
  56827. */
  56828. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56829. /**
  56830. * Fired when the touchpad values on this controller are modified
  56831. */
  56832. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56833. /**
  56834. * Fired when the thumbstick button on this controller is modified
  56835. * here to prevent breaking changes
  56836. */
  56837. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56838. /**
  56839. * updating the thumbstick(!) and not the trackpad.
  56840. * This is named this way due to the difference between WebVR and XR and to avoid
  56841. * changing the parent class.
  56842. */
  56843. protected _updateTrackpad(): void;
  56844. /**
  56845. * Disposes the class with joy
  56846. */
  56847. dispose(): void;
  56848. }
  56849. }
  56850. declare module BABYLON {
  56851. /**
  56852. * Class containing static functions to help procedurally build meshes
  56853. */
  56854. export class PolyhedronBuilder {
  56855. /**
  56856. * Creates a polyhedron mesh
  56857. * * 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
  56858. * * The parameter `size` (positive float, default 1) sets the polygon size
  56859. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56860. * * 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`
  56861. * * 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
  56862. * * 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)`)
  56863. * * 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
  56864. * * 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
  56865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56866. * * 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
  56867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56868. * @param name defines the name of the mesh
  56869. * @param options defines the options used to create the mesh
  56870. * @param scene defines the hosting scene
  56871. * @returns the polyhedron mesh
  56872. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56873. */
  56874. static CreatePolyhedron(name: string, options: {
  56875. type?: number;
  56876. size?: number;
  56877. sizeX?: number;
  56878. sizeY?: number;
  56879. sizeZ?: number;
  56880. custom?: any;
  56881. faceUV?: Vector4[];
  56882. faceColors?: Color4[];
  56883. flat?: boolean;
  56884. updatable?: boolean;
  56885. sideOrientation?: number;
  56886. frontUVs?: Vector4;
  56887. backUVs?: Vector4;
  56888. }, scene?: Nullable<Scene>): Mesh;
  56889. }
  56890. }
  56891. declare module BABYLON {
  56892. /**
  56893. * Gizmo that enables scaling a mesh along 3 axis
  56894. */
  56895. export class ScaleGizmo extends Gizmo {
  56896. /**
  56897. * Internal gizmo used for interactions on the x axis
  56898. */
  56899. xGizmo: AxisScaleGizmo;
  56900. /**
  56901. * Internal gizmo used for interactions on the y axis
  56902. */
  56903. yGizmo: AxisScaleGizmo;
  56904. /**
  56905. * Internal gizmo used for interactions on the z axis
  56906. */
  56907. zGizmo: AxisScaleGizmo;
  56908. /**
  56909. * Internal gizmo used to scale all axis equally
  56910. */
  56911. uniformScaleGizmo: AxisScaleGizmo;
  56912. private _meshAttached;
  56913. private _nodeAttached;
  56914. private _snapDistance;
  56915. private _uniformScalingMesh;
  56916. private _octahedron;
  56917. private _sensitivity;
  56918. /** Fires an event when any of it's sub gizmos are dragged */
  56919. onDragStartObservable: Observable<unknown>;
  56920. /** Fires an event when any of it's sub gizmos are released from dragging */
  56921. onDragEndObservable: Observable<unknown>;
  56922. get attachedMesh(): Nullable<AbstractMesh>;
  56923. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56924. get attachedNode(): Nullable<Node>;
  56925. set attachedNode(node: Nullable<Node>);
  56926. /**
  56927. * True when the mouse pointer is hovering a gizmo mesh
  56928. */
  56929. get isHovered(): boolean;
  56930. /**
  56931. * Creates a ScaleGizmo
  56932. * @param gizmoLayer The utility layer the gizmo will be added to
  56933. * @param thickness display gizmo axis thickness
  56934. */
  56935. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56936. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56937. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56938. /**
  56939. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56940. */
  56941. set snapDistance(value: number);
  56942. get snapDistance(): number;
  56943. /**
  56944. * Ratio for the scale of the gizmo (Default: 1)
  56945. */
  56946. set scaleRatio(value: number);
  56947. get scaleRatio(): number;
  56948. /**
  56949. * Sensitivity factor for dragging (Default: 1)
  56950. */
  56951. set sensitivity(value: number);
  56952. get sensitivity(): number;
  56953. /**
  56954. * Disposes of the gizmo
  56955. */
  56956. dispose(): void;
  56957. }
  56958. }
  56959. declare module BABYLON {
  56960. /**
  56961. * Single axis scale gizmo
  56962. */
  56963. export class AxisScaleGizmo extends Gizmo {
  56964. /**
  56965. * Drag behavior responsible for the gizmos dragging interactions
  56966. */
  56967. dragBehavior: PointerDragBehavior;
  56968. private _pointerObserver;
  56969. /**
  56970. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56971. */
  56972. snapDistance: number;
  56973. /**
  56974. * Event that fires each time the gizmo snaps to a new location.
  56975. * * snapDistance is the the change in distance
  56976. */
  56977. onSnapObservable: Observable<{
  56978. snapDistance: number;
  56979. }>;
  56980. /**
  56981. * If the scaling operation should be done on all axis (default: false)
  56982. */
  56983. uniformScaling: boolean;
  56984. /**
  56985. * Custom sensitivity value for the drag strength
  56986. */
  56987. sensitivity: number;
  56988. private _isEnabled;
  56989. private _parent;
  56990. private _arrow;
  56991. private _coloredMaterial;
  56992. private _hoverMaterial;
  56993. /**
  56994. * Creates an AxisScaleGizmo
  56995. * @param gizmoLayer The utility layer the gizmo will be added to
  56996. * @param dragAxis The axis which the gizmo will be able to scale on
  56997. * @param color The color of the gizmo
  56998. * @param thickness display gizmo axis thickness
  56999. */
  57000. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57001. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57002. /**
  57003. * If the gizmo is enabled
  57004. */
  57005. set isEnabled(value: boolean);
  57006. get isEnabled(): boolean;
  57007. /**
  57008. * Disposes of the gizmo
  57009. */
  57010. dispose(): void;
  57011. /**
  57012. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57013. * @param mesh The mesh to replace the default mesh of the gizmo
  57014. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57015. */
  57016. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57017. }
  57018. }
  57019. declare module BABYLON {
  57020. /**
  57021. * Bounding box gizmo
  57022. */
  57023. export class BoundingBoxGizmo extends Gizmo {
  57024. private _lineBoundingBox;
  57025. private _rotateSpheresParent;
  57026. private _scaleBoxesParent;
  57027. private _boundingDimensions;
  57028. private _renderObserver;
  57029. private _pointerObserver;
  57030. private _scaleDragSpeed;
  57031. private _tmpQuaternion;
  57032. private _tmpVector;
  57033. private _tmpRotationMatrix;
  57034. /**
  57035. * 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)
  57036. */
  57037. ignoreChildren: boolean;
  57038. /**
  57039. * 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)
  57040. */
  57041. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57042. /**
  57043. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57044. */
  57045. rotationSphereSize: number;
  57046. /**
  57047. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57048. */
  57049. scaleBoxSize: number;
  57050. /**
  57051. * 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)
  57052. */
  57053. fixedDragMeshScreenSize: boolean;
  57054. /**
  57055. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57056. */
  57057. fixedDragMeshScreenSizeDistanceFactor: number;
  57058. /**
  57059. * Fired when a rotation sphere or scale box is dragged
  57060. */
  57061. onDragStartObservable: Observable<{}>;
  57062. /**
  57063. * Fired when a scale box is dragged
  57064. */
  57065. onScaleBoxDragObservable: Observable<{}>;
  57066. /**
  57067. * Fired when a scale box drag is ended
  57068. */
  57069. onScaleBoxDragEndObservable: Observable<{}>;
  57070. /**
  57071. * Fired when a rotation sphere is dragged
  57072. */
  57073. onRotationSphereDragObservable: Observable<{}>;
  57074. /**
  57075. * Fired when a rotation sphere drag is ended
  57076. */
  57077. onRotationSphereDragEndObservable: Observable<{}>;
  57078. /**
  57079. * 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)
  57080. */
  57081. scalePivot: Nullable<Vector3>;
  57082. /**
  57083. * Mesh used as a pivot to rotate the attached node
  57084. */
  57085. private _anchorMesh;
  57086. private _existingMeshScale;
  57087. private _dragMesh;
  57088. private pointerDragBehavior;
  57089. private coloredMaterial;
  57090. private hoverColoredMaterial;
  57091. /**
  57092. * Sets the color of the bounding box gizmo
  57093. * @param color the color to set
  57094. */
  57095. setColor(color: Color3): void;
  57096. /**
  57097. * Creates an BoundingBoxGizmo
  57098. * @param gizmoLayer The utility layer the gizmo will be added to
  57099. * @param color The color of the gizmo
  57100. */
  57101. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57102. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57103. private _selectNode;
  57104. /**
  57105. * Updates the bounding box information for the Gizmo
  57106. */
  57107. updateBoundingBox(): void;
  57108. private _updateRotationSpheres;
  57109. private _updateScaleBoxes;
  57110. /**
  57111. * Enables rotation on the specified axis and disables rotation on the others
  57112. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57113. */
  57114. setEnabledRotationAxis(axis: string): void;
  57115. /**
  57116. * Enables/disables scaling
  57117. * @param enable if scaling should be enabled
  57118. * @param homogeneousScaling defines if scaling should only be homogeneous
  57119. */
  57120. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57121. private _updateDummy;
  57122. /**
  57123. * Enables a pointer drag behavior on the bounding box of the gizmo
  57124. */
  57125. enableDragBehavior(): void;
  57126. /**
  57127. * Disposes of the gizmo
  57128. */
  57129. dispose(): void;
  57130. /**
  57131. * 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)
  57132. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57133. * @returns the bounding box mesh with the passed in mesh as a child
  57134. */
  57135. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57136. /**
  57137. * CustomMeshes are not supported by this gizmo
  57138. * @param mesh The mesh to replace the default mesh of the gizmo
  57139. */
  57140. setCustomMesh(mesh: Mesh): void;
  57141. }
  57142. }
  57143. declare module BABYLON {
  57144. /**
  57145. * Single plane rotation gizmo
  57146. */
  57147. export class PlaneRotationGizmo extends Gizmo {
  57148. /**
  57149. * Drag behavior responsible for the gizmos dragging interactions
  57150. */
  57151. dragBehavior: PointerDragBehavior;
  57152. private _pointerObserver;
  57153. /**
  57154. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57155. */
  57156. snapDistance: number;
  57157. /**
  57158. * Event that fires each time the gizmo snaps to a new location.
  57159. * * snapDistance is the the change in distance
  57160. */
  57161. onSnapObservable: Observable<{
  57162. snapDistance: number;
  57163. }>;
  57164. private _isEnabled;
  57165. private _parent;
  57166. /**
  57167. * Creates a PlaneRotationGizmo
  57168. * @param gizmoLayer The utility layer the gizmo will be added to
  57169. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57170. * @param color The color of the gizmo
  57171. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57172. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57173. * @param thickness display gizmo axis thickness
  57174. */
  57175. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57176. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57177. /**
  57178. * If the gizmo is enabled
  57179. */
  57180. set isEnabled(value: boolean);
  57181. get isEnabled(): boolean;
  57182. /**
  57183. * Disposes of the gizmo
  57184. */
  57185. dispose(): void;
  57186. }
  57187. }
  57188. declare module BABYLON {
  57189. /**
  57190. * Gizmo that enables rotating a mesh along 3 axis
  57191. */
  57192. export class RotationGizmo extends Gizmo {
  57193. /**
  57194. * Internal gizmo used for interactions on the x axis
  57195. */
  57196. xGizmo: PlaneRotationGizmo;
  57197. /**
  57198. * Internal gizmo used for interactions on the y axis
  57199. */
  57200. yGizmo: PlaneRotationGizmo;
  57201. /**
  57202. * Internal gizmo used for interactions on the z axis
  57203. */
  57204. zGizmo: PlaneRotationGizmo;
  57205. /** Fires an event when any of it's sub gizmos are dragged */
  57206. onDragStartObservable: Observable<unknown>;
  57207. /** Fires an event when any of it's sub gizmos are released from dragging */
  57208. onDragEndObservable: Observable<unknown>;
  57209. private _meshAttached;
  57210. private _nodeAttached;
  57211. get attachedMesh(): Nullable<AbstractMesh>;
  57212. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57213. get attachedNode(): Nullable<Node>;
  57214. set attachedNode(node: Nullable<Node>);
  57215. protected _checkBillboardTransform(): void;
  57216. /**
  57217. * True when the mouse pointer is hovering a gizmo mesh
  57218. */
  57219. get isHovered(): boolean;
  57220. /**
  57221. * Creates a RotationGizmo
  57222. * @param gizmoLayer The utility layer the gizmo will be added to
  57223. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57224. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57225. * @param thickness display gizmo axis thickness
  57226. */
  57227. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57228. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57229. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57230. /**
  57231. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57232. */
  57233. set snapDistance(value: number);
  57234. get snapDistance(): number;
  57235. /**
  57236. * Ratio for the scale of the gizmo (Default: 1)
  57237. */
  57238. set scaleRatio(value: number);
  57239. get scaleRatio(): number;
  57240. /**
  57241. * Disposes of the gizmo
  57242. */
  57243. dispose(): void;
  57244. /**
  57245. * CustomMeshes are not supported by this gizmo
  57246. * @param mesh The mesh to replace the default mesh of the gizmo
  57247. */
  57248. setCustomMesh(mesh: Mesh): void;
  57249. }
  57250. }
  57251. declare module BABYLON {
  57252. /**
  57253. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57254. */
  57255. export class GizmoManager implements IDisposable {
  57256. private scene;
  57257. /**
  57258. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57259. */
  57260. gizmos: {
  57261. positionGizmo: Nullable<PositionGizmo>;
  57262. rotationGizmo: Nullable<RotationGizmo>;
  57263. scaleGizmo: Nullable<ScaleGizmo>;
  57264. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57265. };
  57266. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57267. clearGizmoOnEmptyPointerEvent: boolean;
  57268. /** Fires an event when the manager is attached to a mesh */
  57269. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57270. /** Fires an event when the manager is attached to a node */
  57271. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57272. private _gizmosEnabled;
  57273. private _pointerObserver;
  57274. private _attachedMesh;
  57275. private _attachedNode;
  57276. private _boundingBoxColor;
  57277. private _defaultUtilityLayer;
  57278. private _defaultKeepDepthUtilityLayer;
  57279. private _thickness;
  57280. /**
  57281. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57282. */
  57283. boundingBoxDragBehavior: SixDofDragBehavior;
  57284. /**
  57285. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57286. */
  57287. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57288. /**
  57289. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57290. */
  57291. attachableNodes: Nullable<Array<Node>>;
  57292. /**
  57293. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57294. */
  57295. usePointerToAttachGizmos: boolean;
  57296. /**
  57297. * Utility layer that the bounding box gizmo belongs to
  57298. */
  57299. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57300. /**
  57301. * Utility layer that all gizmos besides bounding box belong to
  57302. */
  57303. get utilityLayer(): UtilityLayerRenderer;
  57304. /**
  57305. * True when the mouse pointer is hovering a gizmo mesh
  57306. */
  57307. get isHovered(): boolean;
  57308. /**
  57309. * Instatiates a gizmo manager
  57310. * @param scene the scene to overlay the gizmos on top of
  57311. * @param thickness display gizmo axis thickness
  57312. */
  57313. constructor(scene: Scene, thickness?: number);
  57314. /**
  57315. * Attaches a set of gizmos to the specified mesh
  57316. * @param mesh The mesh the gizmo's should be attached to
  57317. */
  57318. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57319. /**
  57320. * Attaches a set of gizmos to the specified node
  57321. * @param node The node the gizmo's should be attached to
  57322. */
  57323. attachToNode(node: Nullable<Node>): void;
  57324. /**
  57325. * If the position gizmo is enabled
  57326. */
  57327. set positionGizmoEnabled(value: boolean);
  57328. get positionGizmoEnabled(): boolean;
  57329. /**
  57330. * If the rotation gizmo is enabled
  57331. */
  57332. set rotationGizmoEnabled(value: boolean);
  57333. get rotationGizmoEnabled(): boolean;
  57334. /**
  57335. * If the scale gizmo is enabled
  57336. */
  57337. set scaleGizmoEnabled(value: boolean);
  57338. get scaleGizmoEnabled(): boolean;
  57339. /**
  57340. * If the boundingBox gizmo is enabled
  57341. */
  57342. set boundingBoxGizmoEnabled(value: boolean);
  57343. get boundingBoxGizmoEnabled(): boolean;
  57344. /**
  57345. * Disposes of the gizmo manager
  57346. */
  57347. dispose(): void;
  57348. }
  57349. }
  57350. declare module BABYLON {
  57351. /**
  57352. * A directional light is defined by a direction (what a surprise!).
  57353. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57354. * 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.
  57355. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57356. */
  57357. export class DirectionalLight extends ShadowLight {
  57358. private _shadowFrustumSize;
  57359. /**
  57360. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57361. */
  57362. get shadowFrustumSize(): number;
  57363. /**
  57364. * Specifies a fix frustum size for the shadow generation.
  57365. */
  57366. set shadowFrustumSize(value: number);
  57367. private _shadowOrthoScale;
  57368. /**
  57369. * Gets the shadow projection scale against the optimal computed one.
  57370. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57371. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57372. */
  57373. get shadowOrthoScale(): number;
  57374. /**
  57375. * Sets the shadow projection scale against the optimal computed one.
  57376. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57377. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57378. */
  57379. set shadowOrthoScale(value: number);
  57380. /**
  57381. * Automatically compute the projection matrix to best fit (including all the casters)
  57382. * on each frame.
  57383. */
  57384. autoUpdateExtends: boolean;
  57385. /**
  57386. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57387. * on each frame. autoUpdateExtends must be set to true for this to work
  57388. */
  57389. autoCalcShadowZBounds: boolean;
  57390. private _orthoLeft;
  57391. private _orthoRight;
  57392. private _orthoTop;
  57393. private _orthoBottom;
  57394. /**
  57395. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57396. * The directional light is emitted from everywhere in the given direction.
  57397. * It can cast shadows.
  57398. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57399. * @param name The friendly name of the light
  57400. * @param direction The direction of the light
  57401. * @param scene The scene the light belongs to
  57402. */
  57403. constructor(name: string, direction: Vector3, scene: Scene);
  57404. /**
  57405. * Returns the string "DirectionalLight".
  57406. * @return The class name
  57407. */
  57408. getClassName(): string;
  57409. /**
  57410. * Returns the integer 1.
  57411. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57412. */
  57413. getTypeID(): number;
  57414. /**
  57415. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57416. * Returns the DirectionalLight Shadow projection matrix.
  57417. */
  57418. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57419. /**
  57420. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57421. * Returns the DirectionalLight Shadow projection matrix.
  57422. */
  57423. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57424. /**
  57425. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57426. * Returns the DirectionalLight Shadow projection matrix.
  57427. */
  57428. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57429. protected _buildUniformLayout(): void;
  57430. /**
  57431. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57432. * @param effect The effect to update
  57433. * @param lightIndex The index of the light in the effect to update
  57434. * @returns The directional light
  57435. */
  57436. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57437. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57438. /**
  57439. * Gets the minZ used for shadow according to both the scene and the light.
  57440. *
  57441. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57442. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57443. * @param activeCamera The camera we are returning the min for
  57444. * @returns the depth min z
  57445. */
  57446. getDepthMinZ(activeCamera: Camera): number;
  57447. /**
  57448. * Gets the maxZ used for shadow according to both the scene and the light.
  57449. *
  57450. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57451. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57452. * @param activeCamera The camera we are returning the max for
  57453. * @returns the depth max z
  57454. */
  57455. getDepthMaxZ(activeCamera: Camera): number;
  57456. /**
  57457. * Prepares the list of defines specific to the light type.
  57458. * @param defines the list of defines
  57459. * @param lightIndex defines the index of the light for the effect
  57460. */
  57461. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57462. }
  57463. }
  57464. declare module BABYLON {
  57465. /**
  57466. * Class containing static functions to help procedurally build meshes
  57467. */
  57468. export class HemisphereBuilder {
  57469. /**
  57470. * Creates a hemisphere mesh
  57471. * @param name defines the name of the mesh
  57472. * @param options defines the options used to create the mesh
  57473. * @param scene defines the hosting scene
  57474. * @returns the hemisphere mesh
  57475. */
  57476. static CreateHemisphere(name: string, options: {
  57477. segments?: number;
  57478. diameter?: number;
  57479. sideOrientation?: number;
  57480. }, scene: any): Mesh;
  57481. }
  57482. }
  57483. declare module BABYLON {
  57484. /**
  57485. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57486. * These values define a cone of light starting from the position, emitting toward the direction.
  57487. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57488. * and the exponent defines the speed of the decay of the light with distance (reach).
  57489. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57490. */
  57491. export class SpotLight extends ShadowLight {
  57492. private _angle;
  57493. private _innerAngle;
  57494. private _cosHalfAngle;
  57495. private _lightAngleScale;
  57496. private _lightAngleOffset;
  57497. /**
  57498. * Gets the cone angle of the spot light in Radians.
  57499. */
  57500. get angle(): number;
  57501. /**
  57502. * Sets the cone angle of the spot light in Radians.
  57503. */
  57504. set angle(value: number);
  57505. /**
  57506. * Only used in gltf falloff mode, this defines the angle where
  57507. * the directional falloff will start before cutting at angle which could be seen
  57508. * as outer angle.
  57509. */
  57510. get innerAngle(): number;
  57511. /**
  57512. * Only used in gltf falloff mode, this defines the angle where
  57513. * the directional falloff will start before cutting at angle which could be seen
  57514. * as outer angle.
  57515. */
  57516. set innerAngle(value: number);
  57517. private _shadowAngleScale;
  57518. /**
  57519. * Allows scaling the angle of the light for shadow generation only.
  57520. */
  57521. get shadowAngleScale(): number;
  57522. /**
  57523. * Allows scaling the angle of the light for shadow generation only.
  57524. */
  57525. set shadowAngleScale(value: number);
  57526. /**
  57527. * The light decay speed with the distance from the emission spot.
  57528. */
  57529. exponent: number;
  57530. private _projectionTextureMatrix;
  57531. /**
  57532. * Allows reading the projecton texture
  57533. */
  57534. get projectionTextureMatrix(): Matrix;
  57535. protected _projectionTextureLightNear: number;
  57536. /**
  57537. * Gets the near clip of the Spotlight for texture projection.
  57538. */
  57539. get projectionTextureLightNear(): number;
  57540. /**
  57541. * Sets the near clip of the Spotlight for texture projection.
  57542. */
  57543. set projectionTextureLightNear(value: number);
  57544. protected _projectionTextureLightFar: number;
  57545. /**
  57546. * Gets the far clip of the Spotlight for texture projection.
  57547. */
  57548. get projectionTextureLightFar(): number;
  57549. /**
  57550. * Sets the far clip of the Spotlight for texture projection.
  57551. */
  57552. set projectionTextureLightFar(value: number);
  57553. protected _projectionTextureUpDirection: Vector3;
  57554. /**
  57555. * Gets the Up vector of the Spotlight for texture projection.
  57556. */
  57557. get projectionTextureUpDirection(): Vector3;
  57558. /**
  57559. * Sets the Up vector of the Spotlight for texture projection.
  57560. */
  57561. set projectionTextureUpDirection(value: Vector3);
  57562. private _projectionTexture;
  57563. /**
  57564. * Gets the projection texture of the light.
  57565. */
  57566. get projectionTexture(): Nullable<BaseTexture>;
  57567. /**
  57568. * Sets the projection texture of the light.
  57569. */
  57570. set projectionTexture(value: Nullable<BaseTexture>);
  57571. private static _IsProceduralTexture;
  57572. private static _IsTexture;
  57573. private _projectionTextureViewLightDirty;
  57574. private _projectionTextureProjectionLightDirty;
  57575. private _projectionTextureDirty;
  57576. private _projectionTextureViewTargetVector;
  57577. private _projectionTextureViewLightMatrix;
  57578. private _projectionTextureProjectionLightMatrix;
  57579. private _projectionTextureScalingMatrix;
  57580. /**
  57581. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57582. * It can cast shadows.
  57583. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57584. * @param name The light friendly name
  57585. * @param position The position of the spot light in the scene
  57586. * @param direction The direction of the light in the scene
  57587. * @param angle The cone angle of the light in Radians
  57588. * @param exponent The light decay speed with the distance from the emission spot
  57589. * @param scene The scene the lights belongs to
  57590. */
  57591. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57592. /**
  57593. * Returns the string "SpotLight".
  57594. * @returns the class name
  57595. */
  57596. getClassName(): string;
  57597. /**
  57598. * Returns the integer 2.
  57599. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57600. */
  57601. getTypeID(): number;
  57602. /**
  57603. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57604. */
  57605. protected _setDirection(value: Vector3): void;
  57606. /**
  57607. * Overrides the position setter to recompute the projection texture view light Matrix.
  57608. */
  57609. protected _setPosition(value: Vector3): void;
  57610. /**
  57611. * 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.
  57612. * Returns the SpotLight.
  57613. */
  57614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57615. protected _computeProjectionTextureViewLightMatrix(): void;
  57616. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57617. /**
  57618. * Main function for light texture projection matrix computing.
  57619. */
  57620. protected _computeProjectionTextureMatrix(): void;
  57621. protected _buildUniformLayout(): void;
  57622. private _computeAngleValues;
  57623. /**
  57624. * Sets the passed Effect "effect" with the Light textures.
  57625. * @param effect The effect to update
  57626. * @param lightIndex The index of the light in the effect to update
  57627. * @returns The light
  57628. */
  57629. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57630. /**
  57631. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57632. * @param effect The effect to update
  57633. * @param lightIndex The index of the light in the effect to update
  57634. * @returns The spot light
  57635. */
  57636. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57637. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57638. /**
  57639. * Disposes the light and the associated resources.
  57640. */
  57641. dispose(): void;
  57642. /**
  57643. * Prepares the list of defines specific to the light type.
  57644. * @param defines the list of defines
  57645. * @param lightIndex defines the index of the light for the effect
  57646. */
  57647. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57648. }
  57649. }
  57650. declare module BABYLON {
  57651. /**
  57652. * Gizmo that enables viewing a light
  57653. */
  57654. export class LightGizmo extends Gizmo {
  57655. private _lightMesh;
  57656. private _material;
  57657. private _cachedPosition;
  57658. private _cachedForward;
  57659. private _attachedMeshParent;
  57660. private _pointerObserver;
  57661. /**
  57662. * Event that fires each time the gizmo is clicked
  57663. */
  57664. onClickedObservable: Observable<Light>;
  57665. /**
  57666. * Creates a LightGizmo
  57667. * @param gizmoLayer The utility layer the gizmo will be added to
  57668. */
  57669. constructor(gizmoLayer?: UtilityLayerRenderer);
  57670. private _light;
  57671. /**
  57672. * The light that the gizmo is attached to
  57673. */
  57674. set light(light: Nullable<Light>);
  57675. get light(): Nullable<Light>;
  57676. /**
  57677. * Gets the material used to render the light gizmo
  57678. */
  57679. get material(): StandardMaterial;
  57680. /**
  57681. * @hidden
  57682. * Updates the gizmo to match the attached mesh's position/rotation
  57683. */
  57684. protected _update(): void;
  57685. private static _Scale;
  57686. /**
  57687. * Creates the lines for a light mesh
  57688. */
  57689. private static _CreateLightLines;
  57690. /**
  57691. * Disposes of the light gizmo
  57692. */
  57693. dispose(): void;
  57694. private static _CreateHemisphericLightMesh;
  57695. private static _CreatePointLightMesh;
  57696. private static _CreateSpotLightMesh;
  57697. private static _CreateDirectionalLightMesh;
  57698. }
  57699. }
  57700. declare module BABYLON {
  57701. /**
  57702. * Gizmo that enables viewing a camera
  57703. */
  57704. export class CameraGizmo extends Gizmo {
  57705. private _cameraMesh;
  57706. private _cameraLinesMesh;
  57707. private _material;
  57708. private _pointerObserver;
  57709. /**
  57710. * Event that fires each time the gizmo is clicked
  57711. */
  57712. onClickedObservable: Observable<Camera>;
  57713. /**
  57714. * Creates a CameraGizmo
  57715. * @param gizmoLayer The utility layer the gizmo will be added to
  57716. */
  57717. constructor(gizmoLayer?: UtilityLayerRenderer);
  57718. private _camera;
  57719. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57720. get displayFrustum(): boolean;
  57721. set displayFrustum(value: boolean);
  57722. /**
  57723. * The camera that the gizmo is attached to
  57724. */
  57725. set camera(camera: Nullable<Camera>);
  57726. get camera(): Nullable<Camera>;
  57727. /**
  57728. * Gets the material used to render the camera gizmo
  57729. */
  57730. get material(): StandardMaterial;
  57731. /**
  57732. * @hidden
  57733. * Updates the gizmo to match the attached mesh's position/rotation
  57734. */
  57735. protected _update(): void;
  57736. private static _Scale;
  57737. private _invProjection;
  57738. /**
  57739. * Disposes of the camera gizmo
  57740. */
  57741. dispose(): void;
  57742. private static _CreateCameraMesh;
  57743. private static _CreateCameraFrustum;
  57744. }
  57745. }
  57746. declare module BABYLON {
  57747. /** @hidden */
  57748. export var backgroundFragmentDeclaration: {
  57749. name: string;
  57750. shader: string;
  57751. };
  57752. }
  57753. declare module BABYLON {
  57754. /** @hidden */
  57755. export var backgroundUboDeclaration: {
  57756. name: string;
  57757. shader: string;
  57758. };
  57759. }
  57760. declare module BABYLON {
  57761. /** @hidden */
  57762. export var backgroundPixelShader: {
  57763. name: string;
  57764. shader: string;
  57765. };
  57766. }
  57767. declare module BABYLON {
  57768. /** @hidden */
  57769. export var backgroundVertexDeclaration: {
  57770. name: string;
  57771. shader: string;
  57772. };
  57773. }
  57774. declare module BABYLON {
  57775. /** @hidden */
  57776. export var backgroundVertexShader: {
  57777. name: string;
  57778. shader: string;
  57779. };
  57780. }
  57781. declare module BABYLON {
  57782. /**
  57783. * Background material used to create an efficient environement around your scene.
  57784. */
  57785. export class BackgroundMaterial extends PushMaterial {
  57786. /**
  57787. * Standard reflectance value at parallel view angle.
  57788. */
  57789. static StandardReflectance0: number;
  57790. /**
  57791. * Standard reflectance value at grazing angle.
  57792. */
  57793. static StandardReflectance90: number;
  57794. protected _primaryColor: Color3;
  57795. /**
  57796. * Key light Color (multiply against the environement texture)
  57797. */
  57798. primaryColor: Color3;
  57799. protected __perceptualColor: Nullable<Color3>;
  57800. /**
  57801. * Experimental Internal Use Only.
  57802. *
  57803. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57804. * This acts as a helper to set the primary color to a more "human friendly" value.
  57805. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57806. * output color as close as possible from the chosen value.
  57807. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57808. * part of lighting setup.)
  57809. */
  57810. get _perceptualColor(): Nullable<Color3>;
  57811. set _perceptualColor(value: Nullable<Color3>);
  57812. protected _primaryColorShadowLevel: float;
  57813. /**
  57814. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57815. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57816. */
  57817. get primaryColorShadowLevel(): float;
  57818. set primaryColorShadowLevel(value: float);
  57819. protected _primaryColorHighlightLevel: float;
  57820. /**
  57821. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57822. * The primary color is used at the level chosen to define what the white area would look.
  57823. */
  57824. get primaryColorHighlightLevel(): float;
  57825. set primaryColorHighlightLevel(value: float);
  57826. protected _reflectionTexture: Nullable<BaseTexture>;
  57827. /**
  57828. * Reflection Texture used in the material.
  57829. * Should be author in a specific way for the best result (refer to the documentation).
  57830. */
  57831. reflectionTexture: Nullable<BaseTexture>;
  57832. protected _reflectionBlur: float;
  57833. /**
  57834. * Reflection Texture level of blur.
  57835. *
  57836. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57837. * texture twice.
  57838. */
  57839. reflectionBlur: float;
  57840. protected _diffuseTexture: Nullable<BaseTexture>;
  57841. /**
  57842. * Diffuse Texture used in the material.
  57843. * Should be author in a specific way for the best result (refer to the documentation).
  57844. */
  57845. diffuseTexture: Nullable<BaseTexture>;
  57846. protected _shadowLights: Nullable<IShadowLight[]>;
  57847. /**
  57848. * Specify the list of lights casting shadow on the material.
  57849. * All scene shadow lights will be included if null.
  57850. */
  57851. shadowLights: Nullable<IShadowLight[]>;
  57852. protected _shadowLevel: float;
  57853. /**
  57854. * Helps adjusting the shadow to a softer level if required.
  57855. * 0 means black shadows and 1 means no shadows.
  57856. */
  57857. shadowLevel: float;
  57858. protected _sceneCenter: Vector3;
  57859. /**
  57860. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57861. * It is usually zero but might be interesting to modify according to your setup.
  57862. */
  57863. sceneCenter: Vector3;
  57864. protected _opacityFresnel: boolean;
  57865. /**
  57866. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57867. * This helps ensuring a nice transition when the camera goes under the ground.
  57868. */
  57869. opacityFresnel: boolean;
  57870. protected _reflectionFresnel: boolean;
  57871. /**
  57872. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57873. * This helps adding a mirror texture on the ground.
  57874. */
  57875. reflectionFresnel: boolean;
  57876. protected _reflectionFalloffDistance: number;
  57877. /**
  57878. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57879. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57880. */
  57881. reflectionFalloffDistance: number;
  57882. protected _reflectionAmount: number;
  57883. /**
  57884. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57885. */
  57886. reflectionAmount: number;
  57887. protected _reflectionReflectance0: number;
  57888. /**
  57889. * This specifies the weight of the reflection at grazing angle.
  57890. */
  57891. reflectionReflectance0: number;
  57892. protected _reflectionReflectance90: number;
  57893. /**
  57894. * This specifies the weight of the reflection at a perpendicular point of view.
  57895. */
  57896. reflectionReflectance90: number;
  57897. /**
  57898. * Sets the reflection reflectance fresnel values according to the default standard
  57899. * empirically know to work well :-)
  57900. */
  57901. set reflectionStandardFresnelWeight(value: number);
  57902. protected _useRGBColor: boolean;
  57903. /**
  57904. * Helps to directly use the maps channels instead of their level.
  57905. */
  57906. useRGBColor: boolean;
  57907. protected _enableNoise: boolean;
  57908. /**
  57909. * This helps reducing the banding effect that could occur on the background.
  57910. */
  57911. enableNoise: boolean;
  57912. /**
  57913. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57914. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57915. * Recommended to be keep at 1.0 except for special cases.
  57916. */
  57917. get fovMultiplier(): number;
  57918. set fovMultiplier(value: number);
  57919. private _fovMultiplier;
  57920. /**
  57921. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57922. */
  57923. useEquirectangularFOV: boolean;
  57924. private _maxSimultaneousLights;
  57925. /**
  57926. * Number of Simultaneous lights allowed on the material.
  57927. */
  57928. maxSimultaneousLights: int;
  57929. private _shadowOnly;
  57930. /**
  57931. * Make the material only render shadows
  57932. */
  57933. shadowOnly: boolean;
  57934. /**
  57935. * Default configuration related to image processing available in the Background Material.
  57936. */
  57937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57938. /**
  57939. * Keep track of the image processing observer to allow dispose and replace.
  57940. */
  57941. private _imageProcessingObserver;
  57942. /**
  57943. * Attaches a new image processing configuration to the PBR Material.
  57944. * @param configuration (if null the scene configuration will be use)
  57945. */
  57946. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57947. /**
  57948. * Gets the image processing configuration used either in this material.
  57949. */
  57950. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57951. /**
  57952. * Sets the Default image processing configuration used either in the this material.
  57953. *
  57954. * If sets to null, the scene one is in use.
  57955. */
  57956. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57957. /**
  57958. * Gets wether the color curves effect is enabled.
  57959. */
  57960. get cameraColorCurvesEnabled(): boolean;
  57961. /**
  57962. * Sets wether the color curves effect is enabled.
  57963. */
  57964. set cameraColorCurvesEnabled(value: boolean);
  57965. /**
  57966. * Gets wether the color grading effect is enabled.
  57967. */
  57968. get cameraColorGradingEnabled(): boolean;
  57969. /**
  57970. * Gets wether the color grading effect is enabled.
  57971. */
  57972. set cameraColorGradingEnabled(value: boolean);
  57973. /**
  57974. * Gets wether tonemapping is enabled or not.
  57975. */
  57976. get cameraToneMappingEnabled(): boolean;
  57977. /**
  57978. * Sets wether tonemapping is enabled or not
  57979. */
  57980. set cameraToneMappingEnabled(value: boolean);
  57981. /**
  57982. * The camera exposure used on this material.
  57983. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57984. * This corresponds to a photographic exposure.
  57985. */
  57986. get cameraExposure(): float;
  57987. /**
  57988. * The camera exposure used on this material.
  57989. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57990. * This corresponds to a photographic exposure.
  57991. */
  57992. set cameraExposure(value: float);
  57993. /**
  57994. * Gets The camera contrast used on this material.
  57995. */
  57996. get cameraContrast(): float;
  57997. /**
  57998. * Sets The camera contrast used on this material.
  57999. */
  58000. set cameraContrast(value: float);
  58001. /**
  58002. * Gets the Color Grading 2D Lookup Texture.
  58003. */
  58004. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58005. /**
  58006. * Sets the Color Grading 2D Lookup Texture.
  58007. */
  58008. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58009. /**
  58010. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58011. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58012. * 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;
  58013. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58014. */
  58015. get cameraColorCurves(): Nullable<ColorCurves>;
  58016. /**
  58017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58019. * 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;
  58020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58021. */
  58022. set cameraColorCurves(value: Nullable<ColorCurves>);
  58023. /**
  58024. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58025. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58026. */
  58027. switchToBGR: boolean;
  58028. private _renderTargets;
  58029. private _reflectionControls;
  58030. private _white;
  58031. private _primaryShadowColor;
  58032. private _primaryHighlightColor;
  58033. /**
  58034. * Instantiates a Background Material in the given scene
  58035. * @param name The friendly name of the material
  58036. * @param scene The scene to add the material to
  58037. */
  58038. constructor(name: string, scene: Scene);
  58039. /**
  58040. * Gets a boolean indicating that current material needs to register RTT
  58041. */
  58042. get hasRenderTargetTextures(): boolean;
  58043. /**
  58044. * The entire material has been created in order to prevent overdraw.
  58045. * @returns false
  58046. */
  58047. needAlphaTesting(): boolean;
  58048. /**
  58049. * The entire material has been created in order to prevent overdraw.
  58050. * @returns true if blending is enable
  58051. */
  58052. needAlphaBlending(): boolean;
  58053. /**
  58054. * Checks wether the material is ready to be rendered for a given mesh.
  58055. * @param mesh The mesh to render
  58056. * @param subMesh The submesh to check against
  58057. * @param useInstances Specify wether or not the material is used with instances
  58058. * @returns true if all the dependencies are ready (Textures, Effects...)
  58059. */
  58060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58061. /**
  58062. * Compute the primary color according to the chosen perceptual color.
  58063. */
  58064. private _computePrimaryColorFromPerceptualColor;
  58065. /**
  58066. * Compute the highlights and shadow colors according to their chosen levels.
  58067. */
  58068. private _computePrimaryColors;
  58069. /**
  58070. * Build the uniform buffer used in the material.
  58071. */
  58072. buildUniformLayout(): void;
  58073. /**
  58074. * Unbind the material.
  58075. */
  58076. unbind(): void;
  58077. /**
  58078. * Bind only the world matrix to the material.
  58079. * @param world The world matrix to bind.
  58080. */
  58081. bindOnlyWorldMatrix(world: Matrix): void;
  58082. /**
  58083. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58084. * @param world The world matrix to bind.
  58085. * @param subMesh The submesh to bind for.
  58086. */
  58087. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58088. /**
  58089. * Checks to see if a texture is used in the material.
  58090. * @param texture - Base texture to use.
  58091. * @returns - Boolean specifying if a texture is used in the material.
  58092. */
  58093. hasTexture(texture: BaseTexture): boolean;
  58094. /**
  58095. * Dispose the material.
  58096. * @param forceDisposeEffect Force disposal of the associated effect.
  58097. * @param forceDisposeTextures Force disposal of the associated textures.
  58098. */
  58099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58100. /**
  58101. * Clones the material.
  58102. * @param name The cloned name.
  58103. * @returns The cloned material.
  58104. */
  58105. clone(name: string): BackgroundMaterial;
  58106. /**
  58107. * Serializes the current material to its JSON representation.
  58108. * @returns The JSON representation.
  58109. */
  58110. serialize(): any;
  58111. /**
  58112. * Gets the class name of the material
  58113. * @returns "BackgroundMaterial"
  58114. */
  58115. getClassName(): string;
  58116. /**
  58117. * Parse a JSON input to create back a background material.
  58118. * @param source The JSON data to parse
  58119. * @param scene The scene to create the parsed material in
  58120. * @param rootUrl The root url of the assets the material depends upon
  58121. * @returns the instantiated BackgroundMaterial.
  58122. */
  58123. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58124. }
  58125. }
  58126. declare module BABYLON {
  58127. /**
  58128. * Represents the different options available during the creation of
  58129. * a Environment helper.
  58130. *
  58131. * This can control the default ground, skybox and image processing setup of your scene.
  58132. */
  58133. export interface IEnvironmentHelperOptions {
  58134. /**
  58135. * Specifies whether or not to create a ground.
  58136. * True by default.
  58137. */
  58138. createGround: boolean;
  58139. /**
  58140. * Specifies the ground size.
  58141. * 15 by default.
  58142. */
  58143. groundSize: number;
  58144. /**
  58145. * The texture used on the ground for the main color.
  58146. * Comes from the BabylonJS CDN by default.
  58147. *
  58148. * Remarks: Can be either a texture or a url.
  58149. */
  58150. groundTexture: string | BaseTexture;
  58151. /**
  58152. * The color mixed in the ground texture by default.
  58153. * BabylonJS clearColor by default.
  58154. */
  58155. groundColor: Color3;
  58156. /**
  58157. * Specifies the ground opacity.
  58158. * 1 by default.
  58159. */
  58160. groundOpacity: number;
  58161. /**
  58162. * Enables the ground to receive shadows.
  58163. * True by default.
  58164. */
  58165. enableGroundShadow: boolean;
  58166. /**
  58167. * Helps preventing the shadow to be fully black on the ground.
  58168. * 0.5 by default.
  58169. */
  58170. groundShadowLevel: number;
  58171. /**
  58172. * Creates a mirror texture attach to the ground.
  58173. * false by default.
  58174. */
  58175. enableGroundMirror: boolean;
  58176. /**
  58177. * Specifies the ground mirror size ratio.
  58178. * 0.3 by default as the default kernel is 64.
  58179. */
  58180. groundMirrorSizeRatio: number;
  58181. /**
  58182. * Specifies the ground mirror blur kernel size.
  58183. * 64 by default.
  58184. */
  58185. groundMirrorBlurKernel: number;
  58186. /**
  58187. * Specifies the ground mirror visibility amount.
  58188. * 1 by default
  58189. */
  58190. groundMirrorAmount: number;
  58191. /**
  58192. * Specifies the ground mirror reflectance weight.
  58193. * This uses the standard weight of the background material to setup the fresnel effect
  58194. * of the mirror.
  58195. * 1 by default.
  58196. */
  58197. groundMirrorFresnelWeight: number;
  58198. /**
  58199. * Specifies the ground mirror Falloff distance.
  58200. * This can helps reducing the size of the reflection.
  58201. * 0 by Default.
  58202. */
  58203. groundMirrorFallOffDistance: number;
  58204. /**
  58205. * Specifies the ground mirror texture type.
  58206. * Unsigned Int by Default.
  58207. */
  58208. groundMirrorTextureType: number;
  58209. /**
  58210. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58211. * the shown objects.
  58212. */
  58213. groundYBias: number;
  58214. /**
  58215. * Specifies whether or not to create a skybox.
  58216. * True by default.
  58217. */
  58218. createSkybox: boolean;
  58219. /**
  58220. * Specifies the skybox size.
  58221. * 20 by default.
  58222. */
  58223. skyboxSize: number;
  58224. /**
  58225. * The texture used on the skybox for the main color.
  58226. * Comes from the BabylonJS CDN by default.
  58227. *
  58228. * Remarks: Can be either a texture or a url.
  58229. */
  58230. skyboxTexture: string | BaseTexture;
  58231. /**
  58232. * The color mixed in the skybox texture by default.
  58233. * BabylonJS clearColor by default.
  58234. */
  58235. skyboxColor: Color3;
  58236. /**
  58237. * The background rotation around the Y axis of the scene.
  58238. * This helps aligning the key lights of your scene with the background.
  58239. * 0 by default.
  58240. */
  58241. backgroundYRotation: number;
  58242. /**
  58243. * Compute automatically the size of the elements to best fit with the scene.
  58244. */
  58245. sizeAuto: boolean;
  58246. /**
  58247. * Default position of the rootMesh if autoSize is not true.
  58248. */
  58249. rootPosition: Vector3;
  58250. /**
  58251. * Sets up the image processing in the scene.
  58252. * true by default.
  58253. */
  58254. setupImageProcessing: boolean;
  58255. /**
  58256. * The texture used as your environment texture in the scene.
  58257. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58258. *
  58259. * Remarks: Can be either a texture or a url.
  58260. */
  58261. environmentTexture: string | BaseTexture;
  58262. /**
  58263. * The value of the exposure to apply to the scene.
  58264. * 0.6 by default if setupImageProcessing is true.
  58265. */
  58266. cameraExposure: number;
  58267. /**
  58268. * The value of the contrast to apply to the scene.
  58269. * 1.6 by default if setupImageProcessing is true.
  58270. */
  58271. cameraContrast: number;
  58272. /**
  58273. * Specifies whether or not tonemapping should be enabled in the scene.
  58274. * true by default if setupImageProcessing is true.
  58275. */
  58276. toneMappingEnabled: boolean;
  58277. }
  58278. /**
  58279. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58280. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58281. * It also helps with the default setup of your imageProcessing configuration.
  58282. */
  58283. export class EnvironmentHelper {
  58284. /**
  58285. * Default ground texture URL.
  58286. */
  58287. private static _groundTextureCDNUrl;
  58288. /**
  58289. * Default skybox texture URL.
  58290. */
  58291. private static _skyboxTextureCDNUrl;
  58292. /**
  58293. * Default environment texture URL.
  58294. */
  58295. private static _environmentTextureCDNUrl;
  58296. /**
  58297. * Creates the default options for the helper.
  58298. */
  58299. private static _getDefaultOptions;
  58300. private _rootMesh;
  58301. /**
  58302. * Gets the root mesh created by the helper.
  58303. */
  58304. get rootMesh(): Mesh;
  58305. private _skybox;
  58306. /**
  58307. * Gets the skybox created by the helper.
  58308. */
  58309. get skybox(): Nullable<Mesh>;
  58310. private _skyboxTexture;
  58311. /**
  58312. * Gets the skybox texture created by the helper.
  58313. */
  58314. get skyboxTexture(): Nullable<BaseTexture>;
  58315. private _skyboxMaterial;
  58316. /**
  58317. * Gets the skybox material created by the helper.
  58318. */
  58319. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58320. private _ground;
  58321. /**
  58322. * Gets the ground mesh created by the helper.
  58323. */
  58324. get ground(): Nullable<Mesh>;
  58325. private _groundTexture;
  58326. /**
  58327. * Gets the ground texture created by the helper.
  58328. */
  58329. get groundTexture(): Nullable<BaseTexture>;
  58330. private _groundMirror;
  58331. /**
  58332. * Gets the ground mirror created by the helper.
  58333. */
  58334. get groundMirror(): Nullable<MirrorTexture>;
  58335. /**
  58336. * Gets the ground mirror render list to helps pushing the meshes
  58337. * you wish in the ground reflection.
  58338. */
  58339. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58340. private _groundMaterial;
  58341. /**
  58342. * Gets the ground material created by the helper.
  58343. */
  58344. get groundMaterial(): Nullable<BackgroundMaterial>;
  58345. /**
  58346. * Stores the creation options.
  58347. */
  58348. private readonly _scene;
  58349. private _options;
  58350. /**
  58351. * This observable will be notified with any error during the creation of the environment,
  58352. * mainly texture creation errors.
  58353. */
  58354. onErrorObservable: Observable<{
  58355. message?: string;
  58356. exception?: any;
  58357. }>;
  58358. /**
  58359. * constructor
  58360. * @param options Defines the options we want to customize the helper
  58361. * @param scene The scene to add the material to
  58362. */
  58363. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58364. /**
  58365. * Updates the background according to the new options
  58366. * @param options
  58367. */
  58368. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58369. /**
  58370. * Sets the primary color of all the available elements.
  58371. * @param color the main color to affect to the ground and the background
  58372. */
  58373. setMainColor(color: Color3): void;
  58374. /**
  58375. * Setup the image processing according to the specified options.
  58376. */
  58377. private _setupImageProcessing;
  58378. /**
  58379. * Setup the environment texture according to the specified options.
  58380. */
  58381. private _setupEnvironmentTexture;
  58382. /**
  58383. * Setup the background according to the specified options.
  58384. */
  58385. private _setupBackground;
  58386. /**
  58387. * Get the scene sizes according to the setup.
  58388. */
  58389. private _getSceneSize;
  58390. /**
  58391. * Setup the ground according to the specified options.
  58392. */
  58393. private _setupGround;
  58394. /**
  58395. * Setup the ground material according to the specified options.
  58396. */
  58397. private _setupGroundMaterial;
  58398. /**
  58399. * Setup the ground diffuse texture according to the specified options.
  58400. */
  58401. private _setupGroundDiffuseTexture;
  58402. /**
  58403. * Setup the ground mirror texture according to the specified options.
  58404. */
  58405. private _setupGroundMirrorTexture;
  58406. /**
  58407. * Setup the ground to receive the mirror texture.
  58408. */
  58409. private _setupMirrorInGroundMaterial;
  58410. /**
  58411. * Setup the skybox according to the specified options.
  58412. */
  58413. private _setupSkybox;
  58414. /**
  58415. * Setup the skybox material according to the specified options.
  58416. */
  58417. private _setupSkyboxMaterial;
  58418. /**
  58419. * Setup the skybox reflection texture according to the specified options.
  58420. */
  58421. private _setupSkyboxReflectionTexture;
  58422. private _errorHandler;
  58423. /**
  58424. * Dispose all the elements created by the Helper.
  58425. */
  58426. dispose(): void;
  58427. }
  58428. }
  58429. declare module BABYLON {
  58430. /**
  58431. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58432. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58433. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58434. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58435. */
  58436. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58437. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58438. /**
  58439. * Define the source as a Monoscopic panoramic 360/180.
  58440. */
  58441. static readonly MODE_MONOSCOPIC: number;
  58442. /**
  58443. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58444. */
  58445. static readonly MODE_TOPBOTTOM: number;
  58446. /**
  58447. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58448. */
  58449. static readonly MODE_SIDEBYSIDE: number;
  58450. private _halfDome;
  58451. private _crossEye;
  58452. protected _useDirectMapping: boolean;
  58453. /**
  58454. * The texture being displayed on the sphere
  58455. */
  58456. protected _texture: T;
  58457. /**
  58458. * Gets the texture being displayed on the sphere
  58459. */
  58460. get texture(): T;
  58461. /**
  58462. * Sets the texture being displayed on the sphere
  58463. */
  58464. set texture(newTexture: T);
  58465. /**
  58466. * The skybox material
  58467. */
  58468. protected _material: BackgroundMaterial;
  58469. /**
  58470. * The surface used for the dome
  58471. */
  58472. protected _mesh: Mesh;
  58473. /**
  58474. * Gets the mesh used for the dome.
  58475. */
  58476. get mesh(): Mesh;
  58477. /**
  58478. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58479. */
  58480. private _halfDomeMask;
  58481. /**
  58482. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58483. * Also see the options.resolution property.
  58484. */
  58485. get fovMultiplier(): number;
  58486. set fovMultiplier(value: number);
  58487. protected _textureMode: number;
  58488. /**
  58489. * Gets or set the current texture mode for the texture. It can be:
  58490. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58491. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58492. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58493. */
  58494. get textureMode(): number;
  58495. /**
  58496. * Sets the current texture mode for the texture. It can be:
  58497. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58498. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58499. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58500. */
  58501. set textureMode(value: number);
  58502. /**
  58503. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58504. */
  58505. get halfDome(): boolean;
  58506. /**
  58507. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58508. */
  58509. set halfDome(enabled: boolean);
  58510. /**
  58511. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58512. */
  58513. set crossEye(enabled: boolean);
  58514. /**
  58515. * Is it a cross-eye texture?
  58516. */
  58517. get crossEye(): boolean;
  58518. /**
  58519. * The background material of this dome.
  58520. */
  58521. get material(): BackgroundMaterial;
  58522. /**
  58523. * Oberserver used in Stereoscopic VR Mode.
  58524. */
  58525. private _onBeforeCameraRenderObserver;
  58526. /**
  58527. * Observable raised when an error occured while loading the 360 image
  58528. */
  58529. onLoadErrorObservable: Observable<string>;
  58530. /**
  58531. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58532. * @param name Element's name, child elements will append suffixes for their own names.
  58533. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58534. * @param options An object containing optional or exposed sub element properties
  58535. */
  58536. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58537. resolution?: number;
  58538. clickToPlay?: boolean;
  58539. autoPlay?: boolean;
  58540. loop?: boolean;
  58541. size?: number;
  58542. poster?: string;
  58543. faceForward?: boolean;
  58544. useDirectMapping?: boolean;
  58545. halfDomeMode?: boolean;
  58546. crossEyeMode?: boolean;
  58547. generateMipMaps?: boolean;
  58548. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58549. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58550. protected _changeTextureMode(value: number): void;
  58551. /**
  58552. * Releases resources associated with this node.
  58553. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58554. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58555. */
  58556. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58557. }
  58558. }
  58559. declare module BABYLON {
  58560. /**
  58561. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58562. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58563. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58564. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58565. */
  58566. export class PhotoDome extends TextureDome<Texture> {
  58567. /**
  58568. * Define the image as a Monoscopic panoramic 360 image.
  58569. */
  58570. static readonly MODE_MONOSCOPIC: number;
  58571. /**
  58572. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58573. */
  58574. static readonly MODE_TOPBOTTOM: number;
  58575. /**
  58576. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58577. */
  58578. static readonly MODE_SIDEBYSIDE: number;
  58579. /**
  58580. * Gets or sets the texture being displayed on the sphere
  58581. */
  58582. get photoTexture(): Texture;
  58583. /**
  58584. * sets the texture being displayed on the sphere
  58585. */
  58586. set photoTexture(value: Texture);
  58587. /**
  58588. * Gets the current video mode for the video. It can be:
  58589. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58590. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58591. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58592. */
  58593. get imageMode(): number;
  58594. /**
  58595. * Sets the current video mode for the video. It can be:
  58596. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58597. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58598. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58599. */
  58600. set imageMode(value: number);
  58601. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58602. }
  58603. }
  58604. declare module BABYLON {
  58605. /**
  58606. * Direct draw surface info
  58607. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58608. */
  58609. export interface DDSInfo {
  58610. /**
  58611. * Width of the texture
  58612. */
  58613. width: number;
  58614. /**
  58615. * Width of the texture
  58616. */
  58617. height: number;
  58618. /**
  58619. * Number of Mipmaps for the texture
  58620. * @see https://en.wikipedia.org/wiki/Mipmap
  58621. */
  58622. mipmapCount: number;
  58623. /**
  58624. * If the textures format is a known fourCC format
  58625. * @see https://www.fourcc.org/
  58626. */
  58627. isFourCC: boolean;
  58628. /**
  58629. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58630. */
  58631. isRGB: boolean;
  58632. /**
  58633. * If the texture is a lumincance format
  58634. */
  58635. isLuminance: boolean;
  58636. /**
  58637. * If this is a cube texture
  58638. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58639. */
  58640. isCube: boolean;
  58641. /**
  58642. * If the texture is a compressed format eg. FOURCC_DXT1
  58643. */
  58644. isCompressed: boolean;
  58645. /**
  58646. * The dxgiFormat of the texture
  58647. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58648. */
  58649. dxgiFormat: number;
  58650. /**
  58651. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58652. */
  58653. textureType: number;
  58654. /**
  58655. * Sphericle polynomial created for the dds texture
  58656. */
  58657. sphericalPolynomial?: SphericalPolynomial;
  58658. }
  58659. /**
  58660. * Class used to provide DDS decompression tools
  58661. */
  58662. export class DDSTools {
  58663. /**
  58664. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58665. */
  58666. static StoreLODInAlphaChannel: boolean;
  58667. /**
  58668. * Gets DDS information from an array buffer
  58669. * @param data defines the array buffer view to read data from
  58670. * @returns the DDS information
  58671. */
  58672. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58673. private static _FloatView;
  58674. private static _Int32View;
  58675. private static _ToHalfFloat;
  58676. private static _FromHalfFloat;
  58677. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58678. private static _GetHalfFloatRGBAArrayBuffer;
  58679. private static _GetFloatRGBAArrayBuffer;
  58680. private static _GetFloatAsUIntRGBAArrayBuffer;
  58681. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58682. private static _GetRGBAArrayBuffer;
  58683. private static _ExtractLongWordOrder;
  58684. private static _GetRGBArrayBuffer;
  58685. private static _GetLuminanceArrayBuffer;
  58686. /**
  58687. * Uploads DDS Levels to a Babylon Texture
  58688. * @hidden
  58689. */
  58690. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58691. }
  58692. interface ThinEngine {
  58693. /**
  58694. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58695. * @param rootUrl defines the url where the file to load is located
  58696. * @param scene defines the current scene
  58697. * @param lodScale defines scale to apply to the mip map selection
  58698. * @param lodOffset defines offset to apply to the mip map selection
  58699. * @param onLoad defines an optional callback raised when the texture is loaded
  58700. * @param onError defines an optional callback raised if there is an issue to load the texture
  58701. * @param format defines the format of the data
  58702. * @param forcedExtension defines the extension to use to pick the right loader
  58703. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58704. * @returns the cube texture as an InternalTexture
  58705. */
  58706. 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;
  58707. }
  58708. }
  58709. declare module BABYLON {
  58710. /**
  58711. * Implementation of the DDS Texture Loader.
  58712. * @hidden
  58713. */
  58714. export class _DDSTextureLoader implements IInternalTextureLoader {
  58715. /**
  58716. * Defines wether the loader supports cascade loading the different faces.
  58717. */
  58718. readonly supportCascades: boolean;
  58719. /**
  58720. * This returns if the loader support the current file information.
  58721. * @param extension defines the file extension of the file being loaded
  58722. * @returns true if the loader can load the specified file
  58723. */
  58724. canLoad(extension: string): boolean;
  58725. /**
  58726. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58727. * @param data contains the texture data
  58728. * @param texture defines the BabylonJS internal texture
  58729. * @param createPolynomials will be true if polynomials have been requested
  58730. * @param onLoad defines the callback to trigger once the texture is ready
  58731. * @param onError defines the callback to trigger in case of error
  58732. */
  58733. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58734. /**
  58735. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58736. * @param data contains the texture data
  58737. * @param texture defines the BabylonJS internal texture
  58738. * @param callback defines the method to call once ready to upload
  58739. */
  58740. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58741. }
  58742. }
  58743. declare module BABYLON {
  58744. /**
  58745. * Implementation of the ENV Texture Loader.
  58746. * @hidden
  58747. */
  58748. export class _ENVTextureLoader implements IInternalTextureLoader {
  58749. /**
  58750. * Defines wether the loader supports cascade loading the different faces.
  58751. */
  58752. readonly supportCascades: boolean;
  58753. /**
  58754. * This returns if the loader support the current file information.
  58755. * @param extension defines the file extension of the file being loaded
  58756. * @returns true if the loader can load the specified file
  58757. */
  58758. canLoad(extension: string): boolean;
  58759. /**
  58760. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58761. * @param data contains the texture data
  58762. * @param texture defines the BabylonJS internal texture
  58763. * @param createPolynomials will be true if polynomials have been requested
  58764. * @param onLoad defines the callback to trigger once the texture is ready
  58765. * @param onError defines the callback to trigger in case of error
  58766. */
  58767. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58768. /**
  58769. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58770. * @param data contains the texture data
  58771. * @param texture defines the BabylonJS internal texture
  58772. * @param callback defines the method to call once ready to upload
  58773. */
  58774. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58775. }
  58776. }
  58777. declare module BABYLON {
  58778. /**
  58779. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58780. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58781. */
  58782. export class KhronosTextureContainer {
  58783. /** contents of the KTX container file */
  58784. data: ArrayBufferView;
  58785. private static HEADER_LEN;
  58786. private static COMPRESSED_2D;
  58787. private static COMPRESSED_3D;
  58788. private static TEX_2D;
  58789. private static TEX_3D;
  58790. /**
  58791. * Gets the openGL type
  58792. */
  58793. glType: number;
  58794. /**
  58795. * Gets the openGL type size
  58796. */
  58797. glTypeSize: number;
  58798. /**
  58799. * Gets the openGL format
  58800. */
  58801. glFormat: number;
  58802. /**
  58803. * Gets the openGL internal format
  58804. */
  58805. glInternalFormat: number;
  58806. /**
  58807. * Gets the base internal format
  58808. */
  58809. glBaseInternalFormat: number;
  58810. /**
  58811. * Gets image width in pixel
  58812. */
  58813. pixelWidth: number;
  58814. /**
  58815. * Gets image height in pixel
  58816. */
  58817. pixelHeight: number;
  58818. /**
  58819. * Gets image depth in pixels
  58820. */
  58821. pixelDepth: number;
  58822. /**
  58823. * Gets the number of array elements
  58824. */
  58825. numberOfArrayElements: number;
  58826. /**
  58827. * Gets the number of faces
  58828. */
  58829. numberOfFaces: number;
  58830. /**
  58831. * Gets the number of mipmap levels
  58832. */
  58833. numberOfMipmapLevels: number;
  58834. /**
  58835. * Gets the bytes of key value data
  58836. */
  58837. bytesOfKeyValueData: number;
  58838. /**
  58839. * Gets the load type
  58840. */
  58841. loadType: number;
  58842. /**
  58843. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58844. */
  58845. isInvalid: boolean;
  58846. /**
  58847. * Creates a new KhronosTextureContainer
  58848. * @param data contents of the KTX container file
  58849. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58850. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58851. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58852. */
  58853. constructor(
  58854. /** contents of the KTX container file */
  58855. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58856. /**
  58857. * Uploads KTX content to a Babylon Texture.
  58858. * It is assumed that the texture has already been created & is currently bound
  58859. * @hidden
  58860. */
  58861. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58862. private _upload2DCompressedLevels;
  58863. /**
  58864. * Checks if the given data starts with a KTX file identifier.
  58865. * @param data the data to check
  58866. * @returns true if the data is a KTX file or false otherwise
  58867. */
  58868. static IsValid(data: ArrayBufferView): boolean;
  58869. }
  58870. }
  58871. declare module BABYLON {
  58872. /**
  58873. * Helper class to push actions to a pool of workers.
  58874. */
  58875. export class WorkerPool implements IDisposable {
  58876. private _workerInfos;
  58877. private _pendingActions;
  58878. /**
  58879. * Constructor
  58880. * @param workers Array of workers to use for actions
  58881. */
  58882. constructor(workers: Array<Worker>);
  58883. /**
  58884. * Terminates all workers and clears any pending actions.
  58885. */
  58886. dispose(): void;
  58887. /**
  58888. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58889. * pended until a worker has completed its action.
  58890. * @param action The action to perform. Call onComplete when the action is complete.
  58891. */
  58892. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58893. private _execute;
  58894. }
  58895. }
  58896. declare module BABYLON {
  58897. /**
  58898. * Class for loading KTX2 files
  58899. */
  58900. export class KhronosTextureContainer2 {
  58901. private static _WorkerPoolPromise?;
  58902. private static _Initialized;
  58903. private static _Ktx2Decoder;
  58904. /**
  58905. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58906. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58907. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58908. * Urls you can change:
  58909. * URLConfig.jsDecoderModule
  58910. * URLConfig.wasmUASTCToASTC
  58911. * URLConfig.wasmUASTCToBC7
  58912. * URLConfig.wasmUASTCToRGBA_UNORM
  58913. * URLConfig.wasmUASTCToRGBA_SRGB
  58914. * URLConfig.jsMSCTranscoder
  58915. * URLConfig.wasmMSCTranscoder
  58916. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58917. */
  58918. static URLConfig: {
  58919. jsDecoderModule: string;
  58920. wasmUASTCToASTC: null;
  58921. wasmUASTCToBC7: null;
  58922. wasmUASTCToRGBA_UNORM: null;
  58923. wasmUASTCToRGBA_SRGB: null;
  58924. jsMSCTranscoder: null;
  58925. wasmMSCTranscoder: null;
  58926. };
  58927. /**
  58928. * Default number of workers used to handle data decoding
  58929. */
  58930. static DefaultNumWorkers: number;
  58931. private static GetDefaultNumWorkers;
  58932. private _engine;
  58933. private static _CreateWorkerPool;
  58934. /**
  58935. * Constructor
  58936. * @param engine The engine to use
  58937. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58938. */
  58939. constructor(engine: ThinEngine, numWorkers?: number);
  58940. /** @hidden */
  58941. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58942. /**
  58943. * Stop all async operations and release resources.
  58944. */
  58945. dispose(): void;
  58946. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  58947. /**
  58948. * Checks if the given data starts with a KTX2 file identifier.
  58949. * @param data the data to check
  58950. * @returns true if the data is a KTX2 file or false otherwise
  58951. */
  58952. static IsValid(data: ArrayBufferView): boolean;
  58953. }
  58954. }
  58955. declare module BABYLON {
  58956. /**
  58957. * Implementation of the KTX Texture Loader.
  58958. * @hidden
  58959. */
  58960. export class _KTXTextureLoader implements IInternalTextureLoader {
  58961. /**
  58962. * Defines wether the loader supports cascade loading the different faces.
  58963. */
  58964. readonly supportCascades: boolean;
  58965. /**
  58966. * This returns if the loader support the current file information.
  58967. * @param extension defines the file extension of the file being loaded
  58968. * @param mimeType defines the optional mime type of the file being loaded
  58969. * @returns true if the loader can load the specified file
  58970. */
  58971. canLoad(extension: string, mimeType?: string): boolean;
  58972. /**
  58973. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58974. * @param data contains the texture data
  58975. * @param texture defines the BabylonJS internal texture
  58976. * @param createPolynomials will be true if polynomials have been requested
  58977. * @param onLoad defines the callback to trigger once the texture is ready
  58978. * @param onError defines the callback to trigger in case of error
  58979. */
  58980. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58981. /**
  58982. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58983. * @param data contains the texture data
  58984. * @param texture defines the BabylonJS internal texture
  58985. * @param callback defines the method to call once ready to upload
  58986. */
  58987. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58988. }
  58989. }
  58990. declare module BABYLON {
  58991. /** @hidden */
  58992. export var _forceSceneHelpersToBundle: boolean;
  58993. interface Scene {
  58994. /**
  58995. * Creates a default light for the scene.
  58996. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58997. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58998. */
  58999. createDefaultLight(replace?: boolean): void;
  59000. /**
  59001. * Creates a default camera for the scene.
  59002. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59003. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59004. * @param replace has default false, when true replaces the active camera in the scene
  59005. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59006. */
  59007. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59008. /**
  59009. * Creates a default camera and a default light.
  59010. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59011. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59012. * @param replace has the default false, when true replaces the active camera/light in the scene
  59013. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59014. */
  59015. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59016. /**
  59017. * Creates a new sky box
  59018. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59019. * @param environmentTexture defines the texture to use as environment texture
  59020. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59021. * @param scale defines the overall scale of the skybox
  59022. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59023. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59024. * @returns a new mesh holding the sky box
  59025. */
  59026. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59027. /**
  59028. * Creates a new environment
  59029. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59030. * @param options defines the options you can use to configure the environment
  59031. * @returns the new EnvironmentHelper
  59032. */
  59033. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59034. /**
  59035. * Creates a new VREXperienceHelper
  59036. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59037. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59038. * @returns a new VREXperienceHelper
  59039. */
  59040. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59041. /**
  59042. * Creates a new WebXRDefaultExperience
  59043. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59044. * @param options experience options
  59045. * @returns a promise for a new WebXRDefaultExperience
  59046. */
  59047. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59048. }
  59049. }
  59050. declare module BABYLON {
  59051. /**
  59052. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59053. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59054. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59055. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59056. */
  59057. export class VideoDome extends TextureDome<VideoTexture> {
  59058. /**
  59059. * Define the video source as a Monoscopic panoramic 360 video.
  59060. */
  59061. static readonly MODE_MONOSCOPIC: number;
  59062. /**
  59063. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59064. */
  59065. static readonly MODE_TOPBOTTOM: number;
  59066. /**
  59067. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59068. */
  59069. static readonly MODE_SIDEBYSIDE: number;
  59070. /**
  59071. * Get the video texture associated with this video dome
  59072. */
  59073. get videoTexture(): VideoTexture;
  59074. /**
  59075. * Get the video mode of this dome
  59076. */
  59077. get videoMode(): number;
  59078. /**
  59079. * Set the video mode of this dome.
  59080. * @see textureMode
  59081. */
  59082. set videoMode(value: number);
  59083. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59084. }
  59085. }
  59086. declare module BABYLON {
  59087. /**
  59088. * This class can be used to get instrumentation data from a Babylon engine
  59089. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59090. */
  59091. export class EngineInstrumentation implements IDisposable {
  59092. /**
  59093. * Define the instrumented engine.
  59094. */
  59095. engine: Engine;
  59096. private _captureGPUFrameTime;
  59097. private _gpuFrameTimeToken;
  59098. private _gpuFrameTime;
  59099. private _captureShaderCompilationTime;
  59100. private _shaderCompilationTime;
  59101. private _onBeginFrameObserver;
  59102. private _onEndFrameObserver;
  59103. private _onBeforeShaderCompilationObserver;
  59104. private _onAfterShaderCompilationObserver;
  59105. /**
  59106. * Gets the perf counter used for GPU frame time
  59107. */
  59108. get gpuFrameTimeCounter(): PerfCounter;
  59109. /**
  59110. * Gets the GPU frame time capture status
  59111. */
  59112. get captureGPUFrameTime(): boolean;
  59113. /**
  59114. * Enable or disable the GPU frame time capture
  59115. */
  59116. set captureGPUFrameTime(value: boolean);
  59117. /**
  59118. * Gets the perf counter used for shader compilation time
  59119. */
  59120. get shaderCompilationTimeCounter(): PerfCounter;
  59121. /**
  59122. * Gets the shader compilation time capture status
  59123. */
  59124. get captureShaderCompilationTime(): boolean;
  59125. /**
  59126. * Enable or disable the shader compilation time capture
  59127. */
  59128. set captureShaderCompilationTime(value: boolean);
  59129. /**
  59130. * Instantiates a new engine instrumentation.
  59131. * This class can be used to get instrumentation data from a Babylon engine
  59132. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59133. * @param engine Defines the engine to instrument
  59134. */
  59135. constructor(
  59136. /**
  59137. * Define the instrumented engine.
  59138. */
  59139. engine: Engine);
  59140. /**
  59141. * Dispose and release associated resources.
  59142. */
  59143. dispose(): void;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /**
  59148. * This class can be used to get instrumentation data from a Babylon engine
  59149. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59150. */
  59151. export class SceneInstrumentation implements IDisposable {
  59152. /**
  59153. * Defines the scene to instrument
  59154. */
  59155. scene: Scene;
  59156. private _captureActiveMeshesEvaluationTime;
  59157. private _activeMeshesEvaluationTime;
  59158. private _captureRenderTargetsRenderTime;
  59159. private _renderTargetsRenderTime;
  59160. private _captureFrameTime;
  59161. private _frameTime;
  59162. private _captureRenderTime;
  59163. private _renderTime;
  59164. private _captureInterFrameTime;
  59165. private _interFrameTime;
  59166. private _captureParticlesRenderTime;
  59167. private _particlesRenderTime;
  59168. private _captureSpritesRenderTime;
  59169. private _spritesRenderTime;
  59170. private _capturePhysicsTime;
  59171. private _physicsTime;
  59172. private _captureAnimationsTime;
  59173. private _animationsTime;
  59174. private _captureCameraRenderTime;
  59175. private _cameraRenderTime;
  59176. private _onBeforeActiveMeshesEvaluationObserver;
  59177. private _onAfterActiveMeshesEvaluationObserver;
  59178. private _onBeforeRenderTargetsRenderObserver;
  59179. private _onAfterRenderTargetsRenderObserver;
  59180. private _onAfterRenderObserver;
  59181. private _onBeforeDrawPhaseObserver;
  59182. private _onAfterDrawPhaseObserver;
  59183. private _onBeforeAnimationsObserver;
  59184. private _onBeforeParticlesRenderingObserver;
  59185. private _onAfterParticlesRenderingObserver;
  59186. private _onBeforeSpritesRenderingObserver;
  59187. private _onAfterSpritesRenderingObserver;
  59188. private _onBeforePhysicsObserver;
  59189. private _onAfterPhysicsObserver;
  59190. private _onAfterAnimationsObserver;
  59191. private _onBeforeCameraRenderObserver;
  59192. private _onAfterCameraRenderObserver;
  59193. /**
  59194. * Gets the perf counter used for active meshes evaluation time
  59195. */
  59196. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59197. /**
  59198. * Gets the active meshes evaluation time capture status
  59199. */
  59200. get captureActiveMeshesEvaluationTime(): boolean;
  59201. /**
  59202. * Enable or disable the active meshes evaluation time capture
  59203. */
  59204. set captureActiveMeshesEvaluationTime(value: boolean);
  59205. /**
  59206. * Gets the perf counter used for render targets render time
  59207. */
  59208. get renderTargetsRenderTimeCounter(): PerfCounter;
  59209. /**
  59210. * Gets the render targets render time capture status
  59211. */
  59212. get captureRenderTargetsRenderTime(): boolean;
  59213. /**
  59214. * Enable or disable the render targets render time capture
  59215. */
  59216. set captureRenderTargetsRenderTime(value: boolean);
  59217. /**
  59218. * Gets the perf counter used for particles render time
  59219. */
  59220. get particlesRenderTimeCounter(): PerfCounter;
  59221. /**
  59222. * Gets the particles render time capture status
  59223. */
  59224. get captureParticlesRenderTime(): boolean;
  59225. /**
  59226. * Enable or disable the particles render time capture
  59227. */
  59228. set captureParticlesRenderTime(value: boolean);
  59229. /**
  59230. * Gets the perf counter used for sprites render time
  59231. */
  59232. get spritesRenderTimeCounter(): PerfCounter;
  59233. /**
  59234. * Gets the sprites render time capture status
  59235. */
  59236. get captureSpritesRenderTime(): boolean;
  59237. /**
  59238. * Enable or disable the sprites render time capture
  59239. */
  59240. set captureSpritesRenderTime(value: boolean);
  59241. /**
  59242. * Gets the perf counter used for physics time
  59243. */
  59244. get physicsTimeCounter(): PerfCounter;
  59245. /**
  59246. * Gets the physics time capture status
  59247. */
  59248. get capturePhysicsTime(): boolean;
  59249. /**
  59250. * Enable or disable the physics time capture
  59251. */
  59252. set capturePhysicsTime(value: boolean);
  59253. /**
  59254. * Gets the perf counter used for animations time
  59255. */
  59256. get animationsTimeCounter(): PerfCounter;
  59257. /**
  59258. * Gets the animations time capture status
  59259. */
  59260. get captureAnimationsTime(): boolean;
  59261. /**
  59262. * Enable or disable the animations time capture
  59263. */
  59264. set captureAnimationsTime(value: boolean);
  59265. /**
  59266. * Gets the perf counter used for frame time capture
  59267. */
  59268. get frameTimeCounter(): PerfCounter;
  59269. /**
  59270. * Gets the frame time capture status
  59271. */
  59272. get captureFrameTime(): boolean;
  59273. /**
  59274. * Enable or disable the frame time capture
  59275. */
  59276. set captureFrameTime(value: boolean);
  59277. /**
  59278. * Gets the perf counter used for inter-frames time capture
  59279. */
  59280. get interFrameTimeCounter(): PerfCounter;
  59281. /**
  59282. * Gets the inter-frames time capture status
  59283. */
  59284. get captureInterFrameTime(): boolean;
  59285. /**
  59286. * Enable or disable the inter-frames time capture
  59287. */
  59288. set captureInterFrameTime(value: boolean);
  59289. /**
  59290. * Gets the perf counter used for render time capture
  59291. */
  59292. get renderTimeCounter(): PerfCounter;
  59293. /**
  59294. * Gets the render time capture status
  59295. */
  59296. get captureRenderTime(): boolean;
  59297. /**
  59298. * Enable or disable the render time capture
  59299. */
  59300. set captureRenderTime(value: boolean);
  59301. /**
  59302. * Gets the perf counter used for camera render time capture
  59303. */
  59304. get cameraRenderTimeCounter(): PerfCounter;
  59305. /**
  59306. * Gets the camera render time capture status
  59307. */
  59308. get captureCameraRenderTime(): boolean;
  59309. /**
  59310. * Enable or disable the camera render time capture
  59311. */
  59312. set captureCameraRenderTime(value: boolean);
  59313. /**
  59314. * Gets the perf counter used for draw calls
  59315. */
  59316. get drawCallsCounter(): PerfCounter;
  59317. /**
  59318. * Instantiates a new scene instrumentation.
  59319. * This class can be used to get instrumentation data from a Babylon engine
  59320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59321. * @param scene Defines the scene to instrument
  59322. */
  59323. constructor(
  59324. /**
  59325. * Defines the scene to instrument
  59326. */
  59327. scene: Scene);
  59328. /**
  59329. * Dispose and release associated resources.
  59330. */
  59331. dispose(): void;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /** @hidden */
  59336. export var glowMapGenerationPixelShader: {
  59337. name: string;
  59338. shader: string;
  59339. };
  59340. }
  59341. declare module BABYLON {
  59342. /** @hidden */
  59343. export var glowMapGenerationVertexShader: {
  59344. name: string;
  59345. shader: string;
  59346. };
  59347. }
  59348. declare module BABYLON {
  59349. /**
  59350. * Effect layer options. This helps customizing the behaviour
  59351. * of the effect layer.
  59352. */
  59353. export interface IEffectLayerOptions {
  59354. /**
  59355. * Multiplication factor apply to the canvas size to compute the render target size
  59356. * used to generated the objects (the smaller the faster).
  59357. */
  59358. mainTextureRatio: number;
  59359. /**
  59360. * Enforces a fixed size texture to ensure effect stability across devices.
  59361. */
  59362. mainTextureFixedSize?: number;
  59363. /**
  59364. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59365. */
  59366. alphaBlendingMode: number;
  59367. /**
  59368. * The camera attached to the layer.
  59369. */
  59370. camera: Nullable<Camera>;
  59371. /**
  59372. * The rendering group to draw the layer in.
  59373. */
  59374. renderingGroupId: number;
  59375. }
  59376. /**
  59377. * The effect layer Helps adding post process effect blended with the main pass.
  59378. *
  59379. * This can be for instance use to generate glow or higlight effects on the scene.
  59380. *
  59381. * The effect layer class can not be used directly and is intented to inherited from to be
  59382. * customized per effects.
  59383. */
  59384. export abstract class EffectLayer {
  59385. private _vertexBuffers;
  59386. private _indexBuffer;
  59387. private _cachedDefines;
  59388. private _effectLayerMapGenerationEffect;
  59389. private _effectLayerOptions;
  59390. private _mergeEffect;
  59391. protected _scene: Scene;
  59392. protected _engine: Engine;
  59393. protected _maxSize: number;
  59394. protected _mainTextureDesiredSize: ISize;
  59395. protected _mainTexture: RenderTargetTexture;
  59396. protected _shouldRender: boolean;
  59397. protected _postProcesses: PostProcess[];
  59398. protected _textures: BaseTexture[];
  59399. protected _emissiveTextureAndColor: {
  59400. texture: Nullable<BaseTexture>;
  59401. color: Color4;
  59402. };
  59403. /**
  59404. * The name of the layer
  59405. */
  59406. name: string;
  59407. /**
  59408. * The clear color of the texture used to generate the glow map.
  59409. */
  59410. neutralColor: Color4;
  59411. /**
  59412. * Specifies whether the highlight layer is enabled or not.
  59413. */
  59414. isEnabled: boolean;
  59415. /**
  59416. * Gets the camera attached to the layer.
  59417. */
  59418. get camera(): Nullable<Camera>;
  59419. /**
  59420. * Gets the rendering group id the layer should render in.
  59421. */
  59422. get renderingGroupId(): number;
  59423. set renderingGroupId(renderingGroupId: number);
  59424. /**
  59425. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59426. */
  59427. disableBoundingBoxesFromEffectLayer: boolean;
  59428. /**
  59429. * An event triggered when the effect layer has been disposed.
  59430. */
  59431. onDisposeObservable: Observable<EffectLayer>;
  59432. /**
  59433. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59434. */
  59435. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59436. /**
  59437. * An event triggered when the generated texture is being merged in the scene.
  59438. */
  59439. onBeforeComposeObservable: Observable<EffectLayer>;
  59440. /**
  59441. * An event triggered when the mesh is rendered into the effect render target.
  59442. */
  59443. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59444. /**
  59445. * An event triggered after the mesh has been rendered into the effect render target.
  59446. */
  59447. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59448. /**
  59449. * An event triggered when the generated texture has been merged in the scene.
  59450. */
  59451. onAfterComposeObservable: Observable<EffectLayer>;
  59452. /**
  59453. * An event triggered when the efffect layer changes its size.
  59454. */
  59455. onSizeChangedObservable: Observable<EffectLayer>;
  59456. /** @hidden */
  59457. static _SceneComponentInitialization: (scene: Scene) => void;
  59458. /**
  59459. * Instantiates a new effect Layer and references it in the scene.
  59460. * @param name The name of the layer
  59461. * @param scene The scene to use the layer in
  59462. */
  59463. constructor(
  59464. /** The Friendly of the effect in the scene */
  59465. name: string, scene: Scene);
  59466. /**
  59467. * Get the effect name of the layer.
  59468. * @return The effect name
  59469. */
  59470. abstract getEffectName(): string;
  59471. /**
  59472. * Checks for the readiness of the element composing the layer.
  59473. * @param subMesh the mesh to check for
  59474. * @param useInstances specify whether or not to use instances to render the mesh
  59475. * @return true if ready otherwise, false
  59476. */
  59477. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59478. /**
  59479. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59480. * @returns true if the effect requires stencil during the main canvas render pass.
  59481. */
  59482. abstract needStencil(): boolean;
  59483. /**
  59484. * Create the merge effect. This is the shader use to blit the information back
  59485. * to the main canvas at the end of the scene rendering.
  59486. * @returns The effect containing the shader used to merge the effect on the main canvas
  59487. */
  59488. protected abstract _createMergeEffect(): Effect;
  59489. /**
  59490. * Creates the render target textures and post processes used in the effect layer.
  59491. */
  59492. protected abstract _createTextureAndPostProcesses(): void;
  59493. /**
  59494. * Implementation specific of rendering the generating effect on the main canvas.
  59495. * @param effect The effect used to render through
  59496. */
  59497. protected abstract _internalRender(effect: Effect): void;
  59498. /**
  59499. * Sets the required values for both the emissive texture and and the main color.
  59500. */
  59501. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59502. /**
  59503. * Free any resources and references associated to a mesh.
  59504. * Internal use
  59505. * @param mesh The mesh to free.
  59506. */
  59507. abstract _disposeMesh(mesh: Mesh): void;
  59508. /**
  59509. * Serializes this layer (Glow or Highlight for example)
  59510. * @returns a serialized layer object
  59511. */
  59512. abstract serialize?(): any;
  59513. /**
  59514. * Initializes the effect layer with the required options.
  59515. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59516. */
  59517. protected _init(options: Partial<IEffectLayerOptions>): void;
  59518. /**
  59519. * Generates the index buffer of the full screen quad blending to the main canvas.
  59520. */
  59521. private _generateIndexBuffer;
  59522. /**
  59523. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59524. */
  59525. private _generateVertexBuffer;
  59526. /**
  59527. * Sets the main texture desired size which is the closest power of two
  59528. * of the engine canvas size.
  59529. */
  59530. private _setMainTextureSize;
  59531. /**
  59532. * Creates the main texture for the effect layer.
  59533. */
  59534. protected _createMainTexture(): void;
  59535. /**
  59536. * Adds specific effects defines.
  59537. * @param defines The defines to add specifics to.
  59538. */
  59539. protected _addCustomEffectDefines(defines: string[]): void;
  59540. /**
  59541. * Checks for the readiness of the element composing the layer.
  59542. * @param subMesh the mesh to check for
  59543. * @param useInstances specify whether or not to use instances to render the mesh
  59544. * @param emissiveTexture the associated emissive texture used to generate the glow
  59545. * @return true if ready otherwise, false
  59546. */
  59547. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59548. /**
  59549. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59550. */
  59551. render(): void;
  59552. /**
  59553. * Determine if a given mesh will be used in the current effect.
  59554. * @param mesh mesh to test
  59555. * @returns true if the mesh will be used
  59556. */
  59557. hasMesh(mesh: AbstractMesh): boolean;
  59558. /**
  59559. * Returns true if the layer contains information to display, otherwise false.
  59560. * @returns true if the glow layer should be rendered
  59561. */
  59562. shouldRender(): boolean;
  59563. /**
  59564. * Returns true if the mesh should render, otherwise false.
  59565. * @param mesh The mesh to render
  59566. * @returns true if it should render otherwise false
  59567. */
  59568. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59569. /**
  59570. * Returns true if the mesh can be rendered, otherwise false.
  59571. * @param mesh The mesh to render
  59572. * @param material The material used on the mesh
  59573. * @returns true if it can be rendered otherwise false
  59574. */
  59575. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59576. /**
  59577. * Returns true if the mesh should render, otherwise false.
  59578. * @param mesh The mesh to render
  59579. * @returns true if it should render otherwise false
  59580. */
  59581. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59582. /**
  59583. * Renders the submesh passed in parameter to the generation map.
  59584. */
  59585. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59586. /**
  59587. * Defines whether the current material of the mesh should be use to render the effect.
  59588. * @param mesh defines the current mesh to render
  59589. */
  59590. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59591. /**
  59592. * Rebuild the required buffers.
  59593. * @hidden Internal use only.
  59594. */
  59595. _rebuild(): void;
  59596. /**
  59597. * Dispose only the render target textures and post process.
  59598. */
  59599. private _disposeTextureAndPostProcesses;
  59600. /**
  59601. * Dispose the highlight layer and free resources.
  59602. */
  59603. dispose(): void;
  59604. /**
  59605. * Gets the class name of the effect layer
  59606. * @returns the string with the class name of the effect layer
  59607. */
  59608. getClassName(): string;
  59609. /**
  59610. * Creates an effect layer from parsed effect layer data
  59611. * @param parsedEffectLayer defines effect layer data
  59612. * @param scene defines the current scene
  59613. * @param rootUrl defines the root URL containing the effect layer information
  59614. * @returns a parsed effect Layer
  59615. */
  59616. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59617. }
  59618. }
  59619. declare module BABYLON {
  59620. interface AbstractScene {
  59621. /**
  59622. * The list of effect layers (highlights/glow) added to the scene
  59623. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59624. * @see https://doc.babylonjs.com/how_to/glow_layer
  59625. */
  59626. effectLayers: Array<EffectLayer>;
  59627. /**
  59628. * Removes the given effect layer from this scene.
  59629. * @param toRemove defines the effect layer to remove
  59630. * @returns the index of the removed effect layer
  59631. */
  59632. removeEffectLayer(toRemove: EffectLayer): number;
  59633. /**
  59634. * Adds the given effect layer to this scene
  59635. * @param newEffectLayer defines the effect layer to add
  59636. */
  59637. addEffectLayer(newEffectLayer: EffectLayer): void;
  59638. }
  59639. /**
  59640. * Defines the layer scene component responsible to manage any effect layers
  59641. * in a given scene.
  59642. */
  59643. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59644. /**
  59645. * The component name helpfull to identify the component in the list of scene components.
  59646. */
  59647. readonly name: string;
  59648. /**
  59649. * The scene the component belongs to.
  59650. */
  59651. scene: Scene;
  59652. private _engine;
  59653. private _renderEffects;
  59654. private _needStencil;
  59655. private _previousStencilState;
  59656. /**
  59657. * Creates a new instance of the component for the given scene
  59658. * @param scene Defines the scene to register the component in
  59659. */
  59660. constructor(scene: Scene);
  59661. /**
  59662. * Registers the component in a given scene
  59663. */
  59664. register(): void;
  59665. /**
  59666. * Rebuilds the elements related to this component in case of
  59667. * context lost for instance.
  59668. */
  59669. rebuild(): void;
  59670. /**
  59671. * Serializes the component data to the specified json object
  59672. * @param serializationObject The object to serialize to
  59673. */
  59674. serialize(serializationObject: any): void;
  59675. /**
  59676. * Adds all the elements from the container to the scene
  59677. * @param container the container holding the elements
  59678. */
  59679. addFromContainer(container: AbstractScene): void;
  59680. /**
  59681. * Removes all the elements in the container from the scene
  59682. * @param container contains the elements to remove
  59683. * @param dispose if the removed element should be disposed (default: false)
  59684. */
  59685. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59686. /**
  59687. * Disposes the component and the associated ressources.
  59688. */
  59689. dispose(): void;
  59690. private _isReadyForMesh;
  59691. private _renderMainTexture;
  59692. private _setStencil;
  59693. private _setStencilBack;
  59694. private _draw;
  59695. private _drawCamera;
  59696. private _drawRenderingGroup;
  59697. }
  59698. }
  59699. declare module BABYLON {
  59700. /** @hidden */
  59701. export var glowMapMergePixelShader: {
  59702. name: string;
  59703. shader: string;
  59704. };
  59705. }
  59706. declare module BABYLON {
  59707. /** @hidden */
  59708. export var glowMapMergeVertexShader: {
  59709. name: string;
  59710. shader: string;
  59711. };
  59712. }
  59713. declare module BABYLON {
  59714. interface AbstractScene {
  59715. /**
  59716. * Return a the first highlight layer of the scene with a given name.
  59717. * @param name The name of the highlight layer to look for.
  59718. * @return The highlight layer if found otherwise null.
  59719. */
  59720. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59721. }
  59722. /**
  59723. * Glow layer options. This helps customizing the behaviour
  59724. * of the glow layer.
  59725. */
  59726. export interface IGlowLayerOptions {
  59727. /**
  59728. * Multiplication factor apply to the canvas size to compute the render target size
  59729. * used to generated the glowing objects (the smaller the faster).
  59730. */
  59731. mainTextureRatio: number;
  59732. /**
  59733. * Enforces a fixed size texture to ensure resize independant blur.
  59734. */
  59735. mainTextureFixedSize?: number;
  59736. /**
  59737. * How big is the kernel of the blur texture.
  59738. */
  59739. blurKernelSize: number;
  59740. /**
  59741. * The camera attached to the layer.
  59742. */
  59743. camera: Nullable<Camera>;
  59744. /**
  59745. * Enable MSAA by chosing the number of samples.
  59746. */
  59747. mainTextureSamples?: number;
  59748. /**
  59749. * The rendering group to draw the layer in.
  59750. */
  59751. renderingGroupId: number;
  59752. }
  59753. /**
  59754. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59755. *
  59756. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59757. *
  59758. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59759. */
  59760. export class GlowLayer extends EffectLayer {
  59761. /**
  59762. * Effect Name of the layer.
  59763. */
  59764. static readonly EffectName: string;
  59765. /**
  59766. * The default blur kernel size used for the glow.
  59767. */
  59768. static DefaultBlurKernelSize: number;
  59769. /**
  59770. * The default texture size ratio used for the glow.
  59771. */
  59772. static DefaultTextureRatio: number;
  59773. /**
  59774. * Sets the kernel size of the blur.
  59775. */
  59776. set blurKernelSize(value: number);
  59777. /**
  59778. * Gets the kernel size of the blur.
  59779. */
  59780. get blurKernelSize(): number;
  59781. /**
  59782. * Sets the glow intensity.
  59783. */
  59784. set intensity(value: number);
  59785. /**
  59786. * Gets the glow intensity.
  59787. */
  59788. get intensity(): number;
  59789. private _options;
  59790. private _intensity;
  59791. private _horizontalBlurPostprocess1;
  59792. private _verticalBlurPostprocess1;
  59793. private _horizontalBlurPostprocess2;
  59794. private _verticalBlurPostprocess2;
  59795. private _blurTexture1;
  59796. private _blurTexture2;
  59797. private _postProcesses1;
  59798. private _postProcesses2;
  59799. private _includedOnlyMeshes;
  59800. private _excludedMeshes;
  59801. private _meshesUsingTheirOwnMaterials;
  59802. /**
  59803. * Callback used to let the user override the color selection on a per mesh basis
  59804. */
  59805. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59806. /**
  59807. * Callback used to let the user override the texture selection on a per mesh basis
  59808. */
  59809. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59810. /**
  59811. * Instantiates a new glow Layer and references it to the scene.
  59812. * @param name The name of the layer
  59813. * @param scene The scene to use the layer in
  59814. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59815. */
  59816. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59817. /**
  59818. * Get the effect name of the layer.
  59819. * @return The effect name
  59820. */
  59821. getEffectName(): string;
  59822. /**
  59823. * Create the merge effect. This is the shader use to blit the information back
  59824. * to the main canvas at the end of the scene rendering.
  59825. */
  59826. protected _createMergeEffect(): Effect;
  59827. /**
  59828. * Creates the render target textures and post processes used in the glow layer.
  59829. */
  59830. protected _createTextureAndPostProcesses(): void;
  59831. /**
  59832. * Checks for the readiness of the element composing the layer.
  59833. * @param subMesh the mesh to check for
  59834. * @param useInstances specify wether or not to use instances to render the mesh
  59835. * @param emissiveTexture the associated emissive texture used to generate the glow
  59836. * @return true if ready otherwise, false
  59837. */
  59838. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59839. /**
  59840. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59841. */
  59842. needStencil(): boolean;
  59843. /**
  59844. * Returns true if the mesh can be rendered, otherwise false.
  59845. * @param mesh The mesh to render
  59846. * @param material The material used on the mesh
  59847. * @returns true if it can be rendered otherwise false
  59848. */
  59849. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59850. /**
  59851. * Implementation specific of rendering the generating effect on the main canvas.
  59852. * @param effect The effect used to render through
  59853. */
  59854. protected _internalRender(effect: Effect): void;
  59855. /**
  59856. * Sets the required values for both the emissive texture and and the main color.
  59857. */
  59858. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59859. /**
  59860. * Returns true if the mesh should render, otherwise false.
  59861. * @param mesh The mesh to render
  59862. * @returns true if it should render otherwise false
  59863. */
  59864. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59865. /**
  59866. * Adds specific effects defines.
  59867. * @param defines The defines to add specifics to.
  59868. */
  59869. protected _addCustomEffectDefines(defines: string[]): void;
  59870. /**
  59871. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59872. * @param mesh The mesh to exclude from the glow layer
  59873. */
  59874. addExcludedMesh(mesh: Mesh): void;
  59875. /**
  59876. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59877. * @param mesh The mesh to remove
  59878. */
  59879. removeExcludedMesh(mesh: Mesh): void;
  59880. /**
  59881. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59882. * @param mesh The mesh to include in the glow layer
  59883. */
  59884. addIncludedOnlyMesh(mesh: Mesh): void;
  59885. /**
  59886. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59887. * @param mesh The mesh to remove
  59888. */
  59889. removeIncludedOnlyMesh(mesh: Mesh): void;
  59890. /**
  59891. * Determine if a given mesh will be used in the glow layer
  59892. * @param mesh The mesh to test
  59893. * @returns true if the mesh will be highlighted by the current glow layer
  59894. */
  59895. hasMesh(mesh: AbstractMesh): boolean;
  59896. /**
  59897. * Defines whether the current material of the mesh should be use to render the effect.
  59898. * @param mesh defines the current mesh to render
  59899. */
  59900. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59901. /**
  59902. * Add a mesh to be rendered through its own material and not with emissive only.
  59903. * @param mesh The mesh for which we need to use its material
  59904. */
  59905. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59906. /**
  59907. * Remove a mesh from being rendered through its own material and not with emissive only.
  59908. * @param mesh The mesh for which we need to not use its material
  59909. */
  59910. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59911. /**
  59912. * Free any resources and references associated to a mesh.
  59913. * Internal use
  59914. * @param mesh The mesh to free.
  59915. * @hidden
  59916. */
  59917. _disposeMesh(mesh: Mesh): void;
  59918. /**
  59919. * Gets the class name of the effect layer
  59920. * @returns the string with the class name of the effect layer
  59921. */
  59922. getClassName(): string;
  59923. /**
  59924. * Serializes this glow layer
  59925. * @returns a serialized glow layer object
  59926. */
  59927. serialize(): any;
  59928. /**
  59929. * Creates a Glow Layer from parsed glow layer data
  59930. * @param parsedGlowLayer defines glow layer data
  59931. * @param scene defines the current scene
  59932. * @param rootUrl defines the root URL containing the glow layer information
  59933. * @returns a parsed Glow Layer
  59934. */
  59935. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59936. }
  59937. }
  59938. declare module BABYLON {
  59939. /** @hidden */
  59940. export var glowBlurPostProcessPixelShader: {
  59941. name: string;
  59942. shader: string;
  59943. };
  59944. }
  59945. declare module BABYLON {
  59946. interface AbstractScene {
  59947. /**
  59948. * Return a the first highlight layer of the scene with a given name.
  59949. * @param name The name of the highlight layer to look for.
  59950. * @return The highlight layer if found otherwise null.
  59951. */
  59952. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59953. }
  59954. /**
  59955. * Highlight layer options. This helps customizing the behaviour
  59956. * of the highlight layer.
  59957. */
  59958. export interface IHighlightLayerOptions {
  59959. /**
  59960. * Multiplication factor apply to the canvas size to compute the render target size
  59961. * used to generated the glowing objects (the smaller the faster).
  59962. */
  59963. mainTextureRatio: number;
  59964. /**
  59965. * Enforces a fixed size texture to ensure resize independant blur.
  59966. */
  59967. mainTextureFixedSize?: number;
  59968. /**
  59969. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59970. * of the picture to blur (the smaller the faster).
  59971. */
  59972. blurTextureSizeRatio: number;
  59973. /**
  59974. * How big in texel of the blur texture is the vertical blur.
  59975. */
  59976. blurVerticalSize: number;
  59977. /**
  59978. * How big in texel of the blur texture is the horizontal blur.
  59979. */
  59980. blurHorizontalSize: number;
  59981. /**
  59982. * Alpha blending mode used to apply the blur. Default is combine.
  59983. */
  59984. alphaBlendingMode: number;
  59985. /**
  59986. * The camera attached to the layer.
  59987. */
  59988. camera: Nullable<Camera>;
  59989. /**
  59990. * Should we display highlight as a solid stroke?
  59991. */
  59992. isStroke?: boolean;
  59993. /**
  59994. * The rendering group to draw the layer in.
  59995. */
  59996. renderingGroupId: number;
  59997. }
  59998. /**
  59999. * The highlight layer Helps adding a glow effect around a mesh.
  60000. *
  60001. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60002. * glowy meshes to your scene.
  60003. *
  60004. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60005. */
  60006. export class HighlightLayer extends EffectLayer {
  60007. name: string;
  60008. /**
  60009. * Effect Name of the highlight layer.
  60010. */
  60011. static readonly EffectName: string;
  60012. /**
  60013. * The neutral color used during the preparation of the glow effect.
  60014. * This is black by default as the blend operation is a blend operation.
  60015. */
  60016. static NeutralColor: Color4;
  60017. /**
  60018. * Stencil value used for glowing meshes.
  60019. */
  60020. static GlowingMeshStencilReference: number;
  60021. /**
  60022. * Stencil value used for the other meshes in the scene.
  60023. */
  60024. static NormalMeshStencilReference: number;
  60025. /**
  60026. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60027. */
  60028. innerGlow: boolean;
  60029. /**
  60030. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60031. */
  60032. outerGlow: boolean;
  60033. /**
  60034. * Specifies the horizontal size of the blur.
  60035. */
  60036. set blurHorizontalSize(value: number);
  60037. /**
  60038. * Specifies the vertical size of the blur.
  60039. */
  60040. set blurVerticalSize(value: number);
  60041. /**
  60042. * Gets the horizontal size of the blur.
  60043. */
  60044. get blurHorizontalSize(): number;
  60045. /**
  60046. * Gets the vertical size of the blur.
  60047. */
  60048. get blurVerticalSize(): number;
  60049. /**
  60050. * An event triggered when the highlight layer is being blurred.
  60051. */
  60052. onBeforeBlurObservable: Observable<HighlightLayer>;
  60053. /**
  60054. * An event triggered when the highlight layer has been blurred.
  60055. */
  60056. onAfterBlurObservable: Observable<HighlightLayer>;
  60057. private _instanceGlowingMeshStencilReference;
  60058. private _options;
  60059. private _downSamplePostprocess;
  60060. private _horizontalBlurPostprocess;
  60061. private _verticalBlurPostprocess;
  60062. private _blurTexture;
  60063. private _meshes;
  60064. private _excludedMeshes;
  60065. /**
  60066. * Instantiates a new highlight Layer and references it to the scene..
  60067. * @param name The name of the layer
  60068. * @param scene The scene to use the layer in
  60069. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60070. */
  60071. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60072. /**
  60073. * Get the effect name of the layer.
  60074. * @return The effect name
  60075. */
  60076. getEffectName(): string;
  60077. /**
  60078. * Create the merge effect. This is the shader use to blit the information back
  60079. * to the main canvas at the end of the scene rendering.
  60080. */
  60081. protected _createMergeEffect(): Effect;
  60082. /**
  60083. * Creates the render target textures and post processes used in the highlight layer.
  60084. */
  60085. protected _createTextureAndPostProcesses(): void;
  60086. /**
  60087. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60088. */
  60089. needStencil(): boolean;
  60090. /**
  60091. * Checks for the readiness of the element composing the layer.
  60092. * @param subMesh the mesh to check for
  60093. * @param useInstances specify wether or not to use instances to render the mesh
  60094. * @param emissiveTexture the associated emissive texture used to generate the glow
  60095. * @return true if ready otherwise, false
  60096. */
  60097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60098. /**
  60099. * Implementation specific of rendering the generating effect on the main canvas.
  60100. * @param effect The effect used to render through
  60101. */
  60102. protected _internalRender(effect: Effect): void;
  60103. /**
  60104. * Returns true if the layer contains information to display, otherwise false.
  60105. */
  60106. shouldRender(): boolean;
  60107. /**
  60108. * Returns true if the mesh should render, otherwise false.
  60109. * @param mesh The mesh to render
  60110. * @returns true if it should render otherwise false
  60111. */
  60112. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60113. /**
  60114. * Returns true if the mesh can be rendered, otherwise false.
  60115. * @param mesh The mesh to render
  60116. * @param material The material used on the mesh
  60117. * @returns true if it can be rendered otherwise false
  60118. */
  60119. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60120. /**
  60121. * Adds specific effects defines.
  60122. * @param defines The defines to add specifics to.
  60123. */
  60124. protected _addCustomEffectDefines(defines: string[]): void;
  60125. /**
  60126. * Sets the required values for both the emissive texture and and the main color.
  60127. */
  60128. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60129. /**
  60130. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60131. * @param mesh The mesh to exclude from the highlight layer
  60132. */
  60133. addExcludedMesh(mesh: Mesh): void;
  60134. /**
  60135. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60136. * @param mesh The mesh to highlight
  60137. */
  60138. removeExcludedMesh(mesh: Mesh): void;
  60139. /**
  60140. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60141. * @param mesh mesh to test
  60142. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60143. */
  60144. hasMesh(mesh: AbstractMesh): boolean;
  60145. /**
  60146. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60147. * @param mesh The mesh to highlight
  60148. * @param color The color of the highlight
  60149. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60150. */
  60151. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60152. /**
  60153. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60154. * @param mesh The mesh to highlight
  60155. */
  60156. removeMesh(mesh: Mesh): void;
  60157. /**
  60158. * Remove all the meshes currently referenced in the highlight layer
  60159. */
  60160. removeAllMeshes(): void;
  60161. /**
  60162. * Force the stencil to the normal expected value for none glowing parts
  60163. */
  60164. private _defaultStencilReference;
  60165. /**
  60166. * Free any resources and references associated to a mesh.
  60167. * Internal use
  60168. * @param mesh The mesh to free.
  60169. * @hidden
  60170. */
  60171. _disposeMesh(mesh: Mesh): void;
  60172. /**
  60173. * Dispose the highlight layer and free resources.
  60174. */
  60175. dispose(): void;
  60176. /**
  60177. * Gets the class name of the effect layer
  60178. * @returns the string with the class name of the effect layer
  60179. */
  60180. getClassName(): string;
  60181. /**
  60182. * Serializes this Highlight layer
  60183. * @returns a serialized Highlight layer object
  60184. */
  60185. serialize(): any;
  60186. /**
  60187. * Creates a Highlight layer from parsed Highlight layer data
  60188. * @param parsedHightlightLayer defines the Highlight layer data
  60189. * @param scene defines the current scene
  60190. * @param rootUrl defines the root URL containing the Highlight layer information
  60191. * @returns a parsed Highlight layer
  60192. */
  60193. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60194. }
  60195. }
  60196. declare module BABYLON {
  60197. interface AbstractScene {
  60198. /**
  60199. * The list of layers (background and foreground) of the scene
  60200. */
  60201. layers: Array<Layer>;
  60202. }
  60203. /**
  60204. * Defines the layer scene component responsible to manage any layers
  60205. * in a given scene.
  60206. */
  60207. export class LayerSceneComponent implements ISceneComponent {
  60208. /**
  60209. * The component name helpfull to identify the component in the list of scene components.
  60210. */
  60211. readonly name: string;
  60212. /**
  60213. * The scene the component belongs to.
  60214. */
  60215. scene: Scene;
  60216. private _engine;
  60217. /**
  60218. * Creates a new instance of the component for the given scene
  60219. * @param scene Defines the scene to register the component in
  60220. */
  60221. constructor(scene: Scene);
  60222. /**
  60223. * Registers the component in a given scene
  60224. */
  60225. register(): void;
  60226. /**
  60227. * Rebuilds the elements related to this component in case of
  60228. * context lost for instance.
  60229. */
  60230. rebuild(): void;
  60231. /**
  60232. * Disposes the component and the associated ressources.
  60233. */
  60234. dispose(): void;
  60235. private _draw;
  60236. private _drawCameraPredicate;
  60237. private _drawCameraBackground;
  60238. private _drawCameraForeground;
  60239. private _drawRenderTargetPredicate;
  60240. private _drawRenderTargetBackground;
  60241. private _drawRenderTargetForeground;
  60242. /**
  60243. * Adds all the elements from the container to the scene
  60244. * @param container the container holding the elements
  60245. */
  60246. addFromContainer(container: AbstractScene): void;
  60247. /**
  60248. * Removes all the elements in the container from the scene
  60249. * @param container contains the elements to remove
  60250. * @param dispose if the removed element should be disposed (default: false)
  60251. */
  60252. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60253. }
  60254. }
  60255. declare module BABYLON {
  60256. /** @hidden */
  60257. export var layerPixelShader: {
  60258. name: string;
  60259. shader: string;
  60260. };
  60261. }
  60262. declare module BABYLON {
  60263. /** @hidden */
  60264. export var layerVertexShader: {
  60265. name: string;
  60266. shader: string;
  60267. };
  60268. }
  60269. declare module BABYLON {
  60270. /**
  60271. * This represents a full screen 2d layer.
  60272. * This can be useful to display a picture in the background of your scene for instance.
  60273. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60274. */
  60275. export class Layer {
  60276. /**
  60277. * Define the name of the layer.
  60278. */
  60279. name: string;
  60280. /**
  60281. * Define the texture the layer should display.
  60282. */
  60283. texture: Nullable<Texture>;
  60284. /**
  60285. * Is the layer in background or foreground.
  60286. */
  60287. isBackground: boolean;
  60288. /**
  60289. * Define the color of the layer (instead of texture).
  60290. */
  60291. color: Color4;
  60292. /**
  60293. * Define the scale of the layer in order to zoom in out of the texture.
  60294. */
  60295. scale: Vector2;
  60296. /**
  60297. * Define an offset for the layer in order to shift the texture.
  60298. */
  60299. offset: Vector2;
  60300. /**
  60301. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60302. */
  60303. alphaBlendingMode: number;
  60304. /**
  60305. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60306. * Alpha test will not mix with the background color in case of transparency.
  60307. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60308. */
  60309. alphaTest: boolean;
  60310. /**
  60311. * Define a mask to restrict the layer to only some of the scene cameras.
  60312. */
  60313. layerMask: number;
  60314. /**
  60315. * Define the list of render target the layer is visible into.
  60316. */
  60317. renderTargetTextures: RenderTargetTexture[];
  60318. /**
  60319. * Define if the layer is only used in renderTarget or if it also
  60320. * renders in the main frame buffer of the canvas.
  60321. */
  60322. renderOnlyInRenderTargetTextures: boolean;
  60323. private _scene;
  60324. private _vertexBuffers;
  60325. private _indexBuffer;
  60326. private _effect;
  60327. private _previousDefines;
  60328. /**
  60329. * An event triggered when the layer is disposed.
  60330. */
  60331. onDisposeObservable: Observable<Layer>;
  60332. private _onDisposeObserver;
  60333. /**
  60334. * Back compatibility with callback before the onDisposeObservable existed.
  60335. * The set callback will be triggered when the layer has been disposed.
  60336. */
  60337. set onDispose(callback: () => void);
  60338. /**
  60339. * An event triggered before rendering the scene
  60340. */
  60341. onBeforeRenderObservable: Observable<Layer>;
  60342. private _onBeforeRenderObserver;
  60343. /**
  60344. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60345. * The set callback will be triggered just before rendering the layer.
  60346. */
  60347. set onBeforeRender(callback: () => void);
  60348. /**
  60349. * An event triggered after rendering the scene
  60350. */
  60351. onAfterRenderObservable: Observable<Layer>;
  60352. private _onAfterRenderObserver;
  60353. /**
  60354. * Back compatibility with callback before the onAfterRenderObservable existed.
  60355. * The set callback will be triggered just after rendering the layer.
  60356. */
  60357. set onAfterRender(callback: () => void);
  60358. /**
  60359. * Instantiates a new layer.
  60360. * This represents a full screen 2d layer.
  60361. * This can be useful to display a picture in the background of your scene for instance.
  60362. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60363. * @param name Define the name of the layer in the scene
  60364. * @param imgUrl Define the url of the texture to display in the layer
  60365. * @param scene Define the scene the layer belongs to
  60366. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60367. * @param color Defines a color for the layer
  60368. */
  60369. constructor(
  60370. /**
  60371. * Define the name of the layer.
  60372. */
  60373. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60374. private _createIndexBuffer;
  60375. /** @hidden */
  60376. _rebuild(): void;
  60377. /**
  60378. * Renders the layer in the scene.
  60379. */
  60380. render(): void;
  60381. /**
  60382. * Disposes and releases the associated ressources.
  60383. */
  60384. dispose(): void;
  60385. }
  60386. }
  60387. declare module BABYLON {
  60388. /** @hidden */
  60389. export var lensFlarePixelShader: {
  60390. name: string;
  60391. shader: string;
  60392. };
  60393. }
  60394. declare module BABYLON {
  60395. /** @hidden */
  60396. export var lensFlareVertexShader: {
  60397. name: string;
  60398. shader: string;
  60399. };
  60400. }
  60401. declare module BABYLON {
  60402. /**
  60403. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60404. * It is usually composed of several `lensFlare`.
  60405. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60406. */
  60407. export class LensFlareSystem {
  60408. /**
  60409. * Define the name of the lens flare system
  60410. */
  60411. name: string;
  60412. /**
  60413. * List of lens flares used in this system.
  60414. */
  60415. lensFlares: LensFlare[];
  60416. /**
  60417. * Define a limit from the border the lens flare can be visible.
  60418. */
  60419. borderLimit: number;
  60420. /**
  60421. * Define a viewport border we do not want to see the lens flare in.
  60422. */
  60423. viewportBorder: number;
  60424. /**
  60425. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60426. */
  60427. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60428. /**
  60429. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60430. */
  60431. layerMask: number;
  60432. /**
  60433. * Define the id of the lens flare system in the scene.
  60434. * (equal to name by default)
  60435. */
  60436. id: string;
  60437. private _scene;
  60438. private _emitter;
  60439. private _vertexBuffers;
  60440. private _indexBuffer;
  60441. private _effect;
  60442. private _positionX;
  60443. private _positionY;
  60444. private _isEnabled;
  60445. /** @hidden */
  60446. static _SceneComponentInitialization: (scene: Scene) => void;
  60447. /**
  60448. * Instantiates a lens flare system.
  60449. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60450. * It is usually composed of several `lensFlare`.
  60451. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60452. * @param name Define the name of the lens flare system in the scene
  60453. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60454. * @param scene Define the scene the lens flare system belongs to
  60455. */
  60456. constructor(
  60457. /**
  60458. * Define the name of the lens flare system
  60459. */
  60460. name: string, emitter: any, scene: Scene);
  60461. /**
  60462. * Define if the lens flare system is enabled.
  60463. */
  60464. get isEnabled(): boolean;
  60465. set isEnabled(value: boolean);
  60466. /**
  60467. * Get the scene the effects belongs to.
  60468. * @returns the scene holding the lens flare system
  60469. */
  60470. getScene(): Scene;
  60471. /**
  60472. * Get the emitter of the lens flare system.
  60473. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60474. * @returns the emitter of the lens flare system
  60475. */
  60476. getEmitter(): any;
  60477. /**
  60478. * Set the emitter of the lens flare system.
  60479. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60480. * @param newEmitter Define the new emitter of the system
  60481. */
  60482. setEmitter(newEmitter: any): void;
  60483. /**
  60484. * Get the lens flare system emitter position.
  60485. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60486. * @returns the position
  60487. */
  60488. getEmitterPosition(): Vector3;
  60489. /**
  60490. * @hidden
  60491. */
  60492. computeEffectivePosition(globalViewport: Viewport): boolean;
  60493. /** @hidden */
  60494. _isVisible(): boolean;
  60495. /**
  60496. * @hidden
  60497. */
  60498. render(): boolean;
  60499. /**
  60500. * Dispose and release the lens flare with its associated resources.
  60501. */
  60502. dispose(): void;
  60503. /**
  60504. * Parse a lens flare system from a JSON repressentation
  60505. * @param parsedLensFlareSystem Define the JSON to parse
  60506. * @param scene Define the scene the parsed system should be instantiated in
  60507. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60508. * @returns the parsed system
  60509. */
  60510. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60511. /**
  60512. * Serialize the current Lens Flare System into a JSON representation.
  60513. * @returns the serialized JSON
  60514. */
  60515. serialize(): any;
  60516. }
  60517. }
  60518. declare module BABYLON {
  60519. /**
  60520. * This represents one of the lens effect in a `lensFlareSystem`.
  60521. * It controls one of the indiviual texture used in the effect.
  60522. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60523. */
  60524. export class LensFlare {
  60525. /**
  60526. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60527. */
  60528. size: number;
  60529. /**
  60530. * 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.
  60531. */
  60532. position: number;
  60533. /**
  60534. * Define the lens color.
  60535. */
  60536. color: Color3;
  60537. /**
  60538. * Define the lens texture.
  60539. */
  60540. texture: Nullable<Texture>;
  60541. /**
  60542. * Define the alpha mode to render this particular lens.
  60543. */
  60544. alphaMode: number;
  60545. private _system;
  60546. /**
  60547. * Creates a new Lens Flare.
  60548. * This represents one of the lens effect in a `lensFlareSystem`.
  60549. * It controls one of the indiviual texture used in the effect.
  60550. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60551. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60552. * @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.
  60553. * @param color Define the lens color
  60554. * @param imgUrl Define the lens texture url
  60555. * @param system Define the `lensFlareSystem` this flare is part of
  60556. * @returns The newly created Lens Flare
  60557. */
  60558. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60559. /**
  60560. * Instantiates a new Lens Flare.
  60561. * This represents one of the lens effect in a `lensFlareSystem`.
  60562. * It controls one of the indiviual texture used in the effect.
  60563. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60564. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60565. * @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.
  60566. * @param color Define the lens color
  60567. * @param imgUrl Define the lens texture url
  60568. * @param system Define the `lensFlareSystem` this flare is part of
  60569. */
  60570. constructor(
  60571. /**
  60572. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60573. */
  60574. size: number,
  60575. /**
  60576. * 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.
  60577. */
  60578. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60579. /**
  60580. * Dispose and release the lens flare with its associated resources.
  60581. */
  60582. dispose(): void;
  60583. }
  60584. }
  60585. declare module BABYLON {
  60586. interface AbstractScene {
  60587. /**
  60588. * The list of lens flare system added to the scene
  60589. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60590. */
  60591. lensFlareSystems: Array<LensFlareSystem>;
  60592. /**
  60593. * Removes the given lens flare system from this scene.
  60594. * @param toRemove The lens flare system to remove
  60595. * @returns The index of the removed lens flare system
  60596. */
  60597. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60598. /**
  60599. * Adds the given lens flare system to this scene
  60600. * @param newLensFlareSystem The lens flare system to add
  60601. */
  60602. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60603. /**
  60604. * Gets a lens flare system using its name
  60605. * @param name defines the name to look for
  60606. * @returns the lens flare system or null if not found
  60607. */
  60608. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60609. /**
  60610. * Gets a lens flare system using its id
  60611. * @param id defines the id to look for
  60612. * @returns the lens flare system or null if not found
  60613. */
  60614. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60615. }
  60616. /**
  60617. * Defines the lens flare scene component responsible to manage any lens flares
  60618. * in a given scene.
  60619. */
  60620. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60621. /**
  60622. * The component name helpfull to identify the component in the list of scene components.
  60623. */
  60624. readonly name: string;
  60625. /**
  60626. * The scene the component belongs to.
  60627. */
  60628. scene: Scene;
  60629. /**
  60630. * Creates a new instance of the component for the given scene
  60631. * @param scene Defines the scene to register the component in
  60632. */
  60633. constructor(scene: Scene);
  60634. /**
  60635. * Registers the component in a given scene
  60636. */
  60637. register(): void;
  60638. /**
  60639. * Rebuilds the elements related to this component in case of
  60640. * context lost for instance.
  60641. */
  60642. rebuild(): void;
  60643. /**
  60644. * Adds all the elements from the container to the scene
  60645. * @param container the container holding the elements
  60646. */
  60647. addFromContainer(container: AbstractScene): void;
  60648. /**
  60649. * Removes all the elements in the container from the scene
  60650. * @param container contains the elements to remove
  60651. * @param dispose if the removed element should be disposed (default: false)
  60652. */
  60653. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60654. /**
  60655. * Serializes the component data to the specified json object
  60656. * @param serializationObject The object to serialize to
  60657. */
  60658. serialize(serializationObject: any): void;
  60659. /**
  60660. * Disposes the component and the associated ressources.
  60661. */
  60662. dispose(): void;
  60663. private _draw;
  60664. }
  60665. }
  60666. declare module BABYLON {
  60667. /** @hidden */
  60668. export var depthPixelShader: {
  60669. name: string;
  60670. shader: string;
  60671. };
  60672. }
  60673. declare module BABYLON {
  60674. /** @hidden */
  60675. export var depthVertexShader: {
  60676. name: string;
  60677. shader: string;
  60678. };
  60679. }
  60680. declare module BABYLON {
  60681. /**
  60682. * This represents a depth renderer in Babylon.
  60683. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60684. */
  60685. export class DepthRenderer {
  60686. private _scene;
  60687. private _depthMap;
  60688. private _effect;
  60689. private readonly _storeNonLinearDepth;
  60690. private readonly _clearColor;
  60691. /** Get if the depth renderer is using packed depth or not */
  60692. readonly isPacked: boolean;
  60693. private _cachedDefines;
  60694. private _camera;
  60695. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60696. enabled: boolean;
  60697. /**
  60698. * Specifiess that the depth renderer will only be used within
  60699. * the camera it is created for.
  60700. * This can help forcing its rendering during the camera processing.
  60701. */
  60702. useOnlyInActiveCamera: boolean;
  60703. /** @hidden */
  60704. static _SceneComponentInitialization: (scene: Scene) => void;
  60705. /**
  60706. * Instantiates a depth renderer
  60707. * @param scene The scene the renderer belongs to
  60708. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60709. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60710. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60711. */
  60712. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60713. /**
  60714. * Creates the depth rendering effect and checks if the effect is ready.
  60715. * @param subMesh The submesh to be used to render the depth map of
  60716. * @param useInstances If multiple world instances should be used
  60717. * @returns if the depth renderer is ready to render the depth map
  60718. */
  60719. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60720. /**
  60721. * Gets the texture which the depth map will be written to.
  60722. * @returns The depth map texture
  60723. */
  60724. getDepthMap(): RenderTargetTexture;
  60725. /**
  60726. * Disposes of the depth renderer.
  60727. */
  60728. dispose(): void;
  60729. }
  60730. }
  60731. declare module BABYLON {
  60732. /** @hidden */
  60733. export var minmaxReduxPixelShader: {
  60734. name: string;
  60735. shader: string;
  60736. };
  60737. }
  60738. declare module BABYLON {
  60739. /**
  60740. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60741. * and maximum values from all values of the texture.
  60742. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60743. * The source values are read from the red channel of the texture.
  60744. */
  60745. export class MinMaxReducer {
  60746. /**
  60747. * Observable triggered when the computation has been performed
  60748. */
  60749. onAfterReductionPerformed: Observable<{
  60750. min: number;
  60751. max: number;
  60752. }>;
  60753. protected _camera: Camera;
  60754. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60755. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60756. protected _postProcessManager: PostProcessManager;
  60757. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60758. protected _forceFullscreenViewport: boolean;
  60759. /**
  60760. * Creates a min/max reducer
  60761. * @param camera The camera to use for the post processes
  60762. */
  60763. constructor(camera: Camera);
  60764. /**
  60765. * Gets the texture used to read the values from.
  60766. */
  60767. get sourceTexture(): Nullable<RenderTargetTexture>;
  60768. /**
  60769. * Sets the source texture to read the values from.
  60770. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60771. * because in such textures '1' value must not be taken into account to compute the maximum
  60772. * as this value is used to clear the texture.
  60773. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60774. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60775. * @param depthRedux Indicates if the texture is a depth texture or not
  60776. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60777. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60778. */
  60779. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60780. /**
  60781. * Defines the refresh rate of the computation.
  60782. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60783. */
  60784. get refreshRate(): number;
  60785. set refreshRate(value: number);
  60786. protected _activated: boolean;
  60787. /**
  60788. * Gets the activation status of the reducer
  60789. */
  60790. get activated(): boolean;
  60791. /**
  60792. * Activates the reduction computation.
  60793. * When activated, the observers registered in onAfterReductionPerformed are
  60794. * called after the compuation is performed
  60795. */
  60796. activate(): void;
  60797. /**
  60798. * Deactivates the reduction computation.
  60799. */
  60800. deactivate(): void;
  60801. /**
  60802. * Disposes the min/max reducer
  60803. * @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.
  60804. */
  60805. dispose(disposeAll?: boolean): void;
  60806. }
  60807. }
  60808. declare module BABYLON {
  60809. /**
  60810. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60811. */
  60812. export class DepthReducer extends MinMaxReducer {
  60813. private _depthRenderer;
  60814. private _depthRendererId;
  60815. /**
  60816. * Gets the depth renderer used for the computation.
  60817. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60818. */
  60819. get depthRenderer(): Nullable<DepthRenderer>;
  60820. /**
  60821. * Creates a depth reducer
  60822. * @param camera The camera used to render the depth texture
  60823. */
  60824. constructor(camera: Camera);
  60825. /**
  60826. * Sets the depth renderer to use to generate the depth map
  60827. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60828. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60829. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60830. */
  60831. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60832. /** @hidden */
  60833. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60834. /**
  60835. * Activates the reduction computation.
  60836. * When activated, the observers registered in onAfterReductionPerformed are
  60837. * called after the compuation is performed
  60838. */
  60839. activate(): void;
  60840. /**
  60841. * Deactivates the reduction computation.
  60842. */
  60843. deactivate(): void;
  60844. /**
  60845. * Disposes the depth reducer
  60846. * @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.
  60847. */
  60848. dispose(disposeAll?: boolean): void;
  60849. }
  60850. }
  60851. declare module BABYLON {
  60852. /**
  60853. * A CSM implementation allowing casting shadows on large scenes.
  60854. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60855. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60856. */
  60857. export class CascadedShadowGenerator extends ShadowGenerator {
  60858. private static readonly frustumCornersNDCSpace;
  60859. /**
  60860. * Name of the CSM class
  60861. */
  60862. static CLASSNAME: string;
  60863. /**
  60864. * Defines the default number of cascades used by the CSM.
  60865. */
  60866. static readonly DEFAULT_CASCADES_COUNT: number;
  60867. /**
  60868. * Defines the minimum number of cascades used by the CSM.
  60869. */
  60870. static readonly MIN_CASCADES_COUNT: number;
  60871. /**
  60872. * Defines the maximum number of cascades used by the CSM.
  60873. */
  60874. static readonly MAX_CASCADES_COUNT: number;
  60875. protected _validateFilter(filter: number): number;
  60876. /**
  60877. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60878. */
  60879. penumbraDarkness: number;
  60880. private _numCascades;
  60881. /**
  60882. * Gets or set the number of cascades used by the CSM.
  60883. */
  60884. get numCascades(): number;
  60885. set numCascades(value: number);
  60886. /**
  60887. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60888. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60889. */
  60890. stabilizeCascades: boolean;
  60891. private _freezeShadowCastersBoundingInfo;
  60892. private _freezeShadowCastersBoundingInfoObservable;
  60893. /**
  60894. * Enables or disables the shadow casters bounding info computation.
  60895. * If your shadow casters don't move, you can disable this feature.
  60896. * If it is enabled, the bounding box computation is done every frame.
  60897. */
  60898. get freezeShadowCastersBoundingInfo(): boolean;
  60899. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60900. private _scbiMin;
  60901. private _scbiMax;
  60902. protected _computeShadowCastersBoundingInfo(): void;
  60903. protected _shadowCastersBoundingInfo: BoundingInfo;
  60904. /**
  60905. * Gets or sets the shadow casters bounding info.
  60906. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60907. * so that the system won't overwrite the bounds you provide
  60908. */
  60909. get shadowCastersBoundingInfo(): BoundingInfo;
  60910. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60911. protected _breaksAreDirty: boolean;
  60912. protected _minDistance: number;
  60913. protected _maxDistance: number;
  60914. /**
  60915. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60916. *
  60917. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60918. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60919. * @param min minimal distance for the breaks (default to 0.)
  60920. * @param max maximal distance for the breaks (default to 1.)
  60921. */
  60922. setMinMaxDistance(min: number, max: number): void;
  60923. /** Gets the minimal distance used in the cascade break computation */
  60924. get minDistance(): number;
  60925. /** Gets the maximal distance used in the cascade break computation */
  60926. get maxDistance(): number;
  60927. /**
  60928. * Gets the class name of that object
  60929. * @returns "CascadedShadowGenerator"
  60930. */
  60931. getClassName(): string;
  60932. private _cascadeMinExtents;
  60933. private _cascadeMaxExtents;
  60934. /**
  60935. * Gets a cascade minimum extents
  60936. * @param cascadeIndex index of the cascade
  60937. * @returns the minimum cascade extents
  60938. */
  60939. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60940. /**
  60941. * Gets a cascade maximum extents
  60942. * @param cascadeIndex index of the cascade
  60943. * @returns the maximum cascade extents
  60944. */
  60945. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60946. private _cascades;
  60947. private _currentLayer;
  60948. private _viewSpaceFrustumsZ;
  60949. private _viewMatrices;
  60950. private _projectionMatrices;
  60951. private _transformMatrices;
  60952. private _transformMatricesAsArray;
  60953. private _frustumLengths;
  60954. private _lightSizeUVCorrection;
  60955. private _depthCorrection;
  60956. private _frustumCornersWorldSpace;
  60957. private _frustumCenter;
  60958. private _shadowCameraPos;
  60959. private _shadowMaxZ;
  60960. /**
  60961. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60962. * It defaults to camera.maxZ
  60963. */
  60964. get shadowMaxZ(): number;
  60965. /**
  60966. * Sets the shadow max z distance.
  60967. */
  60968. set shadowMaxZ(value: number);
  60969. protected _debug: boolean;
  60970. /**
  60971. * Gets or sets the debug flag.
  60972. * When enabled, the cascades are materialized by different colors on the screen.
  60973. */
  60974. get debug(): boolean;
  60975. set debug(dbg: boolean);
  60976. private _depthClamp;
  60977. /**
  60978. * Gets or sets the depth clamping value.
  60979. *
  60980. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60981. * to account for the shadow casters far away.
  60982. *
  60983. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60984. */
  60985. get depthClamp(): boolean;
  60986. set depthClamp(value: boolean);
  60987. private _cascadeBlendPercentage;
  60988. /**
  60989. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60990. * It defaults to 0.1 (10% blending).
  60991. */
  60992. get cascadeBlendPercentage(): number;
  60993. set cascadeBlendPercentage(value: number);
  60994. private _lambda;
  60995. /**
  60996. * Gets or set the lambda parameter.
  60997. * This parameter is used to split the camera frustum and create the cascades.
  60998. * 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.
  60999. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61000. */
  61001. get lambda(): number;
  61002. set lambda(value: number);
  61003. /**
  61004. * Gets the view matrix corresponding to a given cascade
  61005. * @param cascadeNum cascade to retrieve the view matrix from
  61006. * @returns the cascade view matrix
  61007. */
  61008. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61009. /**
  61010. * Gets the projection matrix corresponding to a given cascade
  61011. * @param cascadeNum cascade to retrieve the projection matrix from
  61012. * @returns the cascade projection matrix
  61013. */
  61014. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61015. /**
  61016. * Gets the transformation matrix corresponding to a given cascade
  61017. * @param cascadeNum cascade to retrieve the transformation matrix from
  61018. * @returns the cascade transformation matrix
  61019. */
  61020. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61021. private _depthRenderer;
  61022. /**
  61023. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61024. *
  61025. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61026. *
  61027. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61028. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61029. * @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
  61030. */
  61031. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61032. private _depthReducer;
  61033. private _autoCalcDepthBounds;
  61034. /**
  61035. * Gets or sets the autoCalcDepthBounds property.
  61036. *
  61037. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61038. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61039. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61040. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61041. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61042. */
  61043. get autoCalcDepthBounds(): boolean;
  61044. set autoCalcDepthBounds(value: boolean);
  61045. /**
  61046. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61047. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61048. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61049. * for setting the refresh rate on the renderer yourself!
  61050. */
  61051. get autoCalcDepthBoundsRefreshRate(): number;
  61052. set autoCalcDepthBoundsRefreshRate(value: number);
  61053. /**
  61054. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61055. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61056. * you change the camera near/far planes!
  61057. */
  61058. splitFrustum(): void;
  61059. private _splitFrustum;
  61060. private _computeMatrices;
  61061. private _computeFrustumInWorldSpace;
  61062. private _computeCascadeFrustum;
  61063. /**
  61064. * Support test.
  61065. */
  61066. static get IsSupported(): boolean;
  61067. /** @hidden */
  61068. static _SceneComponentInitialization: (scene: Scene) => void;
  61069. /**
  61070. * Creates a Cascaded Shadow Generator object.
  61071. * A ShadowGenerator is the required tool to use the shadows.
  61072. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61073. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61074. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61075. * @param light The directional light object generating the shadows.
  61076. * @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.
  61077. */
  61078. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61079. protected _initializeGenerator(): void;
  61080. protected _createTargetRenderTexture(): void;
  61081. protected _initializeShadowMap(): void;
  61082. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61083. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61084. /**
  61085. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61086. * @param defines Defines of the material we want to update
  61087. * @param lightIndex Index of the light in the enabled light list of the material
  61088. */
  61089. prepareDefines(defines: any, lightIndex: number): void;
  61090. /**
  61091. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61092. * defined in the generator but impacting the effect).
  61093. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61094. * @param effect The effect we are binfing the information for
  61095. */
  61096. bindShadowLight(lightIndex: string, effect: Effect): void;
  61097. /**
  61098. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61099. * (eq to view projection * shadow projection matrices)
  61100. * @returns The transform matrix used to create the shadow map
  61101. */
  61102. getTransformMatrix(): Matrix;
  61103. /**
  61104. * Disposes the ShadowGenerator.
  61105. * Returns nothing.
  61106. */
  61107. dispose(): void;
  61108. /**
  61109. * Serializes the shadow generator setup to a json object.
  61110. * @returns The serialized JSON object
  61111. */
  61112. serialize(): any;
  61113. /**
  61114. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61115. * @param parsedShadowGenerator The JSON object to parse
  61116. * @param scene The scene to create the shadow map for
  61117. * @returns The parsed shadow generator
  61118. */
  61119. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61120. }
  61121. }
  61122. declare module BABYLON {
  61123. /**
  61124. * Defines the shadow generator component responsible to manage any shadow generators
  61125. * in a given scene.
  61126. */
  61127. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61128. /**
  61129. * The component name helpfull to identify the component in the list of scene components.
  61130. */
  61131. readonly name: string;
  61132. /**
  61133. * The scene the component belongs to.
  61134. */
  61135. scene: Scene;
  61136. /**
  61137. * Creates a new instance of the component for the given scene
  61138. * @param scene Defines the scene to register the component in
  61139. */
  61140. constructor(scene: Scene);
  61141. /**
  61142. * Registers the component in a given scene
  61143. */
  61144. register(): void;
  61145. /**
  61146. * Rebuilds the elements related to this component in case of
  61147. * context lost for instance.
  61148. */
  61149. rebuild(): void;
  61150. /**
  61151. * Serializes the component data to the specified json object
  61152. * @param serializationObject The object to serialize to
  61153. */
  61154. serialize(serializationObject: any): void;
  61155. /**
  61156. * Adds all the elements from the container to the scene
  61157. * @param container the container holding the elements
  61158. */
  61159. addFromContainer(container: AbstractScene): void;
  61160. /**
  61161. * Removes all the elements in the container from the scene
  61162. * @param container contains the elements to remove
  61163. * @param dispose if the removed element should be disposed (default: false)
  61164. */
  61165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61166. /**
  61167. * Rebuilds the elements related to this component in case of
  61168. * context lost for instance.
  61169. */
  61170. dispose(): void;
  61171. private _gatherRenderTargets;
  61172. }
  61173. }
  61174. declare module BABYLON {
  61175. /**
  61176. * A point light is a light defined by an unique point in world space.
  61177. * The light is emitted in every direction from this point.
  61178. * A good example of a point light is a standard light bulb.
  61179. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61180. */
  61181. export class PointLight extends ShadowLight {
  61182. private _shadowAngle;
  61183. /**
  61184. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61185. * This specifies what angle the shadow will use to be created.
  61186. *
  61187. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61188. */
  61189. get shadowAngle(): number;
  61190. /**
  61191. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61192. * This specifies what angle the shadow will use to be created.
  61193. *
  61194. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61195. */
  61196. set shadowAngle(value: number);
  61197. /**
  61198. * Gets the direction if it has been set.
  61199. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61200. */
  61201. get direction(): Vector3;
  61202. /**
  61203. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61204. */
  61205. set direction(value: Vector3);
  61206. /**
  61207. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61208. * A PointLight emits the light in every direction.
  61209. * It can cast shadows.
  61210. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61211. * ```javascript
  61212. * var pointLight = new PointLight("pl", camera.position, scene);
  61213. * ```
  61214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61215. * @param name The light friendly name
  61216. * @param position The position of the point light in the scene
  61217. * @param scene The scene the lights belongs to
  61218. */
  61219. constructor(name: string, position: Vector3, scene: Scene);
  61220. /**
  61221. * Returns the string "PointLight"
  61222. * @returns the class name
  61223. */
  61224. getClassName(): string;
  61225. /**
  61226. * Returns the integer 0.
  61227. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61228. */
  61229. getTypeID(): number;
  61230. /**
  61231. * Specifies wether or not the shadowmap should be a cube texture.
  61232. * @returns true if the shadowmap needs to be a cube texture.
  61233. */
  61234. needCube(): boolean;
  61235. /**
  61236. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61237. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61238. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61239. */
  61240. getShadowDirection(faceIndex?: number): Vector3;
  61241. /**
  61242. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61243. * - fov = PI / 2
  61244. * - aspect ratio : 1.0
  61245. * - z-near and far equal to the active camera minZ and maxZ.
  61246. * Returns the PointLight.
  61247. */
  61248. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61249. protected _buildUniformLayout(): void;
  61250. /**
  61251. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61252. * @param effect The effect to update
  61253. * @param lightIndex The index of the light in the effect to update
  61254. * @returns The point light
  61255. */
  61256. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61257. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61258. /**
  61259. * Prepares the list of defines specific to the light type.
  61260. * @param defines the list of defines
  61261. * @param lightIndex defines the index of the light for the effect
  61262. */
  61263. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61264. }
  61265. }
  61266. declare module BABYLON {
  61267. /**
  61268. * Header information of HDR texture files.
  61269. */
  61270. export interface HDRInfo {
  61271. /**
  61272. * The height of the texture in pixels.
  61273. */
  61274. height: number;
  61275. /**
  61276. * The width of the texture in pixels.
  61277. */
  61278. width: number;
  61279. /**
  61280. * The index of the beginning of the data in the binary file.
  61281. */
  61282. dataPosition: number;
  61283. }
  61284. /**
  61285. * This groups tools to convert HDR texture to native colors array.
  61286. */
  61287. export class HDRTools {
  61288. private static Ldexp;
  61289. private static Rgbe2float;
  61290. private static readStringLine;
  61291. /**
  61292. * Reads header information from an RGBE texture stored in a native array.
  61293. * More information on this format are available here:
  61294. * https://en.wikipedia.org/wiki/RGBE_image_format
  61295. *
  61296. * @param uint8array The binary file stored in native array.
  61297. * @return The header information.
  61298. */
  61299. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61300. /**
  61301. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61302. * This RGBE texture needs to store the information as a panorama.
  61303. *
  61304. * More information on this format are available here:
  61305. * https://en.wikipedia.org/wiki/RGBE_image_format
  61306. *
  61307. * @param buffer The binary file stored in an array buffer.
  61308. * @param size The expected size of the extracted cubemap.
  61309. * @return The Cube Map information.
  61310. */
  61311. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61312. /**
  61313. * Returns the pixels data extracted from an RGBE texture.
  61314. * This pixels will be stored left to right up to down in the R G B order in one array.
  61315. *
  61316. * More information on this format are available here:
  61317. * https://en.wikipedia.org/wiki/RGBE_image_format
  61318. *
  61319. * @param uint8array The binary file stored in an array buffer.
  61320. * @param hdrInfo The header information of the file.
  61321. * @return The pixels data in RGB right to left up to down order.
  61322. */
  61323. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61324. private static RGBE_ReadPixels_RLE;
  61325. private static RGBE_ReadPixels_NOT_RLE;
  61326. }
  61327. }
  61328. declare module BABYLON {
  61329. /**
  61330. * Effect Render Options
  61331. */
  61332. export interface IEffectRendererOptions {
  61333. /**
  61334. * Defines the vertices positions.
  61335. */
  61336. positions?: number[];
  61337. /**
  61338. * Defines the indices.
  61339. */
  61340. indices?: number[];
  61341. }
  61342. /**
  61343. * Helper class to render one or more effects.
  61344. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61345. */
  61346. export class EffectRenderer {
  61347. private engine;
  61348. private static _DefaultOptions;
  61349. private _vertexBuffers;
  61350. private _indexBuffer;
  61351. private _fullscreenViewport;
  61352. /**
  61353. * Creates an effect renderer
  61354. * @param engine the engine to use for rendering
  61355. * @param options defines the options of the effect renderer
  61356. */
  61357. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61358. /**
  61359. * Sets the current viewport in normalized coordinates 0-1
  61360. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61361. */
  61362. setViewport(viewport?: Viewport): void;
  61363. /**
  61364. * Binds the embedded attributes buffer to the effect.
  61365. * @param effect Defines the effect to bind the attributes for
  61366. */
  61367. bindBuffers(effect: Effect): void;
  61368. /**
  61369. * Sets the current effect wrapper to use during draw.
  61370. * The effect needs to be ready before calling this api.
  61371. * This also sets the default full screen position attribute.
  61372. * @param effectWrapper Defines the effect to draw with
  61373. */
  61374. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61375. /**
  61376. * Restores engine states
  61377. */
  61378. restoreStates(): void;
  61379. /**
  61380. * Draws a full screen quad.
  61381. */
  61382. draw(): void;
  61383. private isRenderTargetTexture;
  61384. /**
  61385. * renders one or more effects to a specified texture
  61386. * @param effectWrapper the effect to renderer
  61387. * @param outputTexture texture to draw to, if null it will render to the screen.
  61388. */
  61389. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61390. /**
  61391. * Disposes of the effect renderer
  61392. */
  61393. dispose(): void;
  61394. }
  61395. /**
  61396. * Options to create an EffectWrapper
  61397. */
  61398. interface EffectWrapperCreationOptions {
  61399. /**
  61400. * Engine to use to create the effect
  61401. */
  61402. engine: ThinEngine;
  61403. /**
  61404. * Fragment shader for the effect
  61405. */
  61406. fragmentShader: string;
  61407. /**
  61408. * Use the shader store instead of direct source code
  61409. */
  61410. useShaderStore?: boolean;
  61411. /**
  61412. * Vertex shader for the effect
  61413. */
  61414. vertexShader?: string;
  61415. /**
  61416. * Attributes to use in the shader
  61417. */
  61418. attributeNames?: Array<string>;
  61419. /**
  61420. * Uniforms to use in the shader
  61421. */
  61422. uniformNames?: Array<string>;
  61423. /**
  61424. * Texture sampler names to use in the shader
  61425. */
  61426. samplerNames?: Array<string>;
  61427. /**
  61428. * Defines to use in the shader
  61429. */
  61430. defines?: Array<string>;
  61431. /**
  61432. * Callback when effect is compiled
  61433. */
  61434. onCompiled?: Nullable<(effect: Effect) => void>;
  61435. /**
  61436. * The friendly name of the effect displayed in Spector.
  61437. */
  61438. name?: string;
  61439. }
  61440. /**
  61441. * Wraps an effect to be used for rendering
  61442. */
  61443. export class EffectWrapper {
  61444. /**
  61445. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61446. */
  61447. onApplyObservable: Observable<{}>;
  61448. /**
  61449. * The underlying effect
  61450. */
  61451. effect: Effect;
  61452. /**
  61453. * Creates an effect to be renderer
  61454. * @param creationOptions options to create the effect
  61455. */
  61456. constructor(creationOptions: EffectWrapperCreationOptions);
  61457. /**
  61458. * Disposes of the effect wrapper
  61459. */
  61460. dispose(): void;
  61461. }
  61462. }
  61463. declare module BABYLON {
  61464. /** @hidden */
  61465. export var hdrFilteringVertexShader: {
  61466. name: string;
  61467. shader: string;
  61468. };
  61469. }
  61470. declare module BABYLON {
  61471. /** @hidden */
  61472. export var hdrFilteringPixelShader: {
  61473. name: string;
  61474. shader: string;
  61475. };
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * Options for texture filtering
  61480. */
  61481. interface IHDRFilteringOptions {
  61482. /**
  61483. * Scales pixel intensity for the input HDR map.
  61484. */
  61485. hdrScale?: number;
  61486. /**
  61487. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61488. */
  61489. quality?: number;
  61490. }
  61491. /**
  61492. * Filters HDR maps to get correct renderings of PBR reflections
  61493. */
  61494. export class HDRFiltering {
  61495. private _engine;
  61496. private _effectRenderer;
  61497. private _effectWrapper;
  61498. private _lodGenerationOffset;
  61499. private _lodGenerationScale;
  61500. /**
  61501. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61502. * you care about baking speed.
  61503. */
  61504. quality: number;
  61505. /**
  61506. * Scales pixel intensity for the input HDR map.
  61507. */
  61508. hdrScale: number;
  61509. /**
  61510. * Instantiates HDR filter for reflection maps
  61511. *
  61512. * @param engine Thin engine
  61513. * @param options Options
  61514. */
  61515. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61516. private _createRenderTarget;
  61517. private _prefilterInternal;
  61518. private _createEffect;
  61519. /**
  61520. * Get a value indicating if the filter is ready to be used
  61521. * @param texture Texture to filter
  61522. * @returns true if the filter is ready
  61523. */
  61524. isReady(texture: BaseTexture): boolean;
  61525. /**
  61526. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61527. * Prefiltering will be invoked at the end of next rendering pass.
  61528. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61529. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61530. * @param texture Texture to filter
  61531. * @param onFinished Callback when filtering is done
  61532. * @return Promise called when prefiltering is done
  61533. */
  61534. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61535. }
  61536. }
  61537. declare module BABYLON {
  61538. /**
  61539. * This represents a texture coming from an HDR input.
  61540. *
  61541. * The only supported format is currently panorama picture stored in RGBE format.
  61542. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61543. */
  61544. export class HDRCubeTexture extends BaseTexture {
  61545. private static _facesMapping;
  61546. private _generateHarmonics;
  61547. private _noMipmap;
  61548. private _prefilterOnLoad;
  61549. private _textureMatrix;
  61550. private _size;
  61551. private _onLoad;
  61552. private _onError;
  61553. /**
  61554. * The texture URL.
  61555. */
  61556. url: string;
  61557. protected _isBlocking: boolean;
  61558. /**
  61559. * Sets wether or not the texture is blocking during loading.
  61560. */
  61561. set isBlocking(value: boolean);
  61562. /**
  61563. * Gets wether or not the texture is blocking during loading.
  61564. */
  61565. get isBlocking(): boolean;
  61566. protected _rotationY: number;
  61567. /**
  61568. * Sets texture matrix rotation angle around Y axis in radians.
  61569. */
  61570. set rotationY(value: number);
  61571. /**
  61572. * Gets texture matrix rotation angle around Y axis radians.
  61573. */
  61574. get rotationY(): number;
  61575. /**
  61576. * Gets or sets the center of the bounding box associated with the cube texture
  61577. * It must define where the camera used to render the texture was set
  61578. */
  61579. boundingBoxPosition: Vector3;
  61580. private _boundingBoxSize;
  61581. /**
  61582. * Gets or sets the size of the bounding box associated with the cube texture
  61583. * When defined, the cubemap will switch to local mode
  61584. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61585. * @example https://www.babylonjs-playground.com/#RNASML
  61586. */
  61587. set boundingBoxSize(value: Vector3);
  61588. get boundingBoxSize(): Vector3;
  61589. /**
  61590. * Instantiates an HDRTexture from the following parameters.
  61591. *
  61592. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61593. * @param sceneOrEngine The scene or engine the texture will be used in
  61594. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61595. * @param noMipmap Forces to not generate the mipmap if true
  61596. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61597. * @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)
  61598. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61599. */
  61600. 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>);
  61601. /**
  61602. * Get the current class name of the texture useful for serialization or dynamic coding.
  61603. * @returns "HDRCubeTexture"
  61604. */
  61605. getClassName(): string;
  61606. /**
  61607. * Occurs when the file is raw .hdr file.
  61608. */
  61609. private loadTexture;
  61610. clone(): HDRCubeTexture;
  61611. delayLoad(): void;
  61612. /**
  61613. * Get the texture reflection matrix used to rotate/transform the reflection.
  61614. * @returns the reflection matrix
  61615. */
  61616. getReflectionTextureMatrix(): Matrix;
  61617. /**
  61618. * Set the texture reflection matrix used to rotate/transform the reflection.
  61619. * @param value Define the reflection matrix to set
  61620. */
  61621. setReflectionTextureMatrix(value: Matrix): void;
  61622. /**
  61623. * Parses a JSON representation of an HDR Texture in order to create the texture
  61624. * @param parsedTexture Define the JSON representation
  61625. * @param scene Define the scene the texture should be created in
  61626. * @param rootUrl Define the root url in case we need to load relative dependencies
  61627. * @returns the newly created texture after parsing
  61628. */
  61629. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61630. serialize(): any;
  61631. }
  61632. }
  61633. declare module BABYLON {
  61634. /**
  61635. * Class used to control physics engine
  61636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61637. */
  61638. export class PhysicsEngine implements IPhysicsEngine {
  61639. private _physicsPlugin;
  61640. /**
  61641. * Global value used to control the smallest number supported by the simulation
  61642. */
  61643. static Epsilon: number;
  61644. private _impostors;
  61645. private _joints;
  61646. private _subTimeStep;
  61647. /**
  61648. * Gets the gravity vector used by the simulation
  61649. */
  61650. gravity: Vector3;
  61651. /**
  61652. * Factory used to create the default physics plugin.
  61653. * @returns The default physics plugin
  61654. */
  61655. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61656. /**
  61657. * Creates a new Physics Engine
  61658. * @param gravity defines the gravity vector used by the simulation
  61659. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61660. */
  61661. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61662. /**
  61663. * Sets the gravity vector used by the simulation
  61664. * @param gravity defines the gravity vector to use
  61665. */
  61666. setGravity(gravity: Vector3): void;
  61667. /**
  61668. * Set the time step of the physics engine.
  61669. * Default is 1/60.
  61670. * To slow it down, enter 1/600 for example.
  61671. * To speed it up, 1/30
  61672. * @param newTimeStep defines the new timestep to apply to this world.
  61673. */
  61674. setTimeStep(newTimeStep?: number): void;
  61675. /**
  61676. * Get the time step of the physics engine.
  61677. * @returns the current time step
  61678. */
  61679. getTimeStep(): number;
  61680. /**
  61681. * Set the sub time step of the physics engine.
  61682. * Default is 0 meaning there is no sub steps
  61683. * To increase physics resolution precision, set a small value (like 1 ms)
  61684. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61685. */
  61686. setSubTimeStep(subTimeStep?: number): void;
  61687. /**
  61688. * Get the sub time step of the physics engine.
  61689. * @returns the current sub time step
  61690. */
  61691. getSubTimeStep(): number;
  61692. /**
  61693. * Release all resources
  61694. */
  61695. dispose(): void;
  61696. /**
  61697. * Gets the name of the current physics plugin
  61698. * @returns the name of the plugin
  61699. */
  61700. getPhysicsPluginName(): string;
  61701. /**
  61702. * Adding a new impostor for the impostor tracking.
  61703. * This will be done by the impostor itself.
  61704. * @param impostor the impostor to add
  61705. */
  61706. addImpostor(impostor: PhysicsImpostor): void;
  61707. /**
  61708. * Remove an impostor from the engine.
  61709. * This impostor and its mesh will not longer be updated by the physics engine.
  61710. * @param impostor the impostor to remove
  61711. */
  61712. removeImpostor(impostor: PhysicsImpostor): void;
  61713. /**
  61714. * Add a joint to the physics engine
  61715. * @param mainImpostor defines the main impostor to which the joint is added.
  61716. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61717. * @param joint defines the joint that will connect both impostors.
  61718. */
  61719. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61720. /**
  61721. * Removes a joint from the simulation
  61722. * @param mainImpostor defines the impostor used with the joint
  61723. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61724. * @param joint defines the joint to remove
  61725. */
  61726. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61727. /**
  61728. * Called by the scene. No need to call it.
  61729. * @param delta defines the timespam between frames
  61730. */
  61731. _step(delta: number): void;
  61732. /**
  61733. * Gets the current plugin used to run the simulation
  61734. * @returns current plugin
  61735. */
  61736. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61737. /**
  61738. * Gets the list of physic impostors
  61739. * @returns an array of PhysicsImpostor
  61740. */
  61741. getImpostors(): Array<PhysicsImpostor>;
  61742. /**
  61743. * Gets the impostor for a physics enabled object
  61744. * @param object defines the object impersonated by the impostor
  61745. * @returns the PhysicsImpostor or null if not found
  61746. */
  61747. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61748. /**
  61749. * Gets the impostor for a physics body object
  61750. * @param body defines physics body used by the impostor
  61751. * @returns the PhysicsImpostor or null if not found
  61752. */
  61753. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61754. /**
  61755. * Does a raycast in the physics world
  61756. * @param from when should the ray start?
  61757. * @param to when should the ray end?
  61758. * @returns PhysicsRaycastResult
  61759. */
  61760. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61761. }
  61762. }
  61763. declare module BABYLON {
  61764. /** @hidden */
  61765. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61766. private _useDeltaForWorldStep;
  61767. world: any;
  61768. name: string;
  61769. private _physicsMaterials;
  61770. private _fixedTimeStep;
  61771. private _cannonRaycastResult;
  61772. private _raycastResult;
  61773. private _physicsBodysToRemoveAfterStep;
  61774. private _firstFrame;
  61775. BJSCANNON: any;
  61776. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61777. setGravity(gravity: Vector3): void;
  61778. setTimeStep(timeStep: number): void;
  61779. getTimeStep(): number;
  61780. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61781. private _removeMarkedPhysicsBodiesFromWorld;
  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 _processChildMeshes;
  61786. removePhysicsBody(impostor: PhysicsImpostor): void;
  61787. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61789. private _addMaterial;
  61790. private _checkWithEpsilon;
  61791. private _createShape;
  61792. private _createHeightmap;
  61793. private _minus90X;
  61794. private _plus90X;
  61795. private _tmpPosition;
  61796. private _tmpDeltaPosition;
  61797. private _tmpUnityRotation;
  61798. private _updatePhysicsBodyTransformation;
  61799. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61800. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61801. isSupported(): boolean;
  61802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61807. getBodyMass(impostor: PhysicsImpostor): number;
  61808. getBodyFriction(impostor: PhysicsImpostor): number;
  61809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61810. getBodyRestitution(impostor: PhysicsImpostor): number;
  61811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61812. sleepBody(impostor: PhysicsImpostor): void;
  61813. wakeUpBody(impostor: PhysicsImpostor): void;
  61814. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61815. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61818. getRadius(impostor: PhysicsImpostor): number;
  61819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61820. dispose(): void;
  61821. private _extendNamespace;
  61822. /**
  61823. * Does a raycast in the physics world
  61824. * @param from when should the ray start?
  61825. * @param to when should the ray end?
  61826. * @returns PhysicsRaycastResult
  61827. */
  61828. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61829. }
  61830. }
  61831. declare module BABYLON {
  61832. /** @hidden */
  61833. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61834. private _useDeltaForWorldStep;
  61835. world: any;
  61836. name: string;
  61837. BJSOIMO: any;
  61838. private _raycastResult;
  61839. private _fixedTimeStep;
  61840. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61841. setGravity(gravity: Vector3): void;
  61842. setTimeStep(timeStep: number): void;
  61843. getTimeStep(): number;
  61844. private _tmpImpostorsArray;
  61845. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61846. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61847. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61848. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61849. private _tmpPositionVector;
  61850. removePhysicsBody(impostor: PhysicsImpostor): void;
  61851. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61852. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61853. isSupported(): boolean;
  61854. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61855. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61856. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61857. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61858. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61859. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61860. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61861. getBodyMass(impostor: PhysicsImpostor): number;
  61862. getBodyFriction(impostor: PhysicsImpostor): number;
  61863. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61864. getBodyRestitution(impostor: PhysicsImpostor): number;
  61865. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61866. sleepBody(impostor: PhysicsImpostor): void;
  61867. wakeUpBody(impostor: PhysicsImpostor): void;
  61868. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61869. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61870. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61871. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61872. getRadius(impostor: PhysicsImpostor): number;
  61873. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61874. dispose(): void;
  61875. /**
  61876. * Does a raycast in the physics world
  61877. * @param from when should the ray start?
  61878. * @param to when should the ray end?
  61879. * @returns PhysicsRaycastResult
  61880. */
  61881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61882. }
  61883. }
  61884. declare module BABYLON {
  61885. /**
  61886. * AmmoJS Physics plugin
  61887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61888. * @see https://github.com/kripken/ammo.js/
  61889. */
  61890. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61891. private _useDeltaForWorldStep;
  61892. /**
  61893. * Reference to the Ammo library
  61894. */
  61895. bjsAMMO: any;
  61896. /**
  61897. * Created ammoJS world which physics bodies are added to
  61898. */
  61899. world: any;
  61900. /**
  61901. * Name of the plugin
  61902. */
  61903. name: string;
  61904. private _timeStep;
  61905. private _fixedTimeStep;
  61906. private _maxSteps;
  61907. private _tmpQuaternion;
  61908. private _tmpAmmoTransform;
  61909. private _tmpAmmoQuaternion;
  61910. private _tmpAmmoConcreteContactResultCallback;
  61911. private _collisionConfiguration;
  61912. private _dispatcher;
  61913. private _overlappingPairCache;
  61914. private _solver;
  61915. private _softBodySolver;
  61916. private _tmpAmmoVectorA;
  61917. private _tmpAmmoVectorB;
  61918. private _tmpAmmoVectorC;
  61919. private _tmpAmmoVectorD;
  61920. private _tmpContactCallbackResult;
  61921. private _tmpAmmoVectorRCA;
  61922. private _tmpAmmoVectorRCB;
  61923. private _raycastResult;
  61924. private _tmpContactPoint;
  61925. private static readonly DISABLE_COLLISION_FLAG;
  61926. private static readonly KINEMATIC_FLAG;
  61927. private static readonly DISABLE_DEACTIVATION_FLAG;
  61928. /**
  61929. * Initializes the ammoJS plugin
  61930. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61931. * @param ammoInjection can be used to inject your own ammo reference
  61932. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61933. */
  61934. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61935. /**
  61936. * Sets the gravity of the physics world (m/(s^2))
  61937. * @param gravity Gravity to set
  61938. */
  61939. setGravity(gravity: Vector3): void;
  61940. /**
  61941. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61942. * @param timeStep timestep to use in seconds
  61943. */
  61944. setTimeStep(timeStep: number): void;
  61945. /**
  61946. * 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)
  61947. * @param fixedTimeStep fixedTimeStep to use in seconds
  61948. */
  61949. setFixedTimeStep(fixedTimeStep: number): void;
  61950. /**
  61951. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61952. * @param maxSteps the maximum number of steps by the physics engine per frame
  61953. */
  61954. setMaxSteps(maxSteps: number): void;
  61955. /**
  61956. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61957. * @returns the current timestep in seconds
  61958. */
  61959. getTimeStep(): number;
  61960. /**
  61961. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61962. */
  61963. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61964. private _isImpostorInContact;
  61965. private _isImpostorPairInContact;
  61966. private _stepSimulation;
  61967. /**
  61968. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61969. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61970. * After the step the babylon meshes are set to the position of the physics imposters
  61971. * @param delta amount of time to step forward
  61972. * @param impostors array of imposters to update before/after the step
  61973. */
  61974. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61975. /**
  61976. * Update babylon mesh to match physics world object
  61977. * @param impostor imposter to match
  61978. */
  61979. private _afterSoftStep;
  61980. /**
  61981. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61982. * @param impostor imposter to match
  61983. */
  61984. private _ropeStep;
  61985. /**
  61986. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61987. * @param impostor imposter to match
  61988. */
  61989. private _softbodyOrClothStep;
  61990. private _tmpMatrix;
  61991. /**
  61992. * Applies an impulse on the imposter
  61993. * @param impostor imposter to apply impulse to
  61994. * @param force amount of force to be applied to the imposter
  61995. * @param contactPoint the location to apply the impulse on the imposter
  61996. */
  61997. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61998. /**
  61999. * Applies a force on the imposter
  62000. * @param impostor imposter to apply force
  62001. * @param force amount of force to be applied to the imposter
  62002. * @param contactPoint the location to apply the force on the imposter
  62003. */
  62004. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62005. /**
  62006. * Creates a physics body using the plugin
  62007. * @param impostor the imposter to create the physics body on
  62008. */
  62009. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62010. /**
  62011. * Removes the physics body from the imposter and disposes of the body's memory
  62012. * @param impostor imposter to remove the physics body from
  62013. */
  62014. removePhysicsBody(impostor: PhysicsImpostor): void;
  62015. /**
  62016. * Generates a joint
  62017. * @param impostorJoint the imposter joint to create the joint with
  62018. */
  62019. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62020. /**
  62021. * Removes a joint
  62022. * @param impostorJoint the imposter joint to remove the joint from
  62023. */
  62024. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62025. private _addMeshVerts;
  62026. /**
  62027. * Initialise the soft body vertices to match its object's (mesh) vertices
  62028. * Softbody vertices (nodes) are in world space and to match this
  62029. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62030. * @param impostor to create the softbody for
  62031. */
  62032. private _softVertexData;
  62033. /**
  62034. * Create an impostor's soft body
  62035. * @param impostor to create the softbody for
  62036. */
  62037. private _createSoftbody;
  62038. /**
  62039. * Create cloth for an impostor
  62040. * @param impostor to create the softbody for
  62041. */
  62042. private _createCloth;
  62043. /**
  62044. * Create rope for an impostor
  62045. * @param impostor to create the softbody for
  62046. */
  62047. private _createRope;
  62048. /**
  62049. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62050. * @param impostor to create the custom physics shape for
  62051. */
  62052. private _createCustom;
  62053. private _addHullVerts;
  62054. private _createShape;
  62055. /**
  62056. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62057. * @param impostor imposter containing the physics body and babylon object
  62058. */
  62059. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62060. /**
  62061. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62062. * @param impostor imposter containing the physics body and babylon object
  62063. * @param newPosition new position
  62064. * @param newRotation new rotation
  62065. */
  62066. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62067. /**
  62068. * If this plugin is supported
  62069. * @returns true if its supported
  62070. */
  62071. isSupported(): boolean;
  62072. /**
  62073. * Sets the linear velocity of the physics body
  62074. * @param impostor imposter to set the velocity on
  62075. * @param velocity velocity to set
  62076. */
  62077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62078. /**
  62079. * Sets the angular velocity of the physics body
  62080. * @param impostor imposter to set the velocity on
  62081. * @param velocity velocity to set
  62082. */
  62083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62084. /**
  62085. * gets the linear velocity
  62086. * @param impostor imposter to get linear velocity from
  62087. * @returns linear velocity
  62088. */
  62089. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62090. /**
  62091. * gets the angular velocity
  62092. * @param impostor imposter to get angular velocity from
  62093. * @returns angular velocity
  62094. */
  62095. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62096. /**
  62097. * Sets the mass of physics body
  62098. * @param impostor imposter to set the mass on
  62099. * @param mass mass to set
  62100. */
  62101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62102. /**
  62103. * Gets the mass of the physics body
  62104. * @param impostor imposter to get the mass from
  62105. * @returns mass
  62106. */
  62107. getBodyMass(impostor: PhysicsImpostor): number;
  62108. /**
  62109. * Gets friction of the impostor
  62110. * @param impostor impostor to get friction from
  62111. * @returns friction value
  62112. */
  62113. getBodyFriction(impostor: PhysicsImpostor): number;
  62114. /**
  62115. * Sets friction of the impostor
  62116. * @param impostor impostor to set friction on
  62117. * @param friction friction value
  62118. */
  62119. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62120. /**
  62121. * Gets restitution of the impostor
  62122. * @param impostor impostor to get restitution from
  62123. * @returns restitution value
  62124. */
  62125. getBodyRestitution(impostor: PhysicsImpostor): number;
  62126. /**
  62127. * Sets resitution of the impostor
  62128. * @param impostor impostor to set resitution on
  62129. * @param restitution resitution value
  62130. */
  62131. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62132. /**
  62133. * Gets pressure inside the impostor
  62134. * @param impostor impostor to get pressure from
  62135. * @returns pressure value
  62136. */
  62137. getBodyPressure(impostor: PhysicsImpostor): number;
  62138. /**
  62139. * Sets pressure inside a soft body impostor
  62140. * Cloth and rope must remain 0 pressure
  62141. * @param impostor impostor to set pressure on
  62142. * @param pressure pressure value
  62143. */
  62144. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62145. /**
  62146. * Gets stiffness of the impostor
  62147. * @param impostor impostor to get stiffness from
  62148. * @returns pressure value
  62149. */
  62150. getBodyStiffness(impostor: PhysicsImpostor): number;
  62151. /**
  62152. * Sets stiffness of the impostor
  62153. * @param impostor impostor to set stiffness on
  62154. * @param stiffness stiffness value from 0 to 1
  62155. */
  62156. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62157. /**
  62158. * Gets velocityIterations of the impostor
  62159. * @param impostor impostor to get velocity iterations from
  62160. * @returns velocityIterations value
  62161. */
  62162. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62163. /**
  62164. * Sets velocityIterations of the impostor
  62165. * @param impostor impostor to set velocity iterations on
  62166. * @param velocityIterations velocityIterations value
  62167. */
  62168. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62169. /**
  62170. * Gets positionIterations of the impostor
  62171. * @param impostor impostor to get position iterations from
  62172. * @returns positionIterations value
  62173. */
  62174. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62175. /**
  62176. * Sets positionIterations of the impostor
  62177. * @param impostor impostor to set position on
  62178. * @param positionIterations positionIterations value
  62179. */
  62180. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62181. /**
  62182. * Append an anchor to a cloth object
  62183. * @param impostor is the cloth impostor to add anchor to
  62184. * @param otherImpostor is the rigid impostor to anchor to
  62185. * @param width ratio across width from 0 to 1
  62186. * @param height ratio up height from 0 to 1
  62187. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62188. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62189. */
  62190. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62191. /**
  62192. * Append an hook to a rope object
  62193. * @param impostor is the rope impostor to add hook to
  62194. * @param otherImpostor is the rigid impostor to hook to
  62195. * @param length ratio along the rope from 0 to 1
  62196. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62197. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62198. */
  62199. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62200. /**
  62201. * Sleeps the physics body and stops it from being active
  62202. * @param impostor impostor to sleep
  62203. */
  62204. sleepBody(impostor: PhysicsImpostor): void;
  62205. /**
  62206. * Activates the physics body
  62207. * @param impostor impostor to activate
  62208. */
  62209. wakeUpBody(impostor: PhysicsImpostor): void;
  62210. /**
  62211. * Updates the distance parameters of the joint
  62212. * @param joint joint to update
  62213. * @param maxDistance maximum distance of the joint
  62214. * @param minDistance minimum distance of the joint
  62215. */
  62216. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62217. /**
  62218. * Sets a motor on the joint
  62219. * @param joint joint to set motor on
  62220. * @param speed speed of the motor
  62221. * @param maxForce maximum force of the motor
  62222. * @param motorIndex index of the motor
  62223. */
  62224. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62225. /**
  62226. * Sets the motors limit
  62227. * @param joint joint to set limit on
  62228. * @param upperLimit upper limit
  62229. * @param lowerLimit lower limit
  62230. */
  62231. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62232. /**
  62233. * Syncs the position and rotation of a mesh with the impostor
  62234. * @param mesh mesh to sync
  62235. * @param impostor impostor to update the mesh with
  62236. */
  62237. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62238. /**
  62239. * Gets the radius of the impostor
  62240. * @param impostor impostor to get radius from
  62241. * @returns the radius
  62242. */
  62243. getRadius(impostor: PhysicsImpostor): number;
  62244. /**
  62245. * Gets the box size of the impostor
  62246. * @param impostor impostor to get box size from
  62247. * @param result the resulting box size
  62248. */
  62249. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62250. /**
  62251. * Disposes of the impostor
  62252. */
  62253. dispose(): void;
  62254. /**
  62255. * Does a raycast in the physics world
  62256. * @param from when should the ray start?
  62257. * @param to when should the ray end?
  62258. * @returns PhysicsRaycastResult
  62259. */
  62260. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62261. }
  62262. }
  62263. declare module BABYLON {
  62264. interface AbstractScene {
  62265. /**
  62266. * The list of reflection probes added to the scene
  62267. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62268. */
  62269. reflectionProbes: Array<ReflectionProbe>;
  62270. /**
  62271. * Removes the given reflection probe from this scene.
  62272. * @param toRemove The reflection probe to remove
  62273. * @returns The index of the removed reflection probe
  62274. */
  62275. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62276. /**
  62277. * Adds the given reflection probe to this scene.
  62278. * @param newReflectionProbe The reflection probe to add
  62279. */
  62280. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62281. }
  62282. /**
  62283. * Class used to generate realtime reflection / refraction cube textures
  62284. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62285. */
  62286. export class ReflectionProbe {
  62287. /** defines the name of the probe */
  62288. name: string;
  62289. private _scene;
  62290. private _renderTargetTexture;
  62291. private _projectionMatrix;
  62292. private _viewMatrix;
  62293. private _target;
  62294. private _add;
  62295. private _attachedMesh;
  62296. private _invertYAxis;
  62297. /** Gets or sets probe position (center of the cube map) */
  62298. position: Vector3;
  62299. /**
  62300. * Creates a new reflection probe
  62301. * @param name defines the name of the probe
  62302. * @param size defines the texture resolution (for each face)
  62303. * @param scene defines the hosting scene
  62304. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62305. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62306. */
  62307. constructor(
  62308. /** defines the name of the probe */
  62309. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62310. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62311. get samples(): number;
  62312. set samples(value: number);
  62313. /** Gets or sets the refresh rate to use (on every frame by default) */
  62314. get refreshRate(): number;
  62315. set refreshRate(value: number);
  62316. /**
  62317. * Gets the hosting scene
  62318. * @returns a Scene
  62319. */
  62320. getScene(): Scene;
  62321. /** Gets the internal CubeTexture used to render to */
  62322. get cubeTexture(): RenderTargetTexture;
  62323. /** Gets the list of meshes to render */
  62324. get renderList(): Nullable<AbstractMesh[]>;
  62325. /**
  62326. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62327. * @param mesh defines the mesh to attach to
  62328. */
  62329. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62330. /**
  62331. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62332. * @param renderingGroupId The rendering group id corresponding to its index
  62333. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62334. */
  62335. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62336. /**
  62337. * Clean all associated resources
  62338. */
  62339. dispose(): void;
  62340. /**
  62341. * Converts the reflection probe information to a readable string for debug purpose.
  62342. * @param fullDetails Supports for multiple levels of logging within scene loading
  62343. * @returns the human readable reflection probe info
  62344. */
  62345. toString(fullDetails?: boolean): string;
  62346. /**
  62347. * Get the class name of the relfection probe.
  62348. * @returns "ReflectionProbe"
  62349. */
  62350. getClassName(): string;
  62351. /**
  62352. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62353. * @returns The JSON representation of the texture
  62354. */
  62355. serialize(): any;
  62356. /**
  62357. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62358. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62359. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62360. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62361. * @returns The parsed reflection probe if successful
  62362. */
  62363. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62364. }
  62365. }
  62366. declare module BABYLON {
  62367. /** @hidden */
  62368. export var _BabylonLoaderRegistered: boolean;
  62369. /**
  62370. * Helps setting up some configuration for the babylon file loader.
  62371. */
  62372. export class BabylonFileLoaderConfiguration {
  62373. /**
  62374. * The loader does not allow injecting custom physix engine into the plugins.
  62375. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62376. * So you could set this variable to your engine import to make it work.
  62377. */
  62378. static LoaderInjectedPhysicsEngine: any;
  62379. }
  62380. }
  62381. declare module BABYLON {
  62382. /**
  62383. * The Physically based simple base material of BJS.
  62384. *
  62385. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62386. * It is used as the base class for both the specGloss and metalRough conventions.
  62387. */
  62388. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62389. /**
  62390. * Number of Simultaneous lights allowed on the material.
  62391. */
  62392. maxSimultaneousLights: number;
  62393. /**
  62394. * If sets to true, disables all the lights affecting the material.
  62395. */
  62396. disableLighting: boolean;
  62397. /**
  62398. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62399. */
  62400. environmentTexture: BaseTexture;
  62401. /**
  62402. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62403. */
  62404. invertNormalMapX: boolean;
  62405. /**
  62406. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62407. */
  62408. invertNormalMapY: boolean;
  62409. /**
  62410. * Normal map used in the model.
  62411. */
  62412. normalTexture: BaseTexture;
  62413. /**
  62414. * Emissivie color used to self-illuminate the model.
  62415. */
  62416. emissiveColor: Color3;
  62417. /**
  62418. * Emissivie texture used to self-illuminate the model.
  62419. */
  62420. emissiveTexture: BaseTexture;
  62421. /**
  62422. * Occlusion Channel Strenght.
  62423. */
  62424. occlusionStrength: number;
  62425. /**
  62426. * Occlusion Texture of the material (adding extra occlusion effects).
  62427. */
  62428. occlusionTexture: BaseTexture;
  62429. /**
  62430. * Defines the alpha limits in alpha test mode.
  62431. */
  62432. alphaCutOff: number;
  62433. /**
  62434. * Gets the current double sided mode.
  62435. */
  62436. get doubleSided(): boolean;
  62437. /**
  62438. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62439. */
  62440. set doubleSided(value: boolean);
  62441. /**
  62442. * Stores the pre-calculated light information of a mesh in a texture.
  62443. */
  62444. lightmapTexture: BaseTexture;
  62445. /**
  62446. * If true, the light map contains occlusion information instead of lighting info.
  62447. */
  62448. useLightmapAsShadowmap: boolean;
  62449. /**
  62450. * Instantiates a new PBRMaterial instance.
  62451. *
  62452. * @param name The material name
  62453. * @param scene The scene the material will be use in.
  62454. */
  62455. constructor(name: string, scene: Scene);
  62456. getClassName(): string;
  62457. }
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * The PBR material of BJS following the metal roughness convention.
  62462. *
  62463. * This fits to the PBR convention in the GLTF definition:
  62464. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62465. */
  62466. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62467. /**
  62468. * The base color has two different interpretations depending on the value of metalness.
  62469. * When the material is a metal, the base color is the specific measured reflectance value
  62470. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62471. * of the material.
  62472. */
  62473. baseColor: Color3;
  62474. /**
  62475. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62476. * well as opacity information in the alpha channel.
  62477. */
  62478. baseTexture: BaseTexture;
  62479. /**
  62480. * Specifies the metallic scalar value of the material.
  62481. * Can also be used to scale the metalness values of the metallic texture.
  62482. */
  62483. metallic: number;
  62484. /**
  62485. * Specifies the roughness scalar value of the material.
  62486. * Can also be used to scale the roughness values of the metallic texture.
  62487. */
  62488. roughness: number;
  62489. /**
  62490. * Texture containing both the metallic value in the B channel and the
  62491. * roughness value in the G channel to keep better precision.
  62492. */
  62493. metallicRoughnessTexture: BaseTexture;
  62494. /**
  62495. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62496. *
  62497. * @param name The material name
  62498. * @param scene The scene the material will be use in.
  62499. */
  62500. constructor(name: string, scene: Scene);
  62501. /**
  62502. * Return the currrent class name of the material.
  62503. */
  62504. getClassName(): string;
  62505. /**
  62506. * Makes a duplicate of the current material.
  62507. * @param name - name to use for the new material.
  62508. */
  62509. clone(name: string): PBRMetallicRoughnessMaterial;
  62510. /**
  62511. * Serialize the material to a parsable JSON object.
  62512. */
  62513. serialize(): any;
  62514. /**
  62515. * Parses a JSON object correponding to the serialize function.
  62516. */
  62517. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62518. }
  62519. }
  62520. declare module BABYLON {
  62521. /**
  62522. * The PBR material of BJS following the specular glossiness convention.
  62523. *
  62524. * This fits to the PBR convention in the GLTF definition:
  62525. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62526. */
  62527. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62528. /**
  62529. * Specifies the diffuse color of the material.
  62530. */
  62531. diffuseColor: Color3;
  62532. /**
  62533. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62534. * channel.
  62535. */
  62536. diffuseTexture: BaseTexture;
  62537. /**
  62538. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62539. */
  62540. specularColor: Color3;
  62541. /**
  62542. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62543. */
  62544. glossiness: number;
  62545. /**
  62546. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62547. */
  62548. specularGlossinessTexture: BaseTexture;
  62549. /**
  62550. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62551. *
  62552. * @param name The material name
  62553. * @param scene The scene the material will be use in.
  62554. */
  62555. constructor(name: string, scene: Scene);
  62556. /**
  62557. * Return the currrent class name of the material.
  62558. */
  62559. getClassName(): string;
  62560. /**
  62561. * Makes a duplicate of the current material.
  62562. * @param name - name to use for the new material.
  62563. */
  62564. clone(name: string): PBRSpecularGlossinessMaterial;
  62565. /**
  62566. * Serialize the material to a parsable JSON object.
  62567. */
  62568. serialize(): any;
  62569. /**
  62570. * Parses a JSON object correponding to the serialize function.
  62571. */
  62572. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62573. }
  62574. }
  62575. declare module BABYLON {
  62576. /**
  62577. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62578. * It can help converting any input color in a desired output one. This can then be used to create effects
  62579. * from sepia, black and white to sixties or futuristic rendering...
  62580. *
  62581. * The only supported format is currently 3dl.
  62582. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62583. */
  62584. export class ColorGradingTexture extends BaseTexture {
  62585. /**
  62586. * The texture URL.
  62587. */
  62588. url: string;
  62589. /**
  62590. * Empty line regex stored for GC.
  62591. */
  62592. private static _noneEmptyLineRegex;
  62593. private _textureMatrix;
  62594. private _onLoad;
  62595. /**
  62596. * Instantiates a ColorGradingTexture from the following parameters.
  62597. *
  62598. * @param url The location of the color gradind data (currently only supporting 3dl)
  62599. * @param sceneOrEngine The scene or engine the texture will be used in
  62600. * @param onLoad defines a callback triggered when the texture has been loaded
  62601. */
  62602. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62603. /**
  62604. * Fires the onload event from the constructor if requested.
  62605. */
  62606. private _triggerOnLoad;
  62607. /**
  62608. * Returns the texture matrix used in most of the material.
  62609. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62610. */
  62611. getTextureMatrix(): Matrix;
  62612. /**
  62613. * Occurs when the file being loaded is a .3dl LUT file.
  62614. */
  62615. private load3dlTexture;
  62616. /**
  62617. * Starts the loading process of the texture.
  62618. */
  62619. private loadTexture;
  62620. /**
  62621. * Clones the color gradind texture.
  62622. */
  62623. clone(): ColorGradingTexture;
  62624. /**
  62625. * Called during delayed load for textures.
  62626. */
  62627. delayLoad(): void;
  62628. /**
  62629. * Parses a color grading texture serialized by Babylon.
  62630. * @param parsedTexture The texture information being parsedTexture
  62631. * @param scene The scene to load the texture in
  62632. * @param rootUrl The root url of the data assets to load
  62633. * @return A color gradind texture
  62634. */
  62635. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62636. /**
  62637. * Serializes the LUT texture to json format.
  62638. */
  62639. serialize(): any;
  62640. }
  62641. }
  62642. declare module BABYLON {
  62643. /**
  62644. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62645. */
  62646. export class EquiRectangularCubeTexture extends BaseTexture {
  62647. /** The six faces of the cube. */
  62648. private static _FacesMapping;
  62649. private _noMipmap;
  62650. private _onLoad;
  62651. private _onError;
  62652. /** The size of the cubemap. */
  62653. private _size;
  62654. /** The buffer of the image. */
  62655. private _buffer;
  62656. /** The width of the input image. */
  62657. private _width;
  62658. /** The height of the input image. */
  62659. private _height;
  62660. /** The URL to the image. */
  62661. url: string;
  62662. /**
  62663. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62664. * @param url The location of the image
  62665. * @param scene The scene the texture will be used in
  62666. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62667. * @param noMipmap Forces to not generate the mipmap if true
  62668. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62669. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62670. * @param onLoad — defines a callback called when texture is loaded
  62671. * @param onError — defines a callback called if there is an error
  62672. */
  62673. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62674. /**
  62675. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62676. */
  62677. private loadImage;
  62678. /**
  62679. * Convert the image buffer into a cubemap and create a CubeTexture.
  62680. */
  62681. private loadTexture;
  62682. /**
  62683. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62684. * @param buffer The ArrayBuffer that should be converted.
  62685. * @returns The buffer as Float32Array.
  62686. */
  62687. private getFloat32ArrayFromArrayBuffer;
  62688. /**
  62689. * Get the current class name of the texture useful for serialization or dynamic coding.
  62690. * @returns "EquiRectangularCubeTexture"
  62691. */
  62692. getClassName(): string;
  62693. /**
  62694. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62695. * @returns A clone of the current EquiRectangularCubeTexture.
  62696. */
  62697. clone(): EquiRectangularCubeTexture;
  62698. }
  62699. }
  62700. declare module BABYLON {
  62701. /**
  62702. * Defines the options related to the creation of an HtmlElementTexture
  62703. */
  62704. export interface IHtmlElementTextureOptions {
  62705. /**
  62706. * Defines wether mip maps should be created or not.
  62707. */
  62708. generateMipMaps?: boolean;
  62709. /**
  62710. * Defines the sampling mode of the texture.
  62711. */
  62712. samplingMode?: number;
  62713. /**
  62714. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62715. */
  62716. engine: Nullable<ThinEngine>;
  62717. /**
  62718. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62719. */
  62720. scene: Nullable<Scene>;
  62721. }
  62722. /**
  62723. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62724. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62725. * is automatically managed.
  62726. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62727. * in your application.
  62728. *
  62729. * As the update is not automatic, you need to call them manually.
  62730. */
  62731. export class HtmlElementTexture extends BaseTexture {
  62732. /**
  62733. * The texture URL.
  62734. */
  62735. element: HTMLVideoElement | HTMLCanvasElement;
  62736. private static readonly DefaultOptions;
  62737. private _textureMatrix;
  62738. private _isVideo;
  62739. private _generateMipMaps;
  62740. private _samplingMode;
  62741. /**
  62742. * Instantiates a HtmlElementTexture from the following parameters.
  62743. *
  62744. * @param name Defines the name of the texture
  62745. * @param element Defines the video or canvas the texture is filled with
  62746. * @param options Defines the other none mandatory texture creation options
  62747. */
  62748. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62749. private _createInternalTexture;
  62750. /**
  62751. * Returns the texture matrix used in most of the material.
  62752. */
  62753. getTextureMatrix(): Matrix;
  62754. /**
  62755. * Updates the content of the texture.
  62756. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62757. */
  62758. update(invertY?: Nullable<boolean>): void;
  62759. }
  62760. }
  62761. declare module BABYLON {
  62762. /**
  62763. * Based on jsTGALoader - Javascript loader for TGA file
  62764. * By Vincent Thibault
  62765. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62766. */
  62767. export class TGATools {
  62768. private static _TYPE_INDEXED;
  62769. private static _TYPE_RGB;
  62770. private static _TYPE_GREY;
  62771. private static _TYPE_RLE_INDEXED;
  62772. private static _TYPE_RLE_RGB;
  62773. private static _TYPE_RLE_GREY;
  62774. private static _ORIGIN_MASK;
  62775. private static _ORIGIN_SHIFT;
  62776. private static _ORIGIN_BL;
  62777. private static _ORIGIN_BR;
  62778. private static _ORIGIN_UL;
  62779. private static _ORIGIN_UR;
  62780. /**
  62781. * Gets the header of a TGA file
  62782. * @param data defines the TGA data
  62783. * @returns the header
  62784. */
  62785. static GetTGAHeader(data: Uint8Array): any;
  62786. /**
  62787. * Uploads TGA content to a Babylon Texture
  62788. * @hidden
  62789. */
  62790. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62791. /** @hidden */
  62792. 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;
  62793. /** @hidden */
  62794. 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;
  62795. /** @hidden */
  62796. 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;
  62797. /** @hidden */
  62798. 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;
  62799. /** @hidden */
  62800. 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;
  62801. /** @hidden */
  62802. 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;
  62803. }
  62804. }
  62805. declare module BABYLON {
  62806. /**
  62807. * Implementation of the TGA Texture Loader.
  62808. * @hidden
  62809. */
  62810. export class _TGATextureLoader implements IInternalTextureLoader {
  62811. /**
  62812. * Defines wether the loader supports cascade loading the different faces.
  62813. */
  62814. readonly supportCascades: boolean;
  62815. /**
  62816. * This returns if the loader support the current file information.
  62817. * @param extension defines the file extension of the file being loaded
  62818. * @returns true if the loader can load the specified file
  62819. */
  62820. canLoad(extension: string): boolean;
  62821. /**
  62822. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62823. * @param data contains the texture data
  62824. * @param texture defines the BabylonJS internal texture
  62825. * @param createPolynomials will be true if polynomials have been requested
  62826. * @param onLoad defines the callback to trigger once the texture is ready
  62827. * @param onError defines the callback to trigger in case of error
  62828. */
  62829. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62830. /**
  62831. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62832. * @param data contains the texture data
  62833. * @param texture defines the BabylonJS internal texture
  62834. * @param callback defines the method to call once ready to upload
  62835. */
  62836. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62837. }
  62838. }
  62839. declare module BABYLON {
  62840. /**
  62841. * Info about the .basis files
  62842. */
  62843. class BasisFileInfo {
  62844. /**
  62845. * If the file has alpha
  62846. */
  62847. hasAlpha: boolean;
  62848. /**
  62849. * Info about each image of the basis file
  62850. */
  62851. images: Array<{
  62852. levels: Array<{
  62853. width: number;
  62854. height: number;
  62855. transcodedPixels: ArrayBufferView;
  62856. }>;
  62857. }>;
  62858. }
  62859. /**
  62860. * Result of transcoding a basis file
  62861. */
  62862. class TranscodeResult {
  62863. /**
  62864. * Info about the .basis file
  62865. */
  62866. fileInfo: BasisFileInfo;
  62867. /**
  62868. * Format to use when loading the file
  62869. */
  62870. format: number;
  62871. }
  62872. /**
  62873. * Configuration options for the Basis transcoder
  62874. */
  62875. export class BasisTranscodeConfiguration {
  62876. /**
  62877. * Supported compression formats used to determine the supported output format of the transcoder
  62878. */
  62879. supportedCompressionFormats?: {
  62880. /**
  62881. * etc1 compression format
  62882. */
  62883. etc1?: boolean;
  62884. /**
  62885. * s3tc compression format
  62886. */
  62887. s3tc?: boolean;
  62888. /**
  62889. * pvrtc compression format
  62890. */
  62891. pvrtc?: boolean;
  62892. /**
  62893. * etc2 compression format
  62894. */
  62895. etc2?: boolean;
  62896. };
  62897. /**
  62898. * If mipmap levels should be loaded for transcoded images (Default: true)
  62899. */
  62900. loadMipmapLevels?: boolean;
  62901. /**
  62902. * Index of a single image to load (Default: all images)
  62903. */
  62904. loadSingleImage?: number;
  62905. }
  62906. /**
  62907. * Used to load .Basis files
  62908. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62909. */
  62910. export class BasisTools {
  62911. private static _IgnoreSupportedFormats;
  62912. /**
  62913. * URL to use when loading the basis transcoder
  62914. */
  62915. static JSModuleURL: string;
  62916. /**
  62917. * URL to use when loading the wasm module for the transcoder
  62918. */
  62919. static WasmModuleURL: string;
  62920. /**
  62921. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62922. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62923. * @returns internal format corresponding to the Basis format
  62924. */
  62925. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62926. private static _WorkerPromise;
  62927. private static _Worker;
  62928. private static _actionId;
  62929. private static _CreateWorkerAsync;
  62930. /**
  62931. * Transcodes a loaded image file to compressed pixel data
  62932. * @param data image data to transcode
  62933. * @param config configuration options for the transcoding
  62934. * @returns a promise resulting in the transcoded image
  62935. */
  62936. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62937. /**
  62938. * Loads a texture from the transcode result
  62939. * @param texture texture load to
  62940. * @param transcodeResult the result of transcoding the basis file to load from
  62941. */
  62942. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62943. }
  62944. }
  62945. declare module BABYLON {
  62946. /**
  62947. * Loader for .basis file format
  62948. */
  62949. export class _BasisTextureLoader implements IInternalTextureLoader {
  62950. /**
  62951. * Defines whether the loader supports cascade loading the different faces.
  62952. */
  62953. readonly supportCascades: boolean;
  62954. /**
  62955. * This returns if the loader support the current file information.
  62956. * @param extension defines the file extension of the file being loaded
  62957. * @returns true if the loader can load the specified file
  62958. */
  62959. canLoad(extension: string): boolean;
  62960. /**
  62961. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62962. * @param data contains the texture data
  62963. * @param texture defines the BabylonJS internal texture
  62964. * @param createPolynomials will be true if polynomials have been requested
  62965. * @param onLoad defines the callback to trigger once the texture is ready
  62966. * @param onError defines the callback to trigger in case of error
  62967. */
  62968. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62969. /**
  62970. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62971. * @param data contains the texture data
  62972. * @param texture defines the BabylonJS internal texture
  62973. * @param callback defines the method to call once ready to upload
  62974. */
  62975. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62976. }
  62977. }
  62978. declare module BABYLON {
  62979. /**
  62980. * Defines the basic options interface of a TexturePacker Frame
  62981. */
  62982. export interface ITexturePackerFrame {
  62983. /**
  62984. * The frame ID
  62985. */
  62986. id: number;
  62987. /**
  62988. * The frames Scale
  62989. */
  62990. scale: Vector2;
  62991. /**
  62992. * The Frames offset
  62993. */
  62994. offset: Vector2;
  62995. }
  62996. /**
  62997. * This is a support class for frame Data on texture packer sets.
  62998. */
  62999. export class TexturePackerFrame implements ITexturePackerFrame {
  63000. /**
  63001. * The frame ID
  63002. */
  63003. id: number;
  63004. /**
  63005. * The frames Scale
  63006. */
  63007. scale: Vector2;
  63008. /**
  63009. * The Frames offset
  63010. */
  63011. offset: Vector2;
  63012. /**
  63013. * Initializes a texture package frame.
  63014. * @param id The numerical frame identifier
  63015. * @param scale Scalar Vector2 for UV frame
  63016. * @param offset Vector2 for the frame position in UV units.
  63017. * @returns TexturePackerFrame
  63018. */
  63019. constructor(id: number, scale: Vector2, offset: Vector2);
  63020. }
  63021. }
  63022. declare module BABYLON {
  63023. /**
  63024. * Defines the basic options interface of a TexturePacker
  63025. */
  63026. export interface ITexturePackerOptions {
  63027. /**
  63028. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63029. */
  63030. map?: string[];
  63031. /**
  63032. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63033. */
  63034. uvsIn?: string;
  63035. /**
  63036. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63037. */
  63038. uvsOut?: string;
  63039. /**
  63040. * number representing the layout style. Defaults to LAYOUT_STRIP
  63041. */
  63042. layout?: number;
  63043. /**
  63044. * number of columns if using custom column count layout(2). This defaults to 4.
  63045. */
  63046. colnum?: number;
  63047. /**
  63048. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63049. */
  63050. updateInputMeshes?: boolean;
  63051. /**
  63052. * boolean flag to dispose all the source textures. Defaults to true.
  63053. */
  63054. disposeSources?: boolean;
  63055. /**
  63056. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63057. */
  63058. fillBlanks?: boolean;
  63059. /**
  63060. * string value representing the context fill style color. Defaults to 'black'.
  63061. */
  63062. customFillColor?: string;
  63063. /**
  63064. * Width and Height Value of each Frame in the TexturePacker Sets
  63065. */
  63066. frameSize?: number;
  63067. /**
  63068. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63069. */
  63070. paddingRatio?: number;
  63071. /**
  63072. * Number that declares the fill method for the padding gutter.
  63073. */
  63074. paddingMode?: number;
  63075. /**
  63076. * If in SUBUV_COLOR padding mode what color to use.
  63077. */
  63078. paddingColor?: Color3 | Color4;
  63079. }
  63080. /**
  63081. * Defines the basic interface of a TexturePacker JSON File
  63082. */
  63083. export interface ITexturePackerJSON {
  63084. /**
  63085. * The frame ID
  63086. */
  63087. name: string;
  63088. /**
  63089. * The base64 channel data
  63090. */
  63091. sets: any;
  63092. /**
  63093. * The options of the Packer
  63094. */
  63095. options: ITexturePackerOptions;
  63096. /**
  63097. * The frame data of the Packer
  63098. */
  63099. frames: Array<number>;
  63100. }
  63101. /**
  63102. * This is a support class that generates a series of packed texture sets.
  63103. * @see https://doc.babylonjs.com/babylon101/materials
  63104. */
  63105. export class TexturePacker {
  63106. /** Packer Layout Constant 0 */
  63107. static readonly LAYOUT_STRIP: number;
  63108. /** Packer Layout Constant 1 */
  63109. static readonly LAYOUT_POWER2: number;
  63110. /** Packer Layout Constant 2 */
  63111. static readonly LAYOUT_COLNUM: number;
  63112. /** Packer Layout Constant 0 */
  63113. static readonly SUBUV_WRAP: number;
  63114. /** Packer Layout Constant 1 */
  63115. static readonly SUBUV_EXTEND: number;
  63116. /** Packer Layout Constant 2 */
  63117. static readonly SUBUV_COLOR: number;
  63118. /** The Name of the Texture Package */
  63119. name: string;
  63120. /** The scene scope of the TexturePacker */
  63121. scene: Scene;
  63122. /** The Meshes to target */
  63123. meshes: AbstractMesh[];
  63124. /** Arguments passed with the Constructor */
  63125. options: ITexturePackerOptions;
  63126. /** The promise that is started upon initialization */
  63127. promise: Nullable<Promise<TexturePacker | string>>;
  63128. /** The Container object for the channel sets that are generated */
  63129. sets: object;
  63130. /** The Container array for the frames that are generated */
  63131. frames: TexturePackerFrame[];
  63132. /** The expected number of textures the system is parsing. */
  63133. private _expecting;
  63134. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63135. private _paddingValue;
  63136. /**
  63137. * Initializes a texture package series from an array of meshes or a single mesh.
  63138. * @param name The name of the package
  63139. * @param meshes The target meshes to compose the package from
  63140. * @param options The arguments that texture packer should follow while building.
  63141. * @param scene The scene which the textures are scoped to.
  63142. * @returns TexturePacker
  63143. */
  63144. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63145. /**
  63146. * Starts the package process
  63147. * @param resolve The promises resolution function
  63148. * @returns TexturePacker
  63149. */
  63150. private _createFrames;
  63151. /**
  63152. * Calculates the Size of the Channel Sets
  63153. * @returns Vector2
  63154. */
  63155. private _calculateSize;
  63156. /**
  63157. * Calculates the UV data for the frames.
  63158. * @param baseSize the base frameSize
  63159. * @param padding the base frame padding
  63160. * @param dtSize size of the Dynamic Texture for that channel
  63161. * @param dtUnits is 1/dtSize
  63162. * @param update flag to update the input meshes
  63163. */
  63164. private _calculateMeshUVFrames;
  63165. /**
  63166. * Calculates the frames Offset.
  63167. * @param index of the frame
  63168. * @returns Vector2
  63169. */
  63170. private _getFrameOffset;
  63171. /**
  63172. * Updates a Mesh to the frame data
  63173. * @param mesh that is the target
  63174. * @param frameID or the frame index
  63175. */
  63176. private _updateMeshUV;
  63177. /**
  63178. * Updates a Meshes materials to use the texture packer channels
  63179. * @param m is the mesh to target
  63180. * @param force all channels on the packer to be set.
  63181. */
  63182. private _updateTextureReferences;
  63183. /**
  63184. * Public method to set a Mesh to a frame
  63185. * @param m that is the target
  63186. * @param frameID or the frame index
  63187. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63188. */
  63189. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63190. /**
  63191. * Starts the async promise to compile the texture packer.
  63192. * @returns Promise<void>
  63193. */
  63194. processAsync(): Promise<void>;
  63195. /**
  63196. * Disposes all textures associated with this packer
  63197. */
  63198. dispose(): void;
  63199. /**
  63200. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63201. * @param imageType is the image type to use.
  63202. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63203. */
  63204. download(imageType?: string, quality?: number): void;
  63205. /**
  63206. * Public method to load a texturePacker JSON file.
  63207. * @param data of the JSON file in string format.
  63208. */
  63209. updateFromJSON(data: string): void;
  63210. }
  63211. }
  63212. declare module BABYLON {
  63213. /**
  63214. * 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.
  63215. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63216. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63217. */
  63218. export class CustomProceduralTexture extends ProceduralTexture {
  63219. private _animate;
  63220. private _time;
  63221. private _config;
  63222. private _texturePath;
  63223. /**
  63224. * Instantiates a new Custom Procedural Texture.
  63225. * 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.
  63226. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63227. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63228. * @param name Define the name of the texture
  63229. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63230. * @param size Define the size of the texture to create
  63231. * @param scene Define the scene the texture belongs to
  63232. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63233. * @param generateMipMaps Define if the texture should creates mip maps or not
  63234. */
  63235. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63236. private _loadJson;
  63237. /**
  63238. * Is the texture ready to be used ? (rendered at least once)
  63239. * @returns true if ready, otherwise, false.
  63240. */
  63241. isReady(): boolean;
  63242. /**
  63243. * Render the texture to its associated render target.
  63244. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63245. */
  63246. render(useCameraPostProcess?: boolean): void;
  63247. /**
  63248. * Update the list of dependant textures samplers in the shader.
  63249. */
  63250. updateTextures(): void;
  63251. /**
  63252. * Update the uniform values of the procedural texture in the shader.
  63253. */
  63254. updateShaderUniforms(): void;
  63255. /**
  63256. * Define if the texture animates or not.
  63257. */
  63258. get animate(): boolean;
  63259. set animate(value: boolean);
  63260. }
  63261. }
  63262. declare module BABYLON {
  63263. /** @hidden */
  63264. export var noisePixelShader: {
  63265. name: string;
  63266. shader: string;
  63267. };
  63268. }
  63269. declare module BABYLON {
  63270. /**
  63271. * Class used to generate noise procedural textures
  63272. */
  63273. export class NoiseProceduralTexture extends ProceduralTexture {
  63274. /** Gets or sets the start time (default is 0) */
  63275. time: number;
  63276. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63277. brightness: number;
  63278. /** Defines the number of octaves to process */
  63279. octaves: number;
  63280. /** Defines the level of persistence (0.8 by default) */
  63281. persistence: number;
  63282. /** Gets or sets animation speed factor (default is 1) */
  63283. animationSpeedFactor: number;
  63284. /**
  63285. * Creates a new NoiseProceduralTexture
  63286. * @param name defines the name fo the texture
  63287. * @param size defines the size of the texture (default is 256)
  63288. * @param scene defines the hosting scene
  63289. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63290. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63291. */
  63292. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63293. private _updateShaderUniforms;
  63294. protected _getDefines(): string;
  63295. /** Generate the current state of the procedural texture */
  63296. render(useCameraPostProcess?: boolean): void;
  63297. /**
  63298. * Serializes this noise procedural texture
  63299. * @returns a serialized noise procedural texture object
  63300. */
  63301. serialize(): any;
  63302. /**
  63303. * Clone the texture.
  63304. * @returns the cloned texture
  63305. */
  63306. clone(): NoiseProceduralTexture;
  63307. /**
  63308. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63309. * @param parsedTexture defines parsed texture data
  63310. * @param scene defines the current scene
  63311. * @param rootUrl defines the root URL containing noise procedural texture information
  63312. * @returns a parsed NoiseProceduralTexture
  63313. */
  63314. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63315. }
  63316. }
  63317. declare module BABYLON {
  63318. /**
  63319. * Raw cube texture where the raw buffers are passed in
  63320. */
  63321. export class RawCubeTexture extends CubeTexture {
  63322. /**
  63323. * Creates a cube texture where the raw buffers are passed in.
  63324. * @param scene defines the scene the texture is attached to
  63325. * @param data defines the array of data to use to create each face
  63326. * @param size defines the size of the textures
  63327. * @param format defines the format of the data
  63328. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63329. * @param generateMipMaps defines if the engine should generate the mip levels
  63330. * @param invertY defines if data must be stored with Y axis inverted
  63331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63332. * @param compression defines the compression used (null by default)
  63333. */
  63334. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63335. /**
  63336. * Updates the raw cube texture.
  63337. * @param data defines the data to store
  63338. * @param format defines the data format
  63339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63340. * @param invertY defines if data must be stored with Y axis inverted
  63341. * @param compression defines the compression used (null by default)
  63342. * @param level defines which level of the texture to update
  63343. */
  63344. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63345. /**
  63346. * Updates a raw cube texture with RGBD encoded data.
  63347. * @param data defines the array of data [mipmap][face] to use to create each face
  63348. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63349. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63350. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63351. * @returns a promsie that resolves when the operation is complete
  63352. */
  63353. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63354. /**
  63355. * Clones the raw cube texture.
  63356. * @return a new cube texture
  63357. */
  63358. clone(): CubeTexture;
  63359. /** @hidden */
  63360. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63361. }
  63362. }
  63363. declare module BABYLON {
  63364. /**
  63365. * Class used to store 2D array textures containing user data
  63366. */
  63367. export class RawTexture2DArray extends Texture {
  63368. /** Gets or sets the texture format to use */
  63369. format: number;
  63370. /**
  63371. * Create a new RawTexture2DArray
  63372. * @param data defines the data of the texture
  63373. * @param width defines the width of the texture
  63374. * @param height defines the height of the texture
  63375. * @param depth defines the number of layers of the texture
  63376. * @param format defines the texture format to use
  63377. * @param scene defines the hosting scene
  63378. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63379. * @param invertY defines if texture must be stored with Y axis inverted
  63380. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63381. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63382. */
  63383. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63384. /** Gets or sets the texture format to use */
  63385. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63386. /**
  63387. * Update the texture with new data
  63388. * @param data defines the data to store in the texture
  63389. */
  63390. update(data: ArrayBufferView): void;
  63391. }
  63392. }
  63393. declare module BABYLON {
  63394. /**
  63395. * Class used to store 3D textures containing user data
  63396. */
  63397. export class RawTexture3D extends Texture {
  63398. /** Gets or sets the texture format to use */
  63399. format: number;
  63400. /**
  63401. * Create a new RawTexture3D
  63402. * @param data defines the data of the texture
  63403. * @param width defines the width of the texture
  63404. * @param height defines the height of the texture
  63405. * @param depth defines the depth of the texture
  63406. * @param format defines the texture format to use
  63407. * @param scene defines the hosting scene
  63408. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63409. * @param invertY defines if texture must be stored with Y axis inverted
  63410. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63411. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63412. */
  63413. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63414. /** Gets or sets the texture format to use */
  63415. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63416. /**
  63417. * Update the texture with new data
  63418. * @param data defines the data to store in the texture
  63419. */
  63420. update(data: ArrayBufferView): void;
  63421. }
  63422. }
  63423. declare module BABYLON {
  63424. /**
  63425. * Creates a refraction texture used by refraction channel of the standard material.
  63426. * It is like a mirror but to see through a material.
  63427. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63428. */
  63429. export class RefractionTexture extends RenderTargetTexture {
  63430. /**
  63431. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63432. * 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.
  63433. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63434. */
  63435. refractionPlane: Plane;
  63436. /**
  63437. * Define how deep under the surface we should see.
  63438. */
  63439. depth: number;
  63440. /**
  63441. * Creates a refraction texture used by refraction channel of the standard material.
  63442. * It is like a mirror but to see through a material.
  63443. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63444. * @param name Define the texture name
  63445. * @param size Define the size of the underlying texture
  63446. * @param scene Define the scene the refraction belongs to
  63447. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63448. */
  63449. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63450. /**
  63451. * Clone the refraction texture.
  63452. * @returns the cloned texture
  63453. */
  63454. clone(): RefractionTexture;
  63455. /**
  63456. * Serialize the texture to a JSON representation you could use in Parse later on
  63457. * @returns the serialized JSON representation
  63458. */
  63459. serialize(): any;
  63460. }
  63461. }
  63462. declare module BABYLON {
  63463. /**
  63464. * Block used to add support for vertex skinning (bones)
  63465. */
  63466. export class BonesBlock extends NodeMaterialBlock {
  63467. /**
  63468. * Creates a new BonesBlock
  63469. * @param name defines the block name
  63470. */
  63471. constructor(name: string);
  63472. /**
  63473. * Initialize the block and prepare the context for build
  63474. * @param state defines the state that will be used for the build
  63475. */
  63476. initialize(state: NodeMaterialBuildState): void;
  63477. /**
  63478. * Gets the current class name
  63479. * @returns the class name
  63480. */
  63481. getClassName(): string;
  63482. /**
  63483. * Gets the matrix indices input component
  63484. */
  63485. get matricesIndices(): NodeMaterialConnectionPoint;
  63486. /**
  63487. * Gets the matrix weights input component
  63488. */
  63489. get matricesWeights(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the extra matrix indices input component
  63492. */
  63493. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the extra matrix weights input component
  63496. */
  63497. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63498. /**
  63499. * Gets the world input component
  63500. */
  63501. get world(): NodeMaterialConnectionPoint;
  63502. /**
  63503. * Gets the output component
  63504. */
  63505. get output(): NodeMaterialConnectionPoint;
  63506. autoConfigure(material: NodeMaterial): void;
  63507. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63510. protected _buildBlock(state: NodeMaterialBuildState): this;
  63511. }
  63512. }
  63513. declare module BABYLON {
  63514. /**
  63515. * Block used to add support for instances
  63516. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63517. */
  63518. export class InstancesBlock extends NodeMaterialBlock {
  63519. /**
  63520. * Creates a new InstancesBlock
  63521. * @param name defines the block name
  63522. */
  63523. constructor(name: string);
  63524. /**
  63525. * Gets the current class name
  63526. * @returns the class name
  63527. */
  63528. getClassName(): string;
  63529. /**
  63530. * Gets the first world row input component
  63531. */
  63532. get world0(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the second world row input component
  63535. */
  63536. get world1(): NodeMaterialConnectionPoint;
  63537. /**
  63538. * Gets the third world row input component
  63539. */
  63540. get world2(): NodeMaterialConnectionPoint;
  63541. /**
  63542. * Gets the forth world row input component
  63543. */
  63544. get world3(): NodeMaterialConnectionPoint;
  63545. /**
  63546. * Gets the world input component
  63547. */
  63548. get world(): NodeMaterialConnectionPoint;
  63549. /**
  63550. * Gets the output component
  63551. */
  63552. get output(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the isntanceID component
  63555. */
  63556. get instanceID(): NodeMaterialConnectionPoint;
  63557. autoConfigure(material: NodeMaterial): void;
  63558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63559. protected _buildBlock(state: NodeMaterialBuildState): this;
  63560. }
  63561. }
  63562. declare module BABYLON {
  63563. /**
  63564. * Block used to add morph targets support to vertex shader
  63565. */
  63566. export class MorphTargetsBlock extends NodeMaterialBlock {
  63567. private _repeatableContentAnchor;
  63568. /**
  63569. * Create a new MorphTargetsBlock
  63570. * @param name defines the block name
  63571. */
  63572. constructor(name: string);
  63573. /**
  63574. * Gets the current class name
  63575. * @returns the class name
  63576. */
  63577. getClassName(): string;
  63578. /**
  63579. * Gets the position input component
  63580. */
  63581. get position(): NodeMaterialConnectionPoint;
  63582. /**
  63583. * Gets the normal input component
  63584. */
  63585. get normal(): NodeMaterialConnectionPoint;
  63586. /**
  63587. * Gets the tangent input component
  63588. */
  63589. get tangent(): NodeMaterialConnectionPoint;
  63590. /**
  63591. * Gets the tangent input component
  63592. */
  63593. get uv(): NodeMaterialConnectionPoint;
  63594. /**
  63595. * Gets the position output component
  63596. */
  63597. get positionOutput(): NodeMaterialConnectionPoint;
  63598. /**
  63599. * Gets the normal output component
  63600. */
  63601. get normalOutput(): NodeMaterialConnectionPoint;
  63602. /**
  63603. * Gets the tangent output component
  63604. */
  63605. get tangentOutput(): NodeMaterialConnectionPoint;
  63606. /**
  63607. * Gets the tangent output component
  63608. */
  63609. get uvOutput(): NodeMaterialConnectionPoint;
  63610. initialize(state: NodeMaterialBuildState): void;
  63611. autoConfigure(material: NodeMaterial): void;
  63612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63614. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63615. protected _buildBlock(state: NodeMaterialBuildState): this;
  63616. }
  63617. }
  63618. declare module BABYLON {
  63619. /**
  63620. * Block used to get data information from a light
  63621. */
  63622. export class LightInformationBlock extends NodeMaterialBlock {
  63623. private _lightDataUniformName;
  63624. private _lightColorUniformName;
  63625. private _lightTypeDefineName;
  63626. /**
  63627. * Gets or sets the light associated with this block
  63628. */
  63629. light: Nullable<Light>;
  63630. /**
  63631. * Creates a new LightInformationBlock
  63632. * @param name defines the block name
  63633. */
  63634. constructor(name: string);
  63635. /**
  63636. * Gets the current class name
  63637. * @returns the class name
  63638. */
  63639. getClassName(): string;
  63640. /**
  63641. * Gets the world position input component
  63642. */
  63643. get worldPosition(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the direction output component
  63646. */
  63647. get direction(): NodeMaterialConnectionPoint;
  63648. /**
  63649. * Gets the direction output component
  63650. */
  63651. get color(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the direction output component
  63654. */
  63655. get intensity(): NodeMaterialConnectionPoint;
  63656. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63658. protected _buildBlock(state: NodeMaterialBuildState): this;
  63659. serialize(): any;
  63660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63661. }
  63662. }
  63663. declare module BABYLON {
  63664. /**
  63665. * Block used to add image processing support to fragment shader
  63666. */
  63667. export class ImageProcessingBlock extends NodeMaterialBlock {
  63668. /**
  63669. * Create a new ImageProcessingBlock
  63670. * @param name defines the block name
  63671. */
  63672. constructor(name: string);
  63673. /**
  63674. * Gets the current class name
  63675. * @returns the class name
  63676. */
  63677. getClassName(): string;
  63678. /**
  63679. * Gets the color input component
  63680. */
  63681. get color(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the output component
  63684. */
  63685. get output(): NodeMaterialConnectionPoint;
  63686. /**
  63687. * Initialize the block and prepare the context for build
  63688. * @param state defines the state that will be used for the build
  63689. */
  63690. initialize(state: NodeMaterialBuildState): void;
  63691. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63694. protected _buildBlock(state: NodeMaterialBuildState): this;
  63695. }
  63696. }
  63697. declare module BABYLON {
  63698. /**
  63699. * Block used to pertub normals based on a normal map
  63700. */
  63701. export class PerturbNormalBlock extends NodeMaterialBlock {
  63702. private _tangentSpaceParameterName;
  63703. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63704. invertX: boolean;
  63705. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63706. invertY: boolean;
  63707. /**
  63708. * Create a new PerturbNormalBlock
  63709. * @param name defines the block name
  63710. */
  63711. constructor(name: string);
  63712. /**
  63713. * Gets the current class name
  63714. * @returns the class name
  63715. */
  63716. getClassName(): string;
  63717. /**
  63718. * Gets the world position input component
  63719. */
  63720. get worldPosition(): NodeMaterialConnectionPoint;
  63721. /**
  63722. * Gets the world normal input component
  63723. */
  63724. get worldNormal(): NodeMaterialConnectionPoint;
  63725. /**
  63726. * Gets the world tangent input component
  63727. */
  63728. get worldTangent(): NodeMaterialConnectionPoint;
  63729. /**
  63730. * Gets the uv input component
  63731. */
  63732. get uv(): NodeMaterialConnectionPoint;
  63733. /**
  63734. * Gets the normal map color input component
  63735. */
  63736. get normalMapColor(): NodeMaterialConnectionPoint;
  63737. /**
  63738. * Gets the strength input component
  63739. */
  63740. get strength(): NodeMaterialConnectionPoint;
  63741. /**
  63742. * Gets the output component
  63743. */
  63744. get output(): NodeMaterialConnectionPoint;
  63745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63747. autoConfigure(material: NodeMaterial): void;
  63748. protected _buildBlock(state: NodeMaterialBuildState): this;
  63749. protected _dumpPropertiesCode(): string;
  63750. serialize(): any;
  63751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63752. }
  63753. }
  63754. declare module BABYLON {
  63755. /**
  63756. * Block used to discard a pixel if a value is smaller than a cutoff
  63757. */
  63758. export class DiscardBlock extends NodeMaterialBlock {
  63759. /**
  63760. * Create a new DiscardBlock
  63761. * @param name defines the block name
  63762. */
  63763. constructor(name: string);
  63764. /**
  63765. * Gets the current class name
  63766. * @returns the class name
  63767. */
  63768. getClassName(): string;
  63769. /**
  63770. * Gets the color input component
  63771. */
  63772. get value(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the cutoff input component
  63775. */
  63776. get cutoff(): NodeMaterialConnectionPoint;
  63777. protected _buildBlock(state: NodeMaterialBuildState): this;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /**
  63782. * Block used to test if the fragment shader is front facing
  63783. */
  63784. export class FrontFacingBlock extends NodeMaterialBlock {
  63785. /**
  63786. * Creates a new FrontFacingBlock
  63787. * @param name defines the block name
  63788. */
  63789. constructor(name: string);
  63790. /**
  63791. * Gets the current class name
  63792. * @returns the class name
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets the output component
  63797. */
  63798. get output(): NodeMaterialConnectionPoint;
  63799. protected _buildBlock(state: NodeMaterialBuildState): this;
  63800. }
  63801. }
  63802. declare module BABYLON {
  63803. /**
  63804. * Block used to get the derivative value on x and y of a given input
  63805. */
  63806. export class DerivativeBlock extends NodeMaterialBlock {
  63807. /**
  63808. * Create a new DerivativeBlock
  63809. * @param name defines the block name
  63810. */
  63811. constructor(name: string);
  63812. /**
  63813. * Gets the current class name
  63814. * @returns the class name
  63815. */
  63816. getClassName(): string;
  63817. /**
  63818. * Gets the input component
  63819. */
  63820. get input(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the derivative output on x
  63823. */
  63824. get dx(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the derivative output on y
  63827. */
  63828. get dy(): NodeMaterialConnectionPoint;
  63829. protected _buildBlock(state: NodeMaterialBuildState): this;
  63830. }
  63831. }
  63832. declare module BABYLON {
  63833. /**
  63834. * Block used to make gl_FragCoord available
  63835. */
  63836. export class FragCoordBlock extends NodeMaterialBlock {
  63837. /**
  63838. * Creates a new FragCoordBlock
  63839. * @param name defines the block name
  63840. */
  63841. constructor(name: string);
  63842. /**
  63843. * Gets the current class name
  63844. * @returns the class name
  63845. */
  63846. getClassName(): string;
  63847. /**
  63848. * Gets the xy component
  63849. */
  63850. get xy(): NodeMaterialConnectionPoint;
  63851. /**
  63852. * Gets the xyz component
  63853. */
  63854. get xyz(): NodeMaterialConnectionPoint;
  63855. /**
  63856. * Gets the xyzw component
  63857. */
  63858. get xyzw(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the x component
  63861. */
  63862. get x(): NodeMaterialConnectionPoint;
  63863. /**
  63864. * Gets the y component
  63865. */
  63866. get y(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the z component
  63869. */
  63870. get z(): NodeMaterialConnectionPoint;
  63871. /**
  63872. * Gets the w component
  63873. */
  63874. get output(): NodeMaterialConnectionPoint;
  63875. protected writeOutputs(state: NodeMaterialBuildState): string;
  63876. protected _buildBlock(state: NodeMaterialBuildState): this;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to get the screen sizes
  63882. */
  63883. export class ScreenSizeBlock extends NodeMaterialBlock {
  63884. private _varName;
  63885. private _scene;
  63886. /**
  63887. * Creates a new ScreenSizeBlock
  63888. * @param name defines the block name
  63889. */
  63890. constructor(name: string);
  63891. /**
  63892. * Gets the current class name
  63893. * @returns the class name
  63894. */
  63895. getClassName(): string;
  63896. /**
  63897. * Gets the xy component
  63898. */
  63899. get xy(): NodeMaterialConnectionPoint;
  63900. /**
  63901. * Gets the x component
  63902. */
  63903. get x(): NodeMaterialConnectionPoint;
  63904. /**
  63905. * Gets the y component
  63906. */
  63907. get y(): NodeMaterialConnectionPoint;
  63908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63909. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63910. protected _buildBlock(state: NodeMaterialBuildState): this;
  63911. }
  63912. }
  63913. declare module BABYLON {
  63914. /**
  63915. * Block used to add support for scene fog
  63916. */
  63917. export class FogBlock extends NodeMaterialBlock {
  63918. private _fogDistanceName;
  63919. private _fogParameters;
  63920. /**
  63921. * Create a new FogBlock
  63922. * @param name defines the block name
  63923. */
  63924. constructor(name: string);
  63925. /**
  63926. * Gets the current class name
  63927. * @returns the class name
  63928. */
  63929. getClassName(): string;
  63930. /**
  63931. * Gets the world position input component
  63932. */
  63933. get worldPosition(): NodeMaterialConnectionPoint;
  63934. /**
  63935. * Gets the view input component
  63936. */
  63937. get view(): NodeMaterialConnectionPoint;
  63938. /**
  63939. * Gets the color input component
  63940. */
  63941. get input(): NodeMaterialConnectionPoint;
  63942. /**
  63943. * Gets the fog color input component
  63944. */
  63945. get fogColor(): NodeMaterialConnectionPoint;
  63946. /**
  63947. * Gets the output component
  63948. */
  63949. get output(): NodeMaterialConnectionPoint;
  63950. autoConfigure(material: NodeMaterial): void;
  63951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63953. protected _buildBlock(state: NodeMaterialBuildState): this;
  63954. }
  63955. }
  63956. declare module BABYLON {
  63957. /**
  63958. * Block used to add light in the fragment shader
  63959. */
  63960. export class LightBlock extends NodeMaterialBlock {
  63961. private _lightId;
  63962. /**
  63963. * Gets or sets the light associated with this block
  63964. */
  63965. light: Nullable<Light>;
  63966. /**
  63967. * Create a new LightBlock
  63968. * @param name defines the block name
  63969. */
  63970. constructor(name: string);
  63971. /**
  63972. * Gets the current class name
  63973. * @returns the class name
  63974. */
  63975. getClassName(): string;
  63976. /**
  63977. * Gets the world position input component
  63978. */
  63979. get worldPosition(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the world normal input component
  63982. */
  63983. get worldNormal(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the camera (or eye) position component
  63986. */
  63987. get cameraPosition(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the glossiness component
  63990. */
  63991. get glossiness(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the glossinness power component
  63994. */
  63995. get glossPower(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the diffuse color component
  63998. */
  63999. get diffuseColor(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the specular color component
  64002. */
  64003. get specularColor(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the view matrix component
  64006. */
  64007. get view(): NodeMaterialConnectionPoint;
  64008. /**
  64009. * Gets the diffuse output component
  64010. */
  64011. get diffuseOutput(): NodeMaterialConnectionPoint;
  64012. /**
  64013. * Gets the specular output component
  64014. */
  64015. get specularOutput(): NodeMaterialConnectionPoint;
  64016. /**
  64017. * Gets the shadow output component
  64018. */
  64019. get shadow(): NodeMaterialConnectionPoint;
  64020. autoConfigure(material: NodeMaterial): void;
  64021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64022. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64024. private _injectVertexCode;
  64025. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64026. serialize(): any;
  64027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64028. }
  64029. }
  64030. declare module BABYLON {
  64031. /**
  64032. * Block used to read a reflection texture from a sampler
  64033. */
  64034. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64035. /**
  64036. * Create a new ReflectionTextureBlock
  64037. * @param name defines the block name
  64038. */
  64039. constructor(name: string);
  64040. /**
  64041. * Gets the current class name
  64042. * @returns the class name
  64043. */
  64044. getClassName(): string;
  64045. /**
  64046. * Gets the world position input component
  64047. */
  64048. get position(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the world position input component
  64051. */
  64052. get worldPosition(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the world normal input component
  64055. */
  64056. get worldNormal(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the world input component
  64059. */
  64060. get world(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the camera (or eye) position component
  64063. */
  64064. get cameraPosition(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the view input component
  64067. */
  64068. get view(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the rgb output component
  64071. */
  64072. get rgb(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the rgba output component
  64075. */
  64076. get rgba(): NodeMaterialConnectionPoint;
  64077. /**
  64078. * Gets the r output component
  64079. */
  64080. get r(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the g output component
  64083. */
  64084. get g(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the b output component
  64087. */
  64088. get b(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the a output component
  64091. */
  64092. get a(): NodeMaterialConnectionPoint;
  64093. autoConfigure(material: NodeMaterial): void;
  64094. protected _buildBlock(state: NodeMaterialBuildState): this;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Block used to add 2 vectors
  64100. */
  64101. export class AddBlock extends NodeMaterialBlock {
  64102. /**
  64103. * Creates a new AddBlock
  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 left operand input component
  64114. */
  64115. get left(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the right operand input component
  64118. */
  64119. get right(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the output component
  64122. */
  64123. get output(): NodeMaterialConnectionPoint;
  64124. protected _buildBlock(state: NodeMaterialBuildState): this;
  64125. }
  64126. }
  64127. declare module BABYLON {
  64128. /**
  64129. * Block used to scale a vector by a float
  64130. */
  64131. export class ScaleBlock extends NodeMaterialBlock {
  64132. /**
  64133. * Creates a new ScaleBlock
  64134. * @param name defines the block name
  64135. */
  64136. constructor(name: string);
  64137. /**
  64138. * Gets the current class name
  64139. * @returns the class name
  64140. */
  64141. getClassName(): string;
  64142. /**
  64143. * Gets the input component
  64144. */
  64145. get input(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the factor input component
  64148. */
  64149. get factor(): NodeMaterialConnectionPoint;
  64150. /**
  64151. * Gets the output component
  64152. */
  64153. get output(): NodeMaterialConnectionPoint;
  64154. protected _buildBlock(state: NodeMaterialBuildState): this;
  64155. }
  64156. }
  64157. declare module BABYLON {
  64158. /**
  64159. * Block used to clamp a float
  64160. */
  64161. export class ClampBlock extends NodeMaterialBlock {
  64162. /** Gets or sets the minimum range */
  64163. minimum: number;
  64164. /** Gets or sets the maximum range */
  64165. maximum: number;
  64166. /**
  64167. * Creates a new ClampBlock
  64168. * @param name defines the block name
  64169. */
  64170. constructor(name: string);
  64171. /**
  64172. * Gets the current class name
  64173. * @returns the class name
  64174. */
  64175. getClassName(): string;
  64176. /**
  64177. * Gets the value input component
  64178. */
  64179. get value(): NodeMaterialConnectionPoint;
  64180. /**
  64181. * Gets the output component
  64182. */
  64183. get output(): NodeMaterialConnectionPoint;
  64184. protected _buildBlock(state: NodeMaterialBuildState): this;
  64185. protected _dumpPropertiesCode(): string;
  64186. serialize(): any;
  64187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64188. }
  64189. }
  64190. declare module BABYLON {
  64191. /**
  64192. * Block used to apply a cross product between 2 vectors
  64193. */
  64194. export class CrossBlock extends NodeMaterialBlock {
  64195. /**
  64196. * Creates a new CrossBlock
  64197. * @param name defines the block name
  64198. */
  64199. constructor(name: string);
  64200. /**
  64201. * Gets the current class name
  64202. * @returns the class name
  64203. */
  64204. getClassName(): string;
  64205. /**
  64206. * Gets the left operand input component
  64207. */
  64208. get left(): NodeMaterialConnectionPoint;
  64209. /**
  64210. * Gets the right operand input component
  64211. */
  64212. get right(): NodeMaterialConnectionPoint;
  64213. /**
  64214. * Gets the output component
  64215. */
  64216. get output(): NodeMaterialConnectionPoint;
  64217. protected _buildBlock(state: NodeMaterialBuildState): this;
  64218. }
  64219. }
  64220. declare module BABYLON {
  64221. /**
  64222. * Block used to apply a dot product between 2 vectors
  64223. */
  64224. export class DotBlock extends NodeMaterialBlock {
  64225. /**
  64226. * Creates a new DotBlock
  64227. * @param name defines the block name
  64228. */
  64229. constructor(name: string);
  64230. /**
  64231. * Gets the current class name
  64232. * @returns the class name
  64233. */
  64234. getClassName(): string;
  64235. /**
  64236. * Gets the left operand input component
  64237. */
  64238. get left(): NodeMaterialConnectionPoint;
  64239. /**
  64240. * Gets the right operand input component
  64241. */
  64242. get right(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the output component
  64245. */
  64246. get output(): NodeMaterialConnectionPoint;
  64247. protected _buildBlock(state: NodeMaterialBuildState): this;
  64248. }
  64249. }
  64250. declare module BABYLON {
  64251. /**
  64252. * Block used to normalize a vector
  64253. */
  64254. export class NormalizeBlock extends NodeMaterialBlock {
  64255. /**
  64256. * Creates a new NormalizeBlock
  64257. * @param name defines the block name
  64258. */
  64259. constructor(name: string);
  64260. /**
  64261. * Gets the current class name
  64262. * @returns the class name
  64263. */
  64264. getClassName(): string;
  64265. /**
  64266. * Gets the input component
  64267. */
  64268. get input(): NodeMaterialConnectionPoint;
  64269. /**
  64270. * Gets the output component
  64271. */
  64272. get output(): NodeMaterialConnectionPoint;
  64273. protected _buildBlock(state: NodeMaterialBuildState): this;
  64274. }
  64275. }
  64276. declare module BABYLON {
  64277. /**
  64278. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64279. */
  64280. export class ColorMergerBlock extends NodeMaterialBlock {
  64281. /**
  64282. * Create a new ColorMergerBlock
  64283. * @param name defines the block name
  64284. */
  64285. constructor(name: string);
  64286. /**
  64287. * Gets the current class name
  64288. * @returns the class name
  64289. */
  64290. getClassName(): string;
  64291. /**
  64292. * Gets the rgb component (input)
  64293. */
  64294. get rgbIn(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the r component (input)
  64297. */
  64298. get r(): NodeMaterialConnectionPoint;
  64299. /**
  64300. * Gets the g component (input)
  64301. */
  64302. get g(): NodeMaterialConnectionPoint;
  64303. /**
  64304. * Gets the b component (input)
  64305. */
  64306. get b(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the a component (input)
  64309. */
  64310. get a(): NodeMaterialConnectionPoint;
  64311. /**
  64312. * Gets the rgba component (output)
  64313. */
  64314. get rgba(): NodeMaterialConnectionPoint;
  64315. /**
  64316. * Gets the rgb component (output)
  64317. */
  64318. get rgbOut(): NodeMaterialConnectionPoint;
  64319. /**
  64320. * Gets the rgb component (output)
  64321. * @deprecated Please use rgbOut instead.
  64322. */
  64323. get rgb(): NodeMaterialConnectionPoint;
  64324. protected _buildBlock(state: NodeMaterialBuildState): this;
  64325. }
  64326. }
  64327. declare module BABYLON {
  64328. /**
  64329. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64330. */
  64331. export class VectorSplitterBlock extends NodeMaterialBlock {
  64332. /**
  64333. * Create a new VectorSplitterBlock
  64334. * @param name defines the block name
  64335. */
  64336. constructor(name: string);
  64337. /**
  64338. * Gets the current class name
  64339. * @returns the class name
  64340. */
  64341. getClassName(): string;
  64342. /**
  64343. * Gets the xyzw component (input)
  64344. */
  64345. get xyzw(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the xyz component (input)
  64348. */
  64349. get xyzIn(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the xy component (input)
  64352. */
  64353. get xyIn(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the xyz component (output)
  64356. */
  64357. get xyzOut(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the xy component (output)
  64360. */
  64361. get xyOut(): NodeMaterialConnectionPoint;
  64362. /**
  64363. * Gets the x component (output)
  64364. */
  64365. get x(): NodeMaterialConnectionPoint;
  64366. /**
  64367. * Gets the y component (output)
  64368. */
  64369. get y(): NodeMaterialConnectionPoint;
  64370. /**
  64371. * Gets the z component (output)
  64372. */
  64373. get z(): NodeMaterialConnectionPoint;
  64374. /**
  64375. * Gets the w component (output)
  64376. */
  64377. get w(): NodeMaterialConnectionPoint;
  64378. protected _inputRename(name: string): string;
  64379. protected _outputRename(name: string): string;
  64380. protected _buildBlock(state: NodeMaterialBuildState): this;
  64381. }
  64382. }
  64383. declare module BABYLON {
  64384. /**
  64385. * Block used to lerp between 2 values
  64386. */
  64387. export class LerpBlock extends NodeMaterialBlock {
  64388. /**
  64389. * Creates a new LerpBlock
  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 gradient operand input component
  64408. */
  64409. get gradient(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the output component
  64412. */
  64413. get output(): NodeMaterialConnectionPoint;
  64414. protected _buildBlock(state: NodeMaterialBuildState): this;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /**
  64419. * Block used to divide 2 vectors
  64420. */
  64421. export class DivideBlock extends NodeMaterialBlock {
  64422. /**
  64423. * Creates a new DivideBlock
  64424. * @param name defines the block name
  64425. */
  64426. constructor(name: string);
  64427. /**
  64428. * Gets the current class name
  64429. * @returns the class name
  64430. */
  64431. getClassName(): string;
  64432. /**
  64433. * Gets the left operand input component
  64434. */
  64435. get left(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the right operand input component
  64438. */
  64439. get right(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the output component
  64442. */
  64443. get output(): NodeMaterialConnectionPoint;
  64444. protected _buildBlock(state: NodeMaterialBuildState): this;
  64445. }
  64446. }
  64447. declare module BABYLON {
  64448. /**
  64449. * Block used to subtract 2 vectors
  64450. */
  64451. export class SubtractBlock extends NodeMaterialBlock {
  64452. /**
  64453. * Creates a new SubtractBlock
  64454. * @param name defines the block name
  64455. */
  64456. constructor(name: string);
  64457. /**
  64458. * Gets the current class name
  64459. * @returns the class name
  64460. */
  64461. getClassName(): string;
  64462. /**
  64463. * Gets the left operand input component
  64464. */
  64465. get left(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the right operand input component
  64468. */
  64469. get right(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the output component
  64472. */
  64473. get output(): NodeMaterialConnectionPoint;
  64474. protected _buildBlock(state: NodeMaterialBuildState): this;
  64475. }
  64476. }
  64477. declare module BABYLON {
  64478. /**
  64479. * Block used to step a value
  64480. */
  64481. export class StepBlock extends NodeMaterialBlock {
  64482. /**
  64483. * Creates a new StepBlock
  64484. * @param name defines the block name
  64485. */
  64486. constructor(name: string);
  64487. /**
  64488. * Gets the current class name
  64489. * @returns the class name
  64490. */
  64491. getClassName(): string;
  64492. /**
  64493. * Gets the value operand input component
  64494. */
  64495. get value(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the edge operand input component
  64498. */
  64499. get edge(): NodeMaterialConnectionPoint;
  64500. /**
  64501. * Gets the output component
  64502. */
  64503. get output(): NodeMaterialConnectionPoint;
  64504. protected _buildBlock(state: NodeMaterialBuildState): this;
  64505. }
  64506. }
  64507. declare module BABYLON {
  64508. /**
  64509. * Block used to get the opposite (1 - x) of a value
  64510. */
  64511. export class OneMinusBlock extends NodeMaterialBlock {
  64512. /**
  64513. * Creates a new OneMinusBlock
  64514. * @param name defines the block name
  64515. */
  64516. constructor(name: string);
  64517. /**
  64518. * Gets the current class name
  64519. * @returns the class name
  64520. */
  64521. getClassName(): string;
  64522. /**
  64523. * Gets the input component
  64524. */
  64525. get input(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the output component
  64528. */
  64529. get output(): NodeMaterialConnectionPoint;
  64530. protected _buildBlock(state: NodeMaterialBuildState): this;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * Block used to get the view direction
  64536. */
  64537. export class ViewDirectionBlock extends NodeMaterialBlock {
  64538. /**
  64539. * Creates a new ViewDirectionBlock
  64540. * @param name defines the block name
  64541. */
  64542. constructor(name: string);
  64543. /**
  64544. * Gets the current class name
  64545. * @returns the class name
  64546. */
  64547. getClassName(): string;
  64548. /**
  64549. * Gets the world position component
  64550. */
  64551. get worldPosition(): NodeMaterialConnectionPoint;
  64552. /**
  64553. * Gets the camera position component
  64554. */
  64555. get cameraPosition(): NodeMaterialConnectionPoint;
  64556. /**
  64557. * Gets the output component
  64558. */
  64559. get output(): NodeMaterialConnectionPoint;
  64560. autoConfigure(material: NodeMaterial): void;
  64561. protected _buildBlock(state: NodeMaterialBuildState): this;
  64562. }
  64563. }
  64564. declare module BABYLON {
  64565. /**
  64566. * Block used to compute fresnel value
  64567. */
  64568. export class FresnelBlock extends NodeMaterialBlock {
  64569. /**
  64570. * Create a new FresnelBlock
  64571. * @param name defines the block name
  64572. */
  64573. constructor(name: string);
  64574. /**
  64575. * Gets the current class name
  64576. * @returns the class name
  64577. */
  64578. getClassName(): string;
  64579. /**
  64580. * Gets the world normal input component
  64581. */
  64582. get worldNormal(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the view direction input component
  64585. */
  64586. get viewDirection(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the bias input component
  64589. */
  64590. get bias(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the camera (or eye) position component
  64593. */
  64594. get power(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the fresnel output component
  64597. */
  64598. get fresnel(): NodeMaterialConnectionPoint;
  64599. autoConfigure(material: NodeMaterial): void;
  64600. protected _buildBlock(state: NodeMaterialBuildState): this;
  64601. }
  64602. }
  64603. declare module BABYLON {
  64604. /**
  64605. * Block used to get the max of 2 values
  64606. */
  64607. export class MaxBlock extends NodeMaterialBlock {
  64608. /**
  64609. * Creates a new MaxBlock
  64610. * @param name defines the block name
  64611. */
  64612. constructor(name: string);
  64613. /**
  64614. * Gets the current class name
  64615. * @returns the class name
  64616. */
  64617. getClassName(): string;
  64618. /**
  64619. * Gets the left operand input component
  64620. */
  64621. get left(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the right operand input component
  64624. */
  64625. get right(): NodeMaterialConnectionPoint;
  64626. /**
  64627. * Gets the output component
  64628. */
  64629. get output(): NodeMaterialConnectionPoint;
  64630. protected _buildBlock(state: NodeMaterialBuildState): this;
  64631. }
  64632. }
  64633. declare module BABYLON {
  64634. /**
  64635. * Block used to get the min of 2 values
  64636. */
  64637. export class MinBlock extends NodeMaterialBlock {
  64638. /**
  64639. * Creates a new MinBlock
  64640. * @param name defines the block name
  64641. */
  64642. constructor(name: string);
  64643. /**
  64644. * Gets the current class name
  64645. * @returns the class name
  64646. */
  64647. getClassName(): string;
  64648. /**
  64649. * Gets the left operand input component
  64650. */
  64651. get left(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the right operand input component
  64654. */
  64655. get right(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the output component
  64658. */
  64659. get output(): NodeMaterialConnectionPoint;
  64660. protected _buildBlock(state: NodeMaterialBuildState): this;
  64661. }
  64662. }
  64663. declare module BABYLON {
  64664. /**
  64665. * Block used to get the distance between 2 values
  64666. */
  64667. export class DistanceBlock extends NodeMaterialBlock {
  64668. /**
  64669. * Creates a new DistanceBlock
  64670. * @param name defines the block name
  64671. */
  64672. constructor(name: string);
  64673. /**
  64674. * Gets the current class name
  64675. * @returns the class name
  64676. */
  64677. getClassName(): string;
  64678. /**
  64679. * Gets the left operand input component
  64680. */
  64681. get left(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the right operand input component
  64684. */
  64685. get right(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the output component
  64688. */
  64689. get output(): NodeMaterialConnectionPoint;
  64690. protected _buildBlock(state: NodeMaterialBuildState): this;
  64691. }
  64692. }
  64693. declare module BABYLON {
  64694. /**
  64695. * Block used to get the length of a vector
  64696. */
  64697. export class LengthBlock extends NodeMaterialBlock {
  64698. /**
  64699. * Creates a new LengthBlock
  64700. * @param name defines the block name
  64701. */
  64702. constructor(name: string);
  64703. /**
  64704. * Gets the current class name
  64705. * @returns the class name
  64706. */
  64707. getClassName(): string;
  64708. /**
  64709. * Gets the value input component
  64710. */
  64711. get value(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the output component
  64714. */
  64715. get output(): NodeMaterialConnectionPoint;
  64716. protected _buildBlock(state: NodeMaterialBuildState): this;
  64717. }
  64718. }
  64719. declare module BABYLON {
  64720. /**
  64721. * Block used to get negative version of a value (i.e. x * -1)
  64722. */
  64723. export class NegateBlock extends NodeMaterialBlock {
  64724. /**
  64725. * Creates a new NegateBlock
  64726. * @param name defines the block name
  64727. */
  64728. constructor(name: string);
  64729. /**
  64730. * Gets the current class name
  64731. * @returns the class name
  64732. */
  64733. getClassName(): string;
  64734. /**
  64735. * Gets the value input component
  64736. */
  64737. get value(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the output component
  64740. */
  64741. get output(): NodeMaterialConnectionPoint;
  64742. protected _buildBlock(state: NodeMaterialBuildState): this;
  64743. }
  64744. }
  64745. declare module BABYLON {
  64746. /**
  64747. * Block used to get the value of the first parameter raised to the power of the second
  64748. */
  64749. export class PowBlock extends NodeMaterialBlock {
  64750. /**
  64751. * Creates a new PowBlock
  64752. * @param name defines the block name
  64753. */
  64754. constructor(name: string);
  64755. /**
  64756. * Gets the current class name
  64757. * @returns the class name
  64758. */
  64759. getClassName(): string;
  64760. /**
  64761. * Gets the value operand input component
  64762. */
  64763. get value(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the power operand input component
  64766. */
  64767. get power(): NodeMaterialConnectionPoint;
  64768. /**
  64769. * Gets the output component
  64770. */
  64771. get output(): NodeMaterialConnectionPoint;
  64772. protected _buildBlock(state: NodeMaterialBuildState): this;
  64773. }
  64774. }
  64775. declare module BABYLON {
  64776. /**
  64777. * Block used to get a random number
  64778. */
  64779. export class RandomNumberBlock extends NodeMaterialBlock {
  64780. /**
  64781. * Creates a new RandomNumberBlock
  64782. * @param name defines the block name
  64783. */
  64784. constructor(name: string);
  64785. /**
  64786. * Gets the current class name
  64787. * @returns the class name
  64788. */
  64789. getClassName(): string;
  64790. /**
  64791. * Gets the seed input component
  64792. */
  64793. get seed(): 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 compute arc tangent of 2 values
  64804. */
  64805. export class ArcTan2Block extends NodeMaterialBlock {
  64806. /**
  64807. * Creates a new ArcTan2Block
  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 x operand input component
  64818. */
  64819. get x(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the y operand input component
  64822. */
  64823. get y(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the output component
  64826. */
  64827. get output(): NodeMaterialConnectionPoint;
  64828. protected _buildBlock(state: NodeMaterialBuildState): this;
  64829. }
  64830. }
  64831. declare module BABYLON {
  64832. /**
  64833. * Block used to smooth step a value
  64834. */
  64835. export class SmoothStepBlock extends NodeMaterialBlock {
  64836. /**
  64837. * Creates a new SmoothStepBlock
  64838. * @param name defines the block name
  64839. */
  64840. constructor(name: string);
  64841. /**
  64842. * Gets the current class name
  64843. * @returns the class name
  64844. */
  64845. getClassName(): string;
  64846. /**
  64847. * Gets the value operand input component
  64848. */
  64849. get value(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the first edge operand input component
  64852. */
  64853. get edge0(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the second edge operand input component
  64856. */
  64857. get edge1(): 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 get the reciprocal (1 / x) of a value
  64868. */
  64869. export class ReciprocalBlock extends NodeMaterialBlock {
  64870. /**
  64871. * Creates a new ReciprocalBlock
  64872. * @param name defines the block name
  64873. */
  64874. constructor(name: string);
  64875. /**
  64876. * Gets the current class name
  64877. * @returns the class name
  64878. */
  64879. getClassName(): string;
  64880. /**
  64881. * Gets the input component
  64882. */
  64883. get input(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the output component
  64886. */
  64887. get output(): NodeMaterialConnectionPoint;
  64888. protected _buildBlock(state: NodeMaterialBuildState): this;
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /**
  64893. * Block used to replace a color by another one
  64894. */
  64895. export class ReplaceColorBlock extends NodeMaterialBlock {
  64896. /**
  64897. * Creates a new ReplaceColorBlock
  64898. * @param name defines the block name
  64899. */
  64900. constructor(name: string);
  64901. /**
  64902. * Gets the current class name
  64903. * @returns the class name
  64904. */
  64905. getClassName(): string;
  64906. /**
  64907. * Gets the value input component
  64908. */
  64909. get value(): NodeMaterialConnectionPoint;
  64910. /**
  64911. * Gets the reference input component
  64912. */
  64913. get reference(): NodeMaterialConnectionPoint;
  64914. /**
  64915. * Gets the distance input component
  64916. */
  64917. get distance(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the replacement input component
  64920. */
  64921. get replacement(): NodeMaterialConnectionPoint;
  64922. /**
  64923. * Gets the output component
  64924. */
  64925. get output(): NodeMaterialConnectionPoint;
  64926. protected _buildBlock(state: NodeMaterialBuildState): this;
  64927. }
  64928. }
  64929. declare module BABYLON {
  64930. /**
  64931. * Block used to posterize a value
  64932. * @see https://en.wikipedia.org/wiki/Posterization
  64933. */
  64934. export class PosterizeBlock extends NodeMaterialBlock {
  64935. /**
  64936. * Creates a new PosterizeBlock
  64937. * @param name defines the block name
  64938. */
  64939. constructor(name: string);
  64940. /**
  64941. * Gets the current class name
  64942. * @returns the class name
  64943. */
  64944. getClassName(): string;
  64945. /**
  64946. * Gets the value input component
  64947. */
  64948. get value(): NodeMaterialConnectionPoint;
  64949. /**
  64950. * Gets the steps input component
  64951. */
  64952. get steps(): NodeMaterialConnectionPoint;
  64953. /**
  64954. * Gets the output component
  64955. */
  64956. get output(): NodeMaterialConnectionPoint;
  64957. protected _buildBlock(state: NodeMaterialBuildState): this;
  64958. }
  64959. }
  64960. declare module BABYLON {
  64961. /**
  64962. * Operations supported by the Wave block
  64963. */
  64964. export enum WaveBlockKind {
  64965. /** SawTooth */
  64966. SawTooth = 0,
  64967. /** Square */
  64968. Square = 1,
  64969. /** Triangle */
  64970. Triangle = 2
  64971. }
  64972. /**
  64973. * Block used to apply wave operation to floats
  64974. */
  64975. export class WaveBlock extends NodeMaterialBlock {
  64976. /**
  64977. * Gets or sets the kibnd of wave to be applied by the block
  64978. */
  64979. kind: WaveBlockKind;
  64980. /**
  64981. * Creates a new WaveBlock
  64982. * @param name defines the block name
  64983. */
  64984. constructor(name: string);
  64985. /**
  64986. * Gets the current class name
  64987. * @returns the class name
  64988. */
  64989. getClassName(): string;
  64990. /**
  64991. * Gets the input component
  64992. */
  64993. get input(): NodeMaterialConnectionPoint;
  64994. /**
  64995. * Gets the output component
  64996. */
  64997. get output(): NodeMaterialConnectionPoint;
  64998. protected _buildBlock(state: NodeMaterialBuildState): this;
  64999. serialize(): any;
  65000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65001. }
  65002. }
  65003. declare module BABYLON {
  65004. /**
  65005. * Class used to store a color step for the GradientBlock
  65006. */
  65007. export class GradientBlockColorStep {
  65008. private _step;
  65009. /**
  65010. * Gets value indicating which step this color is associated with (between 0 and 1)
  65011. */
  65012. get step(): number;
  65013. /**
  65014. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65015. */
  65016. set step(val: number);
  65017. private _color;
  65018. /**
  65019. * Gets the color associated with this step
  65020. */
  65021. get color(): Color3;
  65022. /**
  65023. * Sets the color associated with this step
  65024. */
  65025. set color(val: Color3);
  65026. /**
  65027. * Creates a new GradientBlockColorStep
  65028. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65029. * @param color defines the color associated with this step
  65030. */
  65031. constructor(step: number, color: Color3);
  65032. }
  65033. /**
  65034. * Block used to return a color from a gradient based on an input value between 0 and 1
  65035. */
  65036. export class GradientBlock extends NodeMaterialBlock {
  65037. /**
  65038. * Gets or sets the list of color steps
  65039. */
  65040. colorSteps: GradientBlockColorStep[];
  65041. /** Gets an observable raised when the value is changed */
  65042. onValueChangedObservable: Observable<GradientBlock>;
  65043. /** calls observable when the value is changed*/
  65044. colorStepsUpdated(): void;
  65045. /**
  65046. * Creates a new GradientBlock
  65047. * @param name defines the block name
  65048. */
  65049. constructor(name: string);
  65050. /**
  65051. * Gets the current class name
  65052. * @returns the class name
  65053. */
  65054. getClassName(): string;
  65055. /**
  65056. * Gets the gradient input component
  65057. */
  65058. get gradient(): NodeMaterialConnectionPoint;
  65059. /**
  65060. * Gets the output component
  65061. */
  65062. get output(): NodeMaterialConnectionPoint;
  65063. private _writeColorConstant;
  65064. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65065. serialize(): any;
  65066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65067. protected _dumpPropertiesCode(): string;
  65068. }
  65069. }
  65070. declare module BABYLON {
  65071. /**
  65072. * Block used to normalize lerp between 2 values
  65073. */
  65074. export class NLerpBlock extends NodeMaterialBlock {
  65075. /**
  65076. * Creates a new NLerpBlock
  65077. * @param name defines the block name
  65078. */
  65079. constructor(name: string);
  65080. /**
  65081. * Gets the current class name
  65082. * @returns the class name
  65083. */
  65084. getClassName(): string;
  65085. /**
  65086. * Gets the left operand input component
  65087. */
  65088. get left(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the right operand input component
  65091. */
  65092. get right(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the gradient operand input component
  65095. */
  65096. get gradient(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the output component
  65099. */
  65100. get output(): NodeMaterialConnectionPoint;
  65101. protected _buildBlock(state: NodeMaterialBuildState): this;
  65102. }
  65103. }
  65104. declare module BABYLON {
  65105. /**
  65106. * block used to Generate a Worley Noise 3D Noise Pattern
  65107. */
  65108. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65109. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65110. manhattanDistance: boolean;
  65111. /**
  65112. * Creates a new WorleyNoise3DBlock
  65113. * @param name defines the block name
  65114. */
  65115. constructor(name: string);
  65116. /**
  65117. * Gets the current class name
  65118. * @returns the class name
  65119. */
  65120. getClassName(): string;
  65121. /**
  65122. * Gets the seed input component
  65123. */
  65124. get seed(): NodeMaterialConnectionPoint;
  65125. /**
  65126. * Gets the jitter input component
  65127. */
  65128. get jitter(): NodeMaterialConnectionPoint;
  65129. /**
  65130. * Gets the output component
  65131. */
  65132. get output(): NodeMaterialConnectionPoint;
  65133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65134. /**
  65135. * Exposes the properties to the UI?
  65136. */
  65137. protected _dumpPropertiesCode(): string;
  65138. /**
  65139. * Exposes the properties to the Seralize?
  65140. */
  65141. serialize(): any;
  65142. /**
  65143. * Exposes the properties to the deseralize?
  65144. */
  65145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65146. }
  65147. }
  65148. declare module BABYLON {
  65149. /**
  65150. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65151. */
  65152. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65153. /**
  65154. * Creates a new SimplexPerlin3DBlock
  65155. * @param name defines the block name
  65156. */
  65157. constructor(name: string);
  65158. /**
  65159. * Gets the current class name
  65160. * @returns the class name
  65161. */
  65162. getClassName(): string;
  65163. /**
  65164. * Gets the seed operand input component
  65165. */
  65166. get seed(): NodeMaterialConnectionPoint;
  65167. /**
  65168. * Gets the output component
  65169. */
  65170. get output(): NodeMaterialConnectionPoint;
  65171. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65172. }
  65173. }
  65174. declare module BABYLON {
  65175. /**
  65176. * Block used to blend normals
  65177. */
  65178. export class NormalBlendBlock extends NodeMaterialBlock {
  65179. /**
  65180. * Creates a new NormalBlendBlock
  65181. * @param name defines the block name
  65182. */
  65183. constructor(name: string);
  65184. /**
  65185. * Gets the current class name
  65186. * @returns the class name
  65187. */
  65188. getClassName(): string;
  65189. /**
  65190. * Gets the first input component
  65191. */
  65192. get normalMap0(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the second input component
  65195. */
  65196. get normalMap1(): NodeMaterialConnectionPoint;
  65197. /**
  65198. * Gets the output component
  65199. */
  65200. get output(): NodeMaterialConnectionPoint;
  65201. protected _buildBlock(state: NodeMaterialBuildState): this;
  65202. }
  65203. }
  65204. declare module BABYLON {
  65205. /**
  65206. * Block used to rotate a 2d vector by a given angle
  65207. */
  65208. export class Rotate2dBlock extends NodeMaterialBlock {
  65209. /**
  65210. * Creates a new Rotate2dBlock
  65211. * @param name defines the block name
  65212. */
  65213. constructor(name: string);
  65214. /**
  65215. * Gets the current class name
  65216. * @returns the class name
  65217. */
  65218. getClassName(): string;
  65219. /**
  65220. * Gets the input vector
  65221. */
  65222. get input(): NodeMaterialConnectionPoint;
  65223. /**
  65224. * Gets the input angle
  65225. */
  65226. get angle(): NodeMaterialConnectionPoint;
  65227. /**
  65228. * Gets the output component
  65229. */
  65230. get output(): NodeMaterialConnectionPoint;
  65231. autoConfigure(material: NodeMaterial): void;
  65232. protected _buildBlock(state: NodeMaterialBuildState): this;
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /**
  65237. * Block used to get the reflected vector from a direction and a normal
  65238. */
  65239. export class ReflectBlock extends NodeMaterialBlock {
  65240. /**
  65241. * Creates a new ReflectBlock
  65242. * @param name defines the block name
  65243. */
  65244. constructor(name: string);
  65245. /**
  65246. * Gets the current class name
  65247. * @returns the class name
  65248. */
  65249. getClassName(): string;
  65250. /**
  65251. * Gets the incident component
  65252. */
  65253. get incident(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the normal component
  65256. */
  65257. get normal(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the output component
  65260. */
  65261. get output(): NodeMaterialConnectionPoint;
  65262. protected _buildBlock(state: NodeMaterialBuildState): this;
  65263. }
  65264. }
  65265. declare module BABYLON {
  65266. /**
  65267. * Block used to get the refracted vector from a direction and a normal
  65268. */
  65269. export class RefractBlock extends NodeMaterialBlock {
  65270. /**
  65271. * Creates a new RefractBlock
  65272. * @param name defines the block name
  65273. */
  65274. constructor(name: string);
  65275. /**
  65276. * Gets the current class name
  65277. * @returns the class name
  65278. */
  65279. getClassName(): string;
  65280. /**
  65281. * Gets the incident component
  65282. */
  65283. get incident(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the normal component
  65286. */
  65287. get normal(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the index of refraction component
  65290. */
  65291. get ior(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the output component
  65294. */
  65295. get output(): NodeMaterialConnectionPoint;
  65296. protected _buildBlock(state: NodeMaterialBuildState): this;
  65297. }
  65298. }
  65299. declare module BABYLON {
  65300. /**
  65301. * Block used to desaturate a color
  65302. */
  65303. export class DesaturateBlock extends NodeMaterialBlock {
  65304. /**
  65305. * Creates a new DesaturateBlock
  65306. * @param name defines the block name
  65307. */
  65308. constructor(name: string);
  65309. /**
  65310. * Gets the current class name
  65311. * @returns the class name
  65312. */
  65313. getClassName(): string;
  65314. /**
  65315. * Gets the color operand input component
  65316. */
  65317. get color(): NodeMaterialConnectionPoint;
  65318. /**
  65319. * Gets the level operand input component
  65320. */
  65321. get level(): NodeMaterialConnectionPoint;
  65322. /**
  65323. * Gets the output component
  65324. */
  65325. get output(): NodeMaterialConnectionPoint;
  65326. protected _buildBlock(state: NodeMaterialBuildState): this;
  65327. }
  65328. }
  65329. declare module BABYLON {
  65330. /**
  65331. * Block used to implement the ambient occlusion module of the PBR material
  65332. */
  65333. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65334. /**
  65335. * Create a new AmbientOcclusionBlock
  65336. * @param name defines the block name
  65337. */
  65338. constructor(name: string);
  65339. /**
  65340. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65341. */
  65342. useAmbientInGrayScale: boolean;
  65343. /**
  65344. * Initialize the block and prepare the context for build
  65345. * @param state defines the state that will be used for the build
  65346. */
  65347. initialize(state: NodeMaterialBuildState): void;
  65348. /**
  65349. * Gets the current class name
  65350. * @returns the class name
  65351. */
  65352. getClassName(): string;
  65353. /**
  65354. * Gets the texture input component
  65355. */
  65356. get texture(): NodeMaterialConnectionPoint;
  65357. /**
  65358. * Gets the texture intensity component
  65359. */
  65360. get intensity(): NodeMaterialConnectionPoint;
  65361. /**
  65362. * Gets the direct light intensity input component
  65363. */
  65364. get directLightIntensity(): NodeMaterialConnectionPoint;
  65365. /**
  65366. * Gets the ambient occlusion object output component
  65367. */
  65368. get ambientOcc(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the main code of the block (fragment side)
  65371. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65372. * @returns the shader code
  65373. */
  65374. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65376. protected _buildBlock(state: NodeMaterialBuildState): this;
  65377. protected _dumpPropertiesCode(): string;
  65378. serialize(): any;
  65379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65380. }
  65381. }
  65382. declare module BABYLON {
  65383. /**
  65384. * Block used to implement the reflection module of the PBR material
  65385. */
  65386. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65387. /** @hidden */
  65388. _defineLODReflectionAlpha: string;
  65389. /** @hidden */
  65390. _defineLinearSpecularReflection: string;
  65391. private _vEnvironmentIrradianceName;
  65392. /** @hidden */
  65393. _vReflectionMicrosurfaceInfosName: string;
  65394. /** @hidden */
  65395. _vReflectionInfosName: string;
  65396. /** @hidden */
  65397. _vReflectionFilteringInfoName: string;
  65398. private _scene;
  65399. /**
  65400. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65401. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65402. * It's less burden on the user side in the editor part.
  65403. */
  65404. /** @hidden */
  65405. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65406. /** @hidden */
  65407. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65408. /** @hidden */
  65409. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65410. /**
  65411. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65412. * diffuse part of the IBL.
  65413. */
  65414. useSphericalHarmonics: boolean;
  65415. /**
  65416. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65417. */
  65418. forceIrradianceInFragment: boolean;
  65419. /**
  65420. * Create a new ReflectionBlock
  65421. * @param name defines the block name
  65422. */
  65423. constructor(name: string);
  65424. /**
  65425. * Gets the current class name
  65426. * @returns the class name
  65427. */
  65428. getClassName(): string;
  65429. /**
  65430. * Gets the position input component
  65431. */
  65432. get position(): NodeMaterialConnectionPoint;
  65433. /**
  65434. * Gets the world position input component
  65435. */
  65436. get worldPosition(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the world normal input component
  65439. */
  65440. get worldNormal(): NodeMaterialConnectionPoint;
  65441. /**
  65442. * Gets the world input component
  65443. */
  65444. get world(): NodeMaterialConnectionPoint;
  65445. /**
  65446. * Gets the camera (or eye) position component
  65447. */
  65448. get cameraPosition(): NodeMaterialConnectionPoint;
  65449. /**
  65450. * Gets the view input component
  65451. */
  65452. get view(): NodeMaterialConnectionPoint;
  65453. /**
  65454. * Gets the color input component
  65455. */
  65456. get color(): NodeMaterialConnectionPoint;
  65457. /**
  65458. * Gets the reflection object output component
  65459. */
  65460. get reflection(): NodeMaterialConnectionPoint;
  65461. /**
  65462. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65463. */
  65464. get hasTexture(): boolean;
  65465. /**
  65466. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65467. */
  65468. get reflectionColor(): string;
  65469. protected _getTexture(): Nullable<BaseTexture>;
  65470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65471. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65472. /**
  65473. * Gets the code to inject in the vertex shader
  65474. * @param state current state of the node material building
  65475. * @returns the shader code
  65476. */
  65477. handleVertexSide(state: NodeMaterialBuildState): string;
  65478. /**
  65479. * Gets the main code of the block (fragment side)
  65480. * @param state current state of the node material building
  65481. * @param normalVarName name of the existing variable corresponding to the normal
  65482. * @returns the shader code
  65483. */
  65484. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65485. protected _buildBlock(state: NodeMaterialBuildState): this;
  65486. protected _dumpPropertiesCode(): string;
  65487. serialize(): any;
  65488. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65489. }
  65490. }
  65491. declare module BABYLON {
  65492. /**
  65493. * Block used to implement the sheen module of the PBR material
  65494. */
  65495. export class SheenBlock extends NodeMaterialBlock {
  65496. /**
  65497. * Create a new SheenBlock
  65498. * @param name defines the block name
  65499. */
  65500. constructor(name: string);
  65501. /**
  65502. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65503. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65504. * making it easier to setup and tweak the effect
  65505. */
  65506. albedoScaling: boolean;
  65507. /**
  65508. * Defines if the sheen is linked to the sheen color.
  65509. */
  65510. linkSheenWithAlbedo: boolean;
  65511. /**
  65512. * Initialize the block and prepare the context for build
  65513. * @param state defines the state that will be used for the build
  65514. */
  65515. initialize(state: NodeMaterialBuildState): void;
  65516. /**
  65517. * Gets the current class name
  65518. * @returns the class name
  65519. */
  65520. getClassName(): string;
  65521. /**
  65522. * Gets the intensity input component
  65523. */
  65524. get intensity(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the color input component
  65527. */
  65528. get color(): NodeMaterialConnectionPoint;
  65529. /**
  65530. * Gets the roughness input component
  65531. */
  65532. get roughness(): NodeMaterialConnectionPoint;
  65533. /**
  65534. * Gets the sheen object output component
  65535. */
  65536. get sheen(): NodeMaterialConnectionPoint;
  65537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65538. /**
  65539. * Gets the main code of the block (fragment side)
  65540. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65541. * @returns the shader code
  65542. */
  65543. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65544. protected _buildBlock(state: NodeMaterialBuildState): this;
  65545. protected _dumpPropertiesCode(): string;
  65546. serialize(): any;
  65547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65548. }
  65549. }
  65550. declare module BABYLON {
  65551. /**
  65552. * Block used to implement the reflectivity module of the PBR material
  65553. */
  65554. export class ReflectivityBlock extends NodeMaterialBlock {
  65555. private _metallicReflectanceColor;
  65556. private _metallicF0Factor;
  65557. /** @hidden */
  65558. _vMetallicReflectanceFactorsName: string;
  65559. /**
  65560. * The property below is set by the main PBR block prior to calling methods of this class.
  65561. */
  65562. /** @hidden */
  65563. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65564. /**
  65565. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65566. */
  65567. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65568. /**
  65569. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65570. */
  65571. useMetallnessFromMetallicTextureBlue: boolean;
  65572. /**
  65573. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65574. */
  65575. useRoughnessFromMetallicTextureAlpha: boolean;
  65576. /**
  65577. * Specifies if the metallic texture contains the roughness information in its green channel.
  65578. */
  65579. useRoughnessFromMetallicTextureGreen: boolean;
  65580. /**
  65581. * Create a new ReflectivityBlock
  65582. * @param name defines the block name
  65583. */
  65584. constructor(name: string);
  65585. /**
  65586. * Initialize the block and prepare the context for build
  65587. * @param state defines the state that will be used for the build
  65588. */
  65589. initialize(state: NodeMaterialBuildState): void;
  65590. /**
  65591. * Gets the current class name
  65592. * @returns the class name
  65593. */
  65594. getClassName(): string;
  65595. /**
  65596. * Gets the metallic input component
  65597. */
  65598. get metallic(): NodeMaterialConnectionPoint;
  65599. /**
  65600. * Gets the roughness input component
  65601. */
  65602. get roughness(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the texture input component
  65605. */
  65606. get texture(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the reflectivity object output component
  65609. */
  65610. get reflectivity(): NodeMaterialConnectionPoint;
  65611. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65612. /**
  65613. * Gets the main code of the block (fragment side)
  65614. * @param state current state of the node material building
  65615. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65616. * @returns the shader code
  65617. */
  65618. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65620. protected _buildBlock(state: NodeMaterialBuildState): this;
  65621. protected _dumpPropertiesCode(): string;
  65622. serialize(): any;
  65623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65624. }
  65625. }
  65626. declare module BABYLON {
  65627. /**
  65628. * Block used to implement the anisotropy module of the PBR material
  65629. */
  65630. export class AnisotropyBlock extends NodeMaterialBlock {
  65631. /**
  65632. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65633. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65634. * It's less burden on the user side in the editor part.
  65635. */
  65636. /** @hidden */
  65637. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65638. /** @hidden */
  65639. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65640. /**
  65641. * Create a new AnisotropyBlock
  65642. * @param name defines the block name
  65643. */
  65644. constructor(name: string);
  65645. /**
  65646. * Initialize the block and prepare the context for build
  65647. * @param state defines the state that will be used for the build
  65648. */
  65649. initialize(state: NodeMaterialBuildState): void;
  65650. /**
  65651. * Gets the current class name
  65652. * @returns the class name
  65653. */
  65654. getClassName(): string;
  65655. /**
  65656. * Gets the intensity input component
  65657. */
  65658. get intensity(): NodeMaterialConnectionPoint;
  65659. /**
  65660. * Gets the direction input component
  65661. */
  65662. get direction(): NodeMaterialConnectionPoint;
  65663. /**
  65664. * Gets the texture input component
  65665. */
  65666. get texture(): NodeMaterialConnectionPoint;
  65667. /**
  65668. * Gets the uv input component
  65669. */
  65670. get uv(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the worldTangent input component
  65673. */
  65674. get worldTangent(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the anisotropy object output component
  65677. */
  65678. get anisotropy(): NodeMaterialConnectionPoint;
  65679. private _generateTBNSpace;
  65680. /**
  65681. * Gets the main code of the block (fragment side)
  65682. * @param state current state of the node material building
  65683. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65684. * @returns the shader code
  65685. */
  65686. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65688. protected _buildBlock(state: NodeMaterialBuildState): this;
  65689. }
  65690. }
  65691. declare module BABYLON {
  65692. /**
  65693. * Block used to implement the clear coat module of the PBR material
  65694. */
  65695. export class ClearCoatBlock extends NodeMaterialBlock {
  65696. private _scene;
  65697. /**
  65698. * Create a new ClearCoatBlock
  65699. * @param name defines the block name
  65700. */
  65701. constructor(name: string);
  65702. /**
  65703. * Initialize the block and prepare the context for build
  65704. * @param state defines the state that will be used for the build
  65705. */
  65706. initialize(state: NodeMaterialBuildState): void;
  65707. /**
  65708. * Gets the current class name
  65709. * @returns the class name
  65710. */
  65711. getClassName(): string;
  65712. /**
  65713. * Gets the intensity input component
  65714. */
  65715. get intensity(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the roughness input component
  65718. */
  65719. get roughness(): NodeMaterialConnectionPoint;
  65720. /**
  65721. * Gets the ior input component
  65722. */
  65723. get ior(): NodeMaterialConnectionPoint;
  65724. /**
  65725. * Gets the texture input component
  65726. */
  65727. get texture(): NodeMaterialConnectionPoint;
  65728. /**
  65729. * Gets the bump texture input component
  65730. */
  65731. get bumpTexture(): NodeMaterialConnectionPoint;
  65732. /**
  65733. * Gets the uv input component
  65734. */
  65735. get uv(): NodeMaterialConnectionPoint;
  65736. /**
  65737. * Gets the tint color input component
  65738. */
  65739. get tintColor(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Gets the tint "at distance" input component
  65742. */
  65743. get tintAtDistance(): NodeMaterialConnectionPoint;
  65744. /**
  65745. * Gets the tint thickness input component
  65746. */
  65747. get tintThickness(): NodeMaterialConnectionPoint;
  65748. /**
  65749. * Gets the world tangent input component
  65750. */
  65751. get worldTangent(): NodeMaterialConnectionPoint;
  65752. /**
  65753. * Gets the clear coat object output component
  65754. */
  65755. get clearcoat(): NodeMaterialConnectionPoint;
  65756. autoConfigure(material: NodeMaterial): void;
  65757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65759. private _generateTBNSpace;
  65760. /**
  65761. * Gets the main code of the block (fragment side)
  65762. * @param state current state of the node material building
  65763. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65764. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65765. * @param worldPosVarName name of the variable holding the world position
  65766. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65767. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65768. * @param worldNormalVarName name of the variable holding the world normal
  65769. * @returns the shader code
  65770. */
  65771. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65772. protected _buildBlock(state: NodeMaterialBuildState): this;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /**
  65777. * Block used to implement the sub surface module of the PBR material
  65778. */
  65779. export class SubSurfaceBlock extends NodeMaterialBlock {
  65780. /**
  65781. * Create a new SubSurfaceBlock
  65782. * @param name defines the block name
  65783. */
  65784. constructor(name: string);
  65785. /**
  65786. * Stores the intensity of the different subsurface effects in the thickness texture.
  65787. * * the green channel is the translucency intensity.
  65788. * * the blue channel is the scattering intensity.
  65789. * * the alpha channel is the refraction intensity.
  65790. */
  65791. useMaskFromThicknessTexture: boolean;
  65792. /**
  65793. * Initialize the block and prepare the context for build
  65794. * @param state defines the state that will be used for the build
  65795. */
  65796. initialize(state: NodeMaterialBuildState): void;
  65797. /**
  65798. * Gets the current class name
  65799. * @returns the class name
  65800. */
  65801. getClassName(): string;
  65802. /**
  65803. * Gets the min thickness input component
  65804. */
  65805. get minThickness(): NodeMaterialConnectionPoint;
  65806. /**
  65807. * Gets the max thickness input component
  65808. */
  65809. get maxThickness(): NodeMaterialConnectionPoint;
  65810. /**
  65811. * Gets the thickness texture component
  65812. */
  65813. get thicknessTexture(): NodeMaterialConnectionPoint;
  65814. /**
  65815. * Gets the tint color input component
  65816. */
  65817. get tintColor(): NodeMaterialConnectionPoint;
  65818. /**
  65819. * Gets the translucency intensity input component
  65820. */
  65821. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65822. /**
  65823. * Gets the translucency diffusion distance input component
  65824. */
  65825. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65826. /**
  65827. * Gets the refraction object parameters
  65828. */
  65829. get refraction(): NodeMaterialConnectionPoint;
  65830. /**
  65831. * Gets the sub surface object output component
  65832. */
  65833. get subsurface(): NodeMaterialConnectionPoint;
  65834. autoConfigure(material: NodeMaterial): void;
  65835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65836. /**
  65837. * Gets the main code of the block (fragment side)
  65838. * @param state current state of the node material building
  65839. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65840. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65841. * @param worldPosVarName name of the variable holding the world position
  65842. * @returns the shader code
  65843. */
  65844. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65845. protected _buildBlock(state: NodeMaterialBuildState): this;
  65846. }
  65847. }
  65848. declare module BABYLON {
  65849. /**
  65850. * Block used to implement the PBR metallic/roughness model
  65851. */
  65852. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65853. /**
  65854. * Gets or sets the light associated with this block
  65855. */
  65856. light: Nullable<Light>;
  65857. private _lightId;
  65858. private _scene;
  65859. private _environmentBRDFTexture;
  65860. private _environmentBrdfSamplerName;
  65861. private _vNormalWName;
  65862. private _invertNormalName;
  65863. /**
  65864. * Create a new ReflectionBlock
  65865. * @param name defines the block name
  65866. */
  65867. constructor(name: string);
  65868. /**
  65869. * Intensity of the direct lights e.g. the four lights available in your scene.
  65870. * This impacts both the direct diffuse and specular highlights.
  65871. */
  65872. directIntensity: number;
  65873. /**
  65874. * Intensity of the environment e.g. how much the environment will light the object
  65875. * either through harmonics for rough material or through the refelction for shiny ones.
  65876. */
  65877. environmentIntensity: number;
  65878. /**
  65879. * This is a special control allowing the reduction of the specular highlights coming from the
  65880. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65881. */
  65882. specularIntensity: number;
  65883. /**
  65884. * Defines the falloff type used in this material.
  65885. * It by default is Physical.
  65886. */
  65887. lightFalloff: number;
  65888. /**
  65889. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65890. */
  65891. useAlphaFromAlbedoTexture: boolean;
  65892. /**
  65893. * Specifies that alpha test should be used
  65894. */
  65895. useAlphaTest: boolean;
  65896. /**
  65897. * Defines the alpha limits in alpha test mode.
  65898. */
  65899. alphaTestCutoff: number;
  65900. /**
  65901. * Specifies that alpha blending should be used
  65902. */
  65903. useAlphaBlending: boolean;
  65904. /**
  65905. * Defines if the alpha value should be determined via the rgb values.
  65906. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65907. */
  65908. opacityRGB: boolean;
  65909. /**
  65910. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65911. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65912. */
  65913. useRadianceOverAlpha: boolean;
  65914. /**
  65915. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65916. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65917. */
  65918. useSpecularOverAlpha: boolean;
  65919. /**
  65920. * Enables specular anti aliasing in the PBR shader.
  65921. * It will both interacts on the Geometry for analytical and IBL lighting.
  65922. * It also prefilter the roughness map based on the bump values.
  65923. */
  65924. enableSpecularAntiAliasing: boolean;
  65925. /**
  65926. * Enables realtime filtering on the texture.
  65927. */
  65928. realTimeFiltering: boolean;
  65929. /**
  65930. * Quality switch for realtime filtering
  65931. */
  65932. realTimeFilteringQuality: number;
  65933. /**
  65934. * Defines if the material uses energy conservation.
  65935. */
  65936. useEnergyConservation: boolean;
  65937. /**
  65938. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65939. * too much the area relying on ambient texture to define their ambient occlusion.
  65940. */
  65941. useRadianceOcclusion: boolean;
  65942. /**
  65943. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65944. * makes the reflect vector face the model (under horizon).
  65945. */
  65946. useHorizonOcclusion: boolean;
  65947. /**
  65948. * If set to true, no lighting calculations will be applied.
  65949. */
  65950. unlit: boolean;
  65951. /**
  65952. * Force normal to face away from face.
  65953. */
  65954. forceNormalForward: boolean;
  65955. /**
  65956. * Defines the material debug mode.
  65957. * It helps seeing only some components of the material while troubleshooting.
  65958. */
  65959. debugMode: number;
  65960. /**
  65961. * Specify from where on screen the debug mode should start.
  65962. * The value goes from -1 (full screen) to 1 (not visible)
  65963. * It helps with side by side comparison against the final render
  65964. * This defaults to 0
  65965. */
  65966. debugLimit: number;
  65967. /**
  65968. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65969. * You can use the factor to better multiply the final value.
  65970. */
  65971. debugFactor: number;
  65972. /**
  65973. * Initialize the block and prepare the context for build
  65974. * @param state defines the state that will be used for the build
  65975. */
  65976. initialize(state: NodeMaterialBuildState): void;
  65977. /**
  65978. * Gets the current class name
  65979. * @returns the class name
  65980. */
  65981. getClassName(): string;
  65982. /**
  65983. * Gets the world position input component
  65984. */
  65985. get worldPosition(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the world normal input component
  65988. */
  65989. get worldNormal(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the perturbed normal input component
  65992. */
  65993. get perturbedNormal(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the camera position input component
  65996. */
  65997. get cameraPosition(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the base color input component
  66000. */
  66001. get baseColor(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the opacity texture input component
  66004. */
  66005. get opacityTexture(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the ambient color input component
  66008. */
  66009. get ambientColor(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the reflectivity object parameters
  66012. */
  66013. get reflectivity(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the ambient occlusion object parameters
  66016. */
  66017. get ambientOcc(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the reflection object parameters
  66020. */
  66021. get reflection(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the sheen object parameters
  66024. */
  66025. get sheen(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the clear coat object parameters
  66028. */
  66029. get clearcoat(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the sub surface object parameters
  66032. */
  66033. get subsurface(): NodeMaterialConnectionPoint;
  66034. /**
  66035. * Gets the anisotropy object parameters
  66036. */
  66037. get anisotropy(): NodeMaterialConnectionPoint;
  66038. /**
  66039. * Gets the view matrix parameter
  66040. */
  66041. get view(): NodeMaterialConnectionPoint;
  66042. /**
  66043. * Gets the ambient output component
  66044. */
  66045. get ambient(): NodeMaterialConnectionPoint;
  66046. /**
  66047. * Gets the diffuse output component
  66048. */
  66049. get diffuse(): NodeMaterialConnectionPoint;
  66050. /**
  66051. * Gets the specular output component
  66052. */
  66053. get specular(): NodeMaterialConnectionPoint;
  66054. /**
  66055. * Gets the sheen output component
  66056. */
  66057. get sheenDir(): NodeMaterialConnectionPoint;
  66058. /**
  66059. * Gets the clear coat output component
  66060. */
  66061. get clearcoatDir(): NodeMaterialConnectionPoint;
  66062. /**
  66063. * Gets the indirect diffuse output component
  66064. */
  66065. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66066. /**
  66067. * Gets the indirect specular output component
  66068. */
  66069. get specularIndirect(): NodeMaterialConnectionPoint;
  66070. /**
  66071. * Gets the indirect sheen output component
  66072. */
  66073. get sheenIndirect(): NodeMaterialConnectionPoint;
  66074. /**
  66075. * Gets the indirect clear coat output component
  66076. */
  66077. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the refraction output component
  66080. */
  66081. get refraction(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the global lighting output component
  66084. */
  66085. get lighting(): NodeMaterialConnectionPoint;
  66086. /**
  66087. * Gets the shadow output component
  66088. */
  66089. get shadow(): NodeMaterialConnectionPoint;
  66090. /**
  66091. * Gets the alpha output component
  66092. */
  66093. get alpha(): NodeMaterialConnectionPoint;
  66094. autoConfigure(material: NodeMaterial): void;
  66095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66096. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66098. private _injectVertexCode;
  66099. /**
  66100. * Gets the code corresponding to the albedo/opacity module
  66101. * @returns the shader code
  66102. */
  66103. getAlbedoOpacityCode(): string;
  66104. protected _buildBlock(state: NodeMaterialBuildState): this;
  66105. protected _dumpPropertiesCode(): string;
  66106. serialize(): any;
  66107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66108. }
  66109. }
  66110. declare module BABYLON {
  66111. /**
  66112. * Block used to compute value of one parameter modulo another
  66113. */
  66114. export class ModBlock extends NodeMaterialBlock {
  66115. /**
  66116. * Creates a new ModBlock
  66117. * @param name defines the block name
  66118. */
  66119. constructor(name: string);
  66120. /**
  66121. * Gets the current class name
  66122. * @returns the class name
  66123. */
  66124. getClassName(): string;
  66125. /**
  66126. * Gets the left operand input component
  66127. */
  66128. get left(): NodeMaterialConnectionPoint;
  66129. /**
  66130. * Gets the right operand input component
  66131. */
  66132. get right(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the output component
  66135. */
  66136. get output(): NodeMaterialConnectionPoint;
  66137. protected _buildBlock(state: NodeMaterialBuildState): this;
  66138. }
  66139. }
  66140. declare module BABYLON {
  66141. /**
  66142. * Configuration for Draco compression
  66143. */
  66144. export interface IDracoCompressionConfiguration {
  66145. /**
  66146. * Configuration for the decoder.
  66147. */
  66148. decoder: {
  66149. /**
  66150. * The url to the WebAssembly module.
  66151. */
  66152. wasmUrl?: string;
  66153. /**
  66154. * The url to the WebAssembly binary.
  66155. */
  66156. wasmBinaryUrl?: string;
  66157. /**
  66158. * The url to the fallback JavaScript module.
  66159. */
  66160. fallbackUrl?: string;
  66161. };
  66162. }
  66163. /**
  66164. * Draco compression (https://google.github.io/draco/)
  66165. *
  66166. * This class wraps the Draco module.
  66167. *
  66168. * **Encoder**
  66169. *
  66170. * The encoder is not currently implemented.
  66171. *
  66172. * **Decoder**
  66173. *
  66174. * 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.
  66175. *
  66176. * To update the configuration, use the following code:
  66177. * ```javascript
  66178. * DracoCompression.Configuration = {
  66179. * decoder: {
  66180. * wasmUrl: "<url to the WebAssembly library>",
  66181. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66182. * fallbackUrl: "<url to the fallback JavaScript library>",
  66183. * }
  66184. * };
  66185. * ```
  66186. *
  66187. * 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.
  66188. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66189. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66190. *
  66191. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66192. * ```javascript
  66193. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66194. * ```
  66195. *
  66196. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66197. */
  66198. export class DracoCompression implements IDisposable {
  66199. private _workerPoolPromise?;
  66200. private _decoderModulePromise?;
  66201. /**
  66202. * The configuration. Defaults to the following urls:
  66203. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66204. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66205. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66206. */
  66207. static Configuration: IDracoCompressionConfiguration;
  66208. /**
  66209. * Returns true if the decoder configuration is available.
  66210. */
  66211. static get DecoderAvailable(): boolean;
  66212. /**
  66213. * Default number of workers to create when creating the draco compression object.
  66214. */
  66215. static DefaultNumWorkers: number;
  66216. private static GetDefaultNumWorkers;
  66217. private static _Default;
  66218. /**
  66219. * Default instance for the draco compression object.
  66220. */
  66221. static get Default(): DracoCompression;
  66222. /**
  66223. * Constructor
  66224. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66225. */
  66226. constructor(numWorkers?: number);
  66227. /**
  66228. * Stop all async operations and release resources.
  66229. */
  66230. dispose(): void;
  66231. /**
  66232. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66233. * @returns a promise that resolves when ready
  66234. */
  66235. whenReadyAsync(): Promise<void>;
  66236. /**
  66237. * Decode Draco compressed mesh data to vertex data.
  66238. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66239. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66240. * @returns A promise that resolves with the decoded vertex data
  66241. */
  66242. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66243. [kind: string]: number;
  66244. }): Promise<VertexData>;
  66245. }
  66246. }
  66247. declare module BABYLON {
  66248. /**
  66249. * Class for building Constructive Solid Geometry
  66250. */
  66251. export class CSG {
  66252. private polygons;
  66253. /**
  66254. * The world matrix
  66255. */
  66256. matrix: Matrix;
  66257. /**
  66258. * Stores the position
  66259. */
  66260. position: Vector3;
  66261. /**
  66262. * Stores the rotation
  66263. */
  66264. rotation: Vector3;
  66265. /**
  66266. * Stores the rotation quaternion
  66267. */
  66268. rotationQuaternion: Nullable<Quaternion>;
  66269. /**
  66270. * Stores the scaling vector
  66271. */
  66272. scaling: Vector3;
  66273. /**
  66274. * Convert the Mesh to CSG
  66275. * @param mesh The Mesh to convert to CSG
  66276. * @returns A new CSG from the Mesh
  66277. */
  66278. static FromMesh(mesh: Mesh): CSG;
  66279. /**
  66280. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66281. * @param polygons Polygons used to construct a CSG solid
  66282. */
  66283. private static FromPolygons;
  66284. /**
  66285. * Clones, or makes a deep copy, of the CSG
  66286. * @returns A new CSG
  66287. */
  66288. clone(): CSG;
  66289. /**
  66290. * Unions this CSG with another CSG
  66291. * @param csg The CSG to union against this CSG
  66292. * @returns The unioned CSG
  66293. */
  66294. union(csg: CSG): CSG;
  66295. /**
  66296. * Unions this CSG with another CSG in place
  66297. * @param csg The CSG to union against this CSG
  66298. */
  66299. unionInPlace(csg: CSG): void;
  66300. /**
  66301. * Subtracts this CSG with another CSG
  66302. * @param csg The CSG to subtract against this CSG
  66303. * @returns A new CSG
  66304. */
  66305. subtract(csg: CSG): CSG;
  66306. /**
  66307. * Subtracts this CSG with another CSG in place
  66308. * @param csg The CSG to subtact against this CSG
  66309. */
  66310. subtractInPlace(csg: CSG): void;
  66311. /**
  66312. * Intersect this CSG with another CSG
  66313. * @param csg The CSG to intersect against this CSG
  66314. * @returns A new CSG
  66315. */
  66316. intersect(csg: CSG): CSG;
  66317. /**
  66318. * Intersects this CSG with another CSG in place
  66319. * @param csg The CSG to intersect against this CSG
  66320. */
  66321. intersectInPlace(csg: CSG): void;
  66322. /**
  66323. * Return a new CSG solid with solid and empty space switched. This solid is
  66324. * not modified.
  66325. * @returns A new CSG solid with solid and empty space switched
  66326. */
  66327. inverse(): CSG;
  66328. /**
  66329. * Inverses the CSG in place
  66330. */
  66331. inverseInPlace(): void;
  66332. /**
  66333. * This is used to keep meshes transformations so they can be restored
  66334. * when we build back a Babylon Mesh
  66335. * NB : All CSG operations are performed in world coordinates
  66336. * @param csg The CSG to copy the transform attributes from
  66337. * @returns This CSG
  66338. */
  66339. copyTransformAttributes(csg: CSG): CSG;
  66340. /**
  66341. * Build Raw mesh from CSG
  66342. * Coordinates here are in world space
  66343. * @param name The name of the mesh geometry
  66344. * @param scene The Scene
  66345. * @param keepSubMeshes Specifies if the submeshes should be kept
  66346. * @returns A new Mesh
  66347. */
  66348. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66349. /**
  66350. * Build Mesh from CSG taking material and transforms into account
  66351. * @param name The name of the Mesh
  66352. * @param material The material of the Mesh
  66353. * @param scene The Scene
  66354. * @param keepSubMeshes Specifies if submeshes should be kept
  66355. * @returns The new Mesh
  66356. */
  66357. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66358. }
  66359. }
  66360. declare module BABYLON {
  66361. /**
  66362. * Class used to create a trail following a mesh
  66363. */
  66364. export class TrailMesh extends Mesh {
  66365. private _generator;
  66366. private _autoStart;
  66367. private _running;
  66368. private _diameter;
  66369. private _length;
  66370. private _sectionPolygonPointsCount;
  66371. private _sectionVectors;
  66372. private _sectionNormalVectors;
  66373. private _beforeRenderObserver;
  66374. /**
  66375. * @constructor
  66376. * @param name The value used by scene.getMeshByName() to do a lookup.
  66377. * @param generator The mesh or transform node to generate a trail.
  66378. * @param scene The scene to add this mesh to.
  66379. * @param diameter Diameter of trailing mesh. Default is 1.
  66380. * @param length Length of trailing mesh. Default is 60.
  66381. * @param autoStart Automatically start trailing mesh. Default true.
  66382. */
  66383. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66384. /**
  66385. * "TrailMesh"
  66386. * @returns "TrailMesh"
  66387. */
  66388. getClassName(): string;
  66389. private _createMesh;
  66390. /**
  66391. * Start trailing mesh.
  66392. */
  66393. start(): void;
  66394. /**
  66395. * Stop trailing mesh.
  66396. */
  66397. stop(): void;
  66398. /**
  66399. * Update trailing mesh geometry.
  66400. */
  66401. update(): void;
  66402. /**
  66403. * Returns a new TrailMesh object.
  66404. * @param name is a string, the name given to the new mesh
  66405. * @param newGenerator use new generator object for cloned trail mesh
  66406. * @returns a new mesh
  66407. */
  66408. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66409. /**
  66410. * Serializes this trail mesh
  66411. * @param serializationObject object to write serialization to
  66412. */
  66413. serialize(serializationObject: any): void;
  66414. /**
  66415. * Parses a serialized trail mesh
  66416. * @param parsedMesh the serialized mesh
  66417. * @param scene the scene to create the trail mesh in
  66418. * @returns the created trail mesh
  66419. */
  66420. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66421. }
  66422. }
  66423. declare module BABYLON {
  66424. /**
  66425. * Class containing static functions to help procedurally build meshes
  66426. */
  66427. export class TiledBoxBuilder {
  66428. /**
  66429. * Creates a box mesh
  66430. * 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)
  66431. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66433. * * 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
  66434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66435. * @param name defines the name of the mesh
  66436. * @param options defines the options used to create the mesh
  66437. * @param scene defines the hosting scene
  66438. * @returns the box mesh
  66439. */
  66440. static CreateTiledBox(name: string, options: {
  66441. pattern?: number;
  66442. width?: number;
  66443. height?: number;
  66444. depth?: number;
  66445. tileSize?: number;
  66446. tileWidth?: number;
  66447. tileHeight?: number;
  66448. alignHorizontal?: number;
  66449. alignVertical?: number;
  66450. faceUV?: Vector4[];
  66451. faceColors?: Color4[];
  66452. sideOrientation?: number;
  66453. updatable?: boolean;
  66454. }, scene?: Nullable<Scene>): Mesh;
  66455. }
  66456. }
  66457. declare module BABYLON {
  66458. /**
  66459. * Class containing static functions to help procedurally build meshes
  66460. */
  66461. export class TorusKnotBuilder {
  66462. /**
  66463. * Creates a torus knot mesh
  66464. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66465. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66466. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66467. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66469. * * 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
  66470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66471. * @param name defines the name of the mesh
  66472. * @param options defines the options used to create the mesh
  66473. * @param scene defines the hosting scene
  66474. * @returns the torus knot mesh
  66475. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66476. */
  66477. static CreateTorusKnot(name: string, options: {
  66478. radius?: number;
  66479. tube?: number;
  66480. radialSegments?: number;
  66481. tubularSegments?: number;
  66482. p?: number;
  66483. q?: number;
  66484. updatable?: boolean;
  66485. sideOrientation?: number;
  66486. frontUVs?: Vector4;
  66487. backUVs?: Vector4;
  66488. }, scene: any): Mesh;
  66489. }
  66490. }
  66491. declare module BABYLON {
  66492. /**
  66493. * Polygon
  66494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66495. */
  66496. export class Polygon {
  66497. /**
  66498. * Creates a rectangle
  66499. * @param xmin bottom X coord
  66500. * @param ymin bottom Y coord
  66501. * @param xmax top X coord
  66502. * @param ymax top Y coord
  66503. * @returns points that make the resulting rectation
  66504. */
  66505. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66506. /**
  66507. * Creates a circle
  66508. * @param radius radius of circle
  66509. * @param cx scale in x
  66510. * @param cy scale in y
  66511. * @param numberOfSides number of sides that make up the circle
  66512. * @returns points that make the resulting circle
  66513. */
  66514. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66515. /**
  66516. * Creates a polygon from input string
  66517. * @param input Input polygon data
  66518. * @returns the parsed points
  66519. */
  66520. static Parse(input: string): Vector2[];
  66521. /**
  66522. * Starts building a polygon from x and y coordinates
  66523. * @param x x coordinate
  66524. * @param y y coordinate
  66525. * @returns the started path2
  66526. */
  66527. static StartingAt(x: number, y: number): Path2;
  66528. }
  66529. /**
  66530. * Builds a polygon
  66531. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66532. */
  66533. export class PolygonMeshBuilder {
  66534. private _points;
  66535. private _outlinepoints;
  66536. private _holes;
  66537. private _name;
  66538. private _scene;
  66539. private _epoints;
  66540. private _eholes;
  66541. private _addToepoint;
  66542. /**
  66543. * Babylon reference to the earcut plugin.
  66544. */
  66545. bjsEarcut: any;
  66546. /**
  66547. * Creates a PolygonMeshBuilder
  66548. * @param name name of the builder
  66549. * @param contours Path of the polygon
  66550. * @param scene scene to add to when creating the mesh
  66551. * @param earcutInjection can be used to inject your own earcut reference
  66552. */
  66553. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66554. /**
  66555. * Adds a whole within the polygon
  66556. * @param hole Array of points defining the hole
  66557. * @returns this
  66558. */
  66559. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66560. /**
  66561. * Creates the polygon
  66562. * @param updatable If the mesh should be updatable
  66563. * @param depth The depth of the mesh created
  66564. * @returns the created mesh
  66565. */
  66566. build(updatable?: boolean, depth?: number): Mesh;
  66567. /**
  66568. * Creates the polygon
  66569. * @param depth The depth of the mesh created
  66570. * @returns the created VertexData
  66571. */
  66572. buildVertexData(depth?: number): VertexData;
  66573. /**
  66574. * Adds a side to the polygon
  66575. * @param positions points that make the polygon
  66576. * @param normals normals of the polygon
  66577. * @param uvs uvs of the polygon
  66578. * @param indices indices of the polygon
  66579. * @param bounds bounds of the polygon
  66580. * @param points points of the polygon
  66581. * @param depth depth of the polygon
  66582. * @param flip flip of the polygon
  66583. */
  66584. private addSide;
  66585. }
  66586. }
  66587. declare module BABYLON {
  66588. /**
  66589. * Class containing static functions to help procedurally build meshes
  66590. */
  66591. export class PolygonBuilder {
  66592. /**
  66593. * Creates a polygon mesh
  66594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66595. * * 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
  66596. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66598. * * 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)
  66599. * * Remember you can only change the shape positions, not their number when updating a polygon
  66600. * @param name defines the name of the mesh
  66601. * @param options defines the options used to create the mesh
  66602. * @param scene defines the hosting scene
  66603. * @param earcutInjection can be used to inject your own earcut reference
  66604. * @returns the polygon mesh
  66605. */
  66606. static CreatePolygon(name: string, options: {
  66607. shape: Vector3[];
  66608. holes?: Vector3[][];
  66609. depth?: number;
  66610. faceUV?: Vector4[];
  66611. faceColors?: Color4[];
  66612. updatable?: boolean;
  66613. sideOrientation?: number;
  66614. frontUVs?: Vector4;
  66615. backUVs?: Vector4;
  66616. wrap?: boolean;
  66617. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66618. /**
  66619. * Creates an extruded polygon mesh, with depth in the Y direction.
  66620. * * 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)
  66621. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66622. * @param name defines the name of the mesh
  66623. * @param options defines the options used to create the mesh
  66624. * @param scene defines the hosting scene
  66625. * @param earcutInjection can be used to inject your own earcut reference
  66626. * @returns the polygon mesh
  66627. */
  66628. static ExtrudePolygon(name: string, options: {
  66629. shape: Vector3[];
  66630. holes?: Vector3[][];
  66631. depth?: number;
  66632. faceUV?: Vector4[];
  66633. faceColors?: Color4[];
  66634. updatable?: boolean;
  66635. sideOrientation?: number;
  66636. frontUVs?: Vector4;
  66637. backUVs?: Vector4;
  66638. wrap?: boolean;
  66639. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66640. }
  66641. }
  66642. declare module BABYLON {
  66643. /**
  66644. * Class containing static functions to help procedurally build meshes
  66645. */
  66646. export class LatheBuilder {
  66647. /**
  66648. * Creates lathe mesh.
  66649. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66650. * * 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
  66651. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66652. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66653. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66654. * * 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
  66655. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66656. * * 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
  66657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66658. * * 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
  66659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66661. * @param name defines the name of the mesh
  66662. * @param options defines the options used to create the mesh
  66663. * @param scene defines the hosting scene
  66664. * @returns the lathe mesh
  66665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66666. */
  66667. static CreateLathe(name: string, options: {
  66668. shape: Vector3[];
  66669. radius?: number;
  66670. tessellation?: number;
  66671. clip?: number;
  66672. arc?: number;
  66673. closed?: boolean;
  66674. updatable?: boolean;
  66675. sideOrientation?: number;
  66676. frontUVs?: Vector4;
  66677. backUVs?: Vector4;
  66678. cap?: number;
  66679. invertUV?: boolean;
  66680. }, scene?: Nullable<Scene>): Mesh;
  66681. }
  66682. }
  66683. declare module BABYLON {
  66684. /**
  66685. * Class containing static functions to help procedurally build meshes
  66686. */
  66687. export class TiledPlaneBuilder {
  66688. /**
  66689. * Creates a tiled plane mesh
  66690. * * The parameter `pattern` will, depending on value, do nothing or
  66691. * * * flip (reflect about central vertical) alternate tiles across and up
  66692. * * * flip every tile on alternate rows
  66693. * * * rotate (180 degs) alternate tiles across and up
  66694. * * * rotate every tile on alternate rows
  66695. * * * flip and rotate alternate tiles across and up
  66696. * * * flip and rotate every tile on alternate rows
  66697. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66698. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66699. * * 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
  66700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66701. * * 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)
  66702. * * 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)
  66703. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66704. * @param name defines the name of the mesh
  66705. * @param options defines the options used to create the mesh
  66706. * @param scene defines the hosting scene
  66707. * @returns the box mesh
  66708. */
  66709. static CreateTiledPlane(name: string, options: {
  66710. pattern?: number;
  66711. tileSize?: number;
  66712. tileWidth?: number;
  66713. tileHeight?: number;
  66714. size?: number;
  66715. width?: number;
  66716. height?: number;
  66717. alignHorizontal?: number;
  66718. alignVertical?: number;
  66719. sideOrientation?: number;
  66720. frontUVs?: Vector4;
  66721. backUVs?: Vector4;
  66722. updatable?: boolean;
  66723. }, scene?: Nullable<Scene>): Mesh;
  66724. }
  66725. }
  66726. declare module BABYLON {
  66727. /**
  66728. * Class containing static functions to help procedurally build meshes
  66729. */
  66730. export class TubeBuilder {
  66731. /**
  66732. * Creates a tube mesh.
  66733. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66734. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66735. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66736. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66737. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66738. * * 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)
  66739. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66740. * * 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
  66741. * * 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
  66742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66743. * * 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
  66744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66746. * @param name defines the name of the mesh
  66747. * @param options defines the options used to create the mesh
  66748. * @param scene defines the hosting scene
  66749. * @returns the tube mesh
  66750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66751. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66752. */
  66753. static CreateTube(name: string, options: {
  66754. path: Vector3[];
  66755. radius?: number;
  66756. tessellation?: number;
  66757. radiusFunction?: {
  66758. (i: number, distance: number): number;
  66759. };
  66760. cap?: number;
  66761. arc?: number;
  66762. updatable?: boolean;
  66763. sideOrientation?: number;
  66764. frontUVs?: Vector4;
  66765. backUVs?: Vector4;
  66766. instance?: Mesh;
  66767. invertUV?: boolean;
  66768. }, scene?: Nullable<Scene>): Mesh;
  66769. }
  66770. }
  66771. declare module BABYLON {
  66772. /**
  66773. * Class containing static functions to help procedurally build meshes
  66774. */
  66775. export class IcoSphereBuilder {
  66776. /**
  66777. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66778. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66779. * * 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`)
  66780. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66781. * * 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
  66782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66783. * * 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
  66784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66785. * @param name defines the name of the mesh
  66786. * @param options defines the options used to create the mesh
  66787. * @param scene defines the hosting scene
  66788. * @returns the icosahedron mesh
  66789. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66790. */
  66791. static CreateIcoSphere(name: string, options: {
  66792. radius?: number;
  66793. radiusX?: number;
  66794. radiusY?: number;
  66795. radiusZ?: number;
  66796. flat?: boolean;
  66797. subdivisions?: number;
  66798. sideOrientation?: number;
  66799. frontUVs?: Vector4;
  66800. backUVs?: Vector4;
  66801. updatable?: boolean;
  66802. }, scene?: Nullable<Scene>): Mesh;
  66803. }
  66804. }
  66805. declare module BABYLON {
  66806. /**
  66807. * Class containing static functions to help procedurally build meshes
  66808. */
  66809. export class DecalBuilder {
  66810. /**
  66811. * Creates a decal mesh.
  66812. * 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
  66813. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66814. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66815. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66816. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66817. * @param name defines the name of the mesh
  66818. * @param sourceMesh defines the mesh where the decal must be applied
  66819. * @param options defines the options used to create the mesh
  66820. * @param scene defines the hosting scene
  66821. * @returns the decal mesh
  66822. * @see https://doc.babylonjs.com/how_to/decals
  66823. */
  66824. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66825. position?: Vector3;
  66826. normal?: Vector3;
  66827. size?: Vector3;
  66828. angle?: number;
  66829. }): Mesh;
  66830. }
  66831. }
  66832. declare module BABYLON {
  66833. /**
  66834. * Class containing static functions to help procedurally build meshes
  66835. */
  66836. export class MeshBuilder {
  66837. /**
  66838. * Creates a box mesh
  66839. * * The parameter `size` sets the size (float) of each box side (default 1)
  66840. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66841. * * 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)
  66842. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66844. * * 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
  66845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66846. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66847. * @param name defines the name of the mesh
  66848. * @param options defines the options used to create the mesh
  66849. * @param scene defines the hosting scene
  66850. * @returns the box mesh
  66851. */
  66852. static CreateBox(name: string, options: {
  66853. size?: number;
  66854. width?: number;
  66855. height?: number;
  66856. depth?: number;
  66857. faceUV?: Vector4[];
  66858. faceColors?: Color4[];
  66859. sideOrientation?: number;
  66860. frontUVs?: Vector4;
  66861. backUVs?: Vector4;
  66862. wrap?: boolean;
  66863. topBaseAt?: number;
  66864. bottomBaseAt?: number;
  66865. updatable?: boolean;
  66866. }, scene?: Nullable<Scene>): Mesh;
  66867. /**
  66868. * Creates a tiled box mesh
  66869. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66871. * @param name defines the name of the mesh
  66872. * @param options defines the options used to create the mesh
  66873. * @param scene defines the hosting scene
  66874. * @returns the tiled box mesh
  66875. */
  66876. static CreateTiledBox(name: string, options: {
  66877. pattern?: number;
  66878. size?: number;
  66879. width?: number;
  66880. height?: number;
  66881. depth: number;
  66882. tileSize?: number;
  66883. tileWidth?: number;
  66884. tileHeight?: number;
  66885. faceUV?: Vector4[];
  66886. faceColors?: Color4[];
  66887. alignHorizontal?: number;
  66888. alignVertical?: number;
  66889. sideOrientation?: number;
  66890. updatable?: boolean;
  66891. }, scene?: Nullable<Scene>): Mesh;
  66892. /**
  66893. * Creates a sphere mesh
  66894. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66895. * * 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`)
  66896. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66897. * * 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
  66898. * * 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)
  66899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66900. * * 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
  66901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66902. * @param name defines the name of the mesh
  66903. * @param options defines the options used to create the mesh
  66904. * @param scene defines the hosting scene
  66905. * @returns the sphere mesh
  66906. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66907. */
  66908. static CreateSphere(name: string, options: {
  66909. segments?: number;
  66910. diameter?: number;
  66911. diameterX?: number;
  66912. diameterY?: number;
  66913. diameterZ?: number;
  66914. arc?: number;
  66915. slice?: number;
  66916. sideOrientation?: number;
  66917. frontUVs?: Vector4;
  66918. backUVs?: Vector4;
  66919. updatable?: boolean;
  66920. }, scene?: Nullable<Scene>): Mesh;
  66921. /**
  66922. * Creates a plane polygonal mesh. By default, this is a disc
  66923. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66924. * * 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
  66925. * * 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
  66926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66927. * * 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
  66928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66929. * @param name defines the name of the mesh
  66930. * @param options defines the options used to create the mesh
  66931. * @param scene defines the hosting scene
  66932. * @returns the plane polygonal mesh
  66933. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66934. */
  66935. static CreateDisc(name: string, options: {
  66936. radius?: number;
  66937. tessellation?: number;
  66938. arc?: number;
  66939. updatable?: boolean;
  66940. sideOrientation?: number;
  66941. frontUVs?: Vector4;
  66942. backUVs?: Vector4;
  66943. }, scene?: Nullable<Scene>): Mesh;
  66944. /**
  66945. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66946. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66947. * * 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`)
  66948. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66949. * * 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
  66950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66951. * * 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
  66952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66953. * @param name defines the name of the mesh
  66954. * @param options defines the options used to create the mesh
  66955. * @param scene defines the hosting scene
  66956. * @returns the icosahedron mesh
  66957. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66958. */
  66959. static CreateIcoSphere(name: string, options: {
  66960. radius?: number;
  66961. radiusX?: number;
  66962. radiusY?: number;
  66963. radiusZ?: number;
  66964. flat?: boolean;
  66965. subdivisions?: number;
  66966. sideOrientation?: number;
  66967. frontUVs?: Vector4;
  66968. backUVs?: Vector4;
  66969. updatable?: boolean;
  66970. }, scene?: Nullable<Scene>): Mesh;
  66971. /**
  66972. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66973. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66974. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66975. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66976. * * 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
  66977. * * 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
  66978. * * 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
  66979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66980. * * 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
  66981. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66982. * * 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
  66983. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66984. * * 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
  66985. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66987. * @param name defines the name of the mesh
  66988. * @param options defines the options used to create the mesh
  66989. * @param scene defines the hosting scene
  66990. * @returns the ribbon mesh
  66991. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66992. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66993. */
  66994. static CreateRibbon(name: string, options: {
  66995. pathArray: Vector3[][];
  66996. closeArray?: boolean;
  66997. closePath?: boolean;
  66998. offset?: number;
  66999. updatable?: boolean;
  67000. sideOrientation?: number;
  67001. frontUVs?: Vector4;
  67002. backUVs?: Vector4;
  67003. instance?: Mesh;
  67004. invertUV?: boolean;
  67005. uvs?: Vector2[];
  67006. colors?: Color4[];
  67007. }, scene?: Nullable<Scene>): Mesh;
  67008. /**
  67009. * Creates a cylinder or a cone mesh
  67010. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67011. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67012. * * 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.
  67013. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67014. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67015. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67016. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67017. * * 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).
  67018. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67019. * * 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).
  67020. * * 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
  67021. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67022. * * 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
  67023. * * 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.
  67024. * * If `enclose` is false, a ring surface is one element.
  67025. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67026. * * 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
  67027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67028. * * 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
  67029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67030. * @param name defines the name of the mesh
  67031. * @param options defines the options used to create the mesh
  67032. * @param scene defines the hosting scene
  67033. * @returns the cylinder mesh
  67034. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67035. */
  67036. static CreateCylinder(name: string, options: {
  67037. height?: number;
  67038. diameterTop?: number;
  67039. diameterBottom?: number;
  67040. diameter?: number;
  67041. tessellation?: number;
  67042. subdivisions?: number;
  67043. arc?: number;
  67044. faceColors?: Color4[];
  67045. faceUV?: Vector4[];
  67046. updatable?: boolean;
  67047. hasRings?: boolean;
  67048. enclose?: boolean;
  67049. cap?: number;
  67050. sideOrientation?: number;
  67051. frontUVs?: Vector4;
  67052. backUVs?: Vector4;
  67053. }, scene?: Nullable<Scene>): Mesh;
  67054. /**
  67055. * Creates a torus mesh
  67056. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67057. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67058. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67060. * * 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
  67061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67062. * @param name defines the name of the mesh
  67063. * @param options defines the options used to create the mesh
  67064. * @param scene defines the hosting scene
  67065. * @returns the torus mesh
  67066. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67067. */
  67068. static CreateTorus(name: string, options: {
  67069. diameter?: number;
  67070. thickness?: number;
  67071. tessellation?: number;
  67072. updatable?: boolean;
  67073. sideOrientation?: number;
  67074. frontUVs?: Vector4;
  67075. backUVs?: Vector4;
  67076. }, scene?: Nullable<Scene>): Mesh;
  67077. /**
  67078. * Creates a torus knot mesh
  67079. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67080. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67081. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67082. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67084. * * 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
  67085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67086. * @param name defines the name of the mesh
  67087. * @param options defines the options used to create the mesh
  67088. * @param scene defines the hosting scene
  67089. * @returns the torus knot mesh
  67090. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67091. */
  67092. static CreateTorusKnot(name: string, options: {
  67093. radius?: number;
  67094. tube?: number;
  67095. radialSegments?: number;
  67096. tubularSegments?: number;
  67097. p?: number;
  67098. q?: number;
  67099. updatable?: boolean;
  67100. sideOrientation?: number;
  67101. frontUVs?: Vector4;
  67102. backUVs?: Vector4;
  67103. }, scene?: Nullable<Scene>): Mesh;
  67104. /**
  67105. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67106. * * 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
  67107. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67108. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67109. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67110. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67111. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67112. * * 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
  67113. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67116. * @param name defines the name of the new line system
  67117. * @param options defines the options used to create the line system
  67118. * @param scene defines the hosting scene
  67119. * @returns a new line system mesh
  67120. */
  67121. static CreateLineSystem(name: string, options: {
  67122. lines: Vector3[][];
  67123. updatable?: boolean;
  67124. instance?: Nullable<LinesMesh>;
  67125. colors?: Nullable<Color4[][]>;
  67126. useVertexAlpha?: boolean;
  67127. }, scene: Nullable<Scene>): LinesMesh;
  67128. /**
  67129. * Creates a line mesh
  67130. * 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
  67131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67132. * * The parameter `points` is an array successive Vector3
  67133. * * 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
  67134. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67135. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67136. * * When updating an instance, remember that only point positions can change, not the number of points
  67137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67139. * @param name defines the name of the new line system
  67140. * @param options defines the options used to create the line system
  67141. * @param scene defines the hosting scene
  67142. * @returns a new line mesh
  67143. */
  67144. static CreateLines(name: string, options: {
  67145. points: Vector3[];
  67146. updatable?: boolean;
  67147. instance?: Nullable<LinesMesh>;
  67148. colors?: Color4[];
  67149. useVertexAlpha?: boolean;
  67150. }, scene?: Nullable<Scene>): LinesMesh;
  67151. /**
  67152. * Creates a dashed line mesh
  67153. * * 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
  67154. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67155. * * The parameter `points` is an array successive Vector3
  67156. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67157. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67158. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67159. * * 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
  67160. * * When updating an instance, remember that only point positions can change, not the number of points
  67161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67162. * @param name defines the name of the mesh
  67163. * @param options defines the options used to create the mesh
  67164. * @param scene defines the hosting scene
  67165. * @returns the dashed line mesh
  67166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67167. */
  67168. static CreateDashedLines(name: string, options: {
  67169. points: Vector3[];
  67170. dashSize?: number;
  67171. gapSize?: number;
  67172. dashNb?: number;
  67173. updatable?: boolean;
  67174. instance?: LinesMesh;
  67175. }, scene?: Nullable<Scene>): LinesMesh;
  67176. /**
  67177. * 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.
  67178. * * 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.
  67179. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67180. * * 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.
  67181. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67182. * * 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
  67183. * * 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
  67184. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67186. * * 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
  67187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67189. * @param name defines the name of the mesh
  67190. * @param options defines the options used to create the mesh
  67191. * @param scene defines the hosting scene
  67192. * @returns the extruded shape mesh
  67193. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67195. */
  67196. static ExtrudeShape(name: string, options: {
  67197. shape: Vector3[];
  67198. path: Vector3[];
  67199. scale?: number;
  67200. rotation?: number;
  67201. cap?: number;
  67202. updatable?: boolean;
  67203. sideOrientation?: number;
  67204. frontUVs?: Vector4;
  67205. backUVs?: Vector4;
  67206. instance?: Mesh;
  67207. invertUV?: boolean;
  67208. }, scene?: Nullable<Scene>): Mesh;
  67209. /**
  67210. * Creates an custom extruded shape mesh.
  67211. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67212. * * 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.
  67213. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67214. * * 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
  67215. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67216. * * 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
  67217. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67218. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67219. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67220. * * 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
  67221. * * 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
  67222. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67227. * @param name defines the name of the mesh
  67228. * @param options defines the options used to create the mesh
  67229. * @param scene defines the hosting scene
  67230. * @returns the custom extruded shape mesh
  67231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67234. */
  67235. static ExtrudeShapeCustom(name: string, options: {
  67236. shape: Vector3[];
  67237. path: Vector3[];
  67238. scaleFunction?: any;
  67239. rotationFunction?: any;
  67240. ribbonCloseArray?: boolean;
  67241. ribbonClosePath?: boolean;
  67242. cap?: number;
  67243. updatable?: boolean;
  67244. sideOrientation?: number;
  67245. frontUVs?: Vector4;
  67246. backUVs?: Vector4;
  67247. instance?: Mesh;
  67248. invertUV?: boolean;
  67249. }, scene?: Nullable<Scene>): Mesh;
  67250. /**
  67251. * Creates lathe mesh.
  67252. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67253. * * 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
  67254. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67255. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67256. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67257. * * 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
  67258. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67259. * * 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
  67260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67261. * * 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
  67262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67264. * @param name defines the name of the mesh
  67265. * @param options defines the options used to create the mesh
  67266. * @param scene defines the hosting scene
  67267. * @returns the lathe mesh
  67268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67269. */
  67270. static CreateLathe(name: string, options: {
  67271. shape: Vector3[];
  67272. radius?: number;
  67273. tessellation?: number;
  67274. clip?: number;
  67275. arc?: number;
  67276. closed?: boolean;
  67277. updatable?: boolean;
  67278. sideOrientation?: number;
  67279. frontUVs?: Vector4;
  67280. backUVs?: Vector4;
  67281. cap?: number;
  67282. invertUV?: boolean;
  67283. }, scene?: Nullable<Scene>): Mesh;
  67284. /**
  67285. * Creates a tiled plane mesh
  67286. * * You can set a limited pattern arrangement with the tiles
  67287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67288. * * 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
  67289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67290. * @param name defines the name of the mesh
  67291. * @param options defines the options used to create the mesh
  67292. * @param scene defines the hosting scene
  67293. * @returns the plane mesh
  67294. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67295. */
  67296. static CreateTiledPlane(name: string, options: {
  67297. pattern?: number;
  67298. tileSize?: number;
  67299. tileWidth?: number;
  67300. tileHeight?: number;
  67301. size?: number;
  67302. width?: number;
  67303. height?: number;
  67304. alignHorizontal?: number;
  67305. alignVertical?: number;
  67306. sideOrientation?: number;
  67307. frontUVs?: Vector4;
  67308. backUVs?: Vector4;
  67309. updatable?: boolean;
  67310. }, scene?: Nullable<Scene>): Mesh;
  67311. /**
  67312. * Creates a plane mesh
  67313. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67314. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67315. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67317. * * 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
  67318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67319. * @param name defines the name of the mesh
  67320. * @param options defines the options used to create the mesh
  67321. * @param scene defines the hosting scene
  67322. * @returns the plane mesh
  67323. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67324. */
  67325. static CreatePlane(name: string, options: {
  67326. size?: number;
  67327. width?: number;
  67328. height?: number;
  67329. sideOrientation?: number;
  67330. frontUVs?: Vector4;
  67331. backUVs?: Vector4;
  67332. updatable?: boolean;
  67333. sourcePlane?: Plane;
  67334. }, scene?: Nullable<Scene>): Mesh;
  67335. /**
  67336. * Creates a ground mesh
  67337. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67338. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67340. * @param name defines the name of the mesh
  67341. * @param options defines the options used to create the mesh
  67342. * @param scene defines the hosting scene
  67343. * @returns the ground mesh
  67344. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67345. */
  67346. static CreateGround(name: string, options: {
  67347. width?: number;
  67348. height?: number;
  67349. subdivisions?: number;
  67350. subdivisionsX?: number;
  67351. subdivisionsY?: number;
  67352. updatable?: boolean;
  67353. }, scene?: Nullable<Scene>): Mesh;
  67354. /**
  67355. * Creates a tiled ground mesh
  67356. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67357. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67358. * * 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
  67359. * * 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
  67360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67361. * @param name defines the name of the mesh
  67362. * @param options defines the options used to create the mesh
  67363. * @param scene defines the hosting scene
  67364. * @returns the tiled ground mesh
  67365. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67366. */
  67367. static CreateTiledGround(name: string, options: {
  67368. xmin: number;
  67369. zmin: number;
  67370. xmax: number;
  67371. zmax: number;
  67372. subdivisions?: {
  67373. w: number;
  67374. h: number;
  67375. };
  67376. precision?: {
  67377. w: number;
  67378. h: number;
  67379. };
  67380. updatable?: boolean;
  67381. }, scene?: Nullable<Scene>): Mesh;
  67382. /**
  67383. * Creates a ground mesh from a height map
  67384. * * The parameter `url` sets the URL of the height map image resource.
  67385. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67386. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67387. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67388. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67389. * * 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.
  67390. * * 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).
  67391. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67393. * @param name defines the name of the mesh
  67394. * @param url defines the url to the height map
  67395. * @param options defines the options used to create the mesh
  67396. * @param scene defines the hosting scene
  67397. * @returns the ground mesh
  67398. * @see https://doc.babylonjs.com/babylon101/height_map
  67399. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67400. */
  67401. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67402. width?: number;
  67403. height?: number;
  67404. subdivisions?: number;
  67405. minHeight?: number;
  67406. maxHeight?: number;
  67407. colorFilter?: Color3;
  67408. alphaFilter?: number;
  67409. updatable?: boolean;
  67410. onReady?: (mesh: GroundMesh) => void;
  67411. }, scene?: Nullable<Scene>): GroundMesh;
  67412. /**
  67413. * Creates a polygon mesh
  67414. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67415. * * 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
  67416. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67418. * * 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)
  67419. * * Remember you can only change the shape positions, not their number when updating a polygon
  67420. * @param name defines the name of the mesh
  67421. * @param options defines the options used to create the mesh
  67422. * @param scene defines the hosting scene
  67423. * @param earcutInjection can be used to inject your own earcut reference
  67424. * @returns the polygon mesh
  67425. */
  67426. static CreatePolygon(name: string, options: {
  67427. shape: Vector3[];
  67428. holes?: Vector3[][];
  67429. depth?: number;
  67430. faceUV?: Vector4[];
  67431. faceColors?: Color4[];
  67432. updatable?: boolean;
  67433. sideOrientation?: number;
  67434. frontUVs?: Vector4;
  67435. backUVs?: Vector4;
  67436. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67437. /**
  67438. * Creates an extruded polygon mesh, with depth in the Y direction.
  67439. * * 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)
  67440. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67441. * @param name defines the name of the mesh
  67442. * @param options defines the options used to create the mesh
  67443. * @param scene defines the hosting scene
  67444. * @param earcutInjection can be used to inject your own earcut reference
  67445. * @returns the polygon mesh
  67446. */
  67447. static ExtrudePolygon(name: string, options: {
  67448. shape: Vector3[];
  67449. holes?: Vector3[][];
  67450. depth?: number;
  67451. faceUV?: Vector4[];
  67452. faceColors?: Color4[];
  67453. updatable?: boolean;
  67454. sideOrientation?: number;
  67455. frontUVs?: Vector4;
  67456. backUVs?: Vector4;
  67457. wrap?: boolean;
  67458. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67459. /**
  67460. * Creates a tube mesh.
  67461. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67462. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67463. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67464. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67465. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67466. * * 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)
  67467. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67468. * * 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
  67469. * * 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
  67470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67471. * * 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
  67472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67474. * @param name defines the name of the mesh
  67475. * @param options defines the options used to create the mesh
  67476. * @param scene defines the hosting scene
  67477. * @returns the tube mesh
  67478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67479. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67480. */
  67481. static CreateTube(name: string, options: {
  67482. path: Vector3[];
  67483. radius?: number;
  67484. tessellation?: number;
  67485. radiusFunction?: {
  67486. (i: number, distance: number): number;
  67487. };
  67488. cap?: number;
  67489. arc?: number;
  67490. updatable?: boolean;
  67491. sideOrientation?: number;
  67492. frontUVs?: Vector4;
  67493. backUVs?: Vector4;
  67494. instance?: Mesh;
  67495. invertUV?: boolean;
  67496. }, scene?: Nullable<Scene>): Mesh;
  67497. /**
  67498. * Creates a polyhedron mesh
  67499. * * 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
  67500. * * The parameter `size` (positive float, default 1) sets the polygon size
  67501. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67502. * * 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`
  67503. * * 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
  67504. * * 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)`)
  67505. * * 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
  67506. * * 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
  67507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67508. * * 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
  67509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67510. * @param name defines the name of the mesh
  67511. * @param options defines the options used to create the mesh
  67512. * @param scene defines the hosting scene
  67513. * @returns the polyhedron mesh
  67514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67515. */
  67516. static CreatePolyhedron(name: string, options: {
  67517. type?: number;
  67518. size?: number;
  67519. sizeX?: number;
  67520. sizeY?: number;
  67521. sizeZ?: number;
  67522. custom?: any;
  67523. faceUV?: Vector4[];
  67524. faceColors?: Color4[];
  67525. flat?: boolean;
  67526. updatable?: boolean;
  67527. sideOrientation?: number;
  67528. frontUVs?: Vector4;
  67529. backUVs?: Vector4;
  67530. }, scene?: Nullable<Scene>): Mesh;
  67531. /**
  67532. * Creates a decal mesh.
  67533. * 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
  67534. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67535. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67536. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67537. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67538. * @param name defines the name of the mesh
  67539. * @param sourceMesh defines the mesh where the decal must be applied
  67540. * @param options defines the options used to create the mesh
  67541. * @param scene defines the hosting scene
  67542. * @returns the decal mesh
  67543. * @see https://doc.babylonjs.com/how_to/decals
  67544. */
  67545. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67546. position?: Vector3;
  67547. normal?: Vector3;
  67548. size?: Vector3;
  67549. angle?: number;
  67550. }): Mesh;
  67551. /**
  67552. * Creates a Capsule Mesh
  67553. * @param name defines the name of the mesh.
  67554. * @param options the constructors options used to shape the mesh.
  67555. * @param scene defines the scene the mesh is scoped to.
  67556. * @returns the capsule mesh
  67557. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67558. */
  67559. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67560. }
  67561. }
  67562. declare module BABYLON {
  67563. /**
  67564. * A simplifier interface for future simplification implementations
  67565. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67566. */
  67567. export interface ISimplifier {
  67568. /**
  67569. * Simplification of a given mesh according to the given settings.
  67570. * Since this requires computation, it is assumed that the function runs async.
  67571. * @param settings The settings of the simplification, including quality and distance
  67572. * @param successCallback A callback that will be called after the mesh was simplified.
  67573. * @param errorCallback in case of an error, this callback will be called. optional.
  67574. */
  67575. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67576. }
  67577. /**
  67578. * Expected simplification settings.
  67579. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67580. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67581. */
  67582. export interface ISimplificationSettings {
  67583. /**
  67584. * Gets or sets the expected quality
  67585. */
  67586. quality: number;
  67587. /**
  67588. * Gets or sets the distance when this optimized version should be used
  67589. */
  67590. distance: number;
  67591. /**
  67592. * Gets an already optimized mesh
  67593. */
  67594. optimizeMesh?: boolean;
  67595. }
  67596. /**
  67597. * Class used to specify simplification options
  67598. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67599. */
  67600. export class SimplificationSettings implements ISimplificationSettings {
  67601. /** expected quality */
  67602. quality: number;
  67603. /** distance when this optimized version should be used */
  67604. distance: number;
  67605. /** already optimized mesh */
  67606. optimizeMesh?: boolean | undefined;
  67607. /**
  67608. * Creates a SimplificationSettings
  67609. * @param quality expected quality
  67610. * @param distance distance when this optimized version should be used
  67611. * @param optimizeMesh already optimized mesh
  67612. */
  67613. constructor(
  67614. /** expected quality */
  67615. quality: number,
  67616. /** distance when this optimized version should be used */
  67617. distance: number,
  67618. /** already optimized mesh */
  67619. optimizeMesh?: boolean | undefined);
  67620. }
  67621. /**
  67622. * Interface used to define a simplification task
  67623. */
  67624. export interface ISimplificationTask {
  67625. /**
  67626. * Array of settings
  67627. */
  67628. settings: Array<ISimplificationSettings>;
  67629. /**
  67630. * Simplification type
  67631. */
  67632. simplificationType: SimplificationType;
  67633. /**
  67634. * Mesh to simplify
  67635. */
  67636. mesh: Mesh;
  67637. /**
  67638. * Callback called on success
  67639. */
  67640. successCallback?: () => void;
  67641. /**
  67642. * Defines if parallel processing can be used
  67643. */
  67644. parallelProcessing: boolean;
  67645. }
  67646. /**
  67647. * Queue used to order the simplification tasks
  67648. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67649. */
  67650. export class SimplificationQueue {
  67651. private _simplificationArray;
  67652. /**
  67653. * Gets a boolean indicating that the process is still running
  67654. */
  67655. running: boolean;
  67656. /**
  67657. * Creates a new queue
  67658. */
  67659. constructor();
  67660. /**
  67661. * Adds a new simplification task
  67662. * @param task defines a task to add
  67663. */
  67664. addTask(task: ISimplificationTask): void;
  67665. /**
  67666. * Execute next task
  67667. */
  67668. executeNext(): void;
  67669. /**
  67670. * Execute a simplification task
  67671. * @param task defines the task to run
  67672. */
  67673. runSimplification(task: ISimplificationTask): void;
  67674. private getSimplifier;
  67675. }
  67676. /**
  67677. * The implemented types of simplification
  67678. * At the moment only Quadratic Error Decimation is implemented
  67679. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67680. */
  67681. export enum SimplificationType {
  67682. /** Quadratic error decimation */
  67683. QUADRATIC = 0
  67684. }
  67685. /**
  67686. * An implementation of the Quadratic Error simplification algorithm.
  67687. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67688. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67689. * @author RaananW
  67690. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67691. */
  67692. export class QuadraticErrorSimplification implements ISimplifier {
  67693. private _mesh;
  67694. private triangles;
  67695. private vertices;
  67696. private references;
  67697. private _reconstructedMesh;
  67698. /** Gets or sets the number pf sync interations */
  67699. syncIterations: number;
  67700. /** Gets or sets the aggressiveness of the simplifier */
  67701. aggressiveness: number;
  67702. /** Gets or sets the number of allowed iterations for decimation */
  67703. decimationIterations: number;
  67704. /** Gets or sets the espilon to use for bounding box computation */
  67705. boundingBoxEpsilon: number;
  67706. /**
  67707. * Creates a new QuadraticErrorSimplification
  67708. * @param _mesh defines the target mesh
  67709. */
  67710. constructor(_mesh: Mesh);
  67711. /**
  67712. * Simplification of a given mesh according to the given settings.
  67713. * Since this requires computation, it is assumed that the function runs async.
  67714. * @param settings The settings of the simplification, including quality and distance
  67715. * @param successCallback A callback that will be called after the mesh was simplified.
  67716. */
  67717. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67718. private runDecimation;
  67719. private initWithMesh;
  67720. private init;
  67721. private reconstructMesh;
  67722. private initDecimatedMesh;
  67723. private isFlipped;
  67724. private updateTriangles;
  67725. private identifyBorder;
  67726. private updateMesh;
  67727. private vertexError;
  67728. private calculateError;
  67729. }
  67730. }
  67731. declare module BABYLON {
  67732. interface Scene {
  67733. /** @hidden (Backing field) */
  67734. _simplificationQueue: SimplificationQueue;
  67735. /**
  67736. * Gets or sets the simplification queue attached to the scene
  67737. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67738. */
  67739. simplificationQueue: SimplificationQueue;
  67740. }
  67741. interface Mesh {
  67742. /**
  67743. * Simplify the mesh according to the given array of settings.
  67744. * Function will return immediately and will simplify async
  67745. * @param settings a collection of simplification settings
  67746. * @param parallelProcessing should all levels calculate parallel or one after the other
  67747. * @param simplificationType the type of simplification to run
  67748. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67749. * @returns the current mesh
  67750. */
  67751. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67752. }
  67753. /**
  67754. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67755. * created in a scene
  67756. */
  67757. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67758. /**
  67759. * The component name helpfull to identify the component in the list of scene components.
  67760. */
  67761. readonly name: string;
  67762. /**
  67763. * The scene the component belongs to.
  67764. */
  67765. scene: Scene;
  67766. /**
  67767. * Creates a new instance of the component for the given scene
  67768. * @param scene Defines the scene to register the component in
  67769. */
  67770. constructor(scene: Scene);
  67771. /**
  67772. * Registers the component in a given scene
  67773. */
  67774. register(): void;
  67775. /**
  67776. * Rebuilds the elements related to this component in case of
  67777. * context lost for instance.
  67778. */
  67779. rebuild(): void;
  67780. /**
  67781. * Disposes the component and the associated ressources
  67782. */
  67783. dispose(): void;
  67784. private _beforeCameraUpdate;
  67785. }
  67786. }
  67787. declare module BABYLON {
  67788. interface Mesh {
  67789. /**
  67790. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67791. */
  67792. thinInstanceEnablePicking: boolean;
  67793. /**
  67794. * Creates a new thin instance
  67795. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67796. * @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
  67797. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67798. */
  67799. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67800. /**
  67801. * Adds the transformation (matrix) of the current mesh as a thin instance
  67802. * @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
  67803. * @returns the thin instance index number
  67804. */
  67805. thinInstanceAddSelf(refresh: boolean): number;
  67806. /**
  67807. * Registers a custom attribute to be used with thin instances
  67808. * @param kind name of the attribute
  67809. * @param stride size in floats of the attribute
  67810. */
  67811. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67812. /**
  67813. * Sets the matrix of a thin instance
  67814. * @param index index of the thin instance
  67815. * @param matrix matrix to set
  67816. * @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
  67817. */
  67818. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67819. /**
  67820. * Sets the value of a custom attribute for a thin instance
  67821. * @param kind name of the attribute
  67822. * @param index index of the thin instance
  67823. * @param value value to set
  67824. * @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
  67825. */
  67826. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67827. /**
  67828. * 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.
  67829. */
  67830. thinInstanceCount: number;
  67831. /**
  67832. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67833. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67834. * @param buffer buffer to set
  67835. * @param stride size in floats of each value of the buffer
  67836. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67837. */
  67838. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67839. /**
  67840. * Gets the list of world matrices
  67841. * @return an array containing all the world matrices from the thin instances
  67842. */
  67843. thinInstanceGetWorldMatrices(): Matrix[];
  67844. /**
  67845. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67846. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67847. */
  67848. thinInstanceBufferUpdated(kind: string): void;
  67849. /**
  67850. * Applies a partial update to a buffer directly on the GPU
  67851. * 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
  67852. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67853. * @param data the data to set in the GPU buffer
  67854. * @param offset the offset in the GPU buffer where to update the data
  67855. */
  67856. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67857. /**
  67858. * Refreshes the bounding info, taking into account all the thin instances defined
  67859. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67860. */
  67861. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67862. /** @hidden */
  67863. _thinInstanceInitializeUserStorage(): void;
  67864. /** @hidden */
  67865. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67866. /** @hidden */
  67867. _userThinInstanceBuffersStorage: {
  67868. data: {
  67869. [key: string]: Float32Array;
  67870. };
  67871. sizes: {
  67872. [key: string]: number;
  67873. };
  67874. vertexBuffers: {
  67875. [key: string]: Nullable<VertexBuffer>;
  67876. };
  67877. strides: {
  67878. [key: string]: number;
  67879. };
  67880. };
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /**
  67885. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67886. */
  67887. export interface INavigationEnginePlugin {
  67888. /**
  67889. * plugin name
  67890. */
  67891. name: string;
  67892. /**
  67893. * Creates a navigation mesh
  67894. * @param meshes array of all the geometry used to compute the navigatio mesh
  67895. * @param parameters bunch of parameters used to filter geometry
  67896. */
  67897. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67898. /**
  67899. * Create a navigation mesh debug mesh
  67900. * @param scene is where the mesh will be added
  67901. * @returns debug display mesh
  67902. */
  67903. createDebugNavMesh(scene: Scene): Mesh;
  67904. /**
  67905. * Get a navigation mesh constrained position, closest to the parameter position
  67906. * @param position world position
  67907. * @returns the closest point to position constrained by the navigation mesh
  67908. */
  67909. getClosestPoint(position: Vector3): Vector3;
  67910. /**
  67911. * Get a navigation mesh constrained position, closest to the parameter position
  67912. * @param position world position
  67913. * @param result output the closest point to position constrained by the navigation mesh
  67914. */
  67915. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67916. /**
  67917. * Get a navigation mesh constrained position, within a particular radius
  67918. * @param position world position
  67919. * @param maxRadius the maximum distance to the constrained world position
  67920. * @returns the closest point to position constrained by the navigation mesh
  67921. */
  67922. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67923. /**
  67924. * Get a navigation mesh constrained position, within a particular radius
  67925. * @param position world position
  67926. * @param maxRadius the maximum distance to the constrained world position
  67927. * @param result output the closest point to position constrained by the navigation mesh
  67928. */
  67929. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67930. /**
  67931. * Compute the final position from a segment made of destination-position
  67932. * @param position world position
  67933. * @param destination world position
  67934. * @returns the resulting point along the navmesh
  67935. */
  67936. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67937. /**
  67938. * Compute the final position from a segment made of destination-position
  67939. * @param position world position
  67940. * @param destination world position
  67941. * @param result output the resulting point along the navmesh
  67942. */
  67943. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67944. /**
  67945. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67946. * @param start world position
  67947. * @param end world position
  67948. * @returns array containing world position composing the path
  67949. */
  67950. computePath(start: Vector3, end: Vector3): Vector3[];
  67951. /**
  67952. * If this plugin is supported
  67953. * @returns true if plugin is supported
  67954. */
  67955. isSupported(): boolean;
  67956. /**
  67957. * Create a new Crowd so you can add agents
  67958. * @param maxAgents the maximum agent count in the crowd
  67959. * @param maxAgentRadius the maximum radius an agent can have
  67960. * @param scene to attach the crowd to
  67961. * @returns the crowd you can add agents to
  67962. */
  67963. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67964. /**
  67965. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67966. * The queries will try to find a solution within those bounds
  67967. * default is (1,1,1)
  67968. * @param extent x,y,z value that define the extent around the queries point of reference
  67969. */
  67970. setDefaultQueryExtent(extent: Vector3): void;
  67971. /**
  67972. * Get the Bounding box extent specified by setDefaultQueryExtent
  67973. * @returns the box extent values
  67974. */
  67975. getDefaultQueryExtent(): Vector3;
  67976. /**
  67977. * build the navmesh from a previously saved state using getNavmeshData
  67978. * @param data the Uint8Array returned by getNavmeshData
  67979. */
  67980. buildFromNavmeshData(data: Uint8Array): void;
  67981. /**
  67982. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67983. * @returns data the Uint8Array that can be saved and reused
  67984. */
  67985. getNavmeshData(): Uint8Array;
  67986. /**
  67987. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67988. * @param result output the box extent values
  67989. */
  67990. getDefaultQueryExtentToRef(result: Vector3): void;
  67991. /**
  67992. * Release all resources
  67993. */
  67994. dispose(): void;
  67995. }
  67996. /**
  67997. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67998. */
  67999. export interface ICrowd {
  68000. /**
  68001. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68002. * You can attach anything to that node. The node position is updated in the scene update tick.
  68003. * @param pos world position that will be constrained by the navigation mesh
  68004. * @param parameters agent parameters
  68005. * @param transform hooked to the agent that will be update by the scene
  68006. * @returns agent index
  68007. */
  68008. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68009. /**
  68010. * Returns the agent position in world space
  68011. * @param index agent index returned by addAgent
  68012. * @returns world space position
  68013. */
  68014. getAgentPosition(index: number): Vector3;
  68015. /**
  68016. * Gets the agent position result in world space
  68017. * @param index agent index returned by addAgent
  68018. * @param result output world space position
  68019. */
  68020. getAgentPositionToRef(index: number, result: Vector3): void;
  68021. /**
  68022. * Gets the agent velocity in world space
  68023. * @param index agent index returned by addAgent
  68024. * @returns world space velocity
  68025. */
  68026. getAgentVelocity(index: number): Vector3;
  68027. /**
  68028. * Gets the agent velocity result in world space
  68029. * @param index agent index returned by addAgent
  68030. * @param result output world space velocity
  68031. */
  68032. getAgentVelocityToRef(index: number, result: Vector3): void;
  68033. /**
  68034. * Gets the agent next target point on the path
  68035. * @param index agent index returned by addAgent
  68036. * @returns world space position
  68037. */
  68038. getAgentNextTargetPath(index: number): Vector3;
  68039. /**
  68040. * Gets the agent state
  68041. * @param index agent index returned by addAgent
  68042. * @returns agent state
  68043. */
  68044. getAgentState(index: number): number;
  68045. /**
  68046. * returns true if the agent in over an off mesh link connection
  68047. * @param index agent index returned by addAgent
  68048. * @returns true if over an off mesh link connection
  68049. */
  68050. overOffmeshConnection(index: number): boolean;
  68051. /**
  68052. * Gets the agent next target point on the path
  68053. * @param index agent index returned by addAgent
  68054. * @param result output world space position
  68055. */
  68056. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68057. /**
  68058. * remove a particular agent previously created
  68059. * @param index agent index returned by addAgent
  68060. */
  68061. removeAgent(index: number): void;
  68062. /**
  68063. * get the list of all agents attached to this crowd
  68064. * @returns list of agent indices
  68065. */
  68066. getAgents(): number[];
  68067. /**
  68068. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68069. * @param deltaTime in seconds
  68070. */
  68071. update(deltaTime: number): void;
  68072. /**
  68073. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68074. * @param index agent index returned by addAgent
  68075. * @param destination targeted world position
  68076. */
  68077. agentGoto(index: number, destination: Vector3): void;
  68078. /**
  68079. * Teleport the agent to a new position
  68080. * @param index agent index returned by addAgent
  68081. * @param destination targeted world position
  68082. */
  68083. agentTeleport(index: number, destination: Vector3): void;
  68084. /**
  68085. * Update agent parameters
  68086. * @param index agent index returned by addAgent
  68087. * @param parameters agent parameters
  68088. */
  68089. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68090. /**
  68091. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68092. * The queries will try to find a solution within those bounds
  68093. * default is (1,1,1)
  68094. * @param extent x,y,z value that define the extent around the queries point of reference
  68095. */
  68096. setDefaultQueryExtent(extent: Vector3): void;
  68097. /**
  68098. * Get the Bounding box extent specified by setDefaultQueryExtent
  68099. * @returns the box extent values
  68100. */
  68101. getDefaultQueryExtent(): Vector3;
  68102. /**
  68103. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68104. * @param result output the box extent values
  68105. */
  68106. getDefaultQueryExtentToRef(result: Vector3): void;
  68107. /**
  68108. * Release all resources
  68109. */
  68110. dispose(): void;
  68111. }
  68112. /**
  68113. * Configures an agent
  68114. */
  68115. export interface IAgentParameters {
  68116. /**
  68117. * Agent radius. [Limit: >= 0]
  68118. */
  68119. radius: number;
  68120. /**
  68121. * Agent height. [Limit: > 0]
  68122. */
  68123. height: number;
  68124. /**
  68125. * Maximum allowed acceleration. [Limit: >= 0]
  68126. */
  68127. maxAcceleration: number;
  68128. /**
  68129. * Maximum allowed speed. [Limit: >= 0]
  68130. */
  68131. maxSpeed: number;
  68132. /**
  68133. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68134. */
  68135. collisionQueryRange: number;
  68136. /**
  68137. * The path visibility optimization range. [Limit: > 0]
  68138. */
  68139. pathOptimizationRange: number;
  68140. /**
  68141. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68142. */
  68143. separationWeight: number;
  68144. }
  68145. /**
  68146. * Configures the navigation mesh creation
  68147. */
  68148. export interface INavMeshParameters {
  68149. /**
  68150. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68151. */
  68152. cs: number;
  68153. /**
  68154. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68155. */
  68156. ch: number;
  68157. /**
  68158. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68159. */
  68160. walkableSlopeAngle: number;
  68161. /**
  68162. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68163. * be considered walkable. [Limit: >= 3] [Units: vx]
  68164. */
  68165. walkableHeight: number;
  68166. /**
  68167. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68168. */
  68169. walkableClimb: number;
  68170. /**
  68171. * The distance to erode/shrink the walkable area of the heightfield away from
  68172. * obstructions. [Limit: >=0] [Units: vx]
  68173. */
  68174. walkableRadius: number;
  68175. /**
  68176. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68177. */
  68178. maxEdgeLen: number;
  68179. /**
  68180. * The maximum distance a simplfied contour's border edges should deviate
  68181. * the original raw contour. [Limit: >=0] [Units: vx]
  68182. */
  68183. maxSimplificationError: number;
  68184. /**
  68185. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68186. */
  68187. minRegionArea: number;
  68188. /**
  68189. * Any regions with a span count smaller than this value will, if possible,
  68190. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68191. */
  68192. mergeRegionArea: number;
  68193. /**
  68194. * The maximum number of vertices allowed for polygons generated during the
  68195. * contour to polygon conversion process. [Limit: >= 3]
  68196. */
  68197. maxVertsPerPoly: number;
  68198. /**
  68199. * Sets the sampling distance to use when generating the detail mesh.
  68200. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68201. */
  68202. detailSampleDist: number;
  68203. /**
  68204. * The maximum distance the detail mesh surface should deviate from heightfield
  68205. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68206. */
  68207. detailSampleMaxError: number;
  68208. }
  68209. }
  68210. declare module BABYLON {
  68211. /**
  68212. * RecastJS navigation plugin
  68213. */
  68214. export class RecastJSPlugin implements INavigationEnginePlugin {
  68215. /**
  68216. * Reference to the Recast library
  68217. */
  68218. bjsRECAST: any;
  68219. /**
  68220. * plugin name
  68221. */
  68222. name: string;
  68223. /**
  68224. * the first navmesh created. We might extend this to support multiple navmeshes
  68225. */
  68226. navMesh: any;
  68227. /**
  68228. * Initializes the recastJS plugin
  68229. * @param recastInjection can be used to inject your own recast reference
  68230. */
  68231. constructor(recastInjection?: any);
  68232. /**
  68233. * Creates a navigation mesh
  68234. * @param meshes array of all the geometry used to compute the navigatio mesh
  68235. * @param parameters bunch of parameters used to filter geometry
  68236. */
  68237. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68238. /**
  68239. * Create a navigation mesh debug mesh
  68240. * @param scene is where the mesh will be added
  68241. * @returns debug display mesh
  68242. */
  68243. createDebugNavMesh(scene: Scene): Mesh;
  68244. /**
  68245. * Get a navigation mesh constrained position, closest to the parameter position
  68246. * @param position world position
  68247. * @returns the closest point to position constrained by the navigation mesh
  68248. */
  68249. getClosestPoint(position: Vector3): Vector3;
  68250. /**
  68251. * Get a navigation mesh constrained position, closest to the parameter position
  68252. * @param position world position
  68253. * @param result output the closest point to position constrained by the navigation mesh
  68254. */
  68255. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68256. /**
  68257. * Get a navigation mesh constrained position, within a particular radius
  68258. * @param position world position
  68259. * @param maxRadius the maximum distance to the constrained world position
  68260. * @returns the closest point to position constrained by the navigation mesh
  68261. */
  68262. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68263. /**
  68264. * Get a navigation mesh constrained position, within a particular radius
  68265. * @param position world position
  68266. * @param maxRadius the maximum distance to the constrained world position
  68267. * @param result output the closest point to position constrained by the navigation mesh
  68268. */
  68269. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68270. /**
  68271. * Compute the final position from a segment made of destination-position
  68272. * @param position world position
  68273. * @param destination world position
  68274. * @returns the resulting point along the navmesh
  68275. */
  68276. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68277. /**
  68278. * Compute the final position from a segment made of destination-position
  68279. * @param position world position
  68280. * @param destination world position
  68281. * @param result output the resulting point along the navmesh
  68282. */
  68283. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68284. /**
  68285. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68286. * @param start world position
  68287. * @param end world position
  68288. * @returns array containing world position composing the path
  68289. */
  68290. computePath(start: Vector3, end: Vector3): Vector3[];
  68291. /**
  68292. * Create a new Crowd so you can add agents
  68293. * @param maxAgents the maximum agent count in the crowd
  68294. * @param maxAgentRadius the maximum radius an agent can have
  68295. * @param scene to attach the crowd to
  68296. * @returns the crowd you can add agents to
  68297. */
  68298. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68299. /**
  68300. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68301. * The queries will try to find a solution within those bounds
  68302. * default is (1,1,1)
  68303. * @param extent x,y,z value that define the extent around the queries point of reference
  68304. */
  68305. setDefaultQueryExtent(extent: Vector3): void;
  68306. /**
  68307. * Get the Bounding box extent specified by setDefaultQueryExtent
  68308. * @returns the box extent values
  68309. */
  68310. getDefaultQueryExtent(): Vector3;
  68311. /**
  68312. * build the navmesh from a previously saved state using getNavmeshData
  68313. * @param data the Uint8Array returned by getNavmeshData
  68314. */
  68315. buildFromNavmeshData(data: Uint8Array): void;
  68316. /**
  68317. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68318. * @returns data the Uint8Array that can be saved and reused
  68319. */
  68320. getNavmeshData(): Uint8Array;
  68321. /**
  68322. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68323. * @param result output the box extent values
  68324. */
  68325. getDefaultQueryExtentToRef(result: Vector3): void;
  68326. /**
  68327. * Disposes
  68328. */
  68329. dispose(): void;
  68330. /**
  68331. * If this plugin is supported
  68332. * @returns true if plugin is supported
  68333. */
  68334. isSupported(): boolean;
  68335. }
  68336. /**
  68337. * Recast detour crowd implementation
  68338. */
  68339. export class RecastJSCrowd implements ICrowd {
  68340. /**
  68341. * Recast/detour plugin
  68342. */
  68343. bjsRECASTPlugin: RecastJSPlugin;
  68344. /**
  68345. * Link to the detour crowd
  68346. */
  68347. recastCrowd: any;
  68348. /**
  68349. * One transform per agent
  68350. */
  68351. transforms: TransformNode[];
  68352. /**
  68353. * All agents created
  68354. */
  68355. agents: number[];
  68356. /**
  68357. * Link to the scene is kept to unregister the crowd from the scene
  68358. */
  68359. private _scene;
  68360. /**
  68361. * Observer for crowd updates
  68362. */
  68363. private _onBeforeAnimationsObserver;
  68364. /**
  68365. * Constructor
  68366. * @param plugin recastJS plugin
  68367. * @param maxAgents the maximum agent count in the crowd
  68368. * @param maxAgentRadius the maximum radius an agent can have
  68369. * @param scene to attach the crowd to
  68370. * @returns the crowd you can add agents to
  68371. */
  68372. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68373. /**
  68374. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68375. * You can attach anything to that node. The node position is updated in the scene update tick.
  68376. * @param pos world position that will be constrained by the navigation mesh
  68377. * @param parameters agent parameters
  68378. * @param transform hooked to the agent that will be update by the scene
  68379. * @returns agent index
  68380. */
  68381. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68382. /**
  68383. * Returns the agent position in world space
  68384. * @param index agent index returned by addAgent
  68385. * @returns world space position
  68386. */
  68387. getAgentPosition(index: number): Vector3;
  68388. /**
  68389. * Returns the agent position result in world space
  68390. * @param index agent index returned by addAgent
  68391. * @param result output world space position
  68392. */
  68393. getAgentPositionToRef(index: number, result: Vector3): void;
  68394. /**
  68395. * Returns the agent velocity in world space
  68396. * @param index agent index returned by addAgent
  68397. * @returns world space velocity
  68398. */
  68399. getAgentVelocity(index: number): Vector3;
  68400. /**
  68401. * Returns the agent velocity result in world space
  68402. * @param index agent index returned by addAgent
  68403. * @param result output world space velocity
  68404. */
  68405. getAgentVelocityToRef(index: number, result: Vector3): void;
  68406. /**
  68407. * Returns the agent next target point on the path
  68408. * @param index agent index returned by addAgent
  68409. * @returns world space position
  68410. */
  68411. getAgentNextTargetPath(index: number): Vector3;
  68412. /**
  68413. * Returns the agent next target point on the path
  68414. * @param index agent index returned by addAgent
  68415. * @param result output world space position
  68416. */
  68417. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68418. /**
  68419. * Gets the agent state
  68420. * @param index agent index returned by addAgent
  68421. * @returns agent state
  68422. */
  68423. getAgentState(index: number): number;
  68424. /**
  68425. * returns true if the agent in over an off mesh link connection
  68426. * @param index agent index returned by addAgent
  68427. * @returns true if over an off mesh link connection
  68428. */
  68429. overOffmeshConnection(index: number): boolean;
  68430. /**
  68431. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68432. * @param index agent index returned by addAgent
  68433. * @param destination targeted world position
  68434. */
  68435. agentGoto(index: number, destination: Vector3): void;
  68436. /**
  68437. * Teleport the agent to a new position
  68438. * @param index agent index returned by addAgent
  68439. * @param destination targeted world position
  68440. */
  68441. agentTeleport(index: number, destination: Vector3): void;
  68442. /**
  68443. * Update agent parameters
  68444. * @param index agent index returned by addAgent
  68445. * @param parameters agent parameters
  68446. */
  68447. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68448. /**
  68449. * remove a particular agent previously created
  68450. * @param index agent index returned by addAgent
  68451. */
  68452. removeAgent(index: number): void;
  68453. /**
  68454. * get the list of all agents attached to this crowd
  68455. * @returns list of agent indices
  68456. */
  68457. getAgents(): number[];
  68458. /**
  68459. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68460. * @param deltaTime in seconds
  68461. */
  68462. update(deltaTime: number): void;
  68463. /**
  68464. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68465. * The queries will try to find a solution within those bounds
  68466. * default is (1,1,1)
  68467. * @param extent x,y,z value that define the extent around the queries point of reference
  68468. */
  68469. setDefaultQueryExtent(extent: Vector3): void;
  68470. /**
  68471. * Get the Bounding box extent specified by setDefaultQueryExtent
  68472. * @returns the box extent values
  68473. */
  68474. getDefaultQueryExtent(): Vector3;
  68475. /**
  68476. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68477. * @param result output the box extent values
  68478. */
  68479. getDefaultQueryExtentToRef(result: Vector3): void;
  68480. /**
  68481. * Release all resources
  68482. */
  68483. dispose(): void;
  68484. }
  68485. }
  68486. declare module BABYLON {
  68487. /**
  68488. * Class used to enable access to IndexedDB
  68489. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68490. */
  68491. export class Database implements IOfflineProvider {
  68492. private _callbackManifestChecked;
  68493. private _currentSceneUrl;
  68494. private _db;
  68495. private _enableSceneOffline;
  68496. private _enableTexturesOffline;
  68497. private _manifestVersionFound;
  68498. private _mustUpdateRessources;
  68499. private _hasReachedQuota;
  68500. private _isSupported;
  68501. private _idbFactory;
  68502. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68503. private static IsUASupportingBlobStorage;
  68504. /**
  68505. * Gets a boolean indicating if Database storate is enabled (off by default)
  68506. */
  68507. static IDBStorageEnabled: boolean;
  68508. /**
  68509. * Gets a boolean indicating if scene must be saved in the database
  68510. */
  68511. get enableSceneOffline(): boolean;
  68512. /**
  68513. * Gets a boolean indicating if textures must be saved in the database
  68514. */
  68515. get enableTexturesOffline(): boolean;
  68516. /**
  68517. * Creates a new Database
  68518. * @param urlToScene defines the url to load the scene
  68519. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68520. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68521. */
  68522. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68523. private static _ParseURL;
  68524. private static _ReturnFullUrlLocation;
  68525. private _checkManifestFile;
  68526. /**
  68527. * Open the database and make it available
  68528. * @param successCallback defines the callback to call on success
  68529. * @param errorCallback defines the callback to call on error
  68530. */
  68531. open(successCallback: () => void, errorCallback: () => void): void;
  68532. /**
  68533. * Loads an image from the database
  68534. * @param url defines the url to load from
  68535. * @param image defines the target DOM image
  68536. */
  68537. loadImage(url: string, image: HTMLImageElement): void;
  68538. private _loadImageFromDBAsync;
  68539. private _saveImageIntoDBAsync;
  68540. private _checkVersionFromDB;
  68541. private _loadVersionFromDBAsync;
  68542. private _saveVersionIntoDBAsync;
  68543. /**
  68544. * Loads a file from database
  68545. * @param url defines the URL to load from
  68546. * @param sceneLoaded defines a callback to call on success
  68547. * @param progressCallBack defines a callback to call when progress changed
  68548. * @param errorCallback defines a callback to call on error
  68549. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68550. */
  68551. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68552. private _loadFileAsync;
  68553. private _saveFileAsync;
  68554. /**
  68555. * Validates if xhr data is correct
  68556. * @param xhr defines the request to validate
  68557. * @param dataType defines the expected data type
  68558. * @returns true if data is correct
  68559. */
  68560. private static _ValidateXHRData;
  68561. }
  68562. }
  68563. declare module BABYLON {
  68564. /** @hidden */
  68565. export var gpuUpdateParticlesPixelShader: {
  68566. name: string;
  68567. shader: string;
  68568. };
  68569. }
  68570. declare module BABYLON {
  68571. /** @hidden */
  68572. export var gpuUpdateParticlesVertexShader: {
  68573. name: string;
  68574. shader: string;
  68575. };
  68576. }
  68577. declare module BABYLON {
  68578. /** @hidden */
  68579. export var clipPlaneFragmentDeclaration2: {
  68580. name: string;
  68581. shader: string;
  68582. };
  68583. }
  68584. declare module BABYLON {
  68585. /** @hidden */
  68586. export var gpuRenderParticlesPixelShader: {
  68587. name: string;
  68588. shader: string;
  68589. };
  68590. }
  68591. declare module BABYLON {
  68592. /** @hidden */
  68593. export var clipPlaneVertexDeclaration2: {
  68594. name: string;
  68595. shader: string;
  68596. };
  68597. }
  68598. declare module BABYLON {
  68599. /** @hidden */
  68600. export var gpuRenderParticlesVertexShader: {
  68601. name: string;
  68602. shader: string;
  68603. };
  68604. }
  68605. declare module BABYLON {
  68606. /**
  68607. * This represents a GPU particle system in Babylon
  68608. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68609. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68610. */
  68611. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68612. /**
  68613. * The layer mask we are rendering the particles through.
  68614. */
  68615. layerMask: number;
  68616. private _capacity;
  68617. private _activeCount;
  68618. private _currentActiveCount;
  68619. private _accumulatedCount;
  68620. private _renderEffect;
  68621. private _updateEffect;
  68622. private _buffer0;
  68623. private _buffer1;
  68624. private _spriteBuffer;
  68625. private _updateVAO;
  68626. private _renderVAO;
  68627. private _targetIndex;
  68628. private _sourceBuffer;
  68629. private _targetBuffer;
  68630. private _currentRenderId;
  68631. private _started;
  68632. private _stopped;
  68633. private _timeDelta;
  68634. private _randomTexture;
  68635. private _randomTexture2;
  68636. private _attributesStrideSize;
  68637. private _updateEffectOptions;
  68638. private _randomTextureSize;
  68639. private _actualFrame;
  68640. private _customEffect;
  68641. private readonly _rawTextureWidth;
  68642. /**
  68643. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68644. */
  68645. static get IsSupported(): boolean;
  68646. /**
  68647. * An event triggered when the system is disposed.
  68648. */
  68649. onDisposeObservable: Observable<IParticleSystem>;
  68650. /**
  68651. * An event triggered when the system is stopped
  68652. */
  68653. onStoppedObservable: Observable<IParticleSystem>;
  68654. /**
  68655. * Gets the maximum number of particles active at the same time.
  68656. * @returns The max number of active particles.
  68657. */
  68658. getCapacity(): number;
  68659. /**
  68660. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68661. * to override the particles.
  68662. */
  68663. forceDepthWrite: boolean;
  68664. /**
  68665. * Gets or set the number of active particles
  68666. */
  68667. get activeParticleCount(): number;
  68668. set activeParticleCount(value: number);
  68669. private _preWarmDone;
  68670. /**
  68671. * Specifies if the particles are updated in emitter local space or world space.
  68672. */
  68673. isLocal: boolean;
  68674. /** Gets or sets a matrix to use to compute projection */
  68675. defaultProjectionMatrix: Matrix;
  68676. /**
  68677. * Is this system ready to be used/rendered
  68678. * @return true if the system is ready
  68679. */
  68680. isReady(): boolean;
  68681. /**
  68682. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68683. * @returns True if it has been started, otherwise false.
  68684. */
  68685. isStarted(): boolean;
  68686. /**
  68687. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68688. * @returns True if it has been stopped, otherwise false.
  68689. */
  68690. isStopped(): boolean;
  68691. /**
  68692. * Gets a boolean indicating that the system is stopping
  68693. * @returns true if the system is currently stopping
  68694. */
  68695. isStopping(): boolean;
  68696. /**
  68697. * Gets the number of particles active at the same time.
  68698. * @returns The number of active particles.
  68699. */
  68700. getActiveCount(): number;
  68701. /**
  68702. * Starts the particle system and begins to emit
  68703. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68704. */
  68705. start(delay?: number): void;
  68706. /**
  68707. * Stops the particle system.
  68708. */
  68709. stop(): void;
  68710. /**
  68711. * Remove all active particles
  68712. */
  68713. reset(): void;
  68714. /**
  68715. * Returns the string "GPUParticleSystem"
  68716. * @returns a string containing the class name
  68717. */
  68718. getClassName(): string;
  68719. /**
  68720. * Gets the custom effect used to render the particles
  68721. * @param blendMode Blend mode for which the effect should be retrieved
  68722. * @returns The effect
  68723. */
  68724. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68725. /**
  68726. * Sets the custom effect used to render the particles
  68727. * @param effect The effect to set
  68728. * @param blendMode Blend mode for which the effect should be set
  68729. */
  68730. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68731. /** @hidden */
  68732. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68733. /**
  68734. * Observable that will be called just before the particles are drawn
  68735. */
  68736. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68737. /**
  68738. * Gets the name of the particle vertex shader
  68739. */
  68740. get vertexShaderName(): string;
  68741. private _colorGradientsTexture;
  68742. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68743. /**
  68744. * Adds a new color gradient
  68745. * @param gradient defines the gradient to use (between 0 and 1)
  68746. * @param color1 defines the color to affect to the specified gradient
  68747. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68748. * @returns the current particle system
  68749. */
  68750. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68751. private _refreshColorGradient;
  68752. /** Force the system to rebuild all gradients that need to be resync */
  68753. forceRefreshGradients(): void;
  68754. /**
  68755. * Remove a specific color gradient
  68756. * @param gradient defines the gradient to remove
  68757. * @returns the current particle system
  68758. */
  68759. removeColorGradient(gradient: number): GPUParticleSystem;
  68760. private _angularSpeedGradientsTexture;
  68761. private _sizeGradientsTexture;
  68762. private _velocityGradientsTexture;
  68763. private _limitVelocityGradientsTexture;
  68764. private _dragGradientsTexture;
  68765. private _addFactorGradient;
  68766. /**
  68767. * Adds a new size gradient
  68768. * @param gradient defines the gradient to use (between 0 and 1)
  68769. * @param factor defines the size factor to affect to the specified gradient
  68770. * @returns the current particle system
  68771. */
  68772. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68773. /**
  68774. * Remove a specific size gradient
  68775. * @param gradient defines the gradient to remove
  68776. * @returns the current particle system
  68777. */
  68778. removeSizeGradient(gradient: number): GPUParticleSystem;
  68779. private _refreshFactorGradient;
  68780. /**
  68781. * Adds a new angular speed gradient
  68782. * @param gradient defines the gradient to use (between 0 and 1)
  68783. * @param factor defines the angular speed to affect to the specified gradient
  68784. * @returns the current particle system
  68785. */
  68786. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68787. /**
  68788. * Remove a specific angular speed gradient
  68789. * @param gradient defines the gradient to remove
  68790. * @returns the current particle system
  68791. */
  68792. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68793. /**
  68794. * Adds a new velocity gradient
  68795. * @param gradient defines the gradient to use (between 0 and 1)
  68796. * @param factor defines the velocity to affect to the specified gradient
  68797. * @returns the current particle system
  68798. */
  68799. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68800. /**
  68801. * Remove a specific velocity gradient
  68802. * @param gradient defines the gradient to remove
  68803. * @returns the current particle system
  68804. */
  68805. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68806. /**
  68807. * Adds a new limit velocity gradient
  68808. * @param gradient defines the gradient to use (between 0 and 1)
  68809. * @param factor defines the limit velocity value to affect to the specified gradient
  68810. * @returns the current particle system
  68811. */
  68812. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68813. /**
  68814. * Remove a specific limit velocity gradient
  68815. * @param gradient defines the gradient to remove
  68816. * @returns the current particle system
  68817. */
  68818. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68819. /**
  68820. * Adds a new drag gradient
  68821. * @param gradient defines the gradient to use (between 0 and 1)
  68822. * @param factor defines the drag value to affect to the specified gradient
  68823. * @returns the current particle system
  68824. */
  68825. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68826. /**
  68827. * Remove a specific drag gradient
  68828. * @param gradient defines the gradient to remove
  68829. * @returns the current particle system
  68830. */
  68831. removeDragGradient(gradient: number): GPUParticleSystem;
  68832. /**
  68833. * Not supported by GPUParticleSystem
  68834. * @param gradient defines the gradient to use (between 0 and 1)
  68835. * @param factor defines the emit rate value to affect to the specified gradient
  68836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68837. * @returns the current particle system
  68838. */
  68839. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68840. /**
  68841. * Not supported by GPUParticleSystem
  68842. * @param gradient defines the gradient to remove
  68843. * @returns the current particle system
  68844. */
  68845. removeEmitRateGradient(gradient: number): IParticleSystem;
  68846. /**
  68847. * Not supported by GPUParticleSystem
  68848. * @param gradient defines the gradient to use (between 0 and 1)
  68849. * @param factor defines the start size value to affect to the specified gradient
  68850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68851. * @returns the current particle system
  68852. */
  68853. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68854. /**
  68855. * Not supported by GPUParticleSystem
  68856. * @param gradient defines the gradient to remove
  68857. * @returns the current particle system
  68858. */
  68859. removeStartSizeGradient(gradient: number): IParticleSystem;
  68860. /**
  68861. * Not supported by GPUParticleSystem
  68862. * @param gradient defines the gradient to use (between 0 and 1)
  68863. * @param min defines the color remap minimal range
  68864. * @param max defines the color remap maximal range
  68865. * @returns the current particle system
  68866. */
  68867. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68868. /**
  68869. * Not supported by GPUParticleSystem
  68870. * @param gradient defines the gradient to remove
  68871. * @returns the current particle system
  68872. */
  68873. removeColorRemapGradient(): IParticleSystem;
  68874. /**
  68875. * Not supported by GPUParticleSystem
  68876. * @param gradient defines the gradient to use (between 0 and 1)
  68877. * @param min defines the alpha remap minimal range
  68878. * @param max defines the alpha remap maximal range
  68879. * @returns the current particle system
  68880. */
  68881. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68882. /**
  68883. * Not supported by GPUParticleSystem
  68884. * @param gradient defines the gradient to remove
  68885. * @returns the current particle system
  68886. */
  68887. removeAlphaRemapGradient(): IParticleSystem;
  68888. /**
  68889. * Not supported by GPUParticleSystem
  68890. * @param gradient defines the gradient to use (between 0 and 1)
  68891. * @param color defines the color to affect to the specified gradient
  68892. * @returns the current particle system
  68893. */
  68894. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68895. /**
  68896. * Not supported by GPUParticleSystem
  68897. * @param gradient defines the gradient to remove
  68898. * @returns the current particle system
  68899. */
  68900. removeRampGradient(): IParticleSystem;
  68901. /**
  68902. * Not supported by GPUParticleSystem
  68903. * @returns the list of ramp gradients
  68904. */
  68905. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68906. /**
  68907. * Not supported by GPUParticleSystem
  68908. * Gets or sets a boolean indicating that ramp gradients must be used
  68909. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68910. */
  68911. get useRampGradients(): boolean;
  68912. set useRampGradients(value: boolean);
  68913. /**
  68914. * Not supported by GPUParticleSystem
  68915. * @param gradient defines the gradient to use (between 0 and 1)
  68916. * @param factor defines the life time factor to affect to the specified gradient
  68917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68918. * @returns the current particle system
  68919. */
  68920. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68921. /**
  68922. * Not supported by GPUParticleSystem
  68923. * @param gradient defines the gradient to remove
  68924. * @returns the current particle system
  68925. */
  68926. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68927. /**
  68928. * Instantiates a GPU particle system.
  68929. * 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.
  68930. * @param name The name of the particle system
  68931. * @param options The options used to create the system
  68932. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68933. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68934. * @param customEffect a custom effect used to change the way particles are rendered by default
  68935. */
  68936. constructor(name: string, options: Partial<{
  68937. capacity: number;
  68938. randomTextureSize: number;
  68939. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68940. protected _reset(): void;
  68941. private _createUpdateVAO;
  68942. private _createRenderVAO;
  68943. private _initialize;
  68944. /** @hidden */
  68945. _recreateUpdateEffect(): void;
  68946. private _getEffect;
  68947. /**
  68948. * Fill the defines array according to the current settings of the particle system
  68949. * @param defines Array to be updated
  68950. * @param blendMode blend mode to take into account when updating the array
  68951. */
  68952. fillDefines(defines: Array<string>, blendMode?: number): void;
  68953. /**
  68954. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68955. * @param uniforms Uniforms array to fill
  68956. * @param attributes Attributes array to fill
  68957. * @param samplers Samplers array to fill
  68958. */
  68959. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68960. /** @hidden */
  68961. _recreateRenderEffect(): Effect;
  68962. /**
  68963. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68964. * @param preWarm defines if we are in the pre-warmimg phase
  68965. */
  68966. animate(preWarm?: boolean): void;
  68967. private _createFactorGradientTexture;
  68968. private _createSizeGradientTexture;
  68969. private _createAngularSpeedGradientTexture;
  68970. private _createVelocityGradientTexture;
  68971. private _createLimitVelocityGradientTexture;
  68972. private _createDragGradientTexture;
  68973. private _createColorGradientTexture;
  68974. /**
  68975. * Renders the particle system in its current state
  68976. * @param preWarm defines if the system should only update the particles but not render them
  68977. * @returns the current number of particles
  68978. */
  68979. render(preWarm?: boolean): number;
  68980. /**
  68981. * Rebuilds the particle system
  68982. */
  68983. rebuild(): void;
  68984. private _releaseBuffers;
  68985. private _releaseVAOs;
  68986. /**
  68987. * Disposes the particle system and free the associated resources
  68988. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68989. */
  68990. dispose(disposeTexture?: boolean): void;
  68991. /**
  68992. * Clones the particle system.
  68993. * @param name The name of the cloned object
  68994. * @param newEmitter The new emitter to use
  68995. * @returns the cloned particle system
  68996. */
  68997. clone(name: string, newEmitter: any): GPUParticleSystem;
  68998. /**
  68999. * Serializes the particle system to a JSON object
  69000. * @param serializeTexture defines if the texture must be serialized as well
  69001. * @returns the JSON object
  69002. */
  69003. serialize(serializeTexture?: boolean): any;
  69004. /**
  69005. * Parses a JSON object to create a GPU particle system.
  69006. * @param parsedParticleSystem The JSON object to parse
  69007. * @param sceneOrEngine The scene or the engine to create the particle system in
  69008. * @param rootUrl The root url to use to load external dependencies like texture
  69009. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69010. * @returns the parsed GPU particle system
  69011. */
  69012. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69013. }
  69014. }
  69015. declare module BABYLON {
  69016. /**
  69017. * Represents a set of particle systems working together to create a specific effect
  69018. */
  69019. export class ParticleSystemSet implements IDisposable {
  69020. /**
  69021. * Gets or sets base Assets URL
  69022. */
  69023. static BaseAssetsUrl: string;
  69024. private _emitterCreationOptions;
  69025. private _emitterNode;
  69026. /**
  69027. * Gets the particle system list
  69028. */
  69029. systems: IParticleSystem[];
  69030. /**
  69031. * Gets the emitter node used with this set
  69032. */
  69033. get emitterNode(): Nullable<TransformNode>;
  69034. /**
  69035. * Creates a new emitter mesh as a sphere
  69036. * @param options defines the options used to create the sphere
  69037. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69038. * @param scene defines the hosting scene
  69039. */
  69040. setEmitterAsSphere(options: {
  69041. diameter: number;
  69042. segments: number;
  69043. color: Color3;
  69044. }, renderingGroupId: number, scene: Scene): void;
  69045. /**
  69046. * Starts all particle systems of the set
  69047. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69048. */
  69049. start(emitter?: AbstractMesh): void;
  69050. /**
  69051. * Release all associated resources
  69052. */
  69053. dispose(): void;
  69054. /**
  69055. * Serialize the set into a JSON compatible object
  69056. * @param serializeTexture defines if the texture must be serialized as well
  69057. * @returns a JSON compatible representation of the set
  69058. */
  69059. serialize(serializeTexture?: boolean): any;
  69060. /**
  69061. * Parse a new ParticleSystemSet from a serialized source
  69062. * @param data defines a JSON compatible representation of the set
  69063. * @param scene defines the hosting scene
  69064. * @param gpu defines if we want GPU particles or CPU particles
  69065. * @returns a new ParticleSystemSet
  69066. */
  69067. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69068. }
  69069. }
  69070. declare module BABYLON {
  69071. /**
  69072. * This class is made for on one-liner static method to help creating particle system set.
  69073. */
  69074. export class ParticleHelper {
  69075. /**
  69076. * Gets or sets base Assets URL
  69077. */
  69078. static BaseAssetsUrl: string;
  69079. /** Define the Url to load snippets */
  69080. static SnippetUrl: string;
  69081. /**
  69082. * Create a default particle system that you can tweak
  69083. * @param emitter defines the emitter to use
  69084. * @param capacity defines the system capacity (default is 500 particles)
  69085. * @param scene defines the hosting scene
  69086. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69087. * @returns the new Particle system
  69088. */
  69089. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69090. /**
  69091. * This is the main static method (one-liner) of this helper to create different particle systems
  69092. * @param type This string represents the type to the particle system to create
  69093. * @param scene The scene where the particle system should live
  69094. * @param gpu If the system will use gpu
  69095. * @returns the ParticleSystemSet created
  69096. */
  69097. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69098. /**
  69099. * Static function used to export a particle system to a ParticleSystemSet variable.
  69100. * Please note that the emitter shape is not exported
  69101. * @param systems defines the particle systems to export
  69102. * @returns the created particle system set
  69103. */
  69104. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69105. /**
  69106. * Creates a particle system from a snippet saved in a remote file
  69107. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69108. * @param url defines the url to load from
  69109. * @param scene defines the hosting scene
  69110. * @param gpu If the system will use gpu
  69111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69112. * @returns a promise that will resolve to the new particle system
  69113. */
  69114. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69115. /**
  69116. * Creates a particle system from a snippet saved by the particle system editor
  69117. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69118. * @param scene defines the hosting scene
  69119. * @param gpu If the system will use gpu
  69120. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69121. * @returns a promise that will resolve to the new particle system
  69122. */
  69123. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69124. }
  69125. }
  69126. declare module BABYLON {
  69127. interface Engine {
  69128. /**
  69129. * Create an effect to use with particle systems.
  69130. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69131. * the particle system for which you want to create a custom effect in the last parameter
  69132. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69133. * @param uniformsNames defines a list of attribute names
  69134. * @param samplers defines an array of string used to represent textures
  69135. * @param defines defines the string containing the defines to use to compile the shaders
  69136. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69137. * @param onCompiled defines a function to call when the effect creation is successful
  69138. * @param onError defines a function to call when the effect creation has failed
  69139. * @param particleSystem the particle system you want to create the effect for
  69140. * @returns the new Effect
  69141. */
  69142. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69143. }
  69144. interface Mesh {
  69145. /**
  69146. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69147. * @returns an array of IParticleSystem
  69148. */
  69149. getEmittedParticleSystems(): IParticleSystem[];
  69150. /**
  69151. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69152. * @returns an array of IParticleSystem
  69153. */
  69154. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69155. }
  69156. }
  69157. declare module BABYLON {
  69158. /** Defines the 4 color options */
  69159. export enum PointColor {
  69160. /** color value */
  69161. Color = 2,
  69162. /** uv value */
  69163. UV = 1,
  69164. /** random value */
  69165. Random = 0,
  69166. /** stated value */
  69167. Stated = 3
  69168. }
  69169. /**
  69170. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69171. * 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.
  69172. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69173. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69174. *
  69175. * Full documentation here : TO BE ENTERED
  69176. */
  69177. export class PointsCloudSystem implements IDisposable {
  69178. /**
  69179. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69180. * Example : var p = SPS.particles[i];
  69181. */
  69182. particles: CloudPoint[];
  69183. /**
  69184. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69185. */
  69186. nbParticles: number;
  69187. /**
  69188. * This a counter for your own usage. It's not set by any SPS functions.
  69189. */
  69190. counter: number;
  69191. /**
  69192. * The PCS name. This name is also given to the underlying mesh.
  69193. */
  69194. name: string;
  69195. /**
  69196. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69197. */
  69198. mesh: Mesh;
  69199. /**
  69200. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69201. * Please read :
  69202. */
  69203. vars: any;
  69204. /**
  69205. * @hidden
  69206. */
  69207. _size: number;
  69208. private _scene;
  69209. private _promises;
  69210. private _positions;
  69211. private _indices;
  69212. private _normals;
  69213. private _colors;
  69214. private _uvs;
  69215. private _indices32;
  69216. private _positions32;
  69217. private _colors32;
  69218. private _uvs32;
  69219. private _updatable;
  69220. private _isVisibilityBoxLocked;
  69221. private _alwaysVisible;
  69222. private _groups;
  69223. private _groupCounter;
  69224. private _computeParticleColor;
  69225. private _computeParticleTexture;
  69226. private _computeParticleRotation;
  69227. private _computeBoundingBox;
  69228. private _isReady;
  69229. /**
  69230. * Creates a PCS (Points Cloud System) object
  69231. * @param name (String) is the PCS name, this will be the underlying mesh name
  69232. * @param pointSize (number) is the size for each point
  69233. * @param scene (Scene) is the scene in which the PCS is added
  69234. * @param options defines the options of the PCS e.g.
  69235. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69236. */
  69237. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69238. updatable?: boolean;
  69239. });
  69240. /**
  69241. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69242. * If no points were added to the PCS, the returned mesh is just a single point.
  69243. * @returns a promise for the created mesh
  69244. */
  69245. buildMeshAsync(): Promise<Mesh>;
  69246. /**
  69247. * @hidden
  69248. */
  69249. private _buildMesh;
  69250. private _addParticle;
  69251. private _randomUnitVector;
  69252. private _getColorIndicesForCoord;
  69253. private _setPointsColorOrUV;
  69254. private _colorFromTexture;
  69255. private _calculateDensity;
  69256. /**
  69257. * Adds points to the PCS in random positions within a unit sphere
  69258. * @param nb (positive integer) the number of particles to be created from this model
  69259. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69260. * @returns the number of groups in the system
  69261. */
  69262. addPoints(nb: number, pointFunction?: any): number;
  69263. /**
  69264. * Adds points to the PCS from the surface of the model shape
  69265. * @param mesh is any Mesh object that will be used as a surface model for the points
  69266. * @param nb (positive integer) the number of particles to be created from this model
  69267. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69268. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69269. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69270. * @returns the number of groups in the system
  69271. */
  69272. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69273. /**
  69274. * Adds points to the PCS inside the model shape
  69275. * @param mesh is any Mesh object that will be used as a surface model for the points
  69276. * @param nb (positive integer) the number of particles to be created from this model
  69277. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69278. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69279. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69280. * @returns the number of groups in the system
  69281. */
  69282. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69283. /**
  69284. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69285. * This method calls `updateParticle()` for each particle of the SPS.
  69286. * For an animated SPS, it is usually called within the render loop.
  69287. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69288. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69289. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69290. * @returns the PCS.
  69291. */
  69292. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69293. /**
  69294. * Disposes the PCS.
  69295. */
  69296. dispose(): void;
  69297. /**
  69298. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69299. * doc :
  69300. * @returns the PCS.
  69301. */
  69302. refreshVisibleSize(): PointsCloudSystem;
  69303. /**
  69304. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69305. * @param size the size (float) of the visibility box
  69306. * note : this doesn't lock the PCS mesh bounding box.
  69307. * doc :
  69308. */
  69309. setVisibilityBox(size: number): void;
  69310. /**
  69311. * Gets whether the PCS is always visible or not
  69312. * doc :
  69313. */
  69314. get isAlwaysVisible(): boolean;
  69315. /**
  69316. * Sets the PCS as always visible or not
  69317. * doc :
  69318. */
  69319. set isAlwaysVisible(val: boolean);
  69320. /**
  69321. * Tells to `setParticles()` to compute the particle rotations or not
  69322. * Default value : false. The PCS is faster when it's set to false
  69323. * Note : particle rotations are only applied to parent particles
  69324. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69325. */
  69326. set computeParticleRotation(val: boolean);
  69327. /**
  69328. * Tells to `setParticles()` to compute the particle colors or not.
  69329. * Default value : true. The PCS is faster when it's set to false.
  69330. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69331. */
  69332. set computeParticleColor(val: boolean);
  69333. set computeParticleTexture(val: boolean);
  69334. /**
  69335. * Gets if `setParticles()` computes the particle colors or not.
  69336. * Default value : false. The PCS is faster when it's set to false.
  69337. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69338. */
  69339. get computeParticleColor(): boolean;
  69340. /**
  69341. * Gets if `setParticles()` computes the particle textures or not.
  69342. * Default value : false. The PCS is faster when it's set to false.
  69343. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69344. */
  69345. get computeParticleTexture(): boolean;
  69346. /**
  69347. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69348. */
  69349. set computeBoundingBox(val: boolean);
  69350. /**
  69351. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69352. */
  69353. get computeBoundingBox(): boolean;
  69354. /**
  69355. * This function does nothing. It may be overwritten to set all the particle first values.
  69356. * The PCS doesn't call this function, you may have to call it by your own.
  69357. * doc :
  69358. */
  69359. initParticles(): void;
  69360. /**
  69361. * This function does nothing. It may be overwritten to recycle a particle
  69362. * The PCS doesn't call this function, you can to call it
  69363. * doc :
  69364. * @param particle The particle to recycle
  69365. * @returns the recycled particle
  69366. */
  69367. recycleParticle(particle: CloudPoint): CloudPoint;
  69368. /**
  69369. * Updates a particle : this function should be overwritten by the user.
  69370. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69371. * doc :
  69372. * @example : just set a particle position or velocity and recycle conditions
  69373. * @param particle The particle to update
  69374. * @returns the updated particle
  69375. */
  69376. updateParticle(particle: CloudPoint): CloudPoint;
  69377. /**
  69378. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69379. * This does nothing and may be overwritten by the user.
  69380. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69381. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69382. * @param update the boolean update value actually passed to setParticles()
  69383. */
  69384. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69385. /**
  69386. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69387. * This will be passed three parameters.
  69388. * This does nothing and may be overwritten by the user.
  69389. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69390. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69391. * @param update the boolean update value actually passed to setParticles()
  69392. */
  69393. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69394. }
  69395. }
  69396. declare module BABYLON {
  69397. /**
  69398. * Represents one particle of a points cloud system.
  69399. */
  69400. export class CloudPoint {
  69401. /**
  69402. * particle global index
  69403. */
  69404. idx: number;
  69405. /**
  69406. * The color of the particle
  69407. */
  69408. color: Nullable<Color4>;
  69409. /**
  69410. * The world space position of the particle.
  69411. */
  69412. position: Vector3;
  69413. /**
  69414. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69415. */
  69416. rotation: Vector3;
  69417. /**
  69418. * The world space rotation quaternion of the particle.
  69419. */
  69420. rotationQuaternion: Nullable<Quaternion>;
  69421. /**
  69422. * The uv of the particle.
  69423. */
  69424. uv: Nullable<Vector2>;
  69425. /**
  69426. * The current speed of the particle.
  69427. */
  69428. velocity: Vector3;
  69429. /**
  69430. * The pivot point in the particle local space.
  69431. */
  69432. pivot: Vector3;
  69433. /**
  69434. * Must the particle be translated from its pivot point in its local space ?
  69435. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69436. * Default : false
  69437. */
  69438. translateFromPivot: boolean;
  69439. /**
  69440. * Index of this particle in the global "positions" array (Internal use)
  69441. * @hidden
  69442. */
  69443. _pos: number;
  69444. /**
  69445. * @hidden Index of this particle in the global "indices" array (Internal use)
  69446. */
  69447. _ind: number;
  69448. /**
  69449. * Group this particle belongs to
  69450. */
  69451. _group: PointsGroup;
  69452. /**
  69453. * Group id of this particle
  69454. */
  69455. groupId: number;
  69456. /**
  69457. * Index of the particle in its group id (Internal use)
  69458. */
  69459. idxInGroup: number;
  69460. /**
  69461. * @hidden Particle BoundingInfo object (Internal use)
  69462. */
  69463. _boundingInfo: BoundingInfo;
  69464. /**
  69465. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69466. */
  69467. _pcs: PointsCloudSystem;
  69468. /**
  69469. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69470. */
  69471. _stillInvisible: boolean;
  69472. /**
  69473. * @hidden Last computed particle rotation matrix
  69474. */
  69475. _rotationMatrix: number[];
  69476. /**
  69477. * Parent particle Id, if any.
  69478. * Default null.
  69479. */
  69480. parentId: Nullable<number>;
  69481. /**
  69482. * @hidden Internal global position in the PCS.
  69483. */
  69484. _globalPosition: Vector3;
  69485. /**
  69486. * Creates a Point Cloud object.
  69487. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69488. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69489. * @param group (PointsGroup) is the group the particle belongs to
  69490. * @param groupId (integer) is the group identifier in the PCS.
  69491. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69492. * @param pcs defines the PCS it is associated to
  69493. */
  69494. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69495. /**
  69496. * get point size
  69497. */
  69498. get size(): Vector3;
  69499. /**
  69500. * Set point size
  69501. */
  69502. set size(scale: Vector3);
  69503. /**
  69504. * Legacy support, changed quaternion to rotationQuaternion
  69505. */
  69506. get quaternion(): Nullable<Quaternion>;
  69507. /**
  69508. * Legacy support, changed quaternion to rotationQuaternion
  69509. */
  69510. set quaternion(q: Nullable<Quaternion>);
  69511. /**
  69512. * Returns a boolean. True if the particle intersects a mesh, else false
  69513. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69514. * @param target is the object (point or mesh) what the intersection is computed against
  69515. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69516. * @returns true if it intersects
  69517. */
  69518. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69519. /**
  69520. * get the rotation matrix of the particle
  69521. * @hidden
  69522. */
  69523. getRotationMatrix(m: Matrix): void;
  69524. }
  69525. /**
  69526. * Represents a group of points in a points cloud system
  69527. * * PCS internal tool, don't use it manually.
  69528. */
  69529. export class PointsGroup {
  69530. /**
  69531. * The group id
  69532. * @hidden
  69533. */
  69534. groupID: number;
  69535. /**
  69536. * image data for group (internal use)
  69537. * @hidden
  69538. */
  69539. _groupImageData: Nullable<ArrayBufferView>;
  69540. /**
  69541. * Image Width (internal use)
  69542. * @hidden
  69543. */
  69544. _groupImgWidth: number;
  69545. /**
  69546. * Image Height (internal use)
  69547. * @hidden
  69548. */
  69549. _groupImgHeight: number;
  69550. /**
  69551. * Custom position function (internal use)
  69552. * @hidden
  69553. */
  69554. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69555. /**
  69556. * density per facet for surface points
  69557. * @hidden
  69558. */
  69559. _groupDensity: number[];
  69560. /**
  69561. * Only when points are colored by texture carries pointer to texture list array
  69562. * @hidden
  69563. */
  69564. _textureNb: number;
  69565. /**
  69566. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69567. * PCS internal tool, don't use it manually.
  69568. * @hidden
  69569. */
  69570. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69571. }
  69572. }
  69573. declare module BABYLON {
  69574. interface Scene {
  69575. /** @hidden (Backing field) */
  69576. _physicsEngine: Nullable<IPhysicsEngine>;
  69577. /** @hidden */
  69578. _physicsTimeAccumulator: number;
  69579. /**
  69580. * Gets the current physics engine
  69581. * @returns a IPhysicsEngine or null if none attached
  69582. */
  69583. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69584. /**
  69585. * Enables physics to the current scene
  69586. * @param gravity defines the scene's gravity for the physics engine
  69587. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69588. * @return a boolean indicating if the physics engine was initialized
  69589. */
  69590. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69591. /**
  69592. * Disables and disposes the physics engine associated with the scene
  69593. */
  69594. disablePhysicsEngine(): void;
  69595. /**
  69596. * Gets a boolean indicating if there is an active physics engine
  69597. * @returns a boolean indicating if there is an active physics engine
  69598. */
  69599. isPhysicsEnabled(): boolean;
  69600. /**
  69601. * Deletes a physics compound impostor
  69602. * @param compound defines the compound to delete
  69603. */
  69604. deleteCompoundImpostor(compound: any): void;
  69605. /**
  69606. * An event triggered when physic simulation is about to be run
  69607. */
  69608. onBeforePhysicsObservable: Observable<Scene>;
  69609. /**
  69610. * An event triggered when physic simulation has been done
  69611. */
  69612. onAfterPhysicsObservable: Observable<Scene>;
  69613. }
  69614. interface AbstractMesh {
  69615. /** @hidden */
  69616. _physicsImpostor: Nullable<PhysicsImpostor>;
  69617. /**
  69618. * Gets or sets impostor used for physic simulation
  69619. * @see https://doc.babylonjs.com/features/physics_engine
  69620. */
  69621. physicsImpostor: Nullable<PhysicsImpostor>;
  69622. /**
  69623. * Gets the current physics impostor
  69624. * @see https://doc.babylonjs.com/features/physics_engine
  69625. * @returns a physics impostor or null
  69626. */
  69627. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69628. /** Apply a physic impulse to the mesh
  69629. * @param force defines the force to apply
  69630. * @param contactPoint defines where to apply the force
  69631. * @returns the current mesh
  69632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69633. */
  69634. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69635. /**
  69636. * Creates a physic joint between two meshes
  69637. * @param otherMesh defines the other mesh to use
  69638. * @param pivot1 defines the pivot to use on this mesh
  69639. * @param pivot2 defines the pivot to use on the other mesh
  69640. * @param options defines additional options (can be plugin dependent)
  69641. * @returns the current mesh
  69642. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69643. */
  69644. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69645. /** @hidden */
  69646. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69647. }
  69648. /**
  69649. * Defines the physics engine scene component responsible to manage a physics engine
  69650. */
  69651. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69652. /**
  69653. * The component name helpful to identify the component in the list of scene components.
  69654. */
  69655. readonly name: string;
  69656. /**
  69657. * The scene the component belongs to.
  69658. */
  69659. scene: Scene;
  69660. /**
  69661. * Creates a new instance of the component for the given scene
  69662. * @param scene Defines the scene to register the component in
  69663. */
  69664. constructor(scene: Scene);
  69665. /**
  69666. * Registers the component in a given scene
  69667. */
  69668. register(): void;
  69669. /**
  69670. * Rebuilds the elements related to this component in case of
  69671. * context lost for instance.
  69672. */
  69673. rebuild(): void;
  69674. /**
  69675. * Disposes the component and the associated ressources
  69676. */
  69677. dispose(): void;
  69678. }
  69679. }
  69680. declare module BABYLON {
  69681. /**
  69682. * A helper for physics simulations
  69683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69684. */
  69685. export class PhysicsHelper {
  69686. private _scene;
  69687. private _physicsEngine;
  69688. /**
  69689. * Initializes the Physics helper
  69690. * @param scene Babylon.js scene
  69691. */
  69692. constructor(scene: Scene);
  69693. /**
  69694. * Applies a radial explosion impulse
  69695. * @param origin the origin of the explosion
  69696. * @param radiusOrEventOptions the radius or the options of radial explosion
  69697. * @param strength the explosion strength
  69698. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69699. * @returns A physics radial explosion event, or null
  69700. */
  69701. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69702. /**
  69703. * Applies a radial explosion force
  69704. * @param origin the origin of the explosion
  69705. * @param radiusOrEventOptions the radius or the options of radial explosion
  69706. * @param strength the explosion strength
  69707. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69708. * @returns A physics radial explosion event, or null
  69709. */
  69710. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69711. /**
  69712. * Creates a gravitational field
  69713. * @param origin the origin of the explosion
  69714. * @param radiusOrEventOptions the radius or the options of radial explosion
  69715. * @param strength the explosion strength
  69716. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69717. * @returns A physics gravitational field event, or null
  69718. */
  69719. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69720. /**
  69721. * Creates a physics updraft event
  69722. * @param origin the origin of the updraft
  69723. * @param radiusOrEventOptions the radius or the options of the updraft
  69724. * @param strength the strength of the updraft
  69725. * @param height the height of the updraft
  69726. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69727. * @returns A physics updraft event, or null
  69728. */
  69729. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69730. /**
  69731. * Creates a physics vortex event
  69732. * @param origin the of the vortex
  69733. * @param radiusOrEventOptions the radius or the options of the vortex
  69734. * @param strength the strength of the vortex
  69735. * @param height the height of the vortex
  69736. * @returns a Physics vortex event, or null
  69737. * A physics vortex event or null
  69738. */
  69739. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69740. }
  69741. /**
  69742. * Represents a physics radial explosion event
  69743. */
  69744. class PhysicsRadialExplosionEvent {
  69745. private _scene;
  69746. private _options;
  69747. private _sphere;
  69748. private _dataFetched;
  69749. /**
  69750. * Initializes a radial explosioin event
  69751. * @param _scene BabylonJS scene
  69752. * @param _options The options for the vortex event
  69753. */
  69754. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69755. /**
  69756. * Returns the data related to the radial explosion event (sphere).
  69757. * @returns The radial explosion event data
  69758. */
  69759. getData(): PhysicsRadialExplosionEventData;
  69760. /**
  69761. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69762. * @param impostor A physics imposter
  69763. * @param origin the origin of the explosion
  69764. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69765. */
  69766. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69767. /**
  69768. * Triggers affecterd impostors callbacks
  69769. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69770. */
  69771. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69772. /**
  69773. * Disposes the sphere.
  69774. * @param force Specifies if the sphere should be disposed by force
  69775. */
  69776. dispose(force?: boolean): void;
  69777. /*** Helpers ***/
  69778. private _prepareSphere;
  69779. private _intersectsWithSphere;
  69780. }
  69781. /**
  69782. * Represents a gravitational field event
  69783. */
  69784. class PhysicsGravitationalFieldEvent {
  69785. private _physicsHelper;
  69786. private _scene;
  69787. private _origin;
  69788. private _options;
  69789. private _tickCallback;
  69790. private _sphere;
  69791. private _dataFetched;
  69792. /**
  69793. * Initializes the physics gravitational field event
  69794. * @param _physicsHelper A physics helper
  69795. * @param _scene BabylonJS scene
  69796. * @param _origin The origin position of the gravitational field event
  69797. * @param _options The options for the vortex event
  69798. */
  69799. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69800. /**
  69801. * Returns the data related to the gravitational field event (sphere).
  69802. * @returns A gravitational field event
  69803. */
  69804. getData(): PhysicsGravitationalFieldEventData;
  69805. /**
  69806. * Enables the gravitational field.
  69807. */
  69808. enable(): void;
  69809. /**
  69810. * Disables the gravitational field.
  69811. */
  69812. disable(): void;
  69813. /**
  69814. * Disposes the sphere.
  69815. * @param force The force to dispose from the gravitational field event
  69816. */
  69817. dispose(force?: boolean): void;
  69818. private _tick;
  69819. }
  69820. /**
  69821. * Represents a physics updraft event
  69822. */
  69823. class PhysicsUpdraftEvent {
  69824. private _scene;
  69825. private _origin;
  69826. private _options;
  69827. private _physicsEngine;
  69828. private _originTop;
  69829. private _originDirection;
  69830. private _tickCallback;
  69831. private _cylinder;
  69832. private _cylinderPosition;
  69833. private _dataFetched;
  69834. /**
  69835. * Initializes the physics updraft event
  69836. * @param _scene BabylonJS scene
  69837. * @param _origin The origin position of the updraft
  69838. * @param _options The options for the updraft event
  69839. */
  69840. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69841. /**
  69842. * Returns the data related to the updraft event (cylinder).
  69843. * @returns A physics updraft event
  69844. */
  69845. getData(): PhysicsUpdraftEventData;
  69846. /**
  69847. * Enables the updraft.
  69848. */
  69849. enable(): void;
  69850. /**
  69851. * Disables the updraft.
  69852. */
  69853. disable(): void;
  69854. /**
  69855. * Disposes the cylinder.
  69856. * @param force Specifies if the updraft should be disposed by force
  69857. */
  69858. dispose(force?: boolean): void;
  69859. private getImpostorHitData;
  69860. private _tick;
  69861. /*** Helpers ***/
  69862. private _prepareCylinder;
  69863. private _intersectsWithCylinder;
  69864. }
  69865. /**
  69866. * Represents a physics vortex event
  69867. */
  69868. class PhysicsVortexEvent {
  69869. private _scene;
  69870. private _origin;
  69871. private _options;
  69872. private _physicsEngine;
  69873. private _originTop;
  69874. private _tickCallback;
  69875. private _cylinder;
  69876. private _cylinderPosition;
  69877. private _dataFetched;
  69878. /**
  69879. * Initializes the physics vortex event
  69880. * @param _scene The BabylonJS scene
  69881. * @param _origin The origin position of the vortex
  69882. * @param _options The options for the vortex event
  69883. */
  69884. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69885. /**
  69886. * Returns the data related to the vortex event (cylinder).
  69887. * @returns The physics vortex event data
  69888. */
  69889. getData(): PhysicsVortexEventData;
  69890. /**
  69891. * Enables the vortex.
  69892. */
  69893. enable(): void;
  69894. /**
  69895. * Disables the cortex.
  69896. */
  69897. disable(): void;
  69898. /**
  69899. * Disposes the sphere.
  69900. * @param force
  69901. */
  69902. dispose(force?: boolean): void;
  69903. private getImpostorHitData;
  69904. private _tick;
  69905. /*** Helpers ***/
  69906. private _prepareCylinder;
  69907. private _intersectsWithCylinder;
  69908. }
  69909. /**
  69910. * Options fot the radial explosion event
  69911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69912. */
  69913. export class PhysicsRadialExplosionEventOptions {
  69914. /**
  69915. * The radius of the sphere for the radial explosion.
  69916. */
  69917. radius: number;
  69918. /**
  69919. * The strenth of the explosion.
  69920. */
  69921. strength: number;
  69922. /**
  69923. * The strenght of the force in correspondence to the distance of the affected object
  69924. */
  69925. falloff: PhysicsRadialImpulseFalloff;
  69926. /**
  69927. * Sphere options for the radial explosion.
  69928. */
  69929. sphere: {
  69930. segments: number;
  69931. diameter: number;
  69932. };
  69933. /**
  69934. * Sphere options for the radial explosion.
  69935. */
  69936. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69937. }
  69938. /**
  69939. * Options fot the updraft event
  69940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69941. */
  69942. export class PhysicsUpdraftEventOptions {
  69943. /**
  69944. * The radius of the cylinder for the vortex
  69945. */
  69946. radius: number;
  69947. /**
  69948. * The strenth of the updraft.
  69949. */
  69950. strength: number;
  69951. /**
  69952. * The height of the cylinder for the updraft.
  69953. */
  69954. height: number;
  69955. /**
  69956. * The mode for the the updraft.
  69957. */
  69958. updraftMode: PhysicsUpdraftMode;
  69959. }
  69960. /**
  69961. * Options fot the vortex event
  69962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69963. */
  69964. export class PhysicsVortexEventOptions {
  69965. /**
  69966. * The radius of the cylinder for the vortex
  69967. */
  69968. radius: number;
  69969. /**
  69970. * The strenth of the vortex.
  69971. */
  69972. strength: number;
  69973. /**
  69974. * The height of the cylinder for the vortex.
  69975. */
  69976. height: number;
  69977. /**
  69978. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69979. */
  69980. centripetalForceThreshold: number;
  69981. /**
  69982. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69983. */
  69984. centripetalForceMultiplier: number;
  69985. /**
  69986. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69987. */
  69988. centrifugalForceMultiplier: number;
  69989. /**
  69990. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69991. */
  69992. updraftForceMultiplier: number;
  69993. }
  69994. /**
  69995. * The strenght of the force in correspondence to the distance of the affected object
  69996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69997. */
  69998. export enum PhysicsRadialImpulseFalloff {
  69999. /** Defines that impulse is constant in strength across it's whole radius */
  70000. Constant = 0,
  70001. /** Defines that impulse gets weaker if it's further from the origin */
  70002. Linear = 1
  70003. }
  70004. /**
  70005. * The strength of the force in correspondence to the distance of the affected object
  70006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70007. */
  70008. export enum PhysicsUpdraftMode {
  70009. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70010. Center = 0,
  70011. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70012. Perpendicular = 1
  70013. }
  70014. /**
  70015. * Interface for a physics hit data
  70016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70017. */
  70018. export interface PhysicsHitData {
  70019. /**
  70020. * The force applied at the contact point
  70021. */
  70022. force: Vector3;
  70023. /**
  70024. * The contact point
  70025. */
  70026. contactPoint: Vector3;
  70027. /**
  70028. * The distance from the origin to the contact point
  70029. */
  70030. distanceFromOrigin: number;
  70031. }
  70032. /**
  70033. * Interface for radial explosion event data
  70034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70035. */
  70036. export interface PhysicsRadialExplosionEventData {
  70037. /**
  70038. * A sphere used for the radial explosion event
  70039. */
  70040. sphere: Mesh;
  70041. }
  70042. /**
  70043. * Interface for gravitational field event data
  70044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70045. */
  70046. export interface PhysicsGravitationalFieldEventData {
  70047. /**
  70048. * A sphere mesh used for the gravitational field event
  70049. */
  70050. sphere: Mesh;
  70051. }
  70052. /**
  70053. * Interface for updraft event data
  70054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70055. */
  70056. export interface PhysicsUpdraftEventData {
  70057. /**
  70058. * A cylinder used for the updraft event
  70059. */
  70060. cylinder: Mesh;
  70061. }
  70062. /**
  70063. * Interface for vortex event data
  70064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70065. */
  70066. export interface PhysicsVortexEventData {
  70067. /**
  70068. * A cylinder used for the vortex event
  70069. */
  70070. cylinder: Mesh;
  70071. }
  70072. /**
  70073. * Interface for an affected physics impostor
  70074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70075. */
  70076. export interface PhysicsAffectedImpostorWithData {
  70077. /**
  70078. * The impostor affected by the effect
  70079. */
  70080. impostor: PhysicsImpostor;
  70081. /**
  70082. * The data about the hit/horce from the explosion
  70083. */
  70084. hitData: PhysicsHitData;
  70085. }
  70086. }
  70087. declare module BABYLON {
  70088. /** @hidden */
  70089. export var blackAndWhitePixelShader: {
  70090. name: string;
  70091. shader: string;
  70092. };
  70093. }
  70094. declare module BABYLON {
  70095. /**
  70096. * Post process used to render in black and white
  70097. */
  70098. export class BlackAndWhitePostProcess extends PostProcess {
  70099. /**
  70100. * Linear about to convert he result to black and white (default: 1)
  70101. */
  70102. degree: number;
  70103. /**
  70104. * Gets a string identifying the name of the class
  70105. * @returns "BlackAndWhitePostProcess" string
  70106. */
  70107. getClassName(): string;
  70108. /**
  70109. * Creates a black and white post process
  70110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70111. * @param name The name of the effect.
  70112. * @param options The required width/height ratio to downsize to before computing the render pass.
  70113. * @param camera The camera to apply the render pass to.
  70114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70115. * @param engine The engine which the post process will be applied. (default: current engine)
  70116. * @param reusable If the post process can be reused on the same frame. (default: false)
  70117. */
  70118. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70119. /** @hidden */
  70120. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70121. }
  70122. }
  70123. declare module BABYLON {
  70124. /**
  70125. * This represents a set of one or more post processes in Babylon.
  70126. * A post process can be used to apply a shader to a texture after it is rendered.
  70127. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70128. */
  70129. export class PostProcessRenderEffect {
  70130. private _postProcesses;
  70131. private _getPostProcesses;
  70132. private _singleInstance;
  70133. private _cameras;
  70134. private _indicesForCamera;
  70135. /**
  70136. * Name of the effect
  70137. * @hidden
  70138. */
  70139. _name: string;
  70140. /**
  70141. * Instantiates a post process render effect.
  70142. * A post process can be used to apply a shader to a texture after it is rendered.
  70143. * @param engine The engine the effect is tied to
  70144. * @param name The name of the effect
  70145. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70146. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70147. */
  70148. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70149. /**
  70150. * Checks if all the post processes in the effect are supported.
  70151. */
  70152. get isSupported(): boolean;
  70153. /**
  70154. * Updates the current state of the effect
  70155. * @hidden
  70156. */
  70157. _update(): void;
  70158. /**
  70159. * Attaches the effect on cameras
  70160. * @param cameras The camera to attach to.
  70161. * @hidden
  70162. */
  70163. _attachCameras(cameras: Camera): void;
  70164. /**
  70165. * Attaches the effect on cameras
  70166. * @param cameras The camera to attach to.
  70167. * @hidden
  70168. */
  70169. _attachCameras(cameras: Camera[]): void;
  70170. /**
  70171. * Detaches the effect on cameras
  70172. * @param cameras The camera to detatch from.
  70173. * @hidden
  70174. */
  70175. _detachCameras(cameras: Camera): void;
  70176. /**
  70177. * Detatches the effect on cameras
  70178. * @param cameras The camera to detatch from.
  70179. * @hidden
  70180. */
  70181. _detachCameras(cameras: Camera[]): void;
  70182. /**
  70183. * Enables the effect on given cameras
  70184. * @param cameras The camera to enable.
  70185. * @hidden
  70186. */
  70187. _enable(cameras: Camera): void;
  70188. /**
  70189. * Enables the effect on given cameras
  70190. * @param cameras The camera to enable.
  70191. * @hidden
  70192. */
  70193. _enable(cameras: Nullable<Camera[]>): void;
  70194. /**
  70195. * Disables the effect on the given cameras
  70196. * @param cameras The camera to disable.
  70197. * @hidden
  70198. */
  70199. _disable(cameras: Camera): void;
  70200. /**
  70201. * Disables the effect on the given cameras
  70202. * @param cameras The camera to disable.
  70203. * @hidden
  70204. */
  70205. _disable(cameras: Nullable<Camera[]>): void;
  70206. /**
  70207. * Gets a list of the post processes contained in the effect.
  70208. * @param camera The camera to get the post processes on.
  70209. * @returns The list of the post processes in the effect.
  70210. */
  70211. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70212. }
  70213. }
  70214. declare module BABYLON {
  70215. /** @hidden */
  70216. export var extractHighlightsPixelShader: {
  70217. name: string;
  70218. shader: string;
  70219. };
  70220. }
  70221. declare module BABYLON {
  70222. /**
  70223. * 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.
  70224. */
  70225. export class ExtractHighlightsPostProcess extends PostProcess {
  70226. /**
  70227. * The luminance threshold, pixels below this value will be set to black.
  70228. */
  70229. threshold: number;
  70230. /** @hidden */
  70231. _exposure: number;
  70232. /**
  70233. * Post process which has the input texture to be used when performing highlight extraction
  70234. * @hidden
  70235. */
  70236. _inputPostProcess: Nullable<PostProcess>;
  70237. /**
  70238. * Gets a string identifying the name of the class
  70239. * @returns "ExtractHighlightsPostProcess" string
  70240. */
  70241. getClassName(): string;
  70242. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70243. }
  70244. }
  70245. declare module BABYLON {
  70246. /** @hidden */
  70247. export var bloomMergePixelShader: {
  70248. name: string;
  70249. shader: string;
  70250. };
  70251. }
  70252. declare module BABYLON {
  70253. /**
  70254. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70255. */
  70256. export class BloomMergePostProcess extends PostProcess {
  70257. /** Weight of the bloom to be added to the original input. */
  70258. weight: number;
  70259. /**
  70260. * Gets a string identifying the name of the class
  70261. * @returns "BloomMergePostProcess" string
  70262. */
  70263. getClassName(): string;
  70264. /**
  70265. * Creates a new instance of @see BloomMergePostProcess
  70266. * @param name The name of the effect.
  70267. * @param originalFromInput Post process which's input will be used for the merge.
  70268. * @param blurred Blurred highlights post process which's output will be used.
  70269. * @param weight Weight of the bloom to be added to the original input.
  70270. * @param options The required width/height ratio to downsize to before computing the render pass.
  70271. * @param camera The camera to apply the render pass to.
  70272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70273. * @param engine The engine which the post process will be applied. (default: current engine)
  70274. * @param reusable If the post process can be reused on the same frame. (default: false)
  70275. * @param textureType Type of textures used when performing the post process. (default: 0)
  70276. * @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)
  70277. */
  70278. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70279. /** Weight of the bloom to be added to the original input. */
  70280. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70281. }
  70282. }
  70283. declare module BABYLON {
  70284. /**
  70285. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70286. */
  70287. export class BloomEffect extends PostProcessRenderEffect {
  70288. private bloomScale;
  70289. /**
  70290. * @hidden Internal
  70291. */
  70292. _effects: Array<PostProcess>;
  70293. /**
  70294. * @hidden Internal
  70295. */
  70296. _downscale: ExtractHighlightsPostProcess;
  70297. private _blurX;
  70298. private _blurY;
  70299. private _merge;
  70300. /**
  70301. * The luminance threshold to find bright areas of the image to bloom.
  70302. */
  70303. get threshold(): number;
  70304. set threshold(value: number);
  70305. /**
  70306. * The strength of the bloom.
  70307. */
  70308. get weight(): number;
  70309. set weight(value: number);
  70310. /**
  70311. * Specifies the size of the bloom blur kernel, relative to the final output size
  70312. */
  70313. get kernel(): number;
  70314. set kernel(value: number);
  70315. /**
  70316. * Creates a new instance of @see BloomEffect
  70317. * @param scene The scene the effect belongs to.
  70318. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70319. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70320. * @param bloomWeight The the strength of bloom.
  70321. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70322. * @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)
  70323. */
  70324. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70325. /**
  70326. * Disposes each of the internal effects for a given camera.
  70327. * @param camera The camera to dispose the effect on.
  70328. */
  70329. disposeEffects(camera: Camera): void;
  70330. /**
  70331. * @hidden Internal
  70332. */
  70333. _updateEffects(): void;
  70334. /**
  70335. * Internal
  70336. * @returns if all the contained post processes are ready.
  70337. * @hidden
  70338. */
  70339. _isReady(): boolean;
  70340. }
  70341. }
  70342. declare module BABYLON {
  70343. /** @hidden */
  70344. export var chromaticAberrationPixelShader: {
  70345. name: string;
  70346. shader: string;
  70347. };
  70348. }
  70349. declare module BABYLON {
  70350. /**
  70351. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70352. */
  70353. export class ChromaticAberrationPostProcess extends PostProcess {
  70354. /**
  70355. * The amount of seperation of rgb channels (default: 30)
  70356. */
  70357. aberrationAmount: number;
  70358. /**
  70359. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70360. */
  70361. radialIntensity: number;
  70362. /**
  70363. * 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))
  70364. */
  70365. direction: Vector2;
  70366. /**
  70367. * 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))
  70368. */
  70369. centerPosition: Vector2;
  70370. /** The width of the screen to apply the effect on */
  70371. screenWidth: number;
  70372. /** The height of the screen to apply the effect on */
  70373. screenHeight: number;
  70374. /**
  70375. * Gets a string identifying the name of the class
  70376. * @returns "ChromaticAberrationPostProcess" string
  70377. */
  70378. getClassName(): string;
  70379. /**
  70380. * Creates a new instance ChromaticAberrationPostProcess
  70381. * @param name The name of the effect.
  70382. * @param screenWidth The width of the screen to apply the effect on.
  70383. * @param screenHeight The height of the screen to apply the effect on.
  70384. * @param options The required width/height ratio to downsize to before computing the render pass.
  70385. * @param camera The camera to apply the render pass to.
  70386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70387. * @param engine The engine which the post process will be applied. (default: current engine)
  70388. * @param reusable If the post process can be reused on the same frame. (default: false)
  70389. * @param textureType Type of textures used when performing the post process. (default: 0)
  70390. * @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)
  70391. */
  70392. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70393. /** @hidden */
  70394. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70395. }
  70396. }
  70397. declare module BABYLON {
  70398. /** @hidden */
  70399. export var circleOfConfusionPixelShader: {
  70400. name: string;
  70401. shader: string;
  70402. };
  70403. }
  70404. declare module BABYLON {
  70405. /**
  70406. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70407. */
  70408. export class CircleOfConfusionPostProcess extends PostProcess {
  70409. /**
  70410. * 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.
  70411. */
  70412. lensSize: number;
  70413. /**
  70414. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70415. */
  70416. fStop: number;
  70417. /**
  70418. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70419. */
  70420. focusDistance: number;
  70421. /**
  70422. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70423. */
  70424. focalLength: number;
  70425. /**
  70426. * Gets a string identifying the name of the class
  70427. * @returns "CircleOfConfusionPostProcess" string
  70428. */
  70429. getClassName(): string;
  70430. private _depthTexture;
  70431. /**
  70432. * Creates a new instance CircleOfConfusionPostProcess
  70433. * @param name The name of the effect.
  70434. * @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.
  70435. * @param options The required width/height ratio to downsize to before computing the render pass.
  70436. * @param camera The camera to apply the render pass to.
  70437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70438. * @param engine The engine which the post process will be applied. (default: current engine)
  70439. * @param reusable If the post process can be reused on the same frame. (default: false)
  70440. * @param textureType Type of textures used when performing the post process. (default: 0)
  70441. * @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)
  70442. */
  70443. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70444. /**
  70445. * 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.
  70446. */
  70447. set depthTexture(value: RenderTargetTexture);
  70448. }
  70449. }
  70450. declare module BABYLON {
  70451. /** @hidden */
  70452. export var colorCorrectionPixelShader: {
  70453. name: string;
  70454. shader: string;
  70455. };
  70456. }
  70457. declare module BABYLON {
  70458. /**
  70459. *
  70460. * This post-process allows the modification of rendered colors by using
  70461. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70462. *
  70463. * The object needs to be provided an url to a texture containing the color
  70464. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70465. * Use an image editing software to tweak the LUT to match your needs.
  70466. *
  70467. * For an example of a color LUT, see here:
  70468. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70469. * For explanations on color grading, see here:
  70470. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70471. *
  70472. */
  70473. export class ColorCorrectionPostProcess extends PostProcess {
  70474. private _colorTableTexture;
  70475. /**
  70476. * Gets the color table url used to create the LUT texture
  70477. */
  70478. colorTableUrl: string;
  70479. /**
  70480. * Gets a string identifying the name of the class
  70481. * @returns "ColorCorrectionPostProcess" string
  70482. */
  70483. getClassName(): string;
  70484. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70485. /** @hidden */
  70486. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70487. }
  70488. }
  70489. declare module BABYLON {
  70490. /** @hidden */
  70491. export var convolutionPixelShader: {
  70492. name: string;
  70493. shader: string;
  70494. };
  70495. }
  70496. declare module BABYLON {
  70497. /**
  70498. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70499. * input texture to perform effects such as edge detection or sharpening
  70500. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70501. */
  70502. export class ConvolutionPostProcess extends PostProcess {
  70503. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70504. kernel: number[];
  70505. /**
  70506. * Gets a string identifying the name of the class
  70507. * @returns "ConvolutionPostProcess" string
  70508. */
  70509. getClassName(): string;
  70510. /**
  70511. * Creates a new instance ConvolutionPostProcess
  70512. * @param name The name of the effect.
  70513. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70514. * @param options The required width/height ratio to downsize to before computing the render pass.
  70515. * @param camera The camera to apply the render pass to.
  70516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70517. * @param engine The engine which the post process will be applied. (default: current engine)
  70518. * @param reusable If the post process can be reused on the same frame. (default: false)
  70519. * @param textureType Type of textures used when performing the post process. (default: 0)
  70520. */
  70521. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70522. /** @hidden */
  70523. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70524. /**
  70525. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70526. */
  70527. static EdgeDetect0Kernel: number[];
  70528. /**
  70529. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70530. */
  70531. static EdgeDetect1Kernel: number[];
  70532. /**
  70533. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70534. */
  70535. static EdgeDetect2Kernel: number[];
  70536. /**
  70537. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70538. */
  70539. static SharpenKernel: number[];
  70540. /**
  70541. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70542. */
  70543. static EmbossKernel: number[];
  70544. /**
  70545. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70546. */
  70547. static GaussianKernel: number[];
  70548. }
  70549. }
  70550. declare module BABYLON {
  70551. /**
  70552. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70553. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70554. * based on samples that have a large difference in distance than the center pixel.
  70555. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70556. */
  70557. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70558. /**
  70559. * The direction the blur should be applied
  70560. */
  70561. direction: Vector2;
  70562. /**
  70563. * Gets a string identifying the name of the class
  70564. * @returns "DepthOfFieldBlurPostProcess" string
  70565. */
  70566. getClassName(): string;
  70567. /**
  70568. * Creates a new instance CircleOfConfusionPostProcess
  70569. * @param name The name of the effect.
  70570. * @param scene The scene the effect belongs to.
  70571. * @param direction The direction the blur should be applied.
  70572. * @param kernel The size of the kernel used to blur.
  70573. * @param options The required width/height ratio to downsize to before computing the render pass.
  70574. * @param camera The camera to apply the render pass to.
  70575. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70576. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70578. * @param engine The engine which the post process will be applied. (default: current engine)
  70579. * @param reusable If the post process can be reused on the same frame. (default: false)
  70580. * @param textureType Type of textures used when performing the post process. (default: 0)
  70581. * @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)
  70582. */
  70583. 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);
  70584. }
  70585. }
  70586. declare module BABYLON {
  70587. /** @hidden */
  70588. export var depthOfFieldMergePixelShader: {
  70589. name: string;
  70590. shader: string;
  70591. };
  70592. }
  70593. declare module BABYLON {
  70594. /**
  70595. * Options to be set when merging outputs from the default pipeline.
  70596. */
  70597. export class DepthOfFieldMergePostProcessOptions {
  70598. /**
  70599. * The original image to merge on top of
  70600. */
  70601. originalFromInput: PostProcess;
  70602. /**
  70603. * Parameters to perform the merge of the depth of field effect
  70604. */
  70605. depthOfField?: {
  70606. circleOfConfusion: PostProcess;
  70607. blurSteps: Array<PostProcess>;
  70608. };
  70609. /**
  70610. * Parameters to perform the merge of bloom effect
  70611. */
  70612. bloom?: {
  70613. blurred: PostProcess;
  70614. weight: number;
  70615. };
  70616. }
  70617. /**
  70618. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70619. */
  70620. export class DepthOfFieldMergePostProcess extends PostProcess {
  70621. private blurSteps;
  70622. /**
  70623. * Gets a string identifying the name of the class
  70624. * @returns "DepthOfFieldMergePostProcess" string
  70625. */
  70626. getClassName(): string;
  70627. /**
  70628. * Creates a new instance of DepthOfFieldMergePostProcess
  70629. * @param name The name of the effect.
  70630. * @param originalFromInput Post process which's input will be used for the merge.
  70631. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70632. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70633. * @param options The required width/height ratio to downsize to before computing the render pass.
  70634. * @param camera The camera to apply the render pass to.
  70635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70636. * @param engine The engine which the post process will be applied. (default: current engine)
  70637. * @param reusable If the post process can be reused on the same frame. (default: false)
  70638. * @param textureType Type of textures used when performing the post process. (default: 0)
  70639. * @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)
  70640. */
  70641. 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);
  70642. /**
  70643. * Updates the effect with the current post process compile time values and recompiles the shader.
  70644. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70645. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70646. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70647. * @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
  70648. * @param onCompiled Called when the shader has been compiled.
  70649. * @param onError Called if there is an error when compiling a shader.
  70650. */
  70651. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70652. }
  70653. }
  70654. declare module BABYLON {
  70655. /**
  70656. * Specifies the level of max blur that should be applied when using the depth of field effect
  70657. */
  70658. export enum DepthOfFieldEffectBlurLevel {
  70659. /**
  70660. * Subtle blur
  70661. */
  70662. Low = 0,
  70663. /**
  70664. * Medium blur
  70665. */
  70666. Medium = 1,
  70667. /**
  70668. * Large blur
  70669. */
  70670. High = 2
  70671. }
  70672. /**
  70673. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70674. */
  70675. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70676. private _circleOfConfusion;
  70677. /**
  70678. * @hidden Internal, blurs from high to low
  70679. */
  70680. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70681. private _depthOfFieldBlurY;
  70682. private _dofMerge;
  70683. /**
  70684. * @hidden Internal post processes in depth of field effect
  70685. */
  70686. _effects: Array<PostProcess>;
  70687. /**
  70688. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70689. */
  70690. set focalLength(value: number);
  70691. get focalLength(): number;
  70692. /**
  70693. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70694. */
  70695. set fStop(value: number);
  70696. get fStop(): number;
  70697. /**
  70698. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70699. */
  70700. set focusDistance(value: number);
  70701. get focusDistance(): number;
  70702. /**
  70703. * 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.
  70704. */
  70705. set lensSize(value: number);
  70706. get lensSize(): number;
  70707. /**
  70708. * Creates a new instance DepthOfFieldEffect
  70709. * @param scene The scene the effect belongs to.
  70710. * @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.
  70711. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70712. * @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)
  70713. */
  70714. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70715. /**
  70716. * Get the current class name of the current effet
  70717. * @returns "DepthOfFieldEffect"
  70718. */
  70719. getClassName(): string;
  70720. /**
  70721. * 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.
  70722. */
  70723. set depthTexture(value: RenderTargetTexture);
  70724. /**
  70725. * Disposes each of the internal effects for a given camera.
  70726. * @param camera The camera to dispose the effect on.
  70727. */
  70728. disposeEffects(camera: Camera): void;
  70729. /**
  70730. * @hidden Internal
  70731. */
  70732. _updateEffects(): void;
  70733. /**
  70734. * Internal
  70735. * @returns if all the contained post processes are ready.
  70736. * @hidden
  70737. */
  70738. _isReady(): boolean;
  70739. }
  70740. }
  70741. declare module BABYLON {
  70742. /** @hidden */
  70743. export var displayPassPixelShader: {
  70744. name: string;
  70745. shader: string;
  70746. };
  70747. }
  70748. declare module BABYLON {
  70749. /**
  70750. * DisplayPassPostProcess which produces an output the same as it's input
  70751. */
  70752. export class DisplayPassPostProcess extends PostProcess {
  70753. /**
  70754. * Gets a string identifying the name of the class
  70755. * @returns "DisplayPassPostProcess" string
  70756. */
  70757. getClassName(): string;
  70758. /**
  70759. * Creates the DisplayPassPostProcess
  70760. * @param name The name of the effect.
  70761. * @param options The required width/height ratio to downsize to before computing the render pass.
  70762. * @param camera The camera to apply the render pass to.
  70763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70764. * @param engine The engine which the post process will be applied. (default: current engine)
  70765. * @param reusable If the post process can be reused on the same frame. (default: false)
  70766. */
  70767. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70768. /** @hidden */
  70769. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70770. }
  70771. }
  70772. declare module BABYLON {
  70773. /** @hidden */
  70774. export var filterPixelShader: {
  70775. name: string;
  70776. shader: string;
  70777. };
  70778. }
  70779. declare module BABYLON {
  70780. /**
  70781. * Applies a kernel filter to the image
  70782. */
  70783. export class FilterPostProcess extends PostProcess {
  70784. /** The matrix to be applied to the image */
  70785. kernelMatrix: Matrix;
  70786. /**
  70787. * Gets a string identifying the name of the class
  70788. * @returns "FilterPostProcess" string
  70789. */
  70790. getClassName(): string;
  70791. /**
  70792. *
  70793. * @param name The name of the effect.
  70794. * @param kernelMatrix The matrix to be applied to the image
  70795. * @param options The required width/height ratio to downsize to before computing the render pass.
  70796. * @param camera The camera to apply the render pass to.
  70797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70798. * @param engine The engine which the post process will be applied. (default: current engine)
  70799. * @param reusable If the post process can be reused on the same frame. (default: false)
  70800. */
  70801. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70802. /** @hidden */
  70803. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70804. }
  70805. }
  70806. declare module BABYLON {
  70807. /** @hidden */
  70808. export var fxaaPixelShader: {
  70809. name: string;
  70810. shader: string;
  70811. };
  70812. }
  70813. declare module BABYLON {
  70814. /** @hidden */
  70815. export var fxaaVertexShader: {
  70816. name: string;
  70817. shader: string;
  70818. };
  70819. }
  70820. declare module BABYLON {
  70821. /**
  70822. * Fxaa post process
  70823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70824. */
  70825. export class FxaaPostProcess extends PostProcess {
  70826. /**
  70827. * Gets a string identifying the name of the class
  70828. * @returns "FxaaPostProcess" string
  70829. */
  70830. getClassName(): string;
  70831. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70832. private _getDefines;
  70833. /** @hidden */
  70834. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70835. }
  70836. }
  70837. declare module BABYLON {
  70838. /** @hidden */
  70839. export var grainPixelShader: {
  70840. name: string;
  70841. shader: string;
  70842. };
  70843. }
  70844. declare module BABYLON {
  70845. /**
  70846. * The GrainPostProcess adds noise to the image at mid luminance levels
  70847. */
  70848. export class GrainPostProcess extends PostProcess {
  70849. /**
  70850. * The intensity of the grain added (default: 30)
  70851. */
  70852. intensity: number;
  70853. /**
  70854. * If the grain should be randomized on every frame
  70855. */
  70856. animated: boolean;
  70857. /**
  70858. * Gets a string identifying the name of the class
  70859. * @returns "GrainPostProcess" string
  70860. */
  70861. getClassName(): string;
  70862. /**
  70863. * Creates a new instance of @see GrainPostProcess
  70864. * @param name The name of the effect.
  70865. * @param options The required width/height ratio to downsize to before computing the render pass.
  70866. * @param camera The camera to apply the render pass to.
  70867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70868. * @param engine The engine which the post process will be applied. (default: current engine)
  70869. * @param reusable If the post process can be reused on the same frame. (default: false)
  70870. * @param textureType Type of textures used when performing the post process. (default: 0)
  70871. * @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)
  70872. */
  70873. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70874. /** @hidden */
  70875. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /** @hidden */
  70880. export var highlightsPixelShader: {
  70881. name: string;
  70882. shader: string;
  70883. };
  70884. }
  70885. declare module BABYLON {
  70886. /**
  70887. * Extracts highlights from the image
  70888. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70889. */
  70890. export class HighlightsPostProcess extends PostProcess {
  70891. /**
  70892. * Gets a string identifying the name of the class
  70893. * @returns "HighlightsPostProcess" string
  70894. */
  70895. getClassName(): string;
  70896. /**
  70897. * Extracts highlights from the image
  70898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70899. * @param name The name of the effect.
  70900. * @param options The required width/height ratio to downsize to before computing the render pass.
  70901. * @param camera The camera to apply the render pass to.
  70902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70903. * @param engine The engine which the post process will be applied. (default: current engine)
  70904. * @param reusable If the post process can be reused on the same frame. (default: false)
  70905. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70906. */
  70907. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70908. }
  70909. }
  70910. declare module BABYLON {
  70911. /**
  70912. * Contains all parameters needed for the prepass to perform
  70913. * motion blur
  70914. */
  70915. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70916. /**
  70917. * Is motion blur enabled
  70918. */
  70919. enabled: boolean;
  70920. /**
  70921. * Name of the configuration
  70922. */
  70923. name: string;
  70924. /**
  70925. * Textures that should be present in the MRT for this effect to work
  70926. */
  70927. readonly texturesRequired: number[];
  70928. }
  70929. }
  70930. declare module BABYLON {
  70931. interface Scene {
  70932. /** @hidden (Backing field) */
  70933. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70934. /**
  70935. * Gets or Sets the current geometry buffer associated to the scene.
  70936. */
  70937. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70938. /**
  70939. * Enables a GeometryBufferRender and associates it with the scene
  70940. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70941. * @returns the GeometryBufferRenderer
  70942. */
  70943. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70944. /**
  70945. * Disables the GeometryBufferRender associated with the scene
  70946. */
  70947. disableGeometryBufferRenderer(): void;
  70948. }
  70949. /**
  70950. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70951. * in several rendering techniques.
  70952. */
  70953. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70954. /**
  70955. * The component name helpful to identify the component in the list of scene components.
  70956. */
  70957. readonly name: string;
  70958. /**
  70959. * The scene the component belongs to.
  70960. */
  70961. scene: Scene;
  70962. /**
  70963. * Creates a new instance of the component for the given scene
  70964. * @param scene Defines the scene to register the component in
  70965. */
  70966. constructor(scene: Scene);
  70967. /**
  70968. * Registers the component in a given scene
  70969. */
  70970. register(): void;
  70971. /**
  70972. * Rebuilds the elements related to this component in case of
  70973. * context lost for instance.
  70974. */
  70975. rebuild(): void;
  70976. /**
  70977. * Disposes the component and the associated ressources
  70978. */
  70979. dispose(): void;
  70980. private _gatherRenderTargets;
  70981. }
  70982. }
  70983. declare module BABYLON {
  70984. /** @hidden */
  70985. export var motionBlurPixelShader: {
  70986. name: string;
  70987. shader: string;
  70988. };
  70989. }
  70990. declare module BABYLON {
  70991. /**
  70992. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70993. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70994. * As an example, all you have to do is to create the post-process:
  70995. * var mb = new BABYLON.MotionBlurPostProcess(
  70996. * 'mb', // The name of the effect.
  70997. * scene, // The scene containing the objects to blur according to their velocity.
  70998. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70999. * camera // The camera to apply the render pass to.
  71000. * );
  71001. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71002. */
  71003. export class MotionBlurPostProcess extends PostProcess {
  71004. /**
  71005. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71006. */
  71007. motionStrength: number;
  71008. /**
  71009. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71010. */
  71011. get motionBlurSamples(): number;
  71012. /**
  71013. * Sets the number of iterations to be used for motion blur quality
  71014. */
  71015. set motionBlurSamples(samples: number);
  71016. private _motionBlurSamples;
  71017. private _forceGeometryBuffer;
  71018. private _geometryBufferRenderer;
  71019. private _prePassRenderer;
  71020. /**
  71021. * Gets a string identifying the name of the class
  71022. * @returns "MotionBlurPostProcess" string
  71023. */
  71024. getClassName(): string;
  71025. /**
  71026. * Creates a new instance MotionBlurPostProcess
  71027. * @param name The name of the effect.
  71028. * @param scene The scene containing the objects to blur according to their velocity.
  71029. * @param options The required width/height ratio to downsize to before computing the render pass.
  71030. * @param camera The camera to apply the render pass to.
  71031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71032. * @param engine The engine which the post process will be applied. (default: current engine)
  71033. * @param reusable If the post process can be reused on the same frame. (default: false)
  71034. * @param textureType Type of textures used when performing the post process. (default: 0)
  71035. * @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)
  71036. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71037. */
  71038. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71039. /**
  71040. * Excludes the given skinned mesh from computing bones velocities.
  71041. * 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.
  71042. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71043. */
  71044. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71045. /**
  71046. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71047. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71048. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71049. */
  71050. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71051. /**
  71052. * Disposes the post process.
  71053. * @param camera The camera to dispose the post process on.
  71054. */
  71055. dispose(camera?: Camera): void;
  71056. /** @hidden */
  71057. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71058. }
  71059. }
  71060. declare module BABYLON {
  71061. /** @hidden */
  71062. export var refractionPixelShader: {
  71063. name: string;
  71064. shader: string;
  71065. };
  71066. }
  71067. declare module BABYLON {
  71068. /**
  71069. * Post process which applies a refractin texture
  71070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71071. */
  71072. export class RefractionPostProcess extends PostProcess {
  71073. private _refTexture;
  71074. private _ownRefractionTexture;
  71075. /** the base color of the refraction (used to taint the rendering) */
  71076. color: Color3;
  71077. /** simulated refraction depth */
  71078. depth: number;
  71079. /** the coefficient of the base color (0 to remove base color tainting) */
  71080. colorLevel: number;
  71081. /** Gets the url used to load the refraction texture */
  71082. refractionTextureUrl: string;
  71083. /**
  71084. * Gets or sets the refraction texture
  71085. * Please note that you are responsible for disposing the texture if you set it manually
  71086. */
  71087. get refractionTexture(): Texture;
  71088. set refractionTexture(value: Texture);
  71089. /**
  71090. * Gets a string identifying the name of the class
  71091. * @returns "RefractionPostProcess" string
  71092. */
  71093. getClassName(): string;
  71094. /**
  71095. * Initializes the RefractionPostProcess
  71096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71097. * @param name The name of the effect.
  71098. * @param refractionTextureUrl Url of the refraction texture to use
  71099. * @param color the base color of the refraction (used to taint the rendering)
  71100. * @param depth simulated refraction depth
  71101. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71102. * @param camera The camera to apply the render pass to.
  71103. * @param options The required width/height ratio to downsize to before computing the render pass.
  71104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71105. * @param engine The engine which the post process will be applied. (default: current engine)
  71106. * @param reusable If the post process can be reused on the same frame. (default: false)
  71107. */
  71108. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71109. /**
  71110. * Disposes of the post process
  71111. * @param camera Camera to dispose post process on
  71112. */
  71113. dispose(camera: Camera): void;
  71114. /** @hidden */
  71115. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71116. }
  71117. }
  71118. declare module BABYLON {
  71119. /** @hidden */
  71120. export var sharpenPixelShader: {
  71121. name: string;
  71122. shader: string;
  71123. };
  71124. }
  71125. declare module BABYLON {
  71126. /**
  71127. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71128. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71129. */
  71130. export class SharpenPostProcess extends PostProcess {
  71131. /**
  71132. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71133. */
  71134. colorAmount: number;
  71135. /**
  71136. * How much sharpness should be applied (default: 0.3)
  71137. */
  71138. edgeAmount: number;
  71139. /**
  71140. * Gets a string identifying the name of the class
  71141. * @returns "SharpenPostProcess" string
  71142. */
  71143. getClassName(): string;
  71144. /**
  71145. * Creates a new instance ConvolutionPostProcess
  71146. * @param name The name of the effect.
  71147. * @param options The required width/height ratio to downsize to before computing the render pass.
  71148. * @param camera The camera to apply the render pass to.
  71149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71150. * @param engine The engine which the post process will be applied. (default: current engine)
  71151. * @param reusable If the post process can be reused on the same frame. (default: false)
  71152. * @param textureType Type of textures used when performing the post process. (default: 0)
  71153. * @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)
  71154. */
  71155. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71156. /** @hidden */
  71157. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71158. }
  71159. }
  71160. declare module BABYLON {
  71161. /**
  71162. * PostProcessRenderPipeline
  71163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71164. */
  71165. export class PostProcessRenderPipeline {
  71166. private engine;
  71167. private _renderEffects;
  71168. private _renderEffectsForIsolatedPass;
  71169. /**
  71170. * List of inspectable custom properties (used by the Inspector)
  71171. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71172. */
  71173. inspectableCustomProperties: IInspectable[];
  71174. /**
  71175. * @hidden
  71176. */
  71177. protected _cameras: Camera[];
  71178. /** @hidden */
  71179. _name: string;
  71180. /**
  71181. * Gets pipeline name
  71182. */
  71183. get name(): string;
  71184. /** Gets the list of attached cameras */
  71185. get cameras(): Camera[];
  71186. /**
  71187. * Initializes a PostProcessRenderPipeline
  71188. * @param engine engine to add the pipeline to
  71189. * @param name name of the pipeline
  71190. */
  71191. constructor(engine: Engine, name: string);
  71192. /**
  71193. * Gets the class name
  71194. * @returns "PostProcessRenderPipeline"
  71195. */
  71196. getClassName(): string;
  71197. /**
  71198. * If all the render effects in the pipeline are supported
  71199. */
  71200. get isSupported(): boolean;
  71201. /**
  71202. * Adds an effect to the pipeline
  71203. * @param renderEffect the effect to add
  71204. */
  71205. addEffect(renderEffect: PostProcessRenderEffect): void;
  71206. /** @hidden */
  71207. _rebuild(): void;
  71208. /** @hidden */
  71209. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71210. /** @hidden */
  71211. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71212. /** @hidden */
  71213. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71214. /** @hidden */
  71215. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71216. /** @hidden */
  71217. _attachCameras(cameras: Camera, unique: boolean): void;
  71218. /** @hidden */
  71219. _attachCameras(cameras: Camera[], unique: boolean): void;
  71220. /** @hidden */
  71221. _detachCameras(cameras: Camera): void;
  71222. /** @hidden */
  71223. _detachCameras(cameras: Nullable<Camera[]>): void;
  71224. /** @hidden */
  71225. _update(): void;
  71226. /** @hidden */
  71227. _reset(): void;
  71228. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71229. /**
  71230. * Sets the required values to the prepass renderer.
  71231. * @param prePassRenderer defines the prepass renderer to setup.
  71232. * @returns true if the pre pass is needed.
  71233. */
  71234. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71235. /**
  71236. * Disposes of the pipeline
  71237. */
  71238. dispose(): void;
  71239. }
  71240. }
  71241. declare module BABYLON {
  71242. /**
  71243. * PostProcessRenderPipelineManager class
  71244. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71245. */
  71246. export class PostProcessRenderPipelineManager {
  71247. private _renderPipelines;
  71248. /**
  71249. * Initializes a PostProcessRenderPipelineManager
  71250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71251. */
  71252. constructor();
  71253. /**
  71254. * Gets the list of supported render pipelines
  71255. */
  71256. get supportedPipelines(): PostProcessRenderPipeline[];
  71257. /**
  71258. * Adds a pipeline to the manager
  71259. * @param renderPipeline The pipeline to add
  71260. */
  71261. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71262. /**
  71263. * Attaches a camera to the pipeline
  71264. * @param renderPipelineName The name of the pipeline to attach to
  71265. * @param cameras the camera to attach
  71266. * @param unique if the camera can be attached multiple times to the pipeline
  71267. */
  71268. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71269. /**
  71270. * Detaches a camera from the pipeline
  71271. * @param renderPipelineName The name of the pipeline to detach from
  71272. * @param cameras the camera to detach
  71273. */
  71274. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71275. /**
  71276. * Enables an effect by name on a pipeline
  71277. * @param renderPipelineName the name of the pipeline to enable the effect in
  71278. * @param renderEffectName the name of the effect to enable
  71279. * @param cameras the cameras that the effect should be enabled on
  71280. */
  71281. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71282. /**
  71283. * Disables an effect by name on a pipeline
  71284. * @param renderPipelineName the name of the pipeline to disable the effect in
  71285. * @param renderEffectName the name of the effect to disable
  71286. * @param cameras the cameras that the effect should be disabled on
  71287. */
  71288. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71289. /**
  71290. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71291. */
  71292. update(): void;
  71293. /** @hidden */
  71294. _rebuild(): void;
  71295. /**
  71296. * Disposes of the manager and pipelines
  71297. */
  71298. dispose(): void;
  71299. }
  71300. }
  71301. declare module BABYLON {
  71302. interface Scene {
  71303. /** @hidden (Backing field) */
  71304. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71305. /**
  71306. * Gets the postprocess render pipeline manager
  71307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71308. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71309. */
  71310. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71311. }
  71312. /**
  71313. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71314. */
  71315. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71316. /**
  71317. * The component name helpfull to identify the component in the list of scene components.
  71318. */
  71319. readonly name: string;
  71320. /**
  71321. * The scene the component belongs to.
  71322. */
  71323. scene: Scene;
  71324. /**
  71325. * Creates a new instance of the component for the given scene
  71326. * @param scene Defines the scene to register the component in
  71327. */
  71328. constructor(scene: Scene);
  71329. /**
  71330. * Registers the component in a given scene
  71331. */
  71332. register(): void;
  71333. /**
  71334. * Rebuilds the elements related to this component in case of
  71335. * context lost for instance.
  71336. */
  71337. rebuild(): void;
  71338. /**
  71339. * Disposes the component and the associated ressources
  71340. */
  71341. dispose(): void;
  71342. private _gatherRenderTargets;
  71343. }
  71344. }
  71345. declare module BABYLON {
  71346. /**
  71347. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71348. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71349. */
  71350. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71351. private _scene;
  71352. private _camerasToBeAttached;
  71353. /**
  71354. * ID of the sharpen post process,
  71355. */
  71356. private readonly SharpenPostProcessId;
  71357. /**
  71358. * @ignore
  71359. * ID of the image processing post process;
  71360. */
  71361. readonly ImageProcessingPostProcessId: string;
  71362. /**
  71363. * @ignore
  71364. * ID of the Fast Approximate Anti-Aliasing post process;
  71365. */
  71366. readonly FxaaPostProcessId: string;
  71367. /**
  71368. * ID of the chromatic aberration post process,
  71369. */
  71370. private readonly ChromaticAberrationPostProcessId;
  71371. /**
  71372. * ID of the grain post process
  71373. */
  71374. private readonly GrainPostProcessId;
  71375. /**
  71376. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71377. */
  71378. sharpen: SharpenPostProcess;
  71379. private _sharpenEffect;
  71380. private bloom;
  71381. /**
  71382. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71383. */
  71384. depthOfField: DepthOfFieldEffect;
  71385. /**
  71386. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71387. */
  71388. fxaa: FxaaPostProcess;
  71389. /**
  71390. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71391. */
  71392. imageProcessing: ImageProcessingPostProcess;
  71393. /**
  71394. * Chromatic aberration post process which will shift rgb colors in the image
  71395. */
  71396. chromaticAberration: ChromaticAberrationPostProcess;
  71397. private _chromaticAberrationEffect;
  71398. /**
  71399. * Grain post process which add noise to the image
  71400. */
  71401. grain: GrainPostProcess;
  71402. private _grainEffect;
  71403. /**
  71404. * Glow post process which adds a glow to emissive areas of the image
  71405. */
  71406. private _glowLayer;
  71407. /**
  71408. * Animations which can be used to tweak settings over a period of time
  71409. */
  71410. animations: Animation[];
  71411. private _imageProcessingConfigurationObserver;
  71412. private _sharpenEnabled;
  71413. private _bloomEnabled;
  71414. private _depthOfFieldEnabled;
  71415. private _depthOfFieldBlurLevel;
  71416. private _fxaaEnabled;
  71417. private _imageProcessingEnabled;
  71418. private _defaultPipelineTextureType;
  71419. private _bloomScale;
  71420. private _chromaticAberrationEnabled;
  71421. private _grainEnabled;
  71422. private _buildAllowed;
  71423. /**
  71424. * This is triggered each time the pipeline has been built.
  71425. */
  71426. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71427. /**
  71428. * Gets active scene
  71429. */
  71430. get scene(): Scene;
  71431. /**
  71432. * Enable or disable the sharpen process from the pipeline
  71433. */
  71434. set sharpenEnabled(enabled: boolean);
  71435. get sharpenEnabled(): boolean;
  71436. private _resizeObserver;
  71437. private _hardwareScaleLevel;
  71438. private _bloomKernel;
  71439. /**
  71440. * Specifies the size of the bloom blur kernel, relative to the final output size
  71441. */
  71442. get bloomKernel(): number;
  71443. set bloomKernel(value: number);
  71444. /**
  71445. * Specifies the weight of the bloom in the final rendering
  71446. */
  71447. private _bloomWeight;
  71448. /**
  71449. * Specifies the luma threshold for the area that will be blurred by the bloom
  71450. */
  71451. private _bloomThreshold;
  71452. private _hdr;
  71453. /**
  71454. * The strength of the bloom.
  71455. */
  71456. set bloomWeight(value: number);
  71457. get bloomWeight(): number;
  71458. /**
  71459. * The strength of the bloom.
  71460. */
  71461. set bloomThreshold(value: number);
  71462. get bloomThreshold(): number;
  71463. /**
  71464. * The scale of the bloom, lower value will provide better performance.
  71465. */
  71466. set bloomScale(value: number);
  71467. get bloomScale(): number;
  71468. /**
  71469. * Enable or disable the bloom from the pipeline
  71470. */
  71471. set bloomEnabled(enabled: boolean);
  71472. get bloomEnabled(): boolean;
  71473. private _rebuildBloom;
  71474. /**
  71475. * If the depth of field is enabled.
  71476. */
  71477. get depthOfFieldEnabled(): boolean;
  71478. set depthOfFieldEnabled(enabled: boolean);
  71479. /**
  71480. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71481. */
  71482. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71483. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71484. /**
  71485. * If the anti aliasing is enabled.
  71486. */
  71487. set fxaaEnabled(enabled: boolean);
  71488. get fxaaEnabled(): boolean;
  71489. private _samples;
  71490. /**
  71491. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71492. */
  71493. set samples(sampleCount: number);
  71494. get samples(): number;
  71495. /**
  71496. * If image processing is enabled.
  71497. */
  71498. set imageProcessingEnabled(enabled: boolean);
  71499. get imageProcessingEnabled(): boolean;
  71500. /**
  71501. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71502. */
  71503. set glowLayerEnabled(enabled: boolean);
  71504. get glowLayerEnabled(): boolean;
  71505. /**
  71506. * Gets the glow layer (or null if not defined)
  71507. */
  71508. get glowLayer(): Nullable<GlowLayer>;
  71509. /**
  71510. * Enable or disable the chromaticAberration process from the pipeline
  71511. */
  71512. set chromaticAberrationEnabled(enabled: boolean);
  71513. get chromaticAberrationEnabled(): boolean;
  71514. /**
  71515. * Enable or disable the grain process from the pipeline
  71516. */
  71517. set grainEnabled(enabled: boolean);
  71518. get grainEnabled(): boolean;
  71519. /**
  71520. * @constructor
  71521. * @param name - The rendering pipeline name (default: "")
  71522. * @param hdr - If high dynamic range textures should be used (default: true)
  71523. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71524. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71525. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71526. */
  71527. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71528. /**
  71529. * Get the class name
  71530. * @returns "DefaultRenderingPipeline"
  71531. */
  71532. getClassName(): string;
  71533. /**
  71534. * Force the compilation of the entire pipeline.
  71535. */
  71536. prepare(): void;
  71537. private _hasCleared;
  71538. private _prevPostProcess;
  71539. private _prevPrevPostProcess;
  71540. private _setAutoClearAndTextureSharing;
  71541. private _depthOfFieldSceneObserver;
  71542. private _buildPipeline;
  71543. private _disposePostProcesses;
  71544. /**
  71545. * Adds a camera to the pipeline
  71546. * @param camera the camera to be added
  71547. */
  71548. addCamera(camera: Camera): void;
  71549. /**
  71550. * Removes a camera from the pipeline
  71551. * @param camera the camera to remove
  71552. */
  71553. removeCamera(camera: Camera): void;
  71554. /**
  71555. * Dispose of the pipeline and stop all post processes
  71556. */
  71557. dispose(): void;
  71558. /**
  71559. * Serialize the rendering pipeline (Used when exporting)
  71560. * @returns the serialized object
  71561. */
  71562. serialize(): any;
  71563. /**
  71564. * Parse the serialized pipeline
  71565. * @param source Source pipeline.
  71566. * @param scene The scene to load the pipeline to.
  71567. * @param rootUrl The URL of the serialized pipeline.
  71568. * @returns An instantiated pipeline from the serialized object.
  71569. */
  71570. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71571. }
  71572. }
  71573. declare module BABYLON {
  71574. /** @hidden */
  71575. export var lensHighlightsPixelShader: {
  71576. name: string;
  71577. shader: string;
  71578. };
  71579. }
  71580. declare module BABYLON {
  71581. /** @hidden */
  71582. export var depthOfFieldPixelShader: {
  71583. name: string;
  71584. shader: string;
  71585. };
  71586. }
  71587. declare module BABYLON {
  71588. /**
  71589. * BABYLON.JS Chromatic Aberration GLSL Shader
  71590. * Author: Olivier Guyot
  71591. * Separates very slightly R, G and B colors on the edges of the screen
  71592. * Inspired by Francois Tarlier & Martins Upitis
  71593. */
  71594. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71595. /**
  71596. * @ignore
  71597. * The chromatic aberration PostProcess id in the pipeline
  71598. */
  71599. LensChromaticAberrationEffect: string;
  71600. /**
  71601. * @ignore
  71602. * The highlights enhancing PostProcess id in the pipeline
  71603. */
  71604. HighlightsEnhancingEffect: string;
  71605. /**
  71606. * @ignore
  71607. * The depth-of-field PostProcess id in the pipeline
  71608. */
  71609. LensDepthOfFieldEffect: string;
  71610. private _scene;
  71611. private _depthTexture;
  71612. private _grainTexture;
  71613. private _chromaticAberrationPostProcess;
  71614. private _highlightsPostProcess;
  71615. private _depthOfFieldPostProcess;
  71616. private _edgeBlur;
  71617. private _grainAmount;
  71618. private _chromaticAberration;
  71619. private _distortion;
  71620. private _highlightsGain;
  71621. private _highlightsThreshold;
  71622. private _dofDistance;
  71623. private _dofAperture;
  71624. private _dofDarken;
  71625. private _dofPentagon;
  71626. private _blurNoise;
  71627. /**
  71628. * @constructor
  71629. *
  71630. * Effect parameters are as follow:
  71631. * {
  71632. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71633. * edge_blur: number; // from 0 to x (1 for realism)
  71634. * distortion: number; // from 0 to x (1 for realism)
  71635. * grain_amount: number; // from 0 to 1
  71636. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71637. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71638. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71639. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71640. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71641. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71642. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71643. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71644. * }
  71645. * Note: if an effect parameter is unset, effect is disabled
  71646. *
  71647. * @param name The rendering pipeline name
  71648. * @param parameters - An object containing all parameters (see above)
  71649. * @param scene The scene linked to this pipeline
  71650. * @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)
  71651. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71652. */
  71653. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71654. /**
  71655. * Get the class name
  71656. * @returns "LensRenderingPipeline"
  71657. */
  71658. getClassName(): string;
  71659. /**
  71660. * Gets associated scene
  71661. */
  71662. get scene(): Scene;
  71663. /**
  71664. * Gets or sets the edge blur
  71665. */
  71666. get edgeBlur(): number;
  71667. set edgeBlur(value: number);
  71668. /**
  71669. * Gets or sets the grain amount
  71670. */
  71671. get grainAmount(): number;
  71672. set grainAmount(value: number);
  71673. /**
  71674. * Gets or sets the chromatic aberration amount
  71675. */
  71676. get chromaticAberration(): number;
  71677. set chromaticAberration(value: number);
  71678. /**
  71679. * Gets or sets the depth of field aperture
  71680. */
  71681. get dofAperture(): number;
  71682. set dofAperture(value: number);
  71683. /**
  71684. * Gets or sets the edge distortion
  71685. */
  71686. get edgeDistortion(): number;
  71687. set edgeDistortion(value: number);
  71688. /**
  71689. * Gets or sets the depth of field distortion
  71690. */
  71691. get dofDistortion(): number;
  71692. set dofDistortion(value: number);
  71693. /**
  71694. * Gets or sets the darken out of focus amount
  71695. */
  71696. get darkenOutOfFocus(): number;
  71697. set darkenOutOfFocus(value: number);
  71698. /**
  71699. * Gets or sets a boolean indicating if blur noise is enabled
  71700. */
  71701. get blurNoise(): boolean;
  71702. set blurNoise(value: boolean);
  71703. /**
  71704. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71705. */
  71706. get pentagonBokeh(): boolean;
  71707. set pentagonBokeh(value: boolean);
  71708. /**
  71709. * Gets or sets the highlight grain amount
  71710. */
  71711. get highlightsGain(): number;
  71712. set highlightsGain(value: number);
  71713. /**
  71714. * Gets or sets the highlight threshold
  71715. */
  71716. get highlightsThreshold(): number;
  71717. set highlightsThreshold(value: number);
  71718. /**
  71719. * Sets the amount of blur at the edges
  71720. * @param amount blur amount
  71721. */
  71722. setEdgeBlur(amount: number): void;
  71723. /**
  71724. * Sets edge blur to 0
  71725. */
  71726. disableEdgeBlur(): void;
  71727. /**
  71728. * Sets the amout of grain
  71729. * @param amount Amount of grain
  71730. */
  71731. setGrainAmount(amount: number): void;
  71732. /**
  71733. * Set grain amount to 0
  71734. */
  71735. disableGrain(): void;
  71736. /**
  71737. * Sets the chromatic aberration amount
  71738. * @param amount amount of chromatic aberration
  71739. */
  71740. setChromaticAberration(amount: number): void;
  71741. /**
  71742. * Sets chromatic aberration amount to 0
  71743. */
  71744. disableChromaticAberration(): void;
  71745. /**
  71746. * Sets the EdgeDistortion amount
  71747. * @param amount amount of EdgeDistortion
  71748. */
  71749. setEdgeDistortion(amount: number): void;
  71750. /**
  71751. * Sets edge distortion to 0
  71752. */
  71753. disableEdgeDistortion(): void;
  71754. /**
  71755. * Sets the FocusDistance amount
  71756. * @param amount amount of FocusDistance
  71757. */
  71758. setFocusDistance(amount: number): void;
  71759. /**
  71760. * Disables depth of field
  71761. */
  71762. disableDepthOfField(): void;
  71763. /**
  71764. * Sets the Aperture amount
  71765. * @param amount amount of Aperture
  71766. */
  71767. setAperture(amount: number): void;
  71768. /**
  71769. * Sets the DarkenOutOfFocus amount
  71770. * @param amount amount of DarkenOutOfFocus
  71771. */
  71772. setDarkenOutOfFocus(amount: number): void;
  71773. private _pentagonBokehIsEnabled;
  71774. /**
  71775. * Creates a pentagon bokeh effect
  71776. */
  71777. enablePentagonBokeh(): void;
  71778. /**
  71779. * Disables the pentagon bokeh effect
  71780. */
  71781. disablePentagonBokeh(): void;
  71782. /**
  71783. * Enables noise blur
  71784. */
  71785. enableNoiseBlur(): void;
  71786. /**
  71787. * Disables noise blur
  71788. */
  71789. disableNoiseBlur(): void;
  71790. /**
  71791. * Sets the HighlightsGain amount
  71792. * @param amount amount of HighlightsGain
  71793. */
  71794. setHighlightsGain(amount: number): void;
  71795. /**
  71796. * Sets the HighlightsThreshold amount
  71797. * @param amount amount of HighlightsThreshold
  71798. */
  71799. setHighlightsThreshold(amount: number): void;
  71800. /**
  71801. * Disables highlights
  71802. */
  71803. disableHighlights(): void;
  71804. /**
  71805. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71806. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71807. */
  71808. dispose(disableDepthRender?: boolean): void;
  71809. private _createChromaticAberrationPostProcess;
  71810. private _createHighlightsPostProcess;
  71811. private _createDepthOfFieldPostProcess;
  71812. private _createGrainTexture;
  71813. }
  71814. }
  71815. declare module BABYLON {
  71816. /**
  71817. * Contains all parameters needed for the prepass to perform
  71818. * screen space subsurface scattering
  71819. */
  71820. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71821. /**
  71822. * Is subsurface enabled
  71823. */
  71824. enabled: boolean;
  71825. /**
  71826. * Name of the configuration
  71827. */
  71828. name: string;
  71829. /**
  71830. * Textures that should be present in the MRT for this effect to work
  71831. */
  71832. readonly texturesRequired: number[];
  71833. }
  71834. }
  71835. declare module BABYLON {
  71836. /** @hidden */
  71837. export var ssao2PixelShader: {
  71838. name: string;
  71839. shader: string;
  71840. };
  71841. }
  71842. declare module BABYLON {
  71843. /** @hidden */
  71844. export var ssaoCombinePixelShader: {
  71845. name: string;
  71846. shader: string;
  71847. };
  71848. }
  71849. declare module BABYLON {
  71850. /**
  71851. * Render pipeline to produce ssao effect
  71852. */
  71853. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71854. /**
  71855. * @ignore
  71856. * The PassPostProcess id in the pipeline that contains the original scene color
  71857. */
  71858. SSAOOriginalSceneColorEffect: string;
  71859. /**
  71860. * @ignore
  71861. * The SSAO PostProcess id in the pipeline
  71862. */
  71863. SSAORenderEffect: string;
  71864. /**
  71865. * @ignore
  71866. * The horizontal blur PostProcess id in the pipeline
  71867. */
  71868. SSAOBlurHRenderEffect: string;
  71869. /**
  71870. * @ignore
  71871. * The vertical blur PostProcess id in the pipeline
  71872. */
  71873. SSAOBlurVRenderEffect: string;
  71874. /**
  71875. * @ignore
  71876. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71877. */
  71878. SSAOCombineRenderEffect: string;
  71879. /**
  71880. * The output strength of the SSAO post-process. Default value is 1.0.
  71881. */
  71882. totalStrength: number;
  71883. /**
  71884. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71885. */
  71886. maxZ: number;
  71887. /**
  71888. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71889. */
  71890. minZAspect: number;
  71891. private _samples;
  71892. /**
  71893. * Number of samples used for the SSAO calculations. Default value is 8
  71894. */
  71895. set samples(n: number);
  71896. get samples(): number;
  71897. private _textureSamples;
  71898. /**
  71899. * Number of samples to use for antialiasing
  71900. */
  71901. set textureSamples(n: number);
  71902. get textureSamples(): number;
  71903. /**
  71904. * Force rendering the geometry through geometry buffer
  71905. */
  71906. private _forceGeometryBuffer;
  71907. /**
  71908. * Ratio object used for SSAO ratio and blur ratio
  71909. */
  71910. private _ratio;
  71911. /**
  71912. * Dynamically generated sphere sampler.
  71913. */
  71914. private _sampleSphere;
  71915. /**
  71916. * Blur filter offsets
  71917. */
  71918. private _samplerOffsets;
  71919. private _expensiveBlur;
  71920. /**
  71921. * If bilateral blur should be used
  71922. */
  71923. set expensiveBlur(b: boolean);
  71924. get expensiveBlur(): boolean;
  71925. /**
  71926. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71927. */
  71928. radius: number;
  71929. /**
  71930. * The base color of the SSAO post-process
  71931. * The final result is "base + ssao" between [0, 1]
  71932. */
  71933. base: number;
  71934. /**
  71935. * Support test.
  71936. */
  71937. static get IsSupported(): boolean;
  71938. private _scene;
  71939. private _randomTexture;
  71940. private _originalColorPostProcess;
  71941. private _ssaoPostProcess;
  71942. private _blurHPostProcess;
  71943. private _blurVPostProcess;
  71944. private _ssaoCombinePostProcess;
  71945. private _prePassRenderer;
  71946. /**
  71947. * Gets active scene
  71948. */
  71949. get scene(): Scene;
  71950. /**
  71951. * @constructor
  71952. * @param name The rendering pipeline name
  71953. * @param scene The scene linked to this pipeline
  71954. * @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 }
  71955. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71956. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71957. */
  71958. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71959. /**
  71960. * Get the class name
  71961. * @returns "SSAO2RenderingPipeline"
  71962. */
  71963. getClassName(): string;
  71964. /**
  71965. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71966. */
  71967. dispose(disableGeometryBufferRenderer?: boolean): void;
  71968. private _createBlurPostProcess;
  71969. /** @hidden */
  71970. _rebuild(): void;
  71971. private _bits;
  71972. private _radicalInverse_VdC;
  71973. private _hammersley;
  71974. private _hemisphereSample_uniform;
  71975. private _generateHemisphere;
  71976. private _getDefinesForSSAO;
  71977. private _createSSAOPostProcess;
  71978. private _createSSAOCombinePostProcess;
  71979. private _createRandomTexture;
  71980. /**
  71981. * Serialize the rendering pipeline (Used when exporting)
  71982. * @returns the serialized object
  71983. */
  71984. serialize(): any;
  71985. /**
  71986. * Parse the serialized pipeline
  71987. * @param source Source pipeline.
  71988. * @param scene The scene to load the pipeline to.
  71989. * @param rootUrl The URL of the serialized pipeline.
  71990. * @returns An instantiated pipeline from the serialized object.
  71991. */
  71992. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71993. }
  71994. }
  71995. declare module BABYLON {
  71996. /** @hidden */
  71997. export var ssaoPixelShader: {
  71998. name: string;
  71999. shader: string;
  72000. };
  72001. }
  72002. declare module BABYLON {
  72003. /**
  72004. * Render pipeline to produce ssao effect
  72005. */
  72006. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72007. /**
  72008. * @ignore
  72009. * The PassPostProcess id in the pipeline that contains the original scene color
  72010. */
  72011. SSAOOriginalSceneColorEffect: string;
  72012. /**
  72013. * @ignore
  72014. * The SSAO PostProcess id in the pipeline
  72015. */
  72016. SSAORenderEffect: string;
  72017. /**
  72018. * @ignore
  72019. * The horizontal blur PostProcess id in the pipeline
  72020. */
  72021. SSAOBlurHRenderEffect: string;
  72022. /**
  72023. * @ignore
  72024. * The vertical blur PostProcess id in the pipeline
  72025. */
  72026. SSAOBlurVRenderEffect: string;
  72027. /**
  72028. * @ignore
  72029. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72030. */
  72031. SSAOCombineRenderEffect: string;
  72032. /**
  72033. * The output strength of the SSAO post-process. Default value is 1.0.
  72034. */
  72035. totalStrength: number;
  72036. /**
  72037. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72038. */
  72039. radius: number;
  72040. /**
  72041. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72042. * Must not be equal to fallOff and superior to fallOff.
  72043. * Default value is 0.0075
  72044. */
  72045. area: number;
  72046. /**
  72047. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72048. * Must not be equal to area and inferior to area.
  72049. * Default value is 0.000001
  72050. */
  72051. fallOff: number;
  72052. /**
  72053. * The base color of the SSAO post-process
  72054. * The final result is "base + ssao" between [0, 1]
  72055. */
  72056. base: number;
  72057. private _scene;
  72058. private _depthTexture;
  72059. private _randomTexture;
  72060. private _originalColorPostProcess;
  72061. private _ssaoPostProcess;
  72062. private _blurHPostProcess;
  72063. private _blurVPostProcess;
  72064. private _ssaoCombinePostProcess;
  72065. private _firstUpdate;
  72066. /**
  72067. * Gets active scene
  72068. */
  72069. get scene(): Scene;
  72070. /**
  72071. * @constructor
  72072. * @param name - The rendering pipeline name
  72073. * @param scene - The scene linked to this pipeline
  72074. * @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 }
  72075. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72076. */
  72077. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72078. /**
  72079. * Get the class name
  72080. * @returns "SSAORenderingPipeline"
  72081. */
  72082. getClassName(): string;
  72083. /**
  72084. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72085. */
  72086. dispose(disableDepthRender?: boolean): void;
  72087. private _createBlurPostProcess;
  72088. /** @hidden */
  72089. _rebuild(): void;
  72090. private _createSSAOPostProcess;
  72091. private _createSSAOCombinePostProcess;
  72092. private _createRandomTexture;
  72093. }
  72094. }
  72095. declare module BABYLON {
  72096. /**
  72097. * Contains all parameters needed for the prepass to perform
  72098. * screen space reflections
  72099. */
  72100. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72101. /**
  72102. * Is ssr enabled
  72103. */
  72104. enabled: boolean;
  72105. /**
  72106. * Name of the configuration
  72107. */
  72108. name: string;
  72109. /**
  72110. * Textures that should be present in the MRT for this effect to work
  72111. */
  72112. readonly texturesRequired: number[];
  72113. }
  72114. }
  72115. declare module BABYLON {
  72116. /** @hidden */
  72117. export var screenSpaceReflectionPixelShader: {
  72118. name: string;
  72119. shader: string;
  72120. };
  72121. }
  72122. declare module BABYLON {
  72123. /**
  72124. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72125. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72126. */
  72127. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72128. /**
  72129. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72130. */
  72131. threshold: number;
  72132. /**
  72133. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72134. */
  72135. strength: number;
  72136. /**
  72137. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72138. */
  72139. reflectionSpecularFalloffExponent: number;
  72140. /**
  72141. * 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]
  72142. */
  72143. step: number;
  72144. /**
  72145. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72146. */
  72147. roughnessFactor: number;
  72148. private _forceGeometryBuffer;
  72149. private _geometryBufferRenderer;
  72150. private _prePassRenderer;
  72151. private _enableSmoothReflections;
  72152. private _reflectionSamples;
  72153. private _smoothSteps;
  72154. /**
  72155. * Gets a string identifying the name of the class
  72156. * @returns "ScreenSpaceReflectionPostProcess" string
  72157. */
  72158. getClassName(): string;
  72159. /**
  72160. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72161. * @param name The name of the effect.
  72162. * @param scene The scene containing the objects to calculate reflections.
  72163. * @param options The required width/height ratio to downsize to before computing the render pass.
  72164. * @param camera The camera to apply the render pass to.
  72165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72166. * @param engine The engine which the post process will be applied. (default: current engine)
  72167. * @param reusable If the post process can be reused on the same frame. (default: false)
  72168. * @param textureType Type of textures used when performing the post process. (default: 0)
  72169. * @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)
  72170. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72171. */
  72172. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72173. /**
  72174. * Gets wether or not smoothing reflections is enabled.
  72175. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72176. */
  72177. get enableSmoothReflections(): boolean;
  72178. /**
  72179. * Sets wether or not smoothing reflections is enabled.
  72180. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72181. */
  72182. set enableSmoothReflections(enabled: boolean);
  72183. /**
  72184. * Gets the number of samples taken while computing reflections. More samples count is high,
  72185. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72186. */
  72187. get reflectionSamples(): number;
  72188. /**
  72189. * Sets the number of samples taken while computing reflections. More samples count is high,
  72190. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72191. */
  72192. set reflectionSamples(samples: number);
  72193. /**
  72194. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72195. * more the post-process will require GPU power and can generate a drop in FPS.
  72196. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72197. */
  72198. get smoothSteps(): number;
  72199. set smoothSteps(steps: number);
  72200. private _updateEffectDefines;
  72201. /** @hidden */
  72202. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72203. }
  72204. }
  72205. declare module BABYLON {
  72206. /** @hidden */
  72207. export var standardPixelShader: {
  72208. name: string;
  72209. shader: string;
  72210. };
  72211. }
  72212. declare module BABYLON {
  72213. /**
  72214. * Standard rendering pipeline
  72215. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72216. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72217. */
  72218. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72219. /**
  72220. * Public members
  72221. */
  72222. /**
  72223. * Post-process which contains the original scene color before the pipeline applies all the effects
  72224. */
  72225. originalPostProcess: Nullable<PostProcess>;
  72226. /**
  72227. * Post-process used to down scale an image x4
  72228. */
  72229. downSampleX4PostProcess: Nullable<PostProcess>;
  72230. /**
  72231. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72232. */
  72233. brightPassPostProcess: Nullable<PostProcess>;
  72234. /**
  72235. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72236. */
  72237. blurHPostProcesses: PostProcess[];
  72238. /**
  72239. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72240. */
  72241. blurVPostProcesses: PostProcess[];
  72242. /**
  72243. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72244. */
  72245. textureAdderPostProcess: Nullable<PostProcess>;
  72246. /**
  72247. * Post-process used to create volumetric lighting effect
  72248. */
  72249. volumetricLightPostProcess: Nullable<PostProcess>;
  72250. /**
  72251. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72252. */
  72253. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72254. /**
  72255. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72256. */
  72257. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72258. /**
  72259. * Post-process used to merge the volumetric light effect and the real scene color
  72260. */
  72261. volumetricLightMergePostProces: Nullable<PostProcess>;
  72262. /**
  72263. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72264. */
  72265. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72266. /**
  72267. * Base post-process used to calculate the average luminance of the final image for HDR
  72268. */
  72269. luminancePostProcess: Nullable<PostProcess>;
  72270. /**
  72271. * Post-processes used to create down sample post-processes in order to get
  72272. * the average luminance of the final image for HDR
  72273. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72274. */
  72275. luminanceDownSamplePostProcesses: PostProcess[];
  72276. /**
  72277. * Post-process used to create a HDR effect (light adaptation)
  72278. */
  72279. hdrPostProcess: Nullable<PostProcess>;
  72280. /**
  72281. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72282. */
  72283. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72284. /**
  72285. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72286. */
  72287. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72288. /**
  72289. * Post-process used to merge the final HDR post-process and the real scene color
  72290. */
  72291. hdrFinalPostProcess: Nullable<PostProcess>;
  72292. /**
  72293. * Post-process used to create a lens flare effect
  72294. */
  72295. lensFlarePostProcess: Nullable<PostProcess>;
  72296. /**
  72297. * Post-process that merges the result of the lens flare post-process and the real scene color
  72298. */
  72299. lensFlareComposePostProcess: Nullable<PostProcess>;
  72300. /**
  72301. * Post-process used to create a motion blur effect
  72302. */
  72303. motionBlurPostProcess: Nullable<PostProcess>;
  72304. /**
  72305. * Post-process used to create a depth of field effect
  72306. */
  72307. depthOfFieldPostProcess: Nullable<PostProcess>;
  72308. /**
  72309. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72310. */
  72311. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72312. /**
  72313. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72314. */
  72315. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72316. /**
  72317. * Represents the brightness threshold in order to configure the illuminated surfaces
  72318. */
  72319. brightThreshold: number;
  72320. /**
  72321. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72322. */
  72323. blurWidth: number;
  72324. /**
  72325. * Sets if the blur for highlighted surfaces must be only horizontal
  72326. */
  72327. horizontalBlur: boolean;
  72328. /**
  72329. * Gets the overall exposure used by the pipeline
  72330. */
  72331. get exposure(): number;
  72332. /**
  72333. * Sets the overall exposure used by the pipeline
  72334. */
  72335. set exposure(value: number);
  72336. /**
  72337. * Texture used typically to simulate "dirty" on camera lens
  72338. */
  72339. lensTexture: Nullable<Texture>;
  72340. /**
  72341. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72342. */
  72343. volumetricLightCoefficient: number;
  72344. /**
  72345. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72346. */
  72347. volumetricLightPower: number;
  72348. /**
  72349. * Used the set the blur intensity to smooth the volumetric lights
  72350. */
  72351. volumetricLightBlurScale: number;
  72352. /**
  72353. * Light (spot or directional) used to generate the volumetric lights rays
  72354. * The source light must have a shadow generate so the pipeline can get its
  72355. * depth map
  72356. */
  72357. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72358. /**
  72359. * For eye adaptation, represents the minimum luminance the eye can see
  72360. */
  72361. hdrMinimumLuminance: number;
  72362. /**
  72363. * For eye adaptation, represents the decrease luminance speed
  72364. */
  72365. hdrDecreaseRate: number;
  72366. /**
  72367. * For eye adaptation, represents the increase luminance speed
  72368. */
  72369. hdrIncreaseRate: number;
  72370. /**
  72371. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72372. */
  72373. get hdrAutoExposure(): boolean;
  72374. /**
  72375. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72376. */
  72377. set hdrAutoExposure(value: boolean);
  72378. /**
  72379. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72380. */
  72381. lensColorTexture: Nullable<Texture>;
  72382. /**
  72383. * The overall strengh for the lens flare effect
  72384. */
  72385. lensFlareStrength: number;
  72386. /**
  72387. * Dispersion coefficient for lens flare ghosts
  72388. */
  72389. lensFlareGhostDispersal: number;
  72390. /**
  72391. * Main lens flare halo width
  72392. */
  72393. lensFlareHaloWidth: number;
  72394. /**
  72395. * Based on the lens distortion effect, defines how much the lens flare result
  72396. * is distorted
  72397. */
  72398. lensFlareDistortionStrength: number;
  72399. /**
  72400. * Configures the blur intensity used for for lens flare (halo)
  72401. */
  72402. lensFlareBlurWidth: number;
  72403. /**
  72404. * Lens star texture must be used to simulate rays on the flares and is available
  72405. * in the documentation
  72406. */
  72407. lensStarTexture: Nullable<Texture>;
  72408. /**
  72409. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72410. * flare effect by taking account of the dirt texture
  72411. */
  72412. lensFlareDirtTexture: Nullable<Texture>;
  72413. /**
  72414. * Represents the focal length for the depth of field effect
  72415. */
  72416. depthOfFieldDistance: number;
  72417. /**
  72418. * Represents the blur intensity for the blurred part of the depth of field effect
  72419. */
  72420. depthOfFieldBlurWidth: number;
  72421. /**
  72422. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72423. */
  72424. get motionStrength(): number;
  72425. /**
  72426. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72427. */
  72428. set motionStrength(strength: number);
  72429. /**
  72430. * Gets wether or not the motion blur post-process is object based or screen based.
  72431. */
  72432. get objectBasedMotionBlur(): boolean;
  72433. /**
  72434. * Sets wether or not the motion blur post-process should be object based or screen based
  72435. */
  72436. set objectBasedMotionBlur(value: boolean);
  72437. /**
  72438. * List of animations for the pipeline (IAnimatable implementation)
  72439. */
  72440. animations: Animation[];
  72441. /**
  72442. * Private members
  72443. */
  72444. private _scene;
  72445. private _currentDepthOfFieldSource;
  72446. private _basePostProcess;
  72447. private _fixedExposure;
  72448. private _currentExposure;
  72449. private _hdrAutoExposure;
  72450. private _hdrCurrentLuminance;
  72451. private _motionStrength;
  72452. private _isObjectBasedMotionBlur;
  72453. private _floatTextureType;
  72454. private _camerasToBeAttached;
  72455. private _ratio;
  72456. private _bloomEnabled;
  72457. private _depthOfFieldEnabled;
  72458. private _vlsEnabled;
  72459. private _lensFlareEnabled;
  72460. private _hdrEnabled;
  72461. private _motionBlurEnabled;
  72462. private _fxaaEnabled;
  72463. private _screenSpaceReflectionsEnabled;
  72464. private _motionBlurSamples;
  72465. private _volumetricLightStepsCount;
  72466. private _samples;
  72467. /**
  72468. * @ignore
  72469. * Specifies if the bloom pipeline is enabled
  72470. */
  72471. get BloomEnabled(): boolean;
  72472. set BloomEnabled(enabled: boolean);
  72473. /**
  72474. * @ignore
  72475. * Specifies if the depth of field pipeline is enabed
  72476. */
  72477. get DepthOfFieldEnabled(): boolean;
  72478. set DepthOfFieldEnabled(enabled: boolean);
  72479. /**
  72480. * @ignore
  72481. * Specifies if the lens flare pipeline is enabed
  72482. */
  72483. get LensFlareEnabled(): boolean;
  72484. set LensFlareEnabled(enabled: boolean);
  72485. /**
  72486. * @ignore
  72487. * Specifies if the HDR pipeline is enabled
  72488. */
  72489. get HDREnabled(): boolean;
  72490. set HDREnabled(enabled: boolean);
  72491. /**
  72492. * @ignore
  72493. * Specifies if the volumetric lights scattering effect is enabled
  72494. */
  72495. get VLSEnabled(): boolean;
  72496. set VLSEnabled(enabled: boolean);
  72497. /**
  72498. * @ignore
  72499. * Specifies if the motion blur effect is enabled
  72500. */
  72501. get MotionBlurEnabled(): boolean;
  72502. set MotionBlurEnabled(enabled: boolean);
  72503. /**
  72504. * Specifies if anti-aliasing is enabled
  72505. */
  72506. get fxaaEnabled(): boolean;
  72507. set fxaaEnabled(enabled: boolean);
  72508. /**
  72509. * Specifies if screen space reflections are enabled.
  72510. */
  72511. get screenSpaceReflectionsEnabled(): boolean;
  72512. set screenSpaceReflectionsEnabled(enabled: boolean);
  72513. /**
  72514. * Specifies the number of steps used to calculate the volumetric lights
  72515. * Typically in interval [50, 200]
  72516. */
  72517. get volumetricLightStepsCount(): number;
  72518. set volumetricLightStepsCount(count: number);
  72519. /**
  72520. * Specifies the number of samples used for the motion blur effect
  72521. * Typically in interval [16, 64]
  72522. */
  72523. get motionBlurSamples(): number;
  72524. set motionBlurSamples(samples: number);
  72525. /**
  72526. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72527. */
  72528. get samples(): number;
  72529. set samples(sampleCount: number);
  72530. /**
  72531. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72532. * @constructor
  72533. * @param name The rendering pipeline name
  72534. * @param scene The scene linked to this pipeline
  72535. * @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)
  72536. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72537. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72538. */
  72539. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72540. private _buildPipeline;
  72541. private _createDownSampleX4PostProcess;
  72542. private _createBrightPassPostProcess;
  72543. private _createBlurPostProcesses;
  72544. private _createTextureAdderPostProcess;
  72545. private _createVolumetricLightPostProcess;
  72546. private _createLuminancePostProcesses;
  72547. private _createHdrPostProcess;
  72548. private _createLensFlarePostProcess;
  72549. private _createDepthOfFieldPostProcess;
  72550. private _createMotionBlurPostProcess;
  72551. private _getDepthTexture;
  72552. private _disposePostProcesses;
  72553. /**
  72554. * Dispose of the pipeline and stop all post processes
  72555. */
  72556. dispose(): void;
  72557. /**
  72558. * Serialize the rendering pipeline (Used when exporting)
  72559. * @returns the serialized object
  72560. */
  72561. serialize(): any;
  72562. /**
  72563. * Parse the serialized pipeline
  72564. * @param source Source pipeline.
  72565. * @param scene The scene to load the pipeline to.
  72566. * @param rootUrl The URL of the serialized pipeline.
  72567. * @returns An instantiated pipeline from the serialized object.
  72568. */
  72569. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72570. /**
  72571. * Luminance steps
  72572. */
  72573. static LuminanceSteps: number;
  72574. }
  72575. }
  72576. declare module BABYLON {
  72577. /** @hidden */
  72578. export var stereoscopicInterlacePixelShader: {
  72579. name: string;
  72580. shader: string;
  72581. };
  72582. }
  72583. declare module BABYLON {
  72584. /**
  72585. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72586. */
  72587. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72588. private _stepSize;
  72589. private _passedProcess;
  72590. /**
  72591. * Gets a string identifying the name of the class
  72592. * @returns "StereoscopicInterlacePostProcessI" string
  72593. */
  72594. getClassName(): string;
  72595. /**
  72596. * Initializes a StereoscopicInterlacePostProcessI
  72597. * @param name The name of the effect.
  72598. * @param rigCameras The rig cameras to be appled to the post process
  72599. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72600. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72602. * @param engine The engine which the post process will be applied. (default: current engine)
  72603. * @param reusable If the post process can be reused on the same frame. (default: false)
  72604. */
  72605. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72606. }
  72607. /**
  72608. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72609. */
  72610. export class StereoscopicInterlacePostProcess extends PostProcess {
  72611. private _stepSize;
  72612. private _passedProcess;
  72613. /**
  72614. * Gets a string identifying the name of the class
  72615. * @returns "StereoscopicInterlacePostProcess" string
  72616. */
  72617. getClassName(): string;
  72618. /**
  72619. * Initializes a StereoscopicInterlacePostProcess
  72620. * @param name The name of the effect.
  72621. * @param rigCameras The rig cameras to be appled to the post process
  72622. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72624. * @param engine The engine which the post process will be applied. (default: current engine)
  72625. * @param reusable If the post process can be reused on the same frame. (default: false)
  72626. */
  72627. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72628. }
  72629. }
  72630. declare module BABYLON {
  72631. /** @hidden */
  72632. export var tonemapPixelShader: {
  72633. name: string;
  72634. shader: string;
  72635. };
  72636. }
  72637. declare module BABYLON {
  72638. /** Defines operator used for tonemapping */
  72639. export enum TonemappingOperator {
  72640. /** Hable */
  72641. Hable = 0,
  72642. /** Reinhard */
  72643. Reinhard = 1,
  72644. /** HejiDawson */
  72645. HejiDawson = 2,
  72646. /** Photographic */
  72647. Photographic = 3
  72648. }
  72649. /**
  72650. * Defines a post process to apply tone mapping
  72651. */
  72652. export class TonemapPostProcess extends PostProcess {
  72653. private _operator;
  72654. /** Defines the required exposure adjustement */
  72655. exposureAdjustment: number;
  72656. /**
  72657. * Gets a string identifying the name of the class
  72658. * @returns "TonemapPostProcess" string
  72659. */
  72660. getClassName(): string;
  72661. /**
  72662. * Creates a new TonemapPostProcess
  72663. * @param name defines the name of the postprocess
  72664. * @param _operator defines the operator to use
  72665. * @param exposureAdjustment defines the required exposure adjustement
  72666. * @param camera defines the camera to use (can be null)
  72667. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72668. * @param engine defines the hosting engine (can be ignore if camera is set)
  72669. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72670. */
  72671. constructor(name: string, _operator: TonemappingOperator,
  72672. /** Defines the required exposure adjustement */
  72673. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72674. }
  72675. }
  72676. declare module BABYLON {
  72677. /** @hidden */
  72678. export var volumetricLightScatteringPixelShader: {
  72679. name: string;
  72680. shader: string;
  72681. };
  72682. }
  72683. declare module BABYLON {
  72684. /** @hidden */
  72685. export var volumetricLightScatteringPassVertexShader: {
  72686. name: string;
  72687. shader: string;
  72688. };
  72689. }
  72690. declare module BABYLON {
  72691. /** @hidden */
  72692. export var volumetricLightScatteringPassPixelShader: {
  72693. name: string;
  72694. shader: string;
  72695. };
  72696. }
  72697. declare module BABYLON {
  72698. /**
  72699. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72700. */
  72701. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72702. private _volumetricLightScatteringPass;
  72703. private _volumetricLightScatteringRTT;
  72704. private _viewPort;
  72705. private _screenCoordinates;
  72706. private _cachedDefines;
  72707. /**
  72708. * If not undefined, the mesh position is computed from the attached node position
  72709. */
  72710. attachedNode: {
  72711. position: Vector3;
  72712. };
  72713. /**
  72714. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72715. */
  72716. customMeshPosition: Vector3;
  72717. /**
  72718. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72719. */
  72720. useCustomMeshPosition: boolean;
  72721. /**
  72722. * If the post-process should inverse the light scattering direction
  72723. */
  72724. invert: boolean;
  72725. /**
  72726. * The internal mesh used by the post-process
  72727. */
  72728. mesh: Mesh;
  72729. /**
  72730. * @hidden
  72731. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72732. */
  72733. get useDiffuseColor(): boolean;
  72734. set useDiffuseColor(useDiffuseColor: boolean);
  72735. /**
  72736. * Array containing the excluded meshes not rendered in the internal pass
  72737. */
  72738. excludedMeshes: AbstractMesh[];
  72739. /**
  72740. * Controls the overall intensity of the post-process
  72741. */
  72742. exposure: number;
  72743. /**
  72744. * Dissipates each sample's contribution in range [0, 1]
  72745. */
  72746. decay: number;
  72747. /**
  72748. * Controls the overall intensity of each sample
  72749. */
  72750. weight: number;
  72751. /**
  72752. * Controls the density of each sample
  72753. */
  72754. density: number;
  72755. /**
  72756. * @constructor
  72757. * @param name The post-process name
  72758. * @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)
  72759. * @param camera The camera that the post-process will be attached to
  72760. * @param mesh The mesh used to create the light scattering
  72761. * @param samples The post-process quality, default 100
  72762. * @param samplingModeThe post-process filtering mode
  72763. * @param engine The babylon engine
  72764. * @param reusable If the post-process is reusable
  72765. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72766. */
  72767. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72768. /**
  72769. * Returns the string "VolumetricLightScatteringPostProcess"
  72770. * @returns "VolumetricLightScatteringPostProcess"
  72771. */
  72772. getClassName(): string;
  72773. private _isReady;
  72774. /**
  72775. * Sets the new light position for light scattering effect
  72776. * @param position The new custom light position
  72777. */
  72778. setCustomMeshPosition(position: Vector3): void;
  72779. /**
  72780. * Returns the light position for light scattering effect
  72781. * @return Vector3 The custom light position
  72782. */
  72783. getCustomMeshPosition(): Vector3;
  72784. /**
  72785. * Disposes the internal assets and detaches the post-process from the camera
  72786. */
  72787. dispose(camera: Camera): void;
  72788. /**
  72789. * Returns the render target texture used by the post-process
  72790. * @return the render target texture used by the post-process
  72791. */
  72792. getPass(): RenderTargetTexture;
  72793. private _meshExcluded;
  72794. private _createPass;
  72795. private _updateMeshScreenCoordinates;
  72796. /**
  72797. * Creates a default mesh for the Volumeric Light Scattering post-process
  72798. * @param name The mesh name
  72799. * @param scene The scene where to create the mesh
  72800. * @return the default mesh
  72801. */
  72802. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72803. }
  72804. }
  72805. declare module BABYLON {
  72806. /** @hidden */
  72807. export var screenSpaceCurvaturePixelShader: {
  72808. name: string;
  72809. shader: string;
  72810. };
  72811. }
  72812. declare module BABYLON {
  72813. /**
  72814. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72815. */
  72816. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72817. /**
  72818. * Defines how much ridge the curvature effect displays.
  72819. */
  72820. ridge: number;
  72821. /**
  72822. * Defines how much valley the curvature effect displays.
  72823. */
  72824. valley: number;
  72825. private _geometryBufferRenderer;
  72826. /**
  72827. * Gets a string identifying the name of the class
  72828. * @returns "ScreenSpaceCurvaturePostProcess" string
  72829. */
  72830. getClassName(): string;
  72831. /**
  72832. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72833. * @param name The name of the effect.
  72834. * @param scene The scene containing the objects to blur according to their velocity.
  72835. * @param options The required width/height ratio to downsize to before computing the render pass.
  72836. * @param camera The camera to apply the render pass to.
  72837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72838. * @param engine The engine which the post process will be applied. (default: current engine)
  72839. * @param reusable If the post process can be reused on the same frame. (default: false)
  72840. * @param textureType Type of textures used when performing the post process. (default: 0)
  72841. * @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)
  72842. */
  72843. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72844. /**
  72845. * Support test.
  72846. */
  72847. static get IsSupported(): boolean;
  72848. /** @hidden */
  72849. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72850. }
  72851. }
  72852. declare module BABYLON {
  72853. interface Scene {
  72854. /** @hidden (Backing field) */
  72855. _boundingBoxRenderer: BoundingBoxRenderer;
  72856. /** @hidden (Backing field) */
  72857. _forceShowBoundingBoxes: boolean;
  72858. /**
  72859. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72860. */
  72861. forceShowBoundingBoxes: boolean;
  72862. /**
  72863. * Gets the bounding box renderer associated with the scene
  72864. * @returns a BoundingBoxRenderer
  72865. */
  72866. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72867. }
  72868. interface AbstractMesh {
  72869. /** @hidden (Backing field) */
  72870. _showBoundingBox: boolean;
  72871. /**
  72872. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72873. */
  72874. showBoundingBox: boolean;
  72875. }
  72876. /**
  72877. * Component responsible of rendering the bounding box of the meshes in a scene.
  72878. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72879. */
  72880. export class BoundingBoxRenderer implements ISceneComponent {
  72881. /**
  72882. * The component name helpfull to identify the component in the list of scene components.
  72883. */
  72884. readonly name: string;
  72885. /**
  72886. * The scene the component belongs to.
  72887. */
  72888. scene: Scene;
  72889. /**
  72890. * Color of the bounding box lines placed in front of an object
  72891. */
  72892. frontColor: Color3;
  72893. /**
  72894. * Color of the bounding box lines placed behind an object
  72895. */
  72896. backColor: Color3;
  72897. /**
  72898. * Defines if the renderer should show the back lines or not
  72899. */
  72900. showBackLines: boolean;
  72901. /**
  72902. * Observable raised before rendering a bounding box
  72903. */
  72904. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72905. /**
  72906. * Observable raised after rendering a bounding box
  72907. */
  72908. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72909. /**
  72910. * Observable raised after resources are created
  72911. */
  72912. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  72913. /**
  72914. * When false, no bounding boxes will be rendered
  72915. */
  72916. enabled: boolean;
  72917. /**
  72918. * @hidden
  72919. */
  72920. renderList: SmartArray<BoundingBox>;
  72921. private _colorShader;
  72922. private _vertexBuffers;
  72923. private _indexBuffer;
  72924. private _fillIndexBuffer;
  72925. private _fillIndexData;
  72926. /**
  72927. * Instantiates a new bounding box renderer in a scene.
  72928. * @param scene the scene the renderer renders in
  72929. */
  72930. constructor(scene: Scene);
  72931. /**
  72932. * Registers the component in a given scene
  72933. */
  72934. register(): void;
  72935. private _evaluateSubMesh;
  72936. private _preActiveMesh;
  72937. private _prepareResources;
  72938. private _createIndexBuffer;
  72939. /**
  72940. * Rebuilds the elements related to this component in case of
  72941. * context lost for instance.
  72942. */
  72943. rebuild(): void;
  72944. /**
  72945. * @hidden
  72946. */
  72947. reset(): void;
  72948. /**
  72949. * Render the bounding boxes of a specific rendering group
  72950. * @param renderingGroupId defines the rendering group to render
  72951. */
  72952. render(renderingGroupId: number): void;
  72953. /**
  72954. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72955. * @param mesh Define the mesh to render the occlusion bounding box for
  72956. */
  72957. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72958. /**
  72959. * Dispose and release the resources attached to this renderer.
  72960. */
  72961. dispose(): void;
  72962. }
  72963. }
  72964. declare module BABYLON {
  72965. interface Scene {
  72966. /** @hidden (Backing field) */
  72967. _depthRenderer: {
  72968. [id: string]: DepthRenderer;
  72969. };
  72970. /**
  72971. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72972. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72973. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72974. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72975. * @returns the created depth renderer
  72976. */
  72977. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72978. /**
  72979. * Disables a depth renderer for a given camera
  72980. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72981. */
  72982. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72983. }
  72984. /**
  72985. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72986. * in several rendering techniques.
  72987. */
  72988. export class DepthRendererSceneComponent implements ISceneComponent {
  72989. /**
  72990. * The component name helpfull to identify the component in the list of scene components.
  72991. */
  72992. readonly name: string;
  72993. /**
  72994. * The scene the component belongs to.
  72995. */
  72996. scene: Scene;
  72997. /**
  72998. * Creates a new instance of the component for the given scene
  72999. * @param scene Defines the scene to register the component in
  73000. */
  73001. constructor(scene: Scene);
  73002. /**
  73003. * Registers the component in a given scene
  73004. */
  73005. register(): void;
  73006. /**
  73007. * Rebuilds the elements related to this component in case of
  73008. * context lost for instance.
  73009. */
  73010. rebuild(): void;
  73011. /**
  73012. * Disposes the component and the associated ressources
  73013. */
  73014. dispose(): void;
  73015. private _gatherRenderTargets;
  73016. private _gatherActiveCameraRenderTargets;
  73017. }
  73018. }
  73019. declare module BABYLON {
  73020. interface AbstractScene {
  73021. /** @hidden (Backing field) */
  73022. _prePassRenderer: Nullable<PrePassRenderer>;
  73023. /**
  73024. * Gets or Sets the current prepass renderer associated to the scene.
  73025. */
  73026. prePassRenderer: Nullable<PrePassRenderer>;
  73027. /**
  73028. * Enables the prepass and associates it with the scene
  73029. * @returns the PrePassRenderer
  73030. */
  73031. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73032. /**
  73033. * Disables the prepass associated with the scene
  73034. */
  73035. disablePrePassRenderer(): void;
  73036. }
  73037. /**
  73038. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73039. * in several rendering techniques.
  73040. */
  73041. export class PrePassRendererSceneComponent implements ISceneComponent {
  73042. /**
  73043. * The component name helpful to identify the component in the list of scene components.
  73044. */
  73045. readonly name: string;
  73046. /**
  73047. * The scene the component belongs to.
  73048. */
  73049. scene: Scene;
  73050. /**
  73051. * Creates a new instance of the component for the given scene
  73052. * @param scene Defines the scene to register the component in
  73053. */
  73054. constructor(scene: Scene);
  73055. /**
  73056. * Registers the component in a given scene
  73057. */
  73058. register(): void;
  73059. private _beforeCameraDraw;
  73060. private _afterCameraDraw;
  73061. private _beforeClearStage;
  73062. /**
  73063. * Rebuilds the elements related to this component in case of
  73064. * context lost for instance.
  73065. */
  73066. rebuild(): void;
  73067. /**
  73068. * Disposes the component and the associated ressources
  73069. */
  73070. dispose(): void;
  73071. }
  73072. }
  73073. declare module BABYLON {
  73074. /** @hidden */
  73075. export var fibonacci: {
  73076. name: string;
  73077. shader: string;
  73078. };
  73079. }
  73080. declare module BABYLON {
  73081. /** @hidden */
  73082. export var diffusionProfile: {
  73083. name: string;
  73084. shader: string;
  73085. };
  73086. }
  73087. declare module BABYLON {
  73088. /** @hidden */
  73089. export var subSurfaceScatteringPixelShader: {
  73090. name: string;
  73091. shader: string;
  73092. };
  73093. }
  73094. declare module BABYLON {
  73095. /**
  73096. * Sub surface scattering post process
  73097. */
  73098. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73099. /**
  73100. * Gets a string identifying the name of the class
  73101. * @returns "SubSurfaceScatteringPostProcess" string
  73102. */
  73103. getClassName(): string;
  73104. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73105. }
  73106. }
  73107. declare module BABYLON {
  73108. /**
  73109. * Contains all parameters needed for the prepass to perform
  73110. * screen space subsurface scattering
  73111. */
  73112. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73113. /** @hidden */
  73114. static _SceneComponentInitialization: (scene: Scene) => void;
  73115. private _ssDiffusionS;
  73116. private _ssFilterRadii;
  73117. private _ssDiffusionD;
  73118. /**
  73119. * Post process to attach for screen space subsurface scattering
  73120. */
  73121. postProcess: SubSurfaceScatteringPostProcess;
  73122. /**
  73123. * Diffusion profile color for subsurface scattering
  73124. */
  73125. get ssDiffusionS(): number[];
  73126. /**
  73127. * Diffusion profile max color channel value for subsurface scattering
  73128. */
  73129. get ssDiffusionD(): number[];
  73130. /**
  73131. * Diffusion profile filter radius for subsurface scattering
  73132. */
  73133. get ssFilterRadii(): number[];
  73134. /**
  73135. * Is subsurface enabled
  73136. */
  73137. enabled: boolean;
  73138. /**
  73139. * Name of the configuration
  73140. */
  73141. name: string;
  73142. /**
  73143. * Diffusion profile colors for subsurface scattering
  73144. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73145. * See ...
  73146. * Note that you can only store up to 5 of them
  73147. */
  73148. ssDiffusionProfileColors: Color3[];
  73149. /**
  73150. * Defines the ratio real world => scene units.
  73151. * Used for subsurface scattering
  73152. */
  73153. metersPerUnit: number;
  73154. /**
  73155. * Textures that should be present in the MRT for this effect to work
  73156. */
  73157. readonly texturesRequired: number[];
  73158. private _scene;
  73159. /**
  73160. * Builds a subsurface configuration object
  73161. * @param scene The scene
  73162. */
  73163. constructor(scene: Scene);
  73164. /**
  73165. * Adds a new diffusion profile.
  73166. * Useful for more realistic subsurface scattering on diverse materials.
  73167. * @param color The color of the diffusion profile. Should be the average color of the material.
  73168. * @return The index of the diffusion profile for the material subsurface configuration
  73169. */
  73170. addDiffusionProfile(color: Color3): number;
  73171. /**
  73172. * Creates the sss post process
  73173. * @return The created post process
  73174. */
  73175. createPostProcess(): SubSurfaceScatteringPostProcess;
  73176. /**
  73177. * Deletes all diffusion profiles.
  73178. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73179. */
  73180. clearAllDiffusionProfiles(): void;
  73181. /**
  73182. * Disposes this object
  73183. */
  73184. dispose(): void;
  73185. /**
  73186. * @hidden
  73187. * https://zero-radiance.github.io/post/sampling-diffusion/
  73188. *
  73189. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73190. * ------------------------------------------------------------------------------------
  73191. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73192. * PDF[r, phi, s] = r * R[r, phi, s]
  73193. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73194. * ------------------------------------------------------------------------------------
  73195. * We importance sample the color channel with the widest scattering distance.
  73196. */
  73197. getDiffusionProfileParameters(color: Color3): number;
  73198. /**
  73199. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73200. * 'u' is the random number (the value of the CDF): [0, 1).
  73201. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73202. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73203. */
  73204. private _sampleBurleyDiffusionProfile;
  73205. }
  73206. }
  73207. declare module BABYLON {
  73208. interface AbstractScene {
  73209. /** @hidden (Backing field) */
  73210. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73211. /**
  73212. * Gets or Sets the current prepass renderer associated to the scene.
  73213. */
  73214. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73215. /**
  73216. * Enables the subsurface effect for prepass
  73217. * @returns the SubSurfaceConfiguration
  73218. */
  73219. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73220. /**
  73221. * Disables the subsurface effect for prepass
  73222. */
  73223. disableSubSurfaceForPrePass(): void;
  73224. }
  73225. /**
  73226. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73227. * in several rendering techniques.
  73228. */
  73229. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73230. /**
  73231. * The component name helpful to identify the component in the list of scene components.
  73232. */
  73233. readonly name: string;
  73234. /**
  73235. * The scene the component belongs to.
  73236. */
  73237. scene: Scene;
  73238. /**
  73239. * Creates a new instance of the component for the given scene
  73240. * @param scene Defines the scene to register the component in
  73241. */
  73242. constructor(scene: Scene);
  73243. /**
  73244. * Registers the component in a given scene
  73245. */
  73246. register(): void;
  73247. /**
  73248. * Serializes the component data to the specified json object
  73249. * @param serializationObject The object to serialize to
  73250. */
  73251. serialize(serializationObject: any): void;
  73252. /**
  73253. * Adds all the elements from the container to the scene
  73254. * @param container the container holding the elements
  73255. */
  73256. addFromContainer(container: AbstractScene): void;
  73257. /**
  73258. * Removes all the elements in the container from the scene
  73259. * @param container contains the elements to remove
  73260. * @param dispose if the removed element should be disposed (default: false)
  73261. */
  73262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73263. /**
  73264. * Rebuilds the elements related to this component in case of
  73265. * context lost for instance.
  73266. */
  73267. rebuild(): void;
  73268. /**
  73269. * Disposes the component and the associated ressources
  73270. */
  73271. dispose(): void;
  73272. }
  73273. }
  73274. declare module BABYLON {
  73275. /** @hidden */
  73276. export var outlinePixelShader: {
  73277. name: string;
  73278. shader: string;
  73279. };
  73280. }
  73281. declare module BABYLON {
  73282. /** @hidden */
  73283. export var outlineVertexShader: {
  73284. name: string;
  73285. shader: string;
  73286. };
  73287. }
  73288. declare module BABYLON {
  73289. interface Scene {
  73290. /** @hidden */
  73291. _outlineRenderer: OutlineRenderer;
  73292. /**
  73293. * Gets the outline renderer associated with the scene
  73294. * @returns a OutlineRenderer
  73295. */
  73296. getOutlineRenderer(): OutlineRenderer;
  73297. }
  73298. interface AbstractMesh {
  73299. /** @hidden (Backing field) */
  73300. _renderOutline: boolean;
  73301. /**
  73302. * Gets or sets a boolean indicating if the outline must be rendered as well
  73303. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73304. */
  73305. renderOutline: boolean;
  73306. /** @hidden (Backing field) */
  73307. _renderOverlay: boolean;
  73308. /**
  73309. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73310. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73311. */
  73312. renderOverlay: boolean;
  73313. }
  73314. /**
  73315. * This class is responsible to draw bothe outline/overlay of meshes.
  73316. * It should not be used directly but through the available method on mesh.
  73317. */
  73318. export class OutlineRenderer implements ISceneComponent {
  73319. /**
  73320. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73321. */
  73322. private static _StencilReference;
  73323. /**
  73324. * The name of the component. Each component must have a unique name.
  73325. */
  73326. name: string;
  73327. /**
  73328. * The scene the component belongs to.
  73329. */
  73330. scene: Scene;
  73331. /**
  73332. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73333. */
  73334. zOffset: number;
  73335. private _engine;
  73336. private _effect;
  73337. private _cachedDefines;
  73338. private _savedDepthWrite;
  73339. /**
  73340. * Instantiates a new outline renderer. (There could be only one per scene).
  73341. * @param scene Defines the scene it belongs to
  73342. */
  73343. constructor(scene: Scene);
  73344. /**
  73345. * Register the component to one instance of a scene.
  73346. */
  73347. register(): void;
  73348. /**
  73349. * Rebuilds the elements related to this component in case of
  73350. * context lost for instance.
  73351. */
  73352. rebuild(): void;
  73353. /**
  73354. * Disposes the component and the associated ressources.
  73355. */
  73356. dispose(): void;
  73357. /**
  73358. * Renders the outline in the canvas.
  73359. * @param subMesh Defines the sumesh to render
  73360. * @param batch Defines the batch of meshes in case of instances
  73361. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73362. */
  73363. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73364. /**
  73365. * Returns whether or not the outline renderer is ready for a given submesh.
  73366. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73367. * @param subMesh Defines the submesh to check readyness for
  73368. * @param useInstances Defines wheter wee are trying to render instances or not
  73369. * @returns true if ready otherwise false
  73370. */
  73371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73372. private _beforeRenderingMesh;
  73373. private _afterRenderingMesh;
  73374. }
  73375. }
  73376. declare module BABYLON {
  73377. /**
  73378. * Defines the basic options interface of a Sprite Frame Source Size.
  73379. */
  73380. export interface ISpriteJSONSpriteSourceSize {
  73381. /**
  73382. * number of the original width of the Frame
  73383. */
  73384. w: number;
  73385. /**
  73386. * number of the original height of the Frame
  73387. */
  73388. h: number;
  73389. }
  73390. /**
  73391. * Defines the basic options interface of a Sprite Frame Data.
  73392. */
  73393. export interface ISpriteJSONSpriteFrameData {
  73394. /**
  73395. * number of the x offset of the Frame
  73396. */
  73397. x: number;
  73398. /**
  73399. * number of the y offset of the Frame
  73400. */
  73401. y: number;
  73402. /**
  73403. * number of the width of the Frame
  73404. */
  73405. w: number;
  73406. /**
  73407. * number of the height of the Frame
  73408. */
  73409. h: number;
  73410. }
  73411. /**
  73412. * Defines the basic options interface of a JSON Sprite.
  73413. */
  73414. export interface ISpriteJSONSprite {
  73415. /**
  73416. * string name of the Frame
  73417. */
  73418. filename: string;
  73419. /**
  73420. * ISpriteJSONSpriteFrame basic object of the frame data
  73421. */
  73422. frame: ISpriteJSONSpriteFrameData;
  73423. /**
  73424. * boolean to flag is the frame was rotated.
  73425. */
  73426. rotated: boolean;
  73427. /**
  73428. * boolean to flag is the frame was trimmed.
  73429. */
  73430. trimmed: boolean;
  73431. /**
  73432. * ISpriteJSONSpriteFrame basic object of the source data
  73433. */
  73434. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73435. /**
  73436. * ISpriteJSONSpriteFrame basic object of the source data
  73437. */
  73438. sourceSize: ISpriteJSONSpriteSourceSize;
  73439. }
  73440. /**
  73441. * Defines the basic options interface of a JSON atlas.
  73442. */
  73443. export interface ISpriteJSONAtlas {
  73444. /**
  73445. * Array of objects that contain the frame data.
  73446. */
  73447. frames: Array<ISpriteJSONSprite>;
  73448. /**
  73449. * object basic object containing the sprite meta data.
  73450. */
  73451. meta?: object;
  73452. }
  73453. }
  73454. declare module BABYLON {
  73455. /** @hidden */
  73456. export var spriteMapPixelShader: {
  73457. name: string;
  73458. shader: string;
  73459. };
  73460. }
  73461. declare module BABYLON {
  73462. /** @hidden */
  73463. export var spriteMapVertexShader: {
  73464. name: string;
  73465. shader: string;
  73466. };
  73467. }
  73468. declare module BABYLON {
  73469. /**
  73470. * Defines the basic options interface of a SpriteMap
  73471. */
  73472. export interface ISpriteMapOptions {
  73473. /**
  73474. * Vector2 of the number of cells in the grid.
  73475. */
  73476. stageSize?: Vector2;
  73477. /**
  73478. * Vector2 of the size of the output plane in World Units.
  73479. */
  73480. outputSize?: Vector2;
  73481. /**
  73482. * Vector3 of the position of the output plane in World Units.
  73483. */
  73484. outputPosition?: Vector3;
  73485. /**
  73486. * Vector3 of the rotation of the output plane.
  73487. */
  73488. outputRotation?: Vector3;
  73489. /**
  73490. * number of layers that the system will reserve in resources.
  73491. */
  73492. layerCount?: number;
  73493. /**
  73494. * number of max animation frames a single cell will reserve in resources.
  73495. */
  73496. maxAnimationFrames?: number;
  73497. /**
  73498. * number cell index of the base tile when the system compiles.
  73499. */
  73500. baseTile?: number;
  73501. /**
  73502. * boolean flip the sprite after its been repositioned by the framing data.
  73503. */
  73504. flipU?: boolean;
  73505. /**
  73506. * Vector3 scalar of the global RGB values of the SpriteMap.
  73507. */
  73508. colorMultiply?: Vector3;
  73509. }
  73510. /**
  73511. * Defines the IDisposable interface in order to be cleanable from resources.
  73512. */
  73513. export interface ISpriteMap extends IDisposable {
  73514. /**
  73515. * String name of the SpriteMap.
  73516. */
  73517. name: string;
  73518. /**
  73519. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73520. */
  73521. atlasJSON: ISpriteJSONAtlas;
  73522. /**
  73523. * Texture of the SpriteMap.
  73524. */
  73525. spriteSheet: Texture;
  73526. /**
  73527. * The parameters to initialize the SpriteMap with.
  73528. */
  73529. options: ISpriteMapOptions;
  73530. }
  73531. /**
  73532. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73533. */
  73534. export class SpriteMap implements ISpriteMap {
  73535. /** The Name of the spriteMap */
  73536. name: string;
  73537. /** The JSON file with the frame and meta data */
  73538. atlasJSON: ISpriteJSONAtlas;
  73539. /** The systems Sprite Sheet Texture */
  73540. spriteSheet: Texture;
  73541. /** Arguments passed with the Constructor */
  73542. options: ISpriteMapOptions;
  73543. /** Public Sprite Storage array, parsed from atlasJSON */
  73544. sprites: Array<ISpriteJSONSprite>;
  73545. /** Returns the Number of Sprites in the System */
  73546. get spriteCount(): number;
  73547. /** Returns the Position of Output Plane*/
  73548. get position(): Vector3;
  73549. /** Returns the Position of Output Plane*/
  73550. set position(v: Vector3);
  73551. /** Returns the Rotation of Output Plane*/
  73552. get rotation(): Vector3;
  73553. /** Returns the Rotation of Output Plane*/
  73554. set rotation(v: Vector3);
  73555. /** Sets the AnimationMap*/
  73556. get animationMap(): RawTexture;
  73557. /** Sets the AnimationMap*/
  73558. set animationMap(v: RawTexture);
  73559. /** Scene that the SpriteMap was created in */
  73560. private _scene;
  73561. /** Texture Buffer of Float32 that holds tile frame data*/
  73562. private _frameMap;
  73563. /** Texture Buffers of Float32 that holds tileMap data*/
  73564. private _tileMaps;
  73565. /** Texture Buffer of Float32 that holds Animation Data*/
  73566. private _animationMap;
  73567. /** Custom ShaderMaterial Central to the System*/
  73568. private _material;
  73569. /** Custom ShaderMaterial Central to the System*/
  73570. private _output;
  73571. /** Systems Time Ticker*/
  73572. private _time;
  73573. /**
  73574. * Creates a new SpriteMap
  73575. * @param name defines the SpriteMaps Name
  73576. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73577. * @param spriteSheet is the Texture that the Sprites are on.
  73578. * @param options a basic deployment configuration
  73579. * @param scene The Scene that the map is deployed on
  73580. */
  73581. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73582. /**
  73583. * Returns tileID location
  73584. * @returns Vector2 the cell position ID
  73585. */
  73586. getTileID(): Vector2;
  73587. /**
  73588. * Gets the UV location of the mouse over the SpriteMap.
  73589. * @returns Vector2 the UV position of the mouse interaction
  73590. */
  73591. getMousePosition(): Vector2;
  73592. /**
  73593. * Creates the "frame" texture Buffer
  73594. * -------------------------------------
  73595. * Structure of frames
  73596. * "filename": "Falling-Water-2.png",
  73597. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73598. * "rotated": true,
  73599. * "trimmed": true,
  73600. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73601. * "sourceSize": {"w":32,"h":32}
  73602. * @returns RawTexture of the frameMap
  73603. */
  73604. private _createFrameBuffer;
  73605. /**
  73606. * Creates the tileMap texture Buffer
  73607. * @param buffer normally and array of numbers, or a false to generate from scratch
  73608. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73609. * @returns RawTexture of the tileMap
  73610. */
  73611. private _createTileBuffer;
  73612. /**
  73613. * Modifies the data of the tileMaps
  73614. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73615. * @param pos is the iVector2 Coordinates of the Tile
  73616. * @param tile The SpriteIndex of the new Tile
  73617. */
  73618. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73619. /**
  73620. * Creates the animationMap texture Buffer
  73621. * @param buffer normally and array of numbers, or a false to generate from scratch
  73622. * @returns RawTexture of the animationMap
  73623. */
  73624. private _createTileAnimationBuffer;
  73625. /**
  73626. * Modifies the data of the animationMap
  73627. * @param cellID is the Index of the Sprite
  73628. * @param _frame is the target Animation frame
  73629. * @param toCell is the Target Index of the next frame of the animation
  73630. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73631. * @param speed is a global scalar of the time variable on the map.
  73632. */
  73633. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73634. /**
  73635. * Exports the .tilemaps file
  73636. */
  73637. saveTileMaps(): void;
  73638. /**
  73639. * Imports the .tilemaps file
  73640. * @param url of the .tilemaps file
  73641. */
  73642. loadTileMaps(url: string): void;
  73643. /**
  73644. * Release associated resources
  73645. */
  73646. dispose(): void;
  73647. }
  73648. }
  73649. declare module BABYLON {
  73650. /**
  73651. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73652. * @see https://doc.babylonjs.com/babylon101/sprites
  73653. */
  73654. export class SpritePackedManager extends SpriteManager {
  73655. /** defines the packed manager's name */
  73656. name: string;
  73657. /**
  73658. * Creates a new sprite manager from a packed sprite sheet
  73659. * @param name defines the manager's name
  73660. * @param imgUrl defines the sprite sheet url
  73661. * @param capacity defines the maximum allowed number of sprites
  73662. * @param scene defines the hosting scene
  73663. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73664. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73665. * @param samplingMode defines the smapling mode to use with spritesheet
  73666. * @param fromPacked set to true; do not alter
  73667. */
  73668. constructor(
  73669. /** defines the packed manager's name */
  73670. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73671. }
  73672. }
  73673. declare module BABYLON {
  73674. /**
  73675. * Defines the list of states available for a task inside a AssetsManager
  73676. */
  73677. export enum AssetTaskState {
  73678. /**
  73679. * Initialization
  73680. */
  73681. INIT = 0,
  73682. /**
  73683. * Running
  73684. */
  73685. RUNNING = 1,
  73686. /**
  73687. * Done
  73688. */
  73689. DONE = 2,
  73690. /**
  73691. * Error
  73692. */
  73693. ERROR = 3
  73694. }
  73695. /**
  73696. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73697. */
  73698. export abstract class AbstractAssetTask {
  73699. /**
  73700. * Task name
  73701. */ name: string;
  73702. /**
  73703. * Callback called when the task is successful
  73704. */
  73705. onSuccess: (task: any) => void;
  73706. /**
  73707. * Callback called when the task is not successful
  73708. */
  73709. onError: (task: any, message?: string, exception?: any) => void;
  73710. /**
  73711. * Creates a new AssetsManager
  73712. * @param name defines the name of the task
  73713. */
  73714. constructor(
  73715. /**
  73716. * Task name
  73717. */ name: string);
  73718. private _isCompleted;
  73719. private _taskState;
  73720. private _errorObject;
  73721. /**
  73722. * Get if the task is completed
  73723. */
  73724. get isCompleted(): boolean;
  73725. /**
  73726. * Gets the current state of the task
  73727. */
  73728. get taskState(): AssetTaskState;
  73729. /**
  73730. * Gets the current error object (if task is in error)
  73731. */
  73732. get errorObject(): {
  73733. message?: string;
  73734. exception?: any;
  73735. };
  73736. /**
  73737. * Internal only
  73738. * @hidden
  73739. */
  73740. _setErrorObject(message?: string, exception?: any): void;
  73741. /**
  73742. * Execute the current task
  73743. * @param scene defines the scene where you want your assets to be loaded
  73744. * @param onSuccess is a callback called when the task is successfully executed
  73745. * @param onError is a callback called if an error occurs
  73746. */
  73747. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73748. /**
  73749. * Execute the current task
  73750. * @param scene defines the scene where you want your assets to be loaded
  73751. * @param onSuccess is a callback called when the task is successfully executed
  73752. * @param onError is a callback called if an error occurs
  73753. */
  73754. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73755. /**
  73756. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73757. * This can be used with failed tasks that have the reason for failure fixed.
  73758. */
  73759. reset(): void;
  73760. private onErrorCallback;
  73761. private onDoneCallback;
  73762. }
  73763. /**
  73764. * Define the interface used by progress events raised during assets loading
  73765. */
  73766. export interface IAssetsProgressEvent {
  73767. /**
  73768. * Defines the number of remaining tasks to process
  73769. */
  73770. remainingCount: number;
  73771. /**
  73772. * Defines the total number of tasks
  73773. */
  73774. totalCount: number;
  73775. /**
  73776. * Defines the task that was just processed
  73777. */
  73778. task: AbstractAssetTask;
  73779. }
  73780. /**
  73781. * Class used to share progress information about assets loading
  73782. */
  73783. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73784. /**
  73785. * Defines the number of remaining tasks to process
  73786. */
  73787. remainingCount: number;
  73788. /**
  73789. * Defines the total number of tasks
  73790. */
  73791. totalCount: number;
  73792. /**
  73793. * Defines the task that was just processed
  73794. */
  73795. task: AbstractAssetTask;
  73796. /**
  73797. * Creates a AssetsProgressEvent
  73798. * @param remainingCount defines the number of remaining tasks to process
  73799. * @param totalCount defines the total number of tasks
  73800. * @param task defines the task that was just processed
  73801. */
  73802. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73803. }
  73804. /**
  73805. * Define a task used by AssetsManager to load assets into a container
  73806. */
  73807. export class ContainerAssetTask extends AbstractAssetTask {
  73808. /**
  73809. * Defines the name of the task
  73810. */
  73811. name: string;
  73812. /**
  73813. * Defines the list of mesh's names you want to load
  73814. */
  73815. meshesNames: any;
  73816. /**
  73817. * Defines the root url to use as a base to load your meshes and associated resources
  73818. */
  73819. rootUrl: string;
  73820. /**
  73821. * Defines the filename or File of the scene to load from
  73822. */
  73823. sceneFilename: string | File;
  73824. /**
  73825. * Get the loaded asset container
  73826. */
  73827. loadedContainer: AssetContainer;
  73828. /**
  73829. * Gets the list of loaded meshes
  73830. */
  73831. loadedMeshes: Array<AbstractMesh>;
  73832. /**
  73833. * Gets the list of loaded particle systems
  73834. */
  73835. loadedParticleSystems: Array<IParticleSystem>;
  73836. /**
  73837. * Gets the list of loaded skeletons
  73838. */
  73839. loadedSkeletons: Array<Skeleton>;
  73840. /**
  73841. * Gets the list of loaded animation groups
  73842. */
  73843. loadedAnimationGroups: Array<AnimationGroup>;
  73844. /**
  73845. * Callback called when the task is successful
  73846. */
  73847. onSuccess: (task: ContainerAssetTask) => void;
  73848. /**
  73849. * Callback called when the task is successful
  73850. */
  73851. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73852. /**
  73853. * Creates a new ContainerAssetTask
  73854. * @param name defines the name of the task
  73855. * @param meshesNames defines the list of mesh's names you want to load
  73856. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73857. * @param sceneFilename defines the filename or File of the scene to load from
  73858. */
  73859. constructor(
  73860. /**
  73861. * Defines the name of the task
  73862. */
  73863. name: string,
  73864. /**
  73865. * Defines the list of mesh's names you want to load
  73866. */
  73867. meshesNames: any,
  73868. /**
  73869. * Defines the root url to use as a base to load your meshes and associated resources
  73870. */
  73871. rootUrl: string,
  73872. /**
  73873. * Defines the filename or File of the scene to load from
  73874. */
  73875. sceneFilename: string | File);
  73876. /**
  73877. * Execute the current task
  73878. * @param scene defines the scene where you want your assets to be loaded
  73879. * @param onSuccess is a callback called when the task is successfully executed
  73880. * @param onError is a callback called if an error occurs
  73881. */
  73882. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73883. }
  73884. /**
  73885. * Define a task used by AssetsManager to load meshes
  73886. */
  73887. export class MeshAssetTask extends AbstractAssetTask {
  73888. /**
  73889. * Defines the name of the task
  73890. */
  73891. name: string;
  73892. /**
  73893. * Defines the list of mesh's names you want to load
  73894. */
  73895. meshesNames: any;
  73896. /**
  73897. * Defines the root url to use as a base to load your meshes and associated resources
  73898. */
  73899. rootUrl: string;
  73900. /**
  73901. * Defines the filename or File of the scene to load from
  73902. */
  73903. sceneFilename: string | File;
  73904. /**
  73905. * Gets the list of loaded meshes
  73906. */
  73907. loadedMeshes: Array<AbstractMesh>;
  73908. /**
  73909. * Gets the list of loaded particle systems
  73910. */
  73911. loadedParticleSystems: Array<IParticleSystem>;
  73912. /**
  73913. * Gets the list of loaded skeletons
  73914. */
  73915. loadedSkeletons: Array<Skeleton>;
  73916. /**
  73917. * Gets the list of loaded animation groups
  73918. */
  73919. loadedAnimationGroups: Array<AnimationGroup>;
  73920. /**
  73921. * Callback called when the task is successful
  73922. */
  73923. onSuccess: (task: MeshAssetTask) => void;
  73924. /**
  73925. * Callback called when the task is successful
  73926. */
  73927. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73928. /**
  73929. * Creates a new MeshAssetTask
  73930. * @param name defines the name of the task
  73931. * @param meshesNames defines the list of mesh's names you want to load
  73932. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73933. * @param sceneFilename defines the filename or File of the scene to load from
  73934. */
  73935. constructor(
  73936. /**
  73937. * Defines the name of the task
  73938. */
  73939. name: string,
  73940. /**
  73941. * Defines the list of mesh's names you want to load
  73942. */
  73943. meshesNames: any,
  73944. /**
  73945. * Defines the root url to use as a base to load your meshes and associated resources
  73946. */
  73947. rootUrl: string,
  73948. /**
  73949. * Defines the filename or File of the scene to load from
  73950. */
  73951. sceneFilename: string | File);
  73952. /**
  73953. * Execute the current task
  73954. * @param scene defines the scene where you want your assets to be loaded
  73955. * @param onSuccess is a callback called when the task is successfully executed
  73956. * @param onError is a callback called if an error occurs
  73957. */
  73958. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73959. }
  73960. /**
  73961. * Define a task used by AssetsManager to load text content
  73962. */
  73963. export class TextFileAssetTask extends AbstractAssetTask {
  73964. /**
  73965. * Defines the name of the task
  73966. */
  73967. name: string;
  73968. /**
  73969. * Defines the location of the file to load
  73970. */
  73971. url: string;
  73972. /**
  73973. * Gets the loaded text string
  73974. */
  73975. text: string;
  73976. /**
  73977. * Callback called when the task is successful
  73978. */
  73979. onSuccess: (task: TextFileAssetTask) => void;
  73980. /**
  73981. * Callback called when the task is successful
  73982. */
  73983. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73984. /**
  73985. * Creates a new TextFileAssetTask object
  73986. * @param name defines the name of the task
  73987. * @param url defines the location of the file to load
  73988. */
  73989. constructor(
  73990. /**
  73991. * Defines the name of the task
  73992. */
  73993. name: string,
  73994. /**
  73995. * Defines the location of the file to load
  73996. */
  73997. url: string);
  73998. /**
  73999. * Execute the current task
  74000. * @param scene defines the scene where you want your assets to be loaded
  74001. * @param onSuccess is a callback called when the task is successfully executed
  74002. * @param onError is a callback called if an error occurs
  74003. */
  74004. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74005. }
  74006. /**
  74007. * Define a task used by AssetsManager to load binary data
  74008. */
  74009. export class BinaryFileAssetTask extends AbstractAssetTask {
  74010. /**
  74011. * Defines the name of the task
  74012. */
  74013. name: string;
  74014. /**
  74015. * Defines the location of the file to load
  74016. */
  74017. url: string;
  74018. /**
  74019. * Gets the lodaded data (as an array buffer)
  74020. */
  74021. data: ArrayBuffer;
  74022. /**
  74023. * Callback called when the task is successful
  74024. */
  74025. onSuccess: (task: BinaryFileAssetTask) => void;
  74026. /**
  74027. * Callback called when the task is successful
  74028. */
  74029. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74030. /**
  74031. * Creates a new BinaryFileAssetTask object
  74032. * @param name defines the name of the new task
  74033. * @param url defines the location of the file to load
  74034. */
  74035. constructor(
  74036. /**
  74037. * Defines the name of the task
  74038. */
  74039. name: string,
  74040. /**
  74041. * Defines the location of the file to load
  74042. */
  74043. url: string);
  74044. /**
  74045. * Execute the current task
  74046. * @param scene defines the scene where you want your assets to be loaded
  74047. * @param onSuccess is a callback called when the task is successfully executed
  74048. * @param onError is a callback called if an error occurs
  74049. */
  74050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74051. }
  74052. /**
  74053. * Define a task used by AssetsManager to load images
  74054. */
  74055. export class ImageAssetTask extends AbstractAssetTask {
  74056. /**
  74057. * Defines the name of the task
  74058. */
  74059. name: string;
  74060. /**
  74061. * Defines the location of the image to load
  74062. */
  74063. url: string;
  74064. /**
  74065. * Gets the loaded images
  74066. */
  74067. image: HTMLImageElement;
  74068. /**
  74069. * Callback called when the task is successful
  74070. */
  74071. onSuccess: (task: ImageAssetTask) => void;
  74072. /**
  74073. * Callback called when the task is successful
  74074. */
  74075. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74076. /**
  74077. * Creates a new ImageAssetTask
  74078. * @param name defines the name of the task
  74079. * @param url defines the location of the image to load
  74080. */
  74081. constructor(
  74082. /**
  74083. * Defines the name of the task
  74084. */
  74085. name: string,
  74086. /**
  74087. * Defines the location of the image to load
  74088. */
  74089. url: string);
  74090. /**
  74091. * Execute the current task
  74092. * @param scene defines the scene where you want your assets to be loaded
  74093. * @param onSuccess is a callback called when the task is successfully executed
  74094. * @param onError is a callback called if an error occurs
  74095. */
  74096. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74097. }
  74098. /**
  74099. * Defines the interface used by texture loading tasks
  74100. */
  74101. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74102. /**
  74103. * Gets the loaded texture
  74104. */
  74105. texture: TEX;
  74106. }
  74107. /**
  74108. * Define a task used by AssetsManager to load 2D textures
  74109. */
  74110. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74111. /**
  74112. * Defines the name of the task
  74113. */
  74114. name: string;
  74115. /**
  74116. * Defines the location of the file to load
  74117. */
  74118. url: string;
  74119. /**
  74120. * Defines if mipmap should not be generated (default is false)
  74121. */
  74122. noMipmap?: boolean | undefined;
  74123. /**
  74124. * Defines if texture must be inverted on Y axis (default is true)
  74125. */
  74126. invertY: boolean;
  74127. /**
  74128. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74129. */
  74130. samplingMode: number;
  74131. /**
  74132. * Gets the loaded texture
  74133. */
  74134. texture: Texture;
  74135. /**
  74136. * Callback called when the task is successful
  74137. */
  74138. onSuccess: (task: TextureAssetTask) => void;
  74139. /**
  74140. * Callback called when the task is successful
  74141. */
  74142. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74143. /**
  74144. * Creates a new TextureAssetTask object
  74145. * @param name defines the name of the task
  74146. * @param url defines the location of the file to load
  74147. * @param noMipmap defines if mipmap should not be generated (default is false)
  74148. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74149. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74150. */
  74151. constructor(
  74152. /**
  74153. * Defines the name of the task
  74154. */
  74155. name: string,
  74156. /**
  74157. * Defines the location of the file to load
  74158. */
  74159. url: string,
  74160. /**
  74161. * Defines if mipmap should not be generated (default is false)
  74162. */
  74163. noMipmap?: boolean | undefined,
  74164. /**
  74165. * Defines if texture must be inverted on Y axis (default is true)
  74166. */
  74167. invertY?: boolean,
  74168. /**
  74169. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74170. */
  74171. samplingMode?: number);
  74172. /**
  74173. * Execute the current task
  74174. * @param scene defines the scene where you want your assets to be loaded
  74175. * @param onSuccess is a callback called when the task is successfully executed
  74176. * @param onError is a callback called if an error occurs
  74177. */
  74178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74179. }
  74180. /**
  74181. * Define a task used by AssetsManager to load cube textures
  74182. */
  74183. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74184. /**
  74185. * Defines the name of the task
  74186. */
  74187. name: string;
  74188. /**
  74189. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74190. */
  74191. url: string;
  74192. /**
  74193. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74194. */
  74195. extensions?: string[] | undefined;
  74196. /**
  74197. * Defines if mipmaps should not be generated (default is false)
  74198. */
  74199. noMipmap?: boolean | undefined;
  74200. /**
  74201. * Defines the explicit list of files (undefined by default)
  74202. */
  74203. files?: string[] | undefined;
  74204. /**
  74205. * Gets the loaded texture
  74206. */
  74207. texture: CubeTexture;
  74208. /**
  74209. * Callback called when the task is successful
  74210. */
  74211. onSuccess: (task: CubeTextureAssetTask) => void;
  74212. /**
  74213. * Callback called when the task is successful
  74214. */
  74215. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74216. /**
  74217. * Creates a new CubeTextureAssetTask
  74218. * @param name defines the name of the task
  74219. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74220. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74221. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74222. * @param files defines the explicit list of files (undefined by default)
  74223. */
  74224. constructor(
  74225. /**
  74226. * Defines the name of the task
  74227. */
  74228. name: string,
  74229. /**
  74230. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74231. */
  74232. url: string,
  74233. /**
  74234. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74235. */
  74236. extensions?: string[] | undefined,
  74237. /**
  74238. * Defines if mipmaps should not be generated (default is false)
  74239. */
  74240. noMipmap?: boolean | undefined,
  74241. /**
  74242. * Defines the explicit list of files (undefined by default)
  74243. */
  74244. files?: string[] | undefined);
  74245. /**
  74246. * Execute the current task
  74247. * @param scene defines the scene where you want your assets to be loaded
  74248. * @param onSuccess is a callback called when the task is successfully executed
  74249. * @param onError is a callback called if an error occurs
  74250. */
  74251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74252. }
  74253. /**
  74254. * Define a task used by AssetsManager to load HDR cube textures
  74255. */
  74256. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74257. /**
  74258. * Defines the name of the task
  74259. */
  74260. name: string;
  74261. /**
  74262. * Defines the location of the file to load
  74263. */
  74264. url: string;
  74265. /**
  74266. * Defines the desired size (the more it increases the longer the generation will be)
  74267. */
  74268. size: number;
  74269. /**
  74270. * Defines if mipmaps should not be generated (default is false)
  74271. */
  74272. noMipmap: boolean;
  74273. /**
  74274. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74275. */
  74276. generateHarmonics: boolean;
  74277. /**
  74278. * 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)
  74279. */
  74280. gammaSpace: boolean;
  74281. /**
  74282. * Internal Use Only
  74283. */
  74284. reserved: boolean;
  74285. /**
  74286. * Gets the loaded texture
  74287. */
  74288. texture: HDRCubeTexture;
  74289. /**
  74290. * Callback called when the task is successful
  74291. */
  74292. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74293. /**
  74294. * Callback called when the task is successful
  74295. */
  74296. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74297. /**
  74298. * Creates a new HDRCubeTextureAssetTask object
  74299. * @param name defines the name of the task
  74300. * @param url defines the location of the file to load
  74301. * @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.
  74302. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74303. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74304. * @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)
  74305. * @param reserved Internal use only
  74306. */
  74307. constructor(
  74308. /**
  74309. * Defines the name of the task
  74310. */
  74311. name: string,
  74312. /**
  74313. * Defines the location of the file to load
  74314. */
  74315. url: string,
  74316. /**
  74317. * Defines the desired size (the more it increases the longer the generation will be)
  74318. */
  74319. size: number,
  74320. /**
  74321. * Defines if mipmaps should not be generated (default is false)
  74322. */
  74323. noMipmap?: boolean,
  74324. /**
  74325. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74326. */
  74327. generateHarmonics?: boolean,
  74328. /**
  74329. * 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)
  74330. */
  74331. gammaSpace?: boolean,
  74332. /**
  74333. * Internal Use Only
  74334. */
  74335. reserved?: boolean);
  74336. /**
  74337. * Execute the current task
  74338. * @param scene defines the scene where you want your assets to be loaded
  74339. * @param onSuccess is a callback called when the task is successfully executed
  74340. * @param onError is a callback called if an error occurs
  74341. */
  74342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74343. }
  74344. /**
  74345. * Define a task used by AssetsManager to load Equirectangular cube textures
  74346. */
  74347. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74348. /**
  74349. * Defines the name of the task
  74350. */
  74351. name: string;
  74352. /**
  74353. * Defines the location of the file to load
  74354. */
  74355. url: string;
  74356. /**
  74357. * Defines the desired size (the more it increases the longer the generation will be)
  74358. */
  74359. size: number;
  74360. /**
  74361. * Defines if mipmaps should not be generated (default is false)
  74362. */
  74363. noMipmap: boolean;
  74364. /**
  74365. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74366. * but the standard material would require them in Gamma space) (default is true)
  74367. */
  74368. gammaSpace: boolean;
  74369. /**
  74370. * Gets the loaded texture
  74371. */
  74372. texture: EquiRectangularCubeTexture;
  74373. /**
  74374. * Callback called when the task is successful
  74375. */
  74376. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74377. /**
  74378. * Callback called when the task is successful
  74379. */
  74380. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74381. /**
  74382. * Creates a new EquiRectangularCubeTextureAssetTask object
  74383. * @param name defines the name of the task
  74384. * @param url defines the location of the file to load
  74385. * @param size defines the desired size (the more it increases the longer the generation will be)
  74386. * If the size is omitted this implies you are using a preprocessed cubemap.
  74387. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74388. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74389. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74390. * (default is true)
  74391. */
  74392. constructor(
  74393. /**
  74394. * Defines the name of the task
  74395. */
  74396. name: string,
  74397. /**
  74398. * Defines the location of the file to load
  74399. */
  74400. url: string,
  74401. /**
  74402. * Defines the desired size (the more it increases the longer the generation will be)
  74403. */
  74404. size: number,
  74405. /**
  74406. * Defines if mipmaps should not be generated (default is false)
  74407. */
  74408. noMipmap?: boolean,
  74409. /**
  74410. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74411. * but the standard material would require them in Gamma space) (default is true)
  74412. */
  74413. gammaSpace?: boolean);
  74414. /**
  74415. * Execute the current task
  74416. * @param scene defines the scene where you want your assets to be loaded
  74417. * @param onSuccess is a callback called when the task is successfully executed
  74418. * @param onError is a callback called if an error occurs
  74419. */
  74420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74421. }
  74422. /**
  74423. * This class can be used to easily import assets into a scene
  74424. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74425. */
  74426. export class AssetsManager {
  74427. private _scene;
  74428. private _isLoading;
  74429. protected _tasks: AbstractAssetTask[];
  74430. protected _waitingTasksCount: number;
  74431. protected _totalTasksCount: number;
  74432. /**
  74433. * Callback called when all tasks are processed
  74434. */
  74435. onFinish: (tasks: AbstractAssetTask[]) => void;
  74436. /**
  74437. * Callback called when a task is successful
  74438. */
  74439. onTaskSuccess: (task: AbstractAssetTask) => void;
  74440. /**
  74441. * Callback called when a task had an error
  74442. */
  74443. onTaskError: (task: AbstractAssetTask) => void;
  74444. /**
  74445. * Callback called when a task is done (whatever the result is)
  74446. */
  74447. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74448. /**
  74449. * Observable called when all tasks are processed
  74450. */
  74451. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74452. /**
  74453. * Observable called when a task had an error
  74454. */
  74455. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74456. /**
  74457. * Observable called when all tasks were executed
  74458. */
  74459. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74460. /**
  74461. * Observable called when a task is done (whatever the result is)
  74462. */
  74463. onProgressObservable: Observable<IAssetsProgressEvent>;
  74464. /**
  74465. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74466. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74467. */
  74468. useDefaultLoadingScreen: boolean;
  74469. /**
  74470. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74471. * when all assets have been downloaded.
  74472. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74473. */
  74474. autoHideLoadingUI: boolean;
  74475. /**
  74476. * Creates a new AssetsManager
  74477. * @param scene defines the scene to work on
  74478. */
  74479. constructor(scene: Scene);
  74480. /**
  74481. * Add a ContainerAssetTask to the list of active tasks
  74482. * @param taskName defines the name of the new task
  74483. * @param meshesNames defines the name of meshes to load
  74484. * @param rootUrl defines the root url to use to locate files
  74485. * @param sceneFilename defines the filename of the scene file
  74486. * @returns a new ContainerAssetTask object
  74487. */
  74488. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74489. /**
  74490. * Add a MeshAssetTask to the list of active tasks
  74491. * @param taskName defines the name of the new task
  74492. * @param meshesNames defines the name of meshes to load
  74493. * @param rootUrl defines the root url to use to locate files
  74494. * @param sceneFilename defines the filename of the scene file
  74495. * @returns a new MeshAssetTask object
  74496. */
  74497. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74498. /**
  74499. * Add a TextFileAssetTask to the list of active tasks
  74500. * @param taskName defines the name of the new task
  74501. * @param url defines the url of the file to load
  74502. * @returns a new TextFileAssetTask object
  74503. */
  74504. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74505. /**
  74506. * Add a BinaryFileAssetTask to the list of active tasks
  74507. * @param taskName defines the name of the new task
  74508. * @param url defines the url of the file to load
  74509. * @returns a new BinaryFileAssetTask object
  74510. */
  74511. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74512. /**
  74513. * Add a ImageAssetTask to the list of active tasks
  74514. * @param taskName defines the name of the new task
  74515. * @param url defines the url of the file to load
  74516. * @returns a new ImageAssetTask object
  74517. */
  74518. addImageTask(taskName: string, url: string): ImageAssetTask;
  74519. /**
  74520. * Add a TextureAssetTask to the list of active tasks
  74521. * @param taskName defines the name of the new task
  74522. * @param url defines the url of the file to load
  74523. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74524. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74525. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74526. * @returns a new TextureAssetTask object
  74527. */
  74528. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74529. /**
  74530. * Add a CubeTextureAssetTask to the list of active tasks
  74531. * @param taskName defines the name of the new task
  74532. * @param url defines the url of the file to load
  74533. * @param extensions defines the extension to use to load the cube map (can be null)
  74534. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74535. * @param files defines the list of files to load (can be null)
  74536. * @returns a new CubeTextureAssetTask object
  74537. */
  74538. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74539. /**
  74540. *
  74541. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74542. * @param taskName defines the name of the new task
  74543. * @param url defines the url of the file to load
  74544. * @param size defines the size you want for the cubemap (can be null)
  74545. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74546. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74547. * @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)
  74548. * @param reserved Internal use only
  74549. * @returns a new HDRCubeTextureAssetTask object
  74550. */
  74551. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74552. /**
  74553. *
  74554. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74555. * @param taskName defines the name of the new task
  74556. * @param url defines the url of the file to load
  74557. * @param size defines the size you want for the cubemap (can be null)
  74558. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74559. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74560. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74561. * @returns a new EquiRectangularCubeTextureAssetTask object
  74562. */
  74563. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74564. /**
  74565. * Remove a task from the assets manager.
  74566. * @param task the task to remove
  74567. */
  74568. removeTask(task: AbstractAssetTask): void;
  74569. private _decreaseWaitingTasksCount;
  74570. private _runTask;
  74571. /**
  74572. * Reset the AssetsManager and remove all tasks
  74573. * @return the current instance of the AssetsManager
  74574. */
  74575. reset(): AssetsManager;
  74576. /**
  74577. * Start the loading process
  74578. * @return the current instance of the AssetsManager
  74579. */
  74580. load(): AssetsManager;
  74581. /**
  74582. * Start the loading process as an async operation
  74583. * @return a promise returning the list of failed tasks
  74584. */
  74585. loadAsync(): Promise<void>;
  74586. }
  74587. }
  74588. declare module BABYLON {
  74589. /**
  74590. * Wrapper class for promise with external resolve and reject.
  74591. */
  74592. export class Deferred<T> {
  74593. /**
  74594. * The promise associated with this deferred object.
  74595. */
  74596. readonly promise: Promise<T>;
  74597. private _resolve;
  74598. private _reject;
  74599. /**
  74600. * The resolve method of the promise associated with this deferred object.
  74601. */
  74602. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74603. /**
  74604. * The reject method of the promise associated with this deferred object.
  74605. */
  74606. get reject(): (reason?: any) => void;
  74607. /**
  74608. * Constructor for this deferred object.
  74609. */
  74610. constructor();
  74611. }
  74612. }
  74613. declare module BABYLON {
  74614. /**
  74615. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74616. */
  74617. export class MeshExploder {
  74618. private _centerMesh;
  74619. private _meshes;
  74620. private _meshesOrigins;
  74621. private _toCenterVectors;
  74622. private _scaledDirection;
  74623. private _newPosition;
  74624. private _centerPosition;
  74625. /**
  74626. * Explodes meshes from a center mesh.
  74627. * @param meshes The meshes to explode.
  74628. * @param centerMesh The mesh to be center of explosion.
  74629. */
  74630. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74631. private _setCenterMesh;
  74632. /**
  74633. * Get class name
  74634. * @returns "MeshExploder"
  74635. */
  74636. getClassName(): string;
  74637. /**
  74638. * "Exploded meshes"
  74639. * @returns Array of meshes with the centerMesh at index 0.
  74640. */
  74641. getMeshes(): Array<Mesh>;
  74642. /**
  74643. * Explodes meshes giving a specific direction
  74644. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74645. */
  74646. explode(direction?: number): void;
  74647. }
  74648. }
  74649. declare module BABYLON {
  74650. /**
  74651. * Class used to help managing file picking and drag'n'drop
  74652. */
  74653. export class FilesInput {
  74654. /**
  74655. * List of files ready to be loaded
  74656. */
  74657. static get FilesToLoad(): {
  74658. [key: string]: File;
  74659. };
  74660. /**
  74661. * Callback called when a file is processed
  74662. */
  74663. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74664. private _engine;
  74665. private _currentScene;
  74666. private _sceneLoadedCallback;
  74667. private _progressCallback;
  74668. private _additionalRenderLoopLogicCallback;
  74669. private _textureLoadingCallback;
  74670. private _startingProcessingFilesCallback;
  74671. private _onReloadCallback;
  74672. private _errorCallback;
  74673. private _elementToMonitor;
  74674. private _sceneFileToLoad;
  74675. private _filesToLoad;
  74676. /**
  74677. * Creates a new FilesInput
  74678. * @param engine defines the rendering engine
  74679. * @param scene defines the hosting scene
  74680. * @param sceneLoadedCallback callback called when scene is loaded
  74681. * @param progressCallback callback called to track progress
  74682. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74683. * @param textureLoadingCallback callback called when a texture is loading
  74684. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74685. * @param onReloadCallback callback called when a reload is requested
  74686. * @param errorCallback callback call if an error occurs
  74687. */
  74688. 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>);
  74689. private _dragEnterHandler;
  74690. private _dragOverHandler;
  74691. private _dropHandler;
  74692. /**
  74693. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74694. * @param elementToMonitor defines the DOM element to track
  74695. */
  74696. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74697. /** Gets the current list of files to load */
  74698. get filesToLoad(): File[];
  74699. /**
  74700. * Release all associated resources
  74701. */
  74702. dispose(): void;
  74703. private renderFunction;
  74704. private drag;
  74705. private drop;
  74706. private _traverseFolder;
  74707. private _processFiles;
  74708. /**
  74709. * Load files from a drop event
  74710. * @param event defines the drop event to use as source
  74711. */
  74712. loadFiles(event: any): void;
  74713. private _processReload;
  74714. /**
  74715. * Reload the current scene from the loaded files
  74716. */
  74717. reload(): void;
  74718. }
  74719. }
  74720. declare module BABYLON {
  74721. /**
  74722. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74723. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74724. */
  74725. export class SceneOptimization {
  74726. /**
  74727. * Defines the priority of this optimization (0 by default which means first in the list)
  74728. */
  74729. priority: number;
  74730. /**
  74731. * Gets a string describing the action executed by the current optimization
  74732. * @returns description string
  74733. */
  74734. getDescription(): string;
  74735. /**
  74736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74737. * @param scene defines the current scene where to apply this optimization
  74738. * @param optimizer defines the current optimizer
  74739. * @returns true if everything that can be done was applied
  74740. */
  74741. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74742. /**
  74743. * Creates the SceneOptimization object
  74744. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74745. * @param desc defines the description associated with the optimization
  74746. */
  74747. constructor(
  74748. /**
  74749. * Defines the priority of this optimization (0 by default which means first in the list)
  74750. */
  74751. priority?: number);
  74752. }
  74753. /**
  74754. * Defines an optimization used to reduce the size of render target textures
  74755. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74756. */
  74757. export class TextureOptimization extends SceneOptimization {
  74758. /**
  74759. * Defines the priority of this optimization (0 by default which means first in the list)
  74760. */
  74761. priority: number;
  74762. /**
  74763. * 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
  74764. */
  74765. maximumSize: number;
  74766. /**
  74767. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74768. */
  74769. step: number;
  74770. /**
  74771. * Gets a string describing the action executed by the current optimization
  74772. * @returns description string
  74773. */
  74774. getDescription(): string;
  74775. /**
  74776. * Creates the TextureOptimization object
  74777. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74778. * @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
  74779. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74780. */
  74781. constructor(
  74782. /**
  74783. * Defines the priority of this optimization (0 by default which means first in the list)
  74784. */
  74785. priority?: number,
  74786. /**
  74787. * 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
  74788. */
  74789. maximumSize?: number,
  74790. /**
  74791. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74792. */
  74793. step?: number);
  74794. /**
  74795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74796. * @param scene defines the current scene where to apply this optimization
  74797. * @param optimizer defines the current optimizer
  74798. * @returns true if everything that can be done was applied
  74799. */
  74800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74801. }
  74802. /**
  74803. * Defines an optimization used to increase or decrease the rendering resolution
  74804. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74805. */
  74806. export class HardwareScalingOptimization extends SceneOptimization {
  74807. /**
  74808. * Defines the priority of this optimization (0 by default which means first in the list)
  74809. */
  74810. priority: number;
  74811. /**
  74812. * Defines the maximum scale to use (2 by default)
  74813. */
  74814. maximumScale: number;
  74815. /**
  74816. * Defines the step to use between two passes (0.5 by default)
  74817. */
  74818. step: number;
  74819. private _currentScale;
  74820. private _directionOffset;
  74821. /**
  74822. * Gets a string describing the action executed by the current optimization
  74823. * @return description string
  74824. */
  74825. getDescription(): string;
  74826. /**
  74827. * Creates the HardwareScalingOptimization object
  74828. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74829. * @param maximumScale defines the maximum scale to use (2 by default)
  74830. * @param step defines the step to use between two passes (0.5 by default)
  74831. */
  74832. constructor(
  74833. /**
  74834. * Defines the priority of this optimization (0 by default which means first in the list)
  74835. */
  74836. priority?: number,
  74837. /**
  74838. * Defines the maximum scale to use (2 by default)
  74839. */
  74840. maximumScale?: number,
  74841. /**
  74842. * Defines the step to use between two passes (0.5 by default)
  74843. */
  74844. step?: number);
  74845. /**
  74846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74847. * @param scene defines the current scene where to apply this optimization
  74848. * @param optimizer defines the current optimizer
  74849. * @returns true if everything that can be done was applied
  74850. */
  74851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74852. }
  74853. /**
  74854. * Defines an optimization used to remove shadows
  74855. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74856. */
  74857. export class ShadowsOptimization extends SceneOptimization {
  74858. /**
  74859. * Gets a string describing the action executed by the current optimization
  74860. * @return description string
  74861. */
  74862. getDescription(): string;
  74863. /**
  74864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74865. * @param scene defines the current scene where to apply this optimization
  74866. * @param optimizer defines the current optimizer
  74867. * @returns true if everything that can be done was applied
  74868. */
  74869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74870. }
  74871. /**
  74872. * Defines an optimization used to turn post-processes off
  74873. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74874. */
  74875. export class PostProcessesOptimization extends SceneOptimization {
  74876. /**
  74877. * Gets a string describing the action executed by the current optimization
  74878. * @return description string
  74879. */
  74880. getDescription(): string;
  74881. /**
  74882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74883. * @param scene defines the current scene where to apply this optimization
  74884. * @param optimizer defines the current optimizer
  74885. * @returns true if everything that can be done was applied
  74886. */
  74887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74888. }
  74889. /**
  74890. * Defines an optimization used to turn lens flares off
  74891. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74892. */
  74893. export class LensFlaresOptimization extends SceneOptimization {
  74894. /**
  74895. * Gets a string describing the action executed by the current optimization
  74896. * @return description string
  74897. */
  74898. getDescription(): string;
  74899. /**
  74900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74901. * @param scene defines the current scene where to apply this optimization
  74902. * @param optimizer defines the current optimizer
  74903. * @returns true if everything that can be done was applied
  74904. */
  74905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74906. }
  74907. /**
  74908. * Defines an optimization based on user defined callback.
  74909. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74910. */
  74911. export class CustomOptimization extends SceneOptimization {
  74912. /**
  74913. * Callback called to apply the custom optimization.
  74914. */
  74915. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74916. /**
  74917. * Callback called to get custom description
  74918. */
  74919. onGetDescription: () => string;
  74920. /**
  74921. * Gets a string describing the action executed by the current optimization
  74922. * @returns description string
  74923. */
  74924. getDescription(): string;
  74925. /**
  74926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74927. * @param scene defines the current scene where to apply this optimization
  74928. * @param optimizer defines the current optimizer
  74929. * @returns true if everything that can be done was applied
  74930. */
  74931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74932. }
  74933. /**
  74934. * Defines an optimization used to turn particles off
  74935. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74936. */
  74937. export class ParticlesOptimization extends SceneOptimization {
  74938. /**
  74939. * Gets a string describing the action executed by the current optimization
  74940. * @return description string
  74941. */
  74942. getDescription(): string;
  74943. /**
  74944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74945. * @param scene defines the current scene where to apply this optimization
  74946. * @param optimizer defines the current optimizer
  74947. * @returns true if everything that can be done was applied
  74948. */
  74949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74950. }
  74951. /**
  74952. * Defines an optimization used to turn render targets off
  74953. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74954. */
  74955. export class RenderTargetsOptimization extends SceneOptimization {
  74956. /**
  74957. * Gets a string describing the action executed by the current optimization
  74958. * @return description string
  74959. */
  74960. getDescription(): string;
  74961. /**
  74962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74963. * @param scene defines the current scene where to apply this optimization
  74964. * @param optimizer defines the current optimizer
  74965. * @returns true if everything that can be done was applied
  74966. */
  74967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74968. }
  74969. /**
  74970. * Defines an optimization used to merge meshes with compatible materials
  74971. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74972. */
  74973. export class MergeMeshesOptimization extends SceneOptimization {
  74974. private static _UpdateSelectionTree;
  74975. /**
  74976. * Gets or sets a boolean which defines if optimization octree has to be updated
  74977. */
  74978. static get UpdateSelectionTree(): boolean;
  74979. /**
  74980. * Gets or sets a boolean which defines if optimization octree has to be updated
  74981. */
  74982. static set UpdateSelectionTree(value: boolean);
  74983. /**
  74984. * Gets a string describing the action executed by the current optimization
  74985. * @return description string
  74986. */
  74987. getDescription(): string;
  74988. private _canBeMerged;
  74989. /**
  74990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74991. * @param scene defines the current scene where to apply this optimization
  74992. * @param optimizer defines the current optimizer
  74993. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74994. * @returns true if everything that can be done was applied
  74995. */
  74996. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74997. }
  74998. /**
  74999. * Defines a list of options used by SceneOptimizer
  75000. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75001. */
  75002. export class SceneOptimizerOptions {
  75003. /**
  75004. * Defines the target frame rate to reach (60 by default)
  75005. */
  75006. targetFrameRate: number;
  75007. /**
  75008. * Defines the interval between two checkes (2000ms by default)
  75009. */
  75010. trackerDuration: number;
  75011. /**
  75012. * Gets the list of optimizations to apply
  75013. */
  75014. optimizations: SceneOptimization[];
  75015. /**
  75016. * Creates a new list of options used by SceneOptimizer
  75017. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75018. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75019. */
  75020. constructor(
  75021. /**
  75022. * Defines the target frame rate to reach (60 by default)
  75023. */
  75024. targetFrameRate?: number,
  75025. /**
  75026. * Defines the interval between two checkes (2000ms by default)
  75027. */
  75028. trackerDuration?: number);
  75029. /**
  75030. * Add a new optimization
  75031. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75032. * @returns the current SceneOptimizerOptions
  75033. */
  75034. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75035. /**
  75036. * Add a new custom optimization
  75037. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75038. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75039. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75040. * @returns the current SceneOptimizerOptions
  75041. */
  75042. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75043. /**
  75044. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75045. * @param targetFrameRate defines the target frame rate (60 by default)
  75046. * @returns a SceneOptimizerOptions object
  75047. */
  75048. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75049. /**
  75050. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75051. * @param targetFrameRate defines the target frame rate (60 by default)
  75052. * @returns a SceneOptimizerOptions object
  75053. */
  75054. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75055. /**
  75056. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75057. * @param targetFrameRate defines the target frame rate (60 by default)
  75058. * @returns a SceneOptimizerOptions object
  75059. */
  75060. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75061. }
  75062. /**
  75063. * Class used to run optimizations in order to reach a target frame rate
  75064. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75065. */
  75066. export class SceneOptimizer implements IDisposable {
  75067. private _isRunning;
  75068. private _options;
  75069. private _scene;
  75070. private _currentPriorityLevel;
  75071. private _targetFrameRate;
  75072. private _trackerDuration;
  75073. private _currentFrameRate;
  75074. private _sceneDisposeObserver;
  75075. private _improvementMode;
  75076. /**
  75077. * Defines an observable called when the optimizer reaches the target frame rate
  75078. */
  75079. onSuccessObservable: Observable<SceneOptimizer>;
  75080. /**
  75081. * Defines an observable called when the optimizer enables an optimization
  75082. */
  75083. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75084. /**
  75085. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75086. */
  75087. onFailureObservable: Observable<SceneOptimizer>;
  75088. /**
  75089. * Gets a boolean indicating if the optimizer is in improvement mode
  75090. */
  75091. get isInImprovementMode(): boolean;
  75092. /**
  75093. * Gets the current priority level (0 at start)
  75094. */
  75095. get currentPriorityLevel(): number;
  75096. /**
  75097. * Gets the current frame rate checked by the SceneOptimizer
  75098. */
  75099. get currentFrameRate(): number;
  75100. /**
  75101. * Gets or sets the current target frame rate (60 by default)
  75102. */
  75103. get targetFrameRate(): number;
  75104. /**
  75105. * Gets or sets the current target frame rate (60 by default)
  75106. */
  75107. set targetFrameRate(value: number);
  75108. /**
  75109. * Gets or sets the current interval between two checks (every 2000ms by default)
  75110. */
  75111. get trackerDuration(): number;
  75112. /**
  75113. * Gets or sets the current interval between two checks (every 2000ms by default)
  75114. */
  75115. set trackerDuration(value: number);
  75116. /**
  75117. * Gets the list of active optimizations
  75118. */
  75119. get optimizations(): SceneOptimization[];
  75120. /**
  75121. * Creates a new SceneOptimizer
  75122. * @param scene defines the scene to work on
  75123. * @param options defines the options to use with the SceneOptimizer
  75124. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75125. * @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)
  75126. */
  75127. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75128. /**
  75129. * Stops the current optimizer
  75130. */
  75131. stop(): void;
  75132. /**
  75133. * Reset the optimizer to initial step (current priority level = 0)
  75134. */
  75135. reset(): void;
  75136. /**
  75137. * Start the optimizer. By default it will try to reach a specific framerate
  75138. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75139. */
  75140. start(): void;
  75141. private _checkCurrentState;
  75142. /**
  75143. * Release all resources
  75144. */
  75145. dispose(): void;
  75146. /**
  75147. * Helper function to create a SceneOptimizer with one single line of code
  75148. * @param scene defines the scene to work on
  75149. * @param options defines the options to use with the SceneOptimizer
  75150. * @param onSuccess defines a callback to call on success
  75151. * @param onFailure defines a callback to call on failure
  75152. * @returns the new SceneOptimizer object
  75153. */
  75154. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75155. }
  75156. }
  75157. declare module BABYLON {
  75158. /**
  75159. * Class used to serialize a scene into a string
  75160. */
  75161. export class SceneSerializer {
  75162. /**
  75163. * Clear cache used by a previous serialization
  75164. */
  75165. static ClearCache(): void;
  75166. /**
  75167. * Serialize a scene into a JSON compatible object
  75168. * @param scene defines the scene to serialize
  75169. * @returns a JSON compatible object
  75170. */
  75171. static Serialize(scene: Scene): any;
  75172. /**
  75173. * Serialize a mesh into a JSON compatible object
  75174. * @param toSerialize defines the mesh to serialize
  75175. * @param withParents defines if parents must be serialized as well
  75176. * @param withChildren defines if children must be serialized as well
  75177. * @returns a JSON compatible object
  75178. */
  75179. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75180. }
  75181. }
  75182. declare module BABYLON {
  75183. /**
  75184. * Class used to host texture specific utilities
  75185. */
  75186. export class TextureTools {
  75187. /**
  75188. * Uses the GPU to create a copy texture rescaled at a given size
  75189. * @param texture Texture to copy from
  75190. * @param width defines the desired width
  75191. * @param height defines the desired height
  75192. * @param useBilinearMode defines if bilinear mode has to be used
  75193. * @return the generated texture
  75194. */
  75195. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75196. }
  75197. }
  75198. declare module BABYLON {
  75199. /**
  75200. * This represents the different options available for the video capture.
  75201. */
  75202. export interface VideoRecorderOptions {
  75203. /** Defines the mime type of the video. */
  75204. mimeType: string;
  75205. /** Defines the FPS the video should be recorded at. */
  75206. fps: number;
  75207. /** Defines the chunk size for the recording data. */
  75208. recordChunckSize: number;
  75209. /** The audio tracks to attach to the recording. */
  75210. audioTracks?: MediaStreamTrack[];
  75211. }
  75212. /**
  75213. * This can help with recording videos from BabylonJS.
  75214. * This is based on the available WebRTC functionalities of the browser.
  75215. *
  75216. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75217. */
  75218. export class VideoRecorder {
  75219. private static readonly _defaultOptions;
  75220. /**
  75221. * Returns whether or not the VideoRecorder is available in your browser.
  75222. * @param engine Defines the Babylon Engine.
  75223. * @returns true if supported otherwise false.
  75224. */
  75225. static IsSupported(engine: Engine): boolean;
  75226. private readonly _options;
  75227. private _canvas;
  75228. private _mediaRecorder;
  75229. private _recordedChunks;
  75230. private _fileName;
  75231. private _resolve;
  75232. private _reject;
  75233. /**
  75234. * True when a recording is already in progress.
  75235. */
  75236. get isRecording(): boolean;
  75237. /**
  75238. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75239. * @param engine Defines the BabylonJS Engine you wish to record.
  75240. * @param options Defines options that can be used to customize the capture.
  75241. */
  75242. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75243. /**
  75244. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75245. */
  75246. stopRecording(): void;
  75247. /**
  75248. * Starts recording the canvas for a max duration specified in parameters.
  75249. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75250. * If null no automatic download will start and you can rely on the promise to get the data back.
  75251. * @param maxDuration Defines the maximum recording time in seconds.
  75252. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75253. * @return A promise callback at the end of the recording with the video data in Blob.
  75254. */
  75255. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75256. /**
  75257. * Releases internal resources used during the recording.
  75258. */
  75259. dispose(): void;
  75260. private _handleDataAvailable;
  75261. private _handleError;
  75262. private _handleStop;
  75263. }
  75264. }
  75265. declare module BABYLON {
  75266. /**
  75267. * Class containing a set of static utilities functions for screenshots
  75268. */
  75269. export class ScreenshotTools {
  75270. /**
  75271. * Captures a screenshot of the current rendering
  75272. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75273. * @param engine defines the rendering engine
  75274. * @param camera defines the source camera
  75275. * @param size This parameter can be set to a single number or to an object with the
  75276. * following (optional) properties: precision, width, height. If a single number is passed,
  75277. * it will be used for both width and height. If an object is passed, the screenshot size
  75278. * will be derived from the parameters. The precision property is a multiplier allowing
  75279. * rendering at a higher or lower resolution
  75280. * @param successCallback defines the callback receives a single parameter which contains the
  75281. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75282. * src parameter of an <img> to display it
  75283. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75284. * Check your browser for supported MIME types
  75285. */
  75286. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75287. /**
  75288. * Captures a screenshot of the current rendering
  75289. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75290. * @param engine defines the rendering engine
  75291. * @param camera defines the source camera
  75292. * @param size This parameter can be set to a single number or to an object with the
  75293. * following (optional) properties: precision, width, height. If a single number is passed,
  75294. * it will be used for both width and height. If an object is passed, the screenshot size
  75295. * will be derived from the parameters. The precision property is a multiplier allowing
  75296. * rendering at a higher or lower resolution
  75297. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75298. * Check your browser for supported MIME types
  75299. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75300. * to the src parameter of an <img> to display it
  75301. */
  75302. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75303. /**
  75304. * Generates an image screenshot from the specified camera.
  75305. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75306. * @param engine The engine to use for rendering
  75307. * @param camera The camera to use for rendering
  75308. * @param size This parameter can be set to a single number or to an object with the
  75309. * following (optional) properties: precision, width, height. If a single number is passed,
  75310. * it will be used for both width and height. If an object is passed, the screenshot size
  75311. * will be derived from the parameters. The precision property is a multiplier allowing
  75312. * rendering at a higher or lower resolution
  75313. * @param successCallback The callback receives a single parameter which contains the
  75314. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75315. * src parameter of an <img> to display it
  75316. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75317. * Check your browser for supported MIME types
  75318. * @param samples Texture samples (default: 1)
  75319. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75320. * @param fileName A name for for the downloaded file.
  75321. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75322. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75323. */
  75324. 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;
  75325. /**
  75326. * Generates an image screenshot from the specified camera.
  75327. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75328. * @param engine The engine to use for rendering
  75329. * @param camera The camera to use for rendering
  75330. * @param size This parameter can be set to a single number or to an object with the
  75331. * following (optional) properties: precision, width, height. If a single number is passed,
  75332. * it will be used for both width and height. If an object is passed, the screenshot size
  75333. * will be derived from the parameters. The precision property is a multiplier allowing
  75334. * rendering at a higher or lower resolution
  75335. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75336. * Check your browser for supported MIME types
  75337. * @param samples Texture samples (default: 1)
  75338. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75339. * @param fileName A name for for the downloaded file.
  75340. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75341. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75342. * to the src parameter of an <img> to display it
  75343. */
  75344. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75345. /**
  75346. * Gets height and width for screenshot size
  75347. * @private
  75348. */
  75349. private static _getScreenshotSize;
  75350. }
  75351. }
  75352. declare module BABYLON {
  75353. /**
  75354. * Interface for a data buffer
  75355. */
  75356. export interface IDataBuffer {
  75357. /**
  75358. * Reads bytes from the data buffer.
  75359. * @param byteOffset The byte offset to read
  75360. * @param byteLength The byte length to read
  75361. * @returns A promise that resolves when the bytes are read
  75362. */
  75363. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75364. /**
  75365. * The byte length of the buffer.
  75366. */
  75367. readonly byteLength: number;
  75368. }
  75369. /**
  75370. * Utility class for reading from a data buffer
  75371. */
  75372. export class DataReader {
  75373. /**
  75374. * The data buffer associated with this data reader.
  75375. */
  75376. readonly buffer: IDataBuffer;
  75377. /**
  75378. * The current byte offset from the beginning of the data buffer.
  75379. */
  75380. byteOffset: number;
  75381. private _dataView;
  75382. private _dataByteOffset;
  75383. /**
  75384. * Constructor
  75385. * @param buffer The buffer to read
  75386. */
  75387. constructor(buffer: IDataBuffer);
  75388. /**
  75389. * Loads the given byte length.
  75390. * @param byteLength The byte length to load
  75391. * @returns A promise that resolves when the load is complete
  75392. */
  75393. loadAsync(byteLength: number): Promise<void>;
  75394. /**
  75395. * Read a unsigned 32-bit integer from the currently loaded data range.
  75396. * @returns The 32-bit integer read
  75397. */
  75398. readUint32(): number;
  75399. /**
  75400. * Read a byte array from the currently loaded data range.
  75401. * @param byteLength The byte length to read
  75402. * @returns The byte array read
  75403. */
  75404. readUint8Array(byteLength: number): Uint8Array;
  75405. /**
  75406. * Read a string from the currently loaded data range.
  75407. * @param byteLength The byte length to read
  75408. * @returns The string read
  75409. */
  75410. readString(byteLength: number): string;
  75411. /**
  75412. * Skips the given byte length the currently loaded data range.
  75413. * @param byteLength The byte length to skip
  75414. */
  75415. skipBytes(byteLength: number): void;
  75416. }
  75417. }
  75418. declare module BABYLON {
  75419. /**
  75420. * Class for storing data to local storage if available or in-memory storage otherwise
  75421. */
  75422. export class DataStorage {
  75423. private static _Storage;
  75424. private static _GetStorage;
  75425. /**
  75426. * Reads a string from the data storage
  75427. * @param key The key to read
  75428. * @param defaultValue The value if the key doesn't exist
  75429. * @returns The string value
  75430. */
  75431. static ReadString(key: string, defaultValue: string): string;
  75432. /**
  75433. * Writes a string to the data storage
  75434. * @param key The key to write
  75435. * @param value The value to write
  75436. */
  75437. static WriteString(key: string, value: string): void;
  75438. /**
  75439. * Reads a boolean from the data storage
  75440. * @param key The key to read
  75441. * @param defaultValue The value if the key doesn't exist
  75442. * @returns The boolean value
  75443. */
  75444. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75445. /**
  75446. * Writes a boolean to the data storage
  75447. * @param key The key to write
  75448. * @param value The value to write
  75449. */
  75450. static WriteBoolean(key: string, value: boolean): void;
  75451. /**
  75452. * Reads a number from the data storage
  75453. * @param key The key to read
  75454. * @param defaultValue The value if the key doesn't exist
  75455. * @returns The number value
  75456. */
  75457. static ReadNumber(key: string, defaultValue: number): number;
  75458. /**
  75459. * Writes a number to the data storage
  75460. * @param key The key to write
  75461. * @param value The value to write
  75462. */
  75463. static WriteNumber(key: string, value: number): void;
  75464. }
  75465. }
  75466. declare module BABYLON {
  75467. /**
  75468. * Class used to record delta files between 2 scene states
  75469. */
  75470. export class SceneRecorder {
  75471. private _trackedScene;
  75472. private _savedJSON;
  75473. /**
  75474. * Track a given scene. This means the current scene state will be considered the original state
  75475. * @param scene defines the scene to track
  75476. */
  75477. track(scene: Scene): void;
  75478. /**
  75479. * Get the delta between current state and original state
  75480. * @returns a string containing the delta
  75481. */
  75482. getDelta(): any;
  75483. private _compareArray;
  75484. private _compareObjects;
  75485. private _compareCollections;
  75486. private static GetShadowGeneratorById;
  75487. /**
  75488. * Apply a given delta to a given scene
  75489. * @param deltaJSON defines the JSON containing the delta
  75490. * @param scene defines the scene to apply the delta to
  75491. */
  75492. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75493. private static _ApplyPropertiesToEntity;
  75494. private static _ApplyDeltaForEntity;
  75495. }
  75496. }
  75497. declare module BABYLON {
  75498. /**
  75499. * A 3D trajectory consisting of an order list of vectors describing a
  75500. * path of motion through 3D space.
  75501. */
  75502. export class Trajectory {
  75503. private _points;
  75504. private readonly _segmentLength;
  75505. /**
  75506. * Serialize to JSON.
  75507. * @returns serialized JSON string
  75508. */
  75509. serialize(): string;
  75510. /**
  75511. * Deserialize from JSON.
  75512. * @param json serialized JSON string
  75513. * @returns deserialized Trajectory
  75514. */
  75515. static Deserialize(json: string): Trajectory;
  75516. /**
  75517. * Create a new empty Trajectory.
  75518. * @param segmentLength radius of discretization for Trajectory points
  75519. */
  75520. constructor(segmentLength?: number);
  75521. /**
  75522. * Get the length of the Trajectory.
  75523. * @returns length of the Trajectory
  75524. */
  75525. getLength(): number;
  75526. /**
  75527. * Append a new point to the Trajectory.
  75528. * NOTE: This implementation has many allocations.
  75529. * @param point point to append to the Trajectory
  75530. */
  75531. add(point: DeepImmutable<Vector3>): void;
  75532. /**
  75533. * Create a new Trajectory with a segment length chosen to make it
  75534. * probable that the new Trajectory will have a specified number of
  75535. * segments. This operation is imprecise.
  75536. * @param targetResolution number of segments desired
  75537. * @returns new Trajectory with approximately the requested number of segments
  75538. */
  75539. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75540. /**
  75541. * Convert Trajectory segments into tokenized representation. This
  75542. * representation is an array of numbers where each nth number is the
  75543. * index of the token which is most similar to the nth segment of the
  75544. * Trajectory.
  75545. * @param tokens list of vectors which serve as discrete tokens
  75546. * @returns list of indices of most similar token per segment
  75547. */
  75548. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75549. private static _forwardDir;
  75550. private static _inverseFromVec;
  75551. private static _upDir;
  75552. private static _fromToVec;
  75553. private static _lookMatrix;
  75554. /**
  75555. * Transform the rotation (i.e., direction) of a segment to isolate
  75556. * the relative transformation represented by the segment. This operation
  75557. * may or may not succeed due to singularities in the equations that define
  75558. * motion relativity in this context.
  75559. * @param priorVec the origin of the prior segment
  75560. * @param fromVec the origin of the current segment
  75561. * @param toVec the destination of the current segment
  75562. * @param result reference to output variable
  75563. * @returns whether or not transformation was successful
  75564. */
  75565. private static _transformSegmentDirToRef;
  75566. private static _bestMatch;
  75567. private static _score;
  75568. private static _bestScore;
  75569. /**
  75570. * Determine which token vector is most similar to the
  75571. * segment vector.
  75572. * @param segment segment vector
  75573. * @param tokens token vector list
  75574. * @returns index of the most similar token to the segment
  75575. */
  75576. private static _tokenizeSegment;
  75577. }
  75578. /**
  75579. * Class representing a set of known, named trajectories to which Trajectories can be
  75580. * added and using which Trajectories can be recognized.
  75581. */
  75582. export class TrajectoryClassifier {
  75583. private _maximumAllowableMatchCost;
  75584. private _vector3Alphabet;
  75585. private _levenshteinAlphabet;
  75586. private _nameToDescribedTrajectory;
  75587. /**
  75588. * Serialize to JSON.
  75589. * @returns JSON serialization
  75590. */
  75591. serialize(): string;
  75592. /**
  75593. * Deserialize from JSON.
  75594. * @param json JSON serialization
  75595. * @returns deserialized TrajectorySet
  75596. */
  75597. static Deserialize(json: string): TrajectoryClassifier;
  75598. /**
  75599. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75600. * VERY naive, need to be generating these things from known
  75601. * sets. Better version later, probably eliminating this one.
  75602. * @returns auto-generated TrajectorySet
  75603. */
  75604. static Generate(): TrajectoryClassifier;
  75605. private constructor();
  75606. /**
  75607. * Add a new Trajectory to the set with a given name.
  75608. * @param trajectory new Trajectory to be added
  75609. * @param classification name to which to add the Trajectory
  75610. */
  75611. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75612. /**
  75613. * Remove a known named trajectory and all Trajectories associated with it.
  75614. * @param classification name to remove
  75615. * @returns whether anything was removed
  75616. */
  75617. deleteClassification(classification: string): boolean;
  75618. /**
  75619. * Attempt to recognize a Trajectory from among all the classifications
  75620. * already known to the classifier.
  75621. * @param trajectory Trajectory to be recognized
  75622. * @returns classification of Trajectory if recognized, null otherwise
  75623. */
  75624. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75625. }
  75626. }
  75627. declare module BABYLON {
  75628. /**
  75629. * An interface for all Hit test features
  75630. */
  75631. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75632. /**
  75633. * Triggered when new babylon (transformed) hit test results are available
  75634. */
  75635. onHitTestResultObservable: Observable<T[]>;
  75636. }
  75637. /**
  75638. * Options used for hit testing
  75639. */
  75640. export interface IWebXRLegacyHitTestOptions {
  75641. /**
  75642. * Only test when user interacted with the scene. Default - hit test every frame
  75643. */
  75644. testOnPointerDownOnly?: boolean;
  75645. /**
  75646. * The node to use to transform the local results to world coordinates
  75647. */
  75648. worldParentNode?: TransformNode;
  75649. }
  75650. /**
  75651. * Interface defining the babylon result of raycasting/hit-test
  75652. */
  75653. export interface IWebXRLegacyHitResult {
  75654. /**
  75655. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75656. */
  75657. transformationMatrix: Matrix;
  75658. /**
  75659. * The native hit test result
  75660. */
  75661. xrHitResult: XRHitResult | XRHitTestResult;
  75662. }
  75663. /**
  75664. * The currently-working hit-test module.
  75665. * Hit test (or Ray-casting) is used to interact with the real world.
  75666. * For further information read here - https://github.com/immersive-web/hit-test
  75667. */
  75668. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75669. /**
  75670. * options to use when constructing this feature
  75671. */
  75672. readonly options: IWebXRLegacyHitTestOptions;
  75673. private _direction;
  75674. private _mat;
  75675. private _onSelectEnabled;
  75676. private _origin;
  75677. /**
  75678. * The module's name
  75679. */
  75680. static readonly Name: string;
  75681. /**
  75682. * The (Babylon) version of this module.
  75683. * This is an integer representing the implementation version.
  75684. * This number does not correspond to the WebXR specs version
  75685. */
  75686. static readonly Version: number;
  75687. /**
  75688. * Populated with the last native XR Hit Results
  75689. */
  75690. lastNativeXRHitResults: XRHitResult[];
  75691. /**
  75692. * Triggered when new babylon (transformed) hit test results are available
  75693. */
  75694. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75695. /**
  75696. * Creates a new instance of the (legacy version) hit test feature
  75697. * @param _xrSessionManager an instance of WebXRSessionManager
  75698. * @param options options to use when constructing this feature
  75699. */
  75700. constructor(_xrSessionManager: WebXRSessionManager,
  75701. /**
  75702. * options to use when constructing this feature
  75703. */
  75704. options?: IWebXRLegacyHitTestOptions);
  75705. /**
  75706. * execute a hit test with an XR Ray
  75707. *
  75708. * @param xrSession a native xrSession that will execute this hit test
  75709. * @param xrRay the ray (position and direction) to use for ray-casting
  75710. * @param referenceSpace native XR reference space to use for the hit-test
  75711. * @param filter filter function that will filter the results
  75712. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75713. */
  75714. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75715. /**
  75716. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75717. * @param event the (select) event to use to select with
  75718. * @param referenceSpace the reference space to use for this hit test
  75719. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75720. */
  75721. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75722. /**
  75723. * attach this feature
  75724. * Will usually be called by the features manager
  75725. *
  75726. * @returns true if successful.
  75727. */
  75728. attach(): boolean;
  75729. /**
  75730. * detach this feature.
  75731. * Will usually be called by the features manager
  75732. *
  75733. * @returns true if successful.
  75734. */
  75735. detach(): boolean;
  75736. /**
  75737. * Dispose this feature and all of the resources attached
  75738. */
  75739. dispose(): void;
  75740. protected _onXRFrame(frame: XRFrame): void;
  75741. private _onHitTestResults;
  75742. private _onSelect;
  75743. }
  75744. }
  75745. declare module BABYLON {
  75746. /**
  75747. * Options used for hit testing (version 2)
  75748. */
  75749. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75750. /**
  75751. * Do not create a permanent hit test. Will usually be used when only
  75752. * transient inputs are needed.
  75753. */
  75754. disablePermanentHitTest?: boolean;
  75755. /**
  75756. * Enable transient (for example touch-based) hit test inspections
  75757. */
  75758. enableTransientHitTest?: boolean;
  75759. /**
  75760. * Offset ray for the permanent hit test
  75761. */
  75762. offsetRay?: Vector3;
  75763. /**
  75764. * Offset ray for the transient hit test
  75765. */
  75766. transientOffsetRay?: Vector3;
  75767. /**
  75768. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75769. */
  75770. useReferenceSpace?: boolean;
  75771. /**
  75772. * Override the default entity type(s) of the hit-test result
  75773. */
  75774. entityTypes?: XRHitTestTrackableType[];
  75775. }
  75776. /**
  75777. * Interface defining the babylon result of hit-test
  75778. */
  75779. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75780. /**
  75781. * The input source that generated this hit test (if transient)
  75782. */
  75783. inputSource?: XRInputSource;
  75784. /**
  75785. * Is this a transient hit test
  75786. */
  75787. isTransient?: boolean;
  75788. /**
  75789. * Position of the hit test result
  75790. */
  75791. position: Vector3;
  75792. /**
  75793. * Rotation of the hit test result
  75794. */
  75795. rotationQuaternion: Quaternion;
  75796. /**
  75797. * The native hit test result
  75798. */
  75799. xrHitResult: XRHitTestResult;
  75800. }
  75801. /**
  75802. * The currently-working hit-test module.
  75803. * Hit test (or Ray-casting) is used to interact with the real world.
  75804. * For further information read here - https://github.com/immersive-web/hit-test
  75805. *
  75806. * Tested on chrome (mobile) 80.
  75807. */
  75808. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75809. /**
  75810. * options to use when constructing this feature
  75811. */
  75812. readonly options: IWebXRHitTestOptions;
  75813. private _tmpMat;
  75814. private _tmpPos;
  75815. private _tmpQuat;
  75816. private _transientXrHitTestSource;
  75817. private _xrHitTestSource;
  75818. private initHitTestSource;
  75819. /**
  75820. * The module's name
  75821. */
  75822. static readonly Name: string;
  75823. /**
  75824. * The (Babylon) version of this module.
  75825. * This is an integer representing the implementation version.
  75826. * This number does not correspond to the WebXR specs version
  75827. */
  75828. static readonly Version: number;
  75829. /**
  75830. * When set to true, each hit test will have its own position/rotation objects
  75831. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75832. * the developers will clone them or copy them as they see fit.
  75833. */
  75834. autoCloneTransformation: boolean;
  75835. /**
  75836. * Triggered when new babylon (transformed) hit test results are available
  75837. * Note - this will be called when results come back from the device. It can be an empty array!!
  75838. */
  75839. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75840. /**
  75841. * Use this to temporarily pause hit test checks.
  75842. */
  75843. paused: boolean;
  75844. /**
  75845. * Creates a new instance of the hit test feature
  75846. * @param _xrSessionManager an instance of WebXRSessionManager
  75847. * @param options options to use when constructing this feature
  75848. */
  75849. constructor(_xrSessionManager: WebXRSessionManager,
  75850. /**
  75851. * options to use when constructing this feature
  75852. */
  75853. options?: IWebXRHitTestOptions);
  75854. /**
  75855. * attach this feature
  75856. * Will usually be called by the features manager
  75857. *
  75858. * @returns true if successful.
  75859. */
  75860. attach(): boolean;
  75861. /**
  75862. * detach this feature.
  75863. * Will usually be called by the features manager
  75864. *
  75865. * @returns true if successful.
  75866. */
  75867. detach(): boolean;
  75868. /**
  75869. * Dispose this feature and all of the resources attached
  75870. */
  75871. dispose(): void;
  75872. protected _onXRFrame(frame: XRFrame): void;
  75873. private _processWebXRHitTestResult;
  75874. }
  75875. }
  75876. declare module BABYLON {
  75877. /**
  75878. * Configuration options of the anchor system
  75879. */
  75880. export interface IWebXRAnchorSystemOptions {
  75881. /**
  75882. * a node that will be used to convert local to world coordinates
  75883. */
  75884. worldParentNode?: TransformNode;
  75885. /**
  75886. * If set to true a reference of the created anchors will be kept until the next session starts
  75887. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75888. */
  75889. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75890. }
  75891. /**
  75892. * A babylon container for an XR Anchor
  75893. */
  75894. export interface IWebXRAnchor {
  75895. /**
  75896. * A babylon-assigned ID for this anchor
  75897. */
  75898. id: number;
  75899. /**
  75900. * Transformation matrix to apply to an object attached to this anchor
  75901. */
  75902. transformationMatrix: Matrix;
  75903. /**
  75904. * The native anchor object
  75905. */
  75906. xrAnchor: XRAnchor;
  75907. /**
  75908. * if defined, this object will be constantly updated by the anchor's position and rotation
  75909. */
  75910. attachedNode?: TransformNode;
  75911. }
  75912. /**
  75913. * An implementation of the anchor system for WebXR.
  75914. * For further information see https://github.com/immersive-web/anchors/
  75915. */
  75916. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75917. private _options;
  75918. private _lastFrameDetected;
  75919. private _trackedAnchors;
  75920. private _referenceSpaceForFrameAnchors;
  75921. private _futureAnchors;
  75922. /**
  75923. * The module's name
  75924. */
  75925. static readonly Name: string;
  75926. /**
  75927. * The (Babylon) version of this module.
  75928. * This is an integer representing the implementation version.
  75929. * This number does not correspond to the WebXR specs version
  75930. */
  75931. static readonly Version: number;
  75932. /**
  75933. * Observers registered here will be executed when a new anchor was added to the session
  75934. */
  75935. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75936. /**
  75937. * Observers registered here will be executed when an anchor was removed from the session
  75938. */
  75939. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75940. /**
  75941. * Observers registered here will be executed when an existing anchor updates
  75942. * This can execute N times every frame
  75943. */
  75944. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75945. /**
  75946. * Set the reference space to use for anchor creation, when not using a hit test.
  75947. * Will default to the session's reference space if not defined
  75948. */
  75949. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75950. /**
  75951. * constructs a new anchor system
  75952. * @param _xrSessionManager an instance of WebXRSessionManager
  75953. * @param _options configuration object for this feature
  75954. */
  75955. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75956. private _tmpVector;
  75957. private _tmpQuaternion;
  75958. private _populateTmpTransformation;
  75959. /**
  75960. * Create a new anchor point using a hit test result at a specific point in the scene
  75961. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75962. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75963. *
  75964. * @param hitTestResult The hit test result to use for this anchor creation
  75965. * @param position an optional position offset for this anchor
  75966. * @param rotationQuaternion an optional rotation offset for this anchor
  75967. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75968. */
  75969. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75970. /**
  75971. * Add a new anchor at a specific position and rotation
  75972. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75973. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75974. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75975. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75976. *
  75977. * @param position the position in which to add an anchor
  75978. * @param rotationQuaternion an optional rotation for the anchor transformation
  75979. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75980. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75981. */
  75982. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75983. /**
  75984. * detach this feature.
  75985. * Will usually be called by the features manager
  75986. *
  75987. * @returns true if successful.
  75988. */
  75989. detach(): boolean;
  75990. /**
  75991. * Dispose this feature and all of the resources attached
  75992. */
  75993. dispose(): void;
  75994. protected _onXRFrame(frame: XRFrame): void;
  75995. /**
  75996. * avoiding using Array.find for global support.
  75997. * @param xrAnchor the plane to find in the array
  75998. */
  75999. private _findIndexInAnchorArray;
  76000. private _updateAnchorWithXRFrame;
  76001. private _createAnchorAtTransformation;
  76002. }
  76003. }
  76004. declare module BABYLON {
  76005. /**
  76006. * Options used in the plane detector module
  76007. */
  76008. export interface IWebXRPlaneDetectorOptions {
  76009. /**
  76010. * The node to use to transform the local results to world coordinates
  76011. */
  76012. worldParentNode?: TransformNode;
  76013. /**
  76014. * If set to true a reference of the created planes will be kept until the next session starts
  76015. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76016. */
  76017. doNotRemovePlanesOnSessionEnded?: boolean;
  76018. }
  76019. /**
  76020. * A babylon interface for a WebXR plane.
  76021. * A Plane is actually a polygon, built from N points in space
  76022. *
  76023. * Supported in chrome 79, not supported in canary 81 ATM
  76024. */
  76025. export interface IWebXRPlane {
  76026. /**
  76027. * a babylon-assigned ID for this polygon
  76028. */
  76029. id: number;
  76030. /**
  76031. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76032. */
  76033. polygonDefinition: Array<Vector3>;
  76034. /**
  76035. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76036. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76037. */
  76038. transformationMatrix: Matrix;
  76039. /**
  76040. * the native xr-plane object
  76041. */
  76042. xrPlane: XRPlane;
  76043. }
  76044. /**
  76045. * The plane detector is used to detect planes in the real world when in AR
  76046. * For more information see https://github.com/immersive-web/real-world-geometry/
  76047. */
  76048. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76049. private _options;
  76050. private _detectedPlanes;
  76051. private _enabled;
  76052. private _lastFrameDetected;
  76053. /**
  76054. * The module's name
  76055. */
  76056. static readonly Name: string;
  76057. /**
  76058. * The (Babylon) version of this module.
  76059. * This is an integer representing the implementation version.
  76060. * This number does not correspond to the WebXR specs version
  76061. */
  76062. static readonly Version: number;
  76063. /**
  76064. * Observers registered here will be executed when a new plane was added to the session
  76065. */
  76066. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76067. /**
  76068. * Observers registered here will be executed when a plane is no longer detected in the session
  76069. */
  76070. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76071. /**
  76072. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76073. * This can execute N times every frame
  76074. */
  76075. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76076. /**
  76077. * construct a new Plane Detector
  76078. * @param _xrSessionManager an instance of xr Session manager
  76079. * @param _options configuration to use when constructing this feature
  76080. */
  76081. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76082. /**
  76083. * detach this feature.
  76084. * Will usually be called by the features manager
  76085. *
  76086. * @returns true if successful.
  76087. */
  76088. detach(): boolean;
  76089. /**
  76090. * Dispose this feature and all of the resources attached
  76091. */
  76092. dispose(): void;
  76093. /**
  76094. * Check if the needed objects are defined.
  76095. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76096. */
  76097. isCompatible(): boolean;
  76098. protected _onXRFrame(frame: XRFrame): void;
  76099. private _init;
  76100. private _updatePlaneWithXRPlane;
  76101. /**
  76102. * avoiding using Array.find for global support.
  76103. * @param xrPlane the plane to find in the array
  76104. */
  76105. private findIndexInPlaneArray;
  76106. }
  76107. }
  76108. declare module BABYLON {
  76109. /**
  76110. * Options interface for the background remover plugin
  76111. */
  76112. export interface IWebXRBackgroundRemoverOptions {
  76113. /**
  76114. * Further background meshes to disable when entering AR
  76115. */
  76116. backgroundMeshes?: AbstractMesh[];
  76117. /**
  76118. * flags to configure the removal of the environment helper.
  76119. * If not set, the entire background will be removed. If set, flags should be set as well.
  76120. */
  76121. environmentHelperRemovalFlags?: {
  76122. /**
  76123. * Should the skybox be removed (default false)
  76124. */
  76125. skyBox?: boolean;
  76126. /**
  76127. * Should the ground be removed (default false)
  76128. */
  76129. ground?: boolean;
  76130. };
  76131. /**
  76132. * don't disable the environment helper
  76133. */
  76134. ignoreEnvironmentHelper?: boolean;
  76135. }
  76136. /**
  76137. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76138. */
  76139. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76140. /**
  76141. * read-only options to be used in this module
  76142. */
  76143. readonly options: IWebXRBackgroundRemoverOptions;
  76144. /**
  76145. * The module's name
  76146. */
  76147. static readonly Name: string;
  76148. /**
  76149. * The (Babylon) version of this module.
  76150. * This is an integer representing the implementation version.
  76151. * This number does not correspond to the WebXR specs version
  76152. */
  76153. static readonly Version: number;
  76154. /**
  76155. * registered observers will be triggered when the background state changes
  76156. */
  76157. onBackgroundStateChangedObservable: Observable<boolean>;
  76158. /**
  76159. * constructs a new background remover module
  76160. * @param _xrSessionManager the session manager for this module
  76161. * @param options read-only options to be used in this module
  76162. */
  76163. constructor(_xrSessionManager: WebXRSessionManager,
  76164. /**
  76165. * read-only options to be used in this module
  76166. */
  76167. options?: IWebXRBackgroundRemoverOptions);
  76168. /**
  76169. * attach this feature
  76170. * Will usually be called by the features manager
  76171. *
  76172. * @returns true if successful.
  76173. */
  76174. attach(): boolean;
  76175. /**
  76176. * detach this feature.
  76177. * Will usually be called by the features manager
  76178. *
  76179. * @returns true if successful.
  76180. */
  76181. detach(): boolean;
  76182. /**
  76183. * Dispose this feature and all of the resources attached
  76184. */
  76185. dispose(): void;
  76186. protected _onXRFrame(_xrFrame: XRFrame): void;
  76187. private _setBackgroundState;
  76188. }
  76189. }
  76190. declare module BABYLON {
  76191. /**
  76192. * Options for the controller physics feature
  76193. */
  76194. export class IWebXRControllerPhysicsOptions {
  76195. /**
  76196. * Should the headset get its own impostor
  76197. */
  76198. enableHeadsetImpostor?: boolean;
  76199. /**
  76200. * Optional parameters for the headset impostor
  76201. */
  76202. headsetImpostorParams?: {
  76203. /**
  76204. * The type of impostor to create. Default is sphere
  76205. */
  76206. impostorType: number;
  76207. /**
  76208. * the size of the impostor. Defaults to 10cm
  76209. */
  76210. impostorSize?: number | {
  76211. width: number;
  76212. height: number;
  76213. depth: number;
  76214. };
  76215. /**
  76216. * Friction definitions
  76217. */
  76218. friction?: number;
  76219. /**
  76220. * Restitution
  76221. */
  76222. restitution?: number;
  76223. };
  76224. /**
  76225. * The physics properties of the future impostors
  76226. */
  76227. physicsProperties?: {
  76228. /**
  76229. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76230. * Note that this requires a physics engine that supports mesh impostors!
  76231. */
  76232. useControllerMesh?: boolean;
  76233. /**
  76234. * The type of impostor to create. Default is sphere
  76235. */
  76236. impostorType?: number;
  76237. /**
  76238. * the size of the impostor. Defaults to 10cm
  76239. */
  76240. impostorSize?: number | {
  76241. width: number;
  76242. height: number;
  76243. depth: number;
  76244. };
  76245. /**
  76246. * Friction definitions
  76247. */
  76248. friction?: number;
  76249. /**
  76250. * Restitution
  76251. */
  76252. restitution?: number;
  76253. };
  76254. /**
  76255. * the xr input to use with this pointer selection
  76256. */
  76257. xrInput: WebXRInput;
  76258. }
  76259. /**
  76260. * Add physics impostor to your webxr controllers,
  76261. * including naive calculation of their linear and angular velocity
  76262. */
  76263. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76264. private readonly _options;
  76265. private _attachController;
  76266. private _controllers;
  76267. private _debugMode;
  76268. private _delta;
  76269. private _headsetImpostor?;
  76270. private _headsetMesh?;
  76271. private _lastTimestamp;
  76272. private _tmpQuaternion;
  76273. private _tmpVector;
  76274. /**
  76275. * The module's name
  76276. */
  76277. static readonly Name: string;
  76278. /**
  76279. * The (Babylon) version of this module.
  76280. * This is an integer representing the implementation version.
  76281. * This number does not correspond to the webxr specs version
  76282. */
  76283. static readonly Version: number;
  76284. /**
  76285. * Construct a new Controller Physics Feature
  76286. * @param _xrSessionManager the corresponding xr session manager
  76287. * @param _options options to create this feature with
  76288. */
  76289. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76290. /**
  76291. * @hidden
  76292. * enable debugging - will show console outputs and the impostor mesh
  76293. */
  76294. _enablePhysicsDebug(): void;
  76295. /**
  76296. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76297. * @param xrController the controller to add
  76298. */
  76299. addController(xrController: WebXRInputSource): void;
  76300. /**
  76301. * attach this feature
  76302. * Will usually be called by the features manager
  76303. *
  76304. * @returns true if successful.
  76305. */
  76306. attach(): boolean;
  76307. /**
  76308. * detach this feature.
  76309. * Will usually be called by the features manager
  76310. *
  76311. * @returns true if successful.
  76312. */
  76313. detach(): boolean;
  76314. /**
  76315. * Get the headset impostor, if enabled
  76316. * @returns the impostor
  76317. */
  76318. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76319. /**
  76320. * Get the physics impostor of a specific controller.
  76321. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76322. * @param controller the controller or the controller id of which to get the impostor
  76323. * @returns the impostor or null
  76324. */
  76325. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76326. /**
  76327. * Update the physics properties provided in the constructor
  76328. * @param newProperties the new properties object
  76329. */
  76330. setPhysicsProperties(newProperties: {
  76331. impostorType?: number;
  76332. impostorSize?: number | {
  76333. width: number;
  76334. height: number;
  76335. depth: number;
  76336. };
  76337. friction?: number;
  76338. restitution?: number;
  76339. }): void;
  76340. protected _onXRFrame(_xrFrame: any): void;
  76341. private _detachController;
  76342. }
  76343. }
  76344. declare module BABYLON {
  76345. /**
  76346. * A babylon interface for a "WebXR" feature point.
  76347. * Represents the position and confidence value of a given feature point.
  76348. */
  76349. export interface IWebXRFeaturePoint {
  76350. /**
  76351. * Represents the position of the feature point in world space.
  76352. */
  76353. position: Vector3;
  76354. /**
  76355. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76356. */
  76357. confidenceValue: number;
  76358. }
  76359. /**
  76360. * The feature point system is used to detect feature points from real world geometry.
  76361. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76362. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76363. */
  76364. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76365. private _enabled;
  76366. private _featurePointCloud;
  76367. /**
  76368. * The module's name
  76369. */
  76370. static readonly Name: string;
  76371. /**
  76372. * The (Babylon) version of this module.
  76373. * This is an integer representing the implementation version.
  76374. * This number does not correspond to the WebXR specs version
  76375. */
  76376. static readonly Version: number;
  76377. /**
  76378. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76379. * Will notify the observers about which feature points have been added.
  76380. */
  76381. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76382. /**
  76383. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76384. * Will notify the observers about which feature points have been updated.
  76385. */
  76386. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76387. /**
  76388. * The current feature point cloud maintained across frames.
  76389. */
  76390. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76391. /**
  76392. * construct the feature point system
  76393. * @param _xrSessionManager an instance of xr Session manager
  76394. */
  76395. constructor(_xrSessionManager: WebXRSessionManager);
  76396. /**
  76397. * Detach this feature.
  76398. * Will usually be called by the features manager
  76399. *
  76400. * @returns true if successful.
  76401. */
  76402. detach(): boolean;
  76403. /**
  76404. * Dispose this feature and all of the resources attached
  76405. */
  76406. dispose(): void;
  76407. /**
  76408. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76409. */
  76410. protected _onXRFrame(frame: XRFrame): void;
  76411. /**
  76412. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76413. */
  76414. private _init;
  76415. }
  76416. }
  76417. declare module BABYLON {
  76418. /**
  76419. * Configuration interface for the hand tracking feature
  76420. */
  76421. export interface IWebXRHandTrackingOptions {
  76422. /**
  76423. * The xrInput that will be used as source for new hands
  76424. */
  76425. xrInput: WebXRInput;
  76426. /**
  76427. * Configuration object for the joint meshes
  76428. */
  76429. jointMeshes?: {
  76430. /**
  76431. * Should the meshes created be invisible (defaults to false)
  76432. */
  76433. invisible?: boolean;
  76434. /**
  76435. * A source mesh to be used to create instances. Defaults to a sphere.
  76436. * This mesh will be the source for all other (25) meshes.
  76437. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76438. */
  76439. sourceMesh?: Mesh;
  76440. /**
  76441. * This function will be called after a mesh was created for a specific joint.
  76442. * Using this function you can either manipulate the instance or return a new mesh.
  76443. * When returning a new mesh the instance created before will be disposed
  76444. */
  76445. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76446. /**
  76447. * Should the source mesh stay visible. Defaults to false
  76448. */
  76449. keepOriginalVisible?: boolean;
  76450. /**
  76451. * Scale factor for all instances (defaults to 2)
  76452. */
  76453. scaleFactor?: number;
  76454. /**
  76455. * Should each instance have its own physics impostor
  76456. */
  76457. enablePhysics?: boolean;
  76458. /**
  76459. * If enabled, override default physics properties
  76460. */
  76461. physicsProps?: {
  76462. friction?: number;
  76463. restitution?: number;
  76464. impostorType?: number;
  76465. };
  76466. /**
  76467. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76468. */
  76469. handMesh?: AbstractMesh;
  76470. };
  76471. }
  76472. /**
  76473. * Parts of the hands divided to writs and finger names
  76474. */
  76475. export const enum HandPart {
  76476. /**
  76477. * HandPart - Wrist
  76478. */
  76479. WRIST = "wrist",
  76480. /**
  76481. * HandPart - The THumb
  76482. */
  76483. THUMB = "thumb",
  76484. /**
  76485. * HandPart - Index finger
  76486. */
  76487. INDEX = "index",
  76488. /**
  76489. * HandPart - Middle finger
  76490. */
  76491. MIDDLE = "middle",
  76492. /**
  76493. * HandPart - Ring finger
  76494. */
  76495. RING = "ring",
  76496. /**
  76497. * HandPart - Little finger
  76498. */
  76499. LITTLE = "little"
  76500. }
  76501. /**
  76502. * Representing a single hand (with its corresponding native XRHand object)
  76503. */
  76504. export class WebXRHand implements IDisposable {
  76505. /** the controller to which the hand correlates */
  76506. readonly xrController: WebXRInputSource;
  76507. /** the meshes to be used to track the hand joints */
  76508. readonly trackedMeshes: AbstractMesh[];
  76509. /**
  76510. * Hand-parts definition (key is HandPart)
  76511. */
  76512. handPartsDefinition: {
  76513. [key: string]: number[];
  76514. };
  76515. /**
  76516. * Populate the HandPartsDefinition object.
  76517. * This is called as a side effect since certain browsers don't have XRHand defined.
  76518. */
  76519. private generateHandPartsDefinition;
  76520. /**
  76521. * Construct a new hand object
  76522. * @param xrController the controller to which the hand correlates
  76523. * @param trackedMeshes the meshes to be used to track the hand joints
  76524. */
  76525. constructor(
  76526. /** the controller to which the hand correlates */
  76527. xrController: WebXRInputSource,
  76528. /** the meshes to be used to track the hand joints */
  76529. trackedMeshes: AbstractMesh[]);
  76530. /**
  76531. * Update this hand from the latest xr frame
  76532. * @param xrFrame xrFrame to update from
  76533. * @param referenceSpace The current viewer reference space
  76534. * @param scaleFactor optional scale factor for the meshes
  76535. */
  76536. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76537. /**
  76538. * Get meshes of part of the hand
  76539. * @param part the part of hand to get
  76540. * @returns An array of meshes that correlate to the hand part requested
  76541. */
  76542. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76543. /**
  76544. * Dispose this Hand object
  76545. */
  76546. dispose(): void;
  76547. }
  76548. /**
  76549. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76550. */
  76551. export class WebXRHandTracking extends WebXRAbstractFeature {
  76552. /**
  76553. * options to use when constructing this feature
  76554. */
  76555. readonly options: IWebXRHandTrackingOptions;
  76556. private static _idCounter;
  76557. /**
  76558. * The module's name
  76559. */
  76560. static readonly Name: string;
  76561. /**
  76562. * The (Babylon) version of this module.
  76563. * This is an integer representing the implementation version.
  76564. * This number does not correspond to the WebXR specs version
  76565. */
  76566. static readonly Version: number;
  76567. /**
  76568. * This observable will notify registered observers when a new hand object was added and initialized
  76569. */
  76570. onHandAddedObservable: Observable<WebXRHand>;
  76571. /**
  76572. * This observable will notify its observers right before the hand object is disposed
  76573. */
  76574. onHandRemovedObservable: Observable<WebXRHand>;
  76575. private _hands;
  76576. /**
  76577. * Creates a new instance of the hit test feature
  76578. * @param _xrSessionManager an instance of WebXRSessionManager
  76579. * @param options options to use when constructing this feature
  76580. */
  76581. constructor(_xrSessionManager: WebXRSessionManager,
  76582. /**
  76583. * options to use when constructing this feature
  76584. */
  76585. options: IWebXRHandTrackingOptions);
  76586. /**
  76587. * Check if the needed objects are defined.
  76588. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76589. */
  76590. isCompatible(): boolean;
  76591. /**
  76592. * attach this feature
  76593. * Will usually be called by the features manager
  76594. *
  76595. * @returns true if successful.
  76596. */
  76597. attach(): boolean;
  76598. /**
  76599. * detach this feature.
  76600. * Will usually be called by the features manager
  76601. *
  76602. * @returns true if successful.
  76603. */
  76604. detach(): boolean;
  76605. /**
  76606. * Dispose this feature and all of the resources attached
  76607. */
  76608. dispose(): void;
  76609. /**
  76610. * Get the hand object according to the controller id
  76611. * @param controllerId the controller id to which we want to get the hand
  76612. * @returns null if not found or the WebXRHand object if found
  76613. */
  76614. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76615. /**
  76616. * Get a hand object according to the requested handedness
  76617. * @param handedness the handedness to request
  76618. * @returns null if not found or the WebXRHand object if found
  76619. */
  76620. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76621. protected _onXRFrame(_xrFrame: XRFrame): void;
  76622. private _attachHand;
  76623. private _detachHand;
  76624. }
  76625. }
  76626. declare module BABYLON {
  76627. /**
  76628. * The motion controller class for all microsoft mixed reality controllers
  76629. */
  76630. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76631. protected readonly _mapping: {
  76632. defaultButton: {
  76633. valueNodeName: string;
  76634. unpressedNodeName: string;
  76635. pressedNodeName: string;
  76636. };
  76637. defaultAxis: {
  76638. valueNodeName: string;
  76639. minNodeName: string;
  76640. maxNodeName: string;
  76641. };
  76642. buttons: {
  76643. "xr-standard-trigger": {
  76644. rootNodeName: string;
  76645. componentProperty: string;
  76646. states: string[];
  76647. };
  76648. "xr-standard-squeeze": {
  76649. rootNodeName: string;
  76650. componentProperty: string;
  76651. states: string[];
  76652. };
  76653. "xr-standard-touchpad": {
  76654. rootNodeName: string;
  76655. labelAnchorNodeName: string;
  76656. touchPointNodeName: string;
  76657. };
  76658. "xr-standard-thumbstick": {
  76659. rootNodeName: string;
  76660. componentProperty: string;
  76661. states: string[];
  76662. };
  76663. };
  76664. axes: {
  76665. "xr-standard-touchpad": {
  76666. "x-axis": {
  76667. rootNodeName: string;
  76668. };
  76669. "y-axis": {
  76670. rootNodeName: string;
  76671. };
  76672. };
  76673. "xr-standard-thumbstick": {
  76674. "x-axis": {
  76675. rootNodeName: string;
  76676. };
  76677. "y-axis": {
  76678. rootNodeName: string;
  76679. };
  76680. };
  76681. };
  76682. };
  76683. /**
  76684. * The base url used to load the left and right controller models
  76685. */
  76686. static MODEL_BASE_URL: string;
  76687. /**
  76688. * The name of the left controller model file
  76689. */
  76690. static MODEL_LEFT_FILENAME: string;
  76691. /**
  76692. * The name of the right controller model file
  76693. */
  76694. static MODEL_RIGHT_FILENAME: string;
  76695. profileId: string;
  76696. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76697. protected _getFilenameAndPath(): {
  76698. filename: string;
  76699. path: string;
  76700. };
  76701. protected _getModelLoadingConstraints(): boolean;
  76702. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76703. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76704. protected _updateModel(): void;
  76705. }
  76706. }
  76707. declare module BABYLON {
  76708. /**
  76709. * The motion controller class for oculus touch (quest, rift).
  76710. * This class supports legacy mapping as well the standard xr mapping
  76711. */
  76712. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76713. private _forceLegacyControllers;
  76714. private _modelRootNode;
  76715. /**
  76716. * The base url used to load the left and right controller models
  76717. */
  76718. static MODEL_BASE_URL: string;
  76719. /**
  76720. * The name of the left controller model file
  76721. */
  76722. static MODEL_LEFT_FILENAME: string;
  76723. /**
  76724. * The name of the right controller model file
  76725. */
  76726. static MODEL_RIGHT_FILENAME: string;
  76727. /**
  76728. * Base Url for the Quest controller model.
  76729. */
  76730. static QUEST_MODEL_BASE_URL: string;
  76731. profileId: string;
  76732. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76733. protected _getFilenameAndPath(): {
  76734. filename: string;
  76735. path: string;
  76736. };
  76737. protected _getModelLoadingConstraints(): boolean;
  76738. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76739. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76740. protected _updateModel(): void;
  76741. /**
  76742. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76743. * between the touch and touch 2.
  76744. */
  76745. private _isQuest;
  76746. }
  76747. }
  76748. declare module BABYLON {
  76749. /**
  76750. * The motion controller class for the standard HTC-Vive controllers
  76751. */
  76752. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76753. private _modelRootNode;
  76754. /**
  76755. * The base url used to load the left and right controller models
  76756. */
  76757. static MODEL_BASE_URL: string;
  76758. /**
  76759. * File name for the controller model.
  76760. */
  76761. static MODEL_FILENAME: string;
  76762. profileId: string;
  76763. /**
  76764. * Create a new Vive motion controller object
  76765. * @param scene the scene to use to create this controller
  76766. * @param gamepadObject the corresponding gamepad object
  76767. * @param handedness the handedness of the controller
  76768. */
  76769. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76770. protected _getFilenameAndPath(): {
  76771. filename: string;
  76772. path: string;
  76773. };
  76774. protected _getModelLoadingConstraints(): boolean;
  76775. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76776. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76777. protected _updateModel(): void;
  76778. }
  76779. }
  76780. declare module BABYLON {
  76781. /**
  76782. * A cursor which tracks a point on a path
  76783. */
  76784. export class PathCursor {
  76785. private path;
  76786. /**
  76787. * Stores path cursor callbacks for when an onchange event is triggered
  76788. */
  76789. private _onchange;
  76790. /**
  76791. * The value of the path cursor
  76792. */
  76793. value: number;
  76794. /**
  76795. * The animation array of the path cursor
  76796. */
  76797. animations: Animation[];
  76798. /**
  76799. * Initializes the path cursor
  76800. * @param path The path to track
  76801. */
  76802. constructor(path: Path2);
  76803. /**
  76804. * Gets the cursor point on the path
  76805. * @returns A point on the path cursor at the cursor location
  76806. */
  76807. getPoint(): Vector3;
  76808. /**
  76809. * Moves the cursor ahead by the step amount
  76810. * @param step The amount to move the cursor forward
  76811. * @returns This path cursor
  76812. */
  76813. moveAhead(step?: number): PathCursor;
  76814. /**
  76815. * Moves the cursor behind by the step amount
  76816. * @param step The amount to move the cursor back
  76817. * @returns This path cursor
  76818. */
  76819. moveBack(step?: number): PathCursor;
  76820. /**
  76821. * Moves the cursor by the step amount
  76822. * If the step amount is greater than one, an exception is thrown
  76823. * @param step The amount to move the cursor
  76824. * @returns This path cursor
  76825. */
  76826. move(step: number): PathCursor;
  76827. /**
  76828. * Ensures that the value is limited between zero and one
  76829. * @returns This path cursor
  76830. */
  76831. private ensureLimits;
  76832. /**
  76833. * Runs onchange callbacks on change (used by the animation engine)
  76834. * @returns This path cursor
  76835. */
  76836. private raiseOnChange;
  76837. /**
  76838. * Executes a function on change
  76839. * @param f A path cursor onchange callback
  76840. * @returns This path cursor
  76841. */
  76842. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76843. }
  76844. }
  76845. declare module BABYLON {
  76846. /** @hidden */
  76847. export var blurPixelShader: {
  76848. name: string;
  76849. shader: string;
  76850. };
  76851. }
  76852. declare module BABYLON {
  76853. /** @hidden */
  76854. export var pointCloudVertexDeclaration: {
  76855. name: string;
  76856. shader: string;
  76857. };
  76858. }
  76859. // Mixins
  76860. interface Window {
  76861. mozIndexedDB: IDBFactory;
  76862. webkitIndexedDB: IDBFactory;
  76863. msIndexedDB: IDBFactory;
  76864. webkitURL: typeof URL;
  76865. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76866. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76867. WebGLRenderingContext: WebGLRenderingContext;
  76868. MSGesture: MSGesture;
  76869. CANNON: any;
  76870. AudioContext: AudioContext;
  76871. webkitAudioContext: AudioContext;
  76872. PointerEvent: any;
  76873. Math: Math;
  76874. Uint8Array: Uint8ArrayConstructor;
  76875. Float32Array: Float32ArrayConstructor;
  76876. mozURL: typeof URL;
  76877. msURL: typeof URL;
  76878. VRFrameData: any; // WebVR, from specs 1.1
  76879. DracoDecoderModule: any;
  76880. setImmediate(handler: (...args: any[]) => void): number;
  76881. }
  76882. interface HTMLCanvasElement {
  76883. requestPointerLock(): void;
  76884. msRequestPointerLock?(): void;
  76885. mozRequestPointerLock?(): void;
  76886. webkitRequestPointerLock?(): void;
  76887. /** Track wether a record is in progress */
  76888. isRecording: boolean;
  76889. /** Capture Stream method defined by some browsers */
  76890. captureStream(fps?: number): MediaStream;
  76891. }
  76892. interface CanvasRenderingContext2D {
  76893. msImageSmoothingEnabled: boolean;
  76894. }
  76895. interface MouseEvent {
  76896. mozMovementX: number;
  76897. mozMovementY: number;
  76898. webkitMovementX: number;
  76899. webkitMovementY: number;
  76900. msMovementX: number;
  76901. msMovementY: number;
  76902. }
  76903. interface Navigator {
  76904. mozGetVRDevices: (any: any) => any;
  76905. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76906. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76907. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76908. webkitGetGamepads(): Gamepad[];
  76909. msGetGamepads(): Gamepad[];
  76910. webkitGamepads(): Gamepad[];
  76911. }
  76912. interface HTMLVideoElement {
  76913. mozSrcObject: any;
  76914. }
  76915. interface Math {
  76916. fround(x: number): number;
  76917. imul(a: number, b: number): number;
  76918. }
  76919. interface WebGLRenderingContext {
  76920. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76921. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76922. vertexAttribDivisor(index: number, divisor: number): void;
  76923. createVertexArray(): any;
  76924. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76925. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76926. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76927. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76928. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76929. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76930. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76931. // Queries
  76932. createQuery(): WebGLQuery;
  76933. deleteQuery(query: WebGLQuery): void;
  76934. beginQuery(target: number, query: WebGLQuery): void;
  76935. endQuery(target: number): void;
  76936. getQueryParameter(query: WebGLQuery, pname: number): any;
  76937. getQuery(target: number, pname: number): any;
  76938. MAX_SAMPLES: number;
  76939. RGBA8: number;
  76940. READ_FRAMEBUFFER: number;
  76941. DRAW_FRAMEBUFFER: number;
  76942. UNIFORM_BUFFER: number;
  76943. HALF_FLOAT_OES: number;
  76944. RGBA16F: number;
  76945. RGBA32F: number;
  76946. R32F: number;
  76947. RG32F: number;
  76948. RGB32F: number;
  76949. R16F: number;
  76950. RG16F: number;
  76951. RGB16F: number;
  76952. RED: number;
  76953. RG: number;
  76954. R8: number;
  76955. RG8: number;
  76956. UNSIGNED_INT_24_8: number;
  76957. DEPTH24_STENCIL8: number;
  76958. MIN: number;
  76959. MAX: number;
  76960. /* Multiple Render Targets */
  76961. drawBuffers(buffers: number[]): void;
  76962. readBuffer(src: number): void;
  76963. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76964. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76965. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76966. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76967. // Occlusion Query
  76968. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76969. ANY_SAMPLES_PASSED: number;
  76970. QUERY_RESULT_AVAILABLE: number;
  76971. QUERY_RESULT: number;
  76972. }
  76973. interface WebGLProgram {
  76974. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76975. }
  76976. interface EXT_disjoint_timer_query {
  76977. QUERY_COUNTER_BITS_EXT: number;
  76978. TIME_ELAPSED_EXT: number;
  76979. TIMESTAMP_EXT: number;
  76980. GPU_DISJOINT_EXT: number;
  76981. QUERY_RESULT_EXT: number;
  76982. QUERY_RESULT_AVAILABLE_EXT: number;
  76983. queryCounterEXT(query: WebGLQuery, target: number): void;
  76984. createQueryEXT(): WebGLQuery;
  76985. beginQueryEXT(target: number, query: WebGLQuery): void;
  76986. endQueryEXT(target: number): void;
  76987. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76988. deleteQueryEXT(query: WebGLQuery): void;
  76989. }
  76990. interface WebGLUniformLocation {
  76991. _currentState: any;
  76992. }
  76993. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76994. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76995. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76996. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76997. interface WebGLRenderingContext {
  76998. readonly RASTERIZER_DISCARD: number;
  76999. readonly DEPTH_COMPONENT24: number;
  77000. readonly TEXTURE_3D: number;
  77001. readonly TEXTURE_2D_ARRAY: number;
  77002. readonly TEXTURE_COMPARE_FUNC: number;
  77003. readonly TEXTURE_COMPARE_MODE: number;
  77004. readonly COMPARE_REF_TO_TEXTURE: number;
  77005. readonly TEXTURE_WRAP_R: number;
  77006. readonly HALF_FLOAT: number;
  77007. readonly RGB8: number;
  77008. readonly RED_INTEGER: number;
  77009. readonly RG_INTEGER: number;
  77010. readonly RGB_INTEGER: number;
  77011. readonly RGBA_INTEGER: number;
  77012. readonly R8_SNORM: number;
  77013. readonly RG8_SNORM: number;
  77014. readonly RGB8_SNORM: number;
  77015. readonly RGBA8_SNORM: number;
  77016. readonly R8I: number;
  77017. readonly RG8I: number;
  77018. readonly RGB8I: number;
  77019. readonly RGBA8I: number;
  77020. readonly R8UI: number;
  77021. readonly RG8UI: number;
  77022. readonly RGB8UI: number;
  77023. readonly RGBA8UI: number;
  77024. readonly R16I: number;
  77025. readonly RG16I: number;
  77026. readonly RGB16I: number;
  77027. readonly RGBA16I: number;
  77028. readonly R16UI: number;
  77029. readonly RG16UI: number;
  77030. readonly RGB16UI: number;
  77031. readonly RGBA16UI: number;
  77032. readonly R32I: number;
  77033. readonly RG32I: number;
  77034. readonly RGB32I: number;
  77035. readonly RGBA32I: number;
  77036. readonly R32UI: number;
  77037. readonly RG32UI: number;
  77038. readonly RGB32UI: number;
  77039. readonly RGBA32UI: number;
  77040. readonly RGB10_A2UI: number;
  77041. readonly R11F_G11F_B10F: number;
  77042. readonly RGB9_E5: number;
  77043. readonly RGB10_A2: number;
  77044. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77045. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77046. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77047. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77048. readonly DEPTH_COMPONENT32F: number;
  77049. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77050. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77051. 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;
  77052. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77053. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77054. readonly TRANSFORM_FEEDBACK: number;
  77055. readonly INTERLEAVED_ATTRIBS: number;
  77056. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77057. createTransformFeedback(): WebGLTransformFeedback;
  77058. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77059. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77060. beginTransformFeedback(primitiveMode: number): void;
  77061. endTransformFeedback(): void;
  77062. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77063. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77064. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77065. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77066. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77067. }
  77068. interface ImageBitmap {
  77069. readonly width: number;
  77070. readonly height: number;
  77071. close(): void;
  77072. }
  77073. interface WebGLQuery extends WebGLObject {
  77074. }
  77075. declare var WebGLQuery: {
  77076. prototype: WebGLQuery;
  77077. new(): WebGLQuery;
  77078. };
  77079. interface WebGLSampler extends WebGLObject {
  77080. }
  77081. declare var WebGLSampler: {
  77082. prototype: WebGLSampler;
  77083. new(): WebGLSampler;
  77084. };
  77085. interface WebGLSync extends WebGLObject {
  77086. }
  77087. declare var WebGLSync: {
  77088. prototype: WebGLSync;
  77089. new(): WebGLSync;
  77090. };
  77091. interface WebGLTransformFeedback extends WebGLObject {
  77092. }
  77093. declare var WebGLTransformFeedback: {
  77094. prototype: WebGLTransformFeedback;
  77095. new(): WebGLTransformFeedback;
  77096. };
  77097. interface WebGLVertexArrayObject extends WebGLObject {
  77098. }
  77099. declare var WebGLVertexArrayObject: {
  77100. prototype: WebGLVertexArrayObject;
  77101. new(): WebGLVertexArrayObject;
  77102. };
  77103. // Type definitions for WebVR API
  77104. // Project: https://w3c.github.io/webvr/
  77105. // Definitions by: six a <https://github.com/lostfictions>
  77106. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77107. interface VRDisplay extends EventTarget {
  77108. /**
  77109. * Dictionary of capabilities describing the VRDisplay.
  77110. */
  77111. readonly capabilities: VRDisplayCapabilities;
  77112. /**
  77113. * z-depth defining the far plane of the eye view frustum
  77114. * enables mapping of values in the render target depth
  77115. * attachment to scene coordinates. Initially set to 10000.0.
  77116. */
  77117. depthFar: number;
  77118. /**
  77119. * z-depth defining the near plane of the eye view frustum
  77120. * enables mapping of values in the render target depth
  77121. * attachment to scene coordinates. Initially set to 0.01.
  77122. */
  77123. depthNear: number;
  77124. /**
  77125. * An identifier for this distinct VRDisplay. Used as an
  77126. * association point in the Gamepad API.
  77127. */
  77128. readonly displayId: number;
  77129. /**
  77130. * A display name, a user-readable name identifying it.
  77131. */
  77132. readonly displayName: string;
  77133. readonly isConnected: boolean;
  77134. readonly isPresenting: boolean;
  77135. /**
  77136. * If this VRDisplay supports room-scale experiences, the optional
  77137. * stage attribute contains details on the room-scale parameters.
  77138. */
  77139. readonly stageParameters: VRStageParameters | null;
  77140. /**
  77141. * Passing the value returned by `requestAnimationFrame` to
  77142. * `cancelAnimationFrame` will unregister the callback.
  77143. * @param handle Define the hanle of the request to cancel
  77144. */
  77145. cancelAnimationFrame(handle: number): void;
  77146. /**
  77147. * Stops presenting to the VRDisplay.
  77148. * @returns a promise to know when it stopped
  77149. */
  77150. exitPresent(): Promise<void>;
  77151. /**
  77152. * Return the current VREyeParameters for the given eye.
  77153. * @param whichEye Define the eye we want the parameter for
  77154. * @returns the eye parameters
  77155. */
  77156. getEyeParameters(whichEye: string): VREyeParameters;
  77157. /**
  77158. * Populates the passed VRFrameData with the information required to render
  77159. * the current frame.
  77160. * @param frameData Define the data structure to populate
  77161. * @returns true if ok otherwise false
  77162. */
  77163. getFrameData(frameData: VRFrameData): boolean;
  77164. /**
  77165. * Get the layers currently being presented.
  77166. * @returns the list of VR layers
  77167. */
  77168. getLayers(): VRLayer[];
  77169. /**
  77170. * Return a VRPose containing the future predicted pose of the VRDisplay
  77171. * when the current frame will be presented. The value returned will not
  77172. * change until JavaScript has returned control to the browser.
  77173. *
  77174. * The VRPose will contain the position, orientation, velocity,
  77175. * and acceleration of each of these properties.
  77176. * @returns the pose object
  77177. */
  77178. getPose(): VRPose;
  77179. /**
  77180. * Return the current instantaneous pose of the VRDisplay, with no
  77181. * prediction applied.
  77182. * @returns the current instantaneous pose
  77183. */
  77184. getImmediatePose(): VRPose;
  77185. /**
  77186. * The callback passed to `requestAnimationFrame` will be called
  77187. * any time a new frame should be rendered. When the VRDisplay is
  77188. * presenting the callback will be called at the native refresh
  77189. * rate of the HMD. When not presenting this function acts
  77190. * identically to how window.requestAnimationFrame acts. Content should
  77191. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77192. * asynchronously from other displays and at differing refresh rates.
  77193. * @param callback Define the eaction to run next frame
  77194. * @returns the request handle it
  77195. */
  77196. requestAnimationFrame(callback: FrameRequestCallback): number;
  77197. /**
  77198. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77199. * Repeat calls while already presenting will update the VRLayers being displayed.
  77200. * @param layers Define the list of layer to present
  77201. * @returns a promise to know when the request has been fulfilled
  77202. */
  77203. requestPresent(layers: VRLayer[]): Promise<void>;
  77204. /**
  77205. * Reset the pose for this display, treating its current position and
  77206. * orientation as the "origin/zero" values. VRPose.position,
  77207. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77208. * updated when calling resetPose(). This should be called in only
  77209. * sitting-space experiences.
  77210. */
  77211. resetPose(): void;
  77212. /**
  77213. * The VRLayer provided to the VRDisplay will be captured and presented
  77214. * in the HMD. Calling this function has the same effect on the source
  77215. * canvas as any other operation that uses its source image, and canvases
  77216. * created without preserveDrawingBuffer set to true will be cleared.
  77217. * @param pose Define the pose to submit
  77218. */
  77219. submitFrame(pose?: VRPose): void;
  77220. }
  77221. declare var VRDisplay: {
  77222. prototype: VRDisplay;
  77223. new(): VRDisplay;
  77224. };
  77225. interface VRLayer {
  77226. leftBounds?: number[] | Float32Array | null;
  77227. rightBounds?: number[] | Float32Array | null;
  77228. source?: HTMLCanvasElement | null;
  77229. }
  77230. interface VRDisplayCapabilities {
  77231. readonly canPresent: boolean;
  77232. readonly hasExternalDisplay: boolean;
  77233. readonly hasOrientation: boolean;
  77234. readonly hasPosition: boolean;
  77235. readonly maxLayers: number;
  77236. }
  77237. interface VREyeParameters {
  77238. /** @deprecated */
  77239. readonly fieldOfView: VRFieldOfView;
  77240. readonly offset: Float32Array;
  77241. readonly renderHeight: number;
  77242. readonly renderWidth: number;
  77243. }
  77244. interface VRFieldOfView {
  77245. readonly downDegrees: number;
  77246. readonly leftDegrees: number;
  77247. readonly rightDegrees: number;
  77248. readonly upDegrees: number;
  77249. }
  77250. interface VRFrameData {
  77251. readonly leftProjectionMatrix: Float32Array;
  77252. readonly leftViewMatrix: Float32Array;
  77253. readonly pose: VRPose;
  77254. readonly rightProjectionMatrix: Float32Array;
  77255. readonly rightViewMatrix: Float32Array;
  77256. readonly timestamp: number;
  77257. }
  77258. interface VRPose {
  77259. readonly angularAcceleration: Float32Array | null;
  77260. readonly angularVelocity: Float32Array | null;
  77261. readonly linearAcceleration: Float32Array | null;
  77262. readonly linearVelocity: Float32Array | null;
  77263. readonly orientation: Float32Array | null;
  77264. readonly position: Float32Array | null;
  77265. readonly timestamp: number;
  77266. }
  77267. interface VRStageParameters {
  77268. sittingToStandingTransform?: Float32Array;
  77269. sizeX?: number;
  77270. sizeY?: number;
  77271. }
  77272. interface Navigator {
  77273. getVRDisplays(): Promise<VRDisplay[]>;
  77274. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77275. }
  77276. interface Window {
  77277. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77278. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77279. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77280. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77281. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77282. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77283. }
  77284. interface Gamepad {
  77285. readonly displayId: number;
  77286. }
  77287. /**
  77288. * Available session modes
  77289. */
  77290. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77291. /**
  77292. * Reference space types
  77293. */
  77294. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77295. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77296. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77297. /**
  77298. * Handedness types
  77299. */
  77300. type XRHandedness = "none" | "left" | "right";
  77301. /**
  77302. * InputSource target ray modes
  77303. */
  77304. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77305. /**
  77306. * Eye types
  77307. */
  77308. type XREye = "none" | "left" | "right";
  77309. /**
  77310. * Type of XR events available
  77311. */
  77312. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77313. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77314. type XRPlaneSet = Set<XRPlane>;
  77315. type XRAnchorSet = Set<XRAnchor>;
  77316. type XREventHandler = (callback: any) => void;
  77317. interface XRLayer extends EventTarget {}
  77318. interface XRSessionInit {
  77319. optionalFeatures?: string[];
  77320. requiredFeatures?: string[];
  77321. }
  77322. interface XRSessionEvent extends Event {
  77323. readonly session: XRSession;
  77324. }
  77325. interface XRSystem {
  77326. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77327. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77328. }
  77329. interface XRViewport {
  77330. readonly x: number;
  77331. readonly y: number;
  77332. readonly width: number;
  77333. readonly height: number;
  77334. }
  77335. interface XRWebGLLayerInit {
  77336. antialias?: boolean;
  77337. depth?: boolean;
  77338. stencil?: boolean;
  77339. alpha?: boolean;
  77340. multiview?: boolean;
  77341. framebufferScaleFactor?: number;
  77342. }
  77343. declare class XRWebGLLayer {
  77344. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77345. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77346. readonly antialias: boolean;
  77347. readonly framebuffer: WebGLFramebuffer;
  77348. readonly framebufferWidth: number;
  77349. readonly framebufferHeight: number;
  77350. readonly ignoreDepthValues: boolean;
  77351. getViewport: (view: XRView) => XRViewport;
  77352. }
  77353. // tslint:disable-next-line no-empty-interface
  77354. interface XRSpace extends EventTarget {}
  77355. interface XRRenderState {
  77356. readonly baseLayer?: XRWebGLLayer;
  77357. readonly depthFar: number;
  77358. readonly depthNear: number;
  77359. readonly inlineVerticalFieldOfView?: number;
  77360. }
  77361. interface XRRenderStateInit extends XRRenderState {
  77362. baseLayer: XRWebGLLayer;
  77363. depthFar: number;
  77364. depthNear: number;
  77365. inlineVerticalFieldOfView?: number;
  77366. layers?: XRLayer[];
  77367. }
  77368. interface XRReferenceSpace extends XRSpace {
  77369. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77370. onreset: XREventHandler;
  77371. }
  77372. interface XRBoundedReferenceSpace extends XRSpace {
  77373. readonly boundsGeometry: DOMPointReadOnly[];
  77374. }
  77375. interface XRInputSource {
  77376. readonly handedness: XRHandedness;
  77377. readonly targetRayMode: XRTargetRayMode;
  77378. readonly targetRaySpace: XRSpace;
  77379. readonly gripSpace?: XRSpace;
  77380. readonly gamepad?: Gamepad;
  77381. readonly profiles: Array<string>;
  77382. readonly hand?: XRHand;
  77383. }
  77384. interface XRPose {
  77385. readonly transform: XRRigidTransform;
  77386. readonly emulatedPosition: boolean;
  77387. }
  77388. interface XRFrame {
  77389. readonly session: XRSession;
  77390. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77391. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77392. // AR
  77393. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77394. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77395. // Anchors
  77396. trackedAnchors?: XRAnchorSet;
  77397. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77398. // Planes
  77399. worldInformation?: {
  77400. detectedPlanes?: XRPlaneSet;
  77401. };
  77402. // Hand tracking
  77403. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77404. }
  77405. interface XRInputSourceEvent extends Event {
  77406. readonly frame: XRFrame;
  77407. readonly inputSource: XRInputSource;
  77408. }
  77409. type XRInputSourceArray = XRInputSource[];
  77410. interface XRSession {
  77411. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77412. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77413. /**
  77414. * Returns a list of this session's XRInputSources, each representing an input device
  77415. * used to control the camera and/or scene.
  77416. */
  77417. readonly inputSources: Array<XRInputSource>;
  77418. /**
  77419. * object which contains options affecting how the imagery is rendered.
  77420. * This includes things such as the near and far clipping planes
  77421. */
  77422. readonly renderState: XRRenderState;
  77423. readonly visibilityState: XRVisibilityState;
  77424. /**
  77425. * Removes a callback from the animation frame painting callback from
  77426. * XRSession's set of animation frame rendering callbacks, given the
  77427. * identifying handle returned by a previous call to requestAnimationFrame().
  77428. */
  77429. cancelAnimationFrame: (handle: number) => void;
  77430. /**
  77431. * Ends the WebXR session. Returns a promise which resolves when the
  77432. * session has been shut down.
  77433. */
  77434. end(): Promise<void>;
  77435. /**
  77436. * Schedules the specified method to be called the next time the user agent
  77437. * is working on rendering an animation frame for the WebXR device. Returns an
  77438. * integer value which can be used to identify the request for the purposes of
  77439. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77440. * to the Window.requestAnimationFrame() method.
  77441. */
  77442. requestAnimationFrame: XRFrameRequestCallback;
  77443. /**
  77444. * Requests that a new XRReferenceSpace of the specified type be created.
  77445. * Returns a promise which resolves with the XRReferenceSpace or
  77446. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77447. * the requested space type isn't supported by the device.
  77448. */
  77449. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77450. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77451. onend: XREventHandler;
  77452. oninputsourceschange: XREventHandler;
  77453. onselect: XREventHandler;
  77454. onselectstart: XREventHandler;
  77455. onselectend: XREventHandler;
  77456. onsqueeze: XREventHandler;
  77457. onsqueezestart: XREventHandler;
  77458. onsqueezeend: XREventHandler;
  77459. onvisibilitychange: XREventHandler;
  77460. // hit test
  77461. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77462. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77463. // legacy AR hit test
  77464. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77465. // legacy plane detection
  77466. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77467. }
  77468. interface XRViewerPose extends XRPose {
  77469. readonly views: Array<XRView>;
  77470. }
  77471. declare class XRRigidTransform {
  77472. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77473. position: DOMPointReadOnly;
  77474. orientation: DOMPointReadOnly;
  77475. matrix: Float32Array;
  77476. inverse: XRRigidTransform;
  77477. }
  77478. interface XRView {
  77479. readonly eye: XREye;
  77480. readonly projectionMatrix: Float32Array;
  77481. readonly transform: XRRigidTransform;
  77482. readonly recommendedViewportScale?: number;
  77483. requestViewportScale(scale: number): void;
  77484. }
  77485. interface XRInputSourceChangeEvent extends Event {
  77486. session: XRSession;
  77487. removed: Array<XRInputSource>;
  77488. added: Array<XRInputSource>;
  77489. }
  77490. // Experimental/Draft features
  77491. declare class XRRay {
  77492. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77493. origin: DOMPointReadOnly;
  77494. direction: DOMPointReadOnly;
  77495. matrix: Float32Array;
  77496. }
  77497. declare enum XRHitTestTrackableType {
  77498. "point",
  77499. "plane",
  77500. "mesh",
  77501. }
  77502. interface XRHitResult {
  77503. hitMatrix: Float32Array;
  77504. }
  77505. interface XRTransientInputHitTestResult {
  77506. readonly inputSource: XRInputSource;
  77507. readonly results: Array<XRHitTestResult>;
  77508. }
  77509. interface XRHitTestResult {
  77510. getPose(baseSpace: XRSpace): XRPose | undefined;
  77511. // When anchor system is enabled
  77512. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77513. }
  77514. interface XRHitTestSource {
  77515. cancel(): void;
  77516. }
  77517. interface XRTransientInputHitTestSource {
  77518. cancel(): void;
  77519. }
  77520. interface XRHitTestOptionsInit {
  77521. space: XRSpace;
  77522. entityTypes?: Array<XRHitTestTrackableType>;
  77523. offsetRay?: XRRay;
  77524. }
  77525. interface XRTransientInputHitTestOptionsInit {
  77526. profile: string;
  77527. entityTypes?: Array<XRHitTestTrackableType>;
  77528. offsetRay?: XRRay;
  77529. }
  77530. interface XRAnchor {
  77531. anchorSpace: XRSpace;
  77532. delete(): void;
  77533. }
  77534. interface XRPlane {
  77535. orientation: "Horizontal" | "Vertical";
  77536. planeSpace: XRSpace;
  77537. polygon: Array<DOMPointReadOnly>;
  77538. lastChangedTime: number;
  77539. }
  77540. interface XRJointSpace extends XRSpace {}
  77541. interface XRJointPose extends XRPose {
  77542. radius: number | undefined;
  77543. }
  77544. interface XRHand extends Iterable<XRJointSpace> {
  77545. readonly length: number;
  77546. [index: number]: XRJointSpace;
  77547. readonly WRIST: number;
  77548. readonly THUMB_METACARPAL: number;
  77549. readonly THUMB_PHALANX_PROXIMAL: number;
  77550. readonly THUMB_PHALANX_DISTAL: number;
  77551. readonly THUMB_PHALANX_TIP: number;
  77552. readonly INDEX_METACARPAL: number;
  77553. readonly INDEX_PHALANX_PROXIMAL: number;
  77554. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77555. readonly INDEX_PHALANX_DISTAL: number;
  77556. readonly INDEX_PHALANX_TIP: number;
  77557. readonly MIDDLE_METACARPAL: number;
  77558. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77559. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77560. readonly MIDDLE_PHALANX_DISTAL: number;
  77561. readonly MIDDLE_PHALANX_TIP: number;
  77562. readonly RING_METACARPAL: number;
  77563. readonly RING_PHALANX_PROXIMAL: number;
  77564. readonly RING_PHALANX_INTERMEDIATE: number;
  77565. readonly RING_PHALANX_DISTAL: number;
  77566. readonly RING_PHALANX_TIP: number;
  77567. readonly LITTLE_METACARPAL: number;
  77568. readonly LITTLE_PHALANX_PROXIMAL: number;
  77569. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77570. readonly LITTLE_PHALANX_DISTAL: number;
  77571. readonly LITTLE_PHALANX_TIP: number;
  77572. }
  77573. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77574. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77575. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77576. interface XRSession {
  77577. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77578. }
  77579. interface XRFrame {
  77580. featurePointCloud? : Array<number>;
  77581. }
  77582. /**
  77583. * @ignore
  77584. */
  77585. declare module BABYLON.GLTF2.Exporter {
  77586. }
  77587. /**
  77588. * @ignore
  77589. */
  77590. declare module BABYLON.GLTF1 {
  77591. }
  77592. declare module BABYLON.GUI {
  77593. /**
  77594. * Class used to specific a value and its associated unit
  77595. */
  77596. export class ValueAndUnit {
  77597. /** defines the unit to store */
  77598. unit: number;
  77599. /** defines a boolean indicating if the value can be negative */
  77600. negativeValueAllowed: boolean;
  77601. private _value;
  77602. private _originalUnit;
  77603. /**
  77604. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77605. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77606. */
  77607. ignoreAdaptiveScaling: boolean;
  77608. /**
  77609. * Creates a new ValueAndUnit
  77610. * @param value defines the value to store
  77611. * @param unit defines the unit to store
  77612. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77613. */
  77614. constructor(value: number,
  77615. /** defines the unit to store */
  77616. unit?: number,
  77617. /** defines a boolean indicating if the value can be negative */
  77618. negativeValueAllowed?: boolean);
  77619. /** Gets a boolean indicating if the value is a percentage */
  77620. get isPercentage(): boolean;
  77621. /** Gets a boolean indicating if the value is store as pixel */
  77622. get isPixel(): boolean;
  77623. /** Gets direct internal value */
  77624. get internalValue(): number;
  77625. /**
  77626. * Gets value as pixel
  77627. * @param host defines the root host
  77628. * @param refValue defines the reference value for percentages
  77629. * @returns the value as pixel
  77630. */
  77631. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77632. /**
  77633. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77634. * @param value defines the value to store
  77635. * @param unit defines the unit to store
  77636. * @returns the current ValueAndUnit
  77637. */
  77638. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77639. /**
  77640. * Gets the value accordingly to its unit
  77641. * @param host defines the root host
  77642. * @returns the value
  77643. */
  77644. getValue(host: AdvancedDynamicTexture): number;
  77645. /**
  77646. * Gets a string representation of the value
  77647. * @param host defines the root host
  77648. * @param decimals defines an optional number of decimals to display
  77649. * @returns a string
  77650. */
  77651. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77652. /**
  77653. * Store a value parsed from a string
  77654. * @param source defines the source string
  77655. * @returns true if the value was successfully parsed
  77656. */
  77657. fromString(source: string | number): boolean;
  77658. private static _Regex;
  77659. private static _UNITMODE_PERCENTAGE;
  77660. private static _UNITMODE_PIXEL;
  77661. /** UNITMODE_PERCENTAGE */
  77662. static get UNITMODE_PERCENTAGE(): number;
  77663. /** UNITMODE_PIXEL */
  77664. static get UNITMODE_PIXEL(): number;
  77665. }
  77666. }
  77667. declare module BABYLON.GUI {
  77668. /**
  77669. * Define a style used by control to automatically setup properties based on a template.
  77670. * Only support font related properties so far
  77671. */
  77672. export class Style implements BABYLON.IDisposable {
  77673. private _fontFamily;
  77674. private _fontStyle;
  77675. private _fontWeight;
  77676. /** @hidden */
  77677. _host: AdvancedDynamicTexture;
  77678. /** @hidden */
  77679. _fontSize: ValueAndUnit;
  77680. /**
  77681. * BABYLON.Observable raised when the style values are changed
  77682. */
  77683. onChangedObservable: BABYLON.Observable<Style>;
  77684. /**
  77685. * Creates a new style object
  77686. * @param host defines the AdvancedDynamicTexture which hosts this style
  77687. */
  77688. constructor(host: AdvancedDynamicTexture);
  77689. /**
  77690. * Gets or sets the font size
  77691. */
  77692. get fontSize(): string | number;
  77693. set fontSize(value: string | number);
  77694. /**
  77695. * Gets or sets the font family
  77696. */
  77697. get fontFamily(): string;
  77698. set fontFamily(value: string);
  77699. /**
  77700. * Gets or sets the font style
  77701. */
  77702. get fontStyle(): string;
  77703. set fontStyle(value: string);
  77704. /** Gets or sets font weight */
  77705. get fontWeight(): string;
  77706. set fontWeight(value: string);
  77707. /** Dispose all associated resources */
  77708. dispose(): void;
  77709. }
  77710. }
  77711. declare module BABYLON.GUI {
  77712. /**
  77713. * Class used to transport BABYLON.Vector2 information for pointer events
  77714. */
  77715. export class Vector2WithInfo extends BABYLON.Vector2 {
  77716. /** defines the current mouse button index */
  77717. buttonIndex: number;
  77718. /**
  77719. * Creates a new Vector2WithInfo
  77720. * @param source defines the vector2 data to transport
  77721. * @param buttonIndex defines the current mouse button index
  77722. */
  77723. constructor(source: BABYLON.Vector2,
  77724. /** defines the current mouse button index */
  77725. buttonIndex?: number);
  77726. }
  77727. /** Class used to provide 2D matrix features */
  77728. export class Matrix2D {
  77729. /** Gets the internal array of 6 floats used to store matrix data */
  77730. m: Float32Array;
  77731. /**
  77732. * Creates a new matrix
  77733. * @param m00 defines value for (0, 0)
  77734. * @param m01 defines value for (0, 1)
  77735. * @param m10 defines value for (1, 0)
  77736. * @param m11 defines value for (1, 1)
  77737. * @param m20 defines value for (2, 0)
  77738. * @param m21 defines value for (2, 1)
  77739. */
  77740. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77741. /**
  77742. * Fills the matrix from direct values
  77743. * @param m00 defines value for (0, 0)
  77744. * @param m01 defines value for (0, 1)
  77745. * @param m10 defines value for (1, 0)
  77746. * @param m11 defines value for (1, 1)
  77747. * @param m20 defines value for (2, 0)
  77748. * @param m21 defines value for (2, 1)
  77749. * @returns the current modified matrix
  77750. */
  77751. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77752. /**
  77753. * Gets matrix determinant
  77754. * @returns the determinant
  77755. */
  77756. determinant(): number;
  77757. /**
  77758. * Inverses the matrix and stores it in a target matrix
  77759. * @param result defines the target matrix
  77760. * @returns the current matrix
  77761. */
  77762. invertToRef(result: Matrix2D): Matrix2D;
  77763. /**
  77764. * Multiplies the current matrix with another one
  77765. * @param other defines the second operand
  77766. * @param result defines the target matrix
  77767. * @returns the current matrix
  77768. */
  77769. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77770. /**
  77771. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77772. * @param x defines the x coordinate to transform
  77773. * @param y defines the x coordinate to transform
  77774. * @param result defines the target vector2
  77775. * @returns the current matrix
  77776. */
  77777. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77778. /**
  77779. * Creates an identity matrix
  77780. * @returns a new matrix
  77781. */
  77782. static Identity(): Matrix2D;
  77783. /**
  77784. * Creates a translation matrix and stores it in a target matrix
  77785. * @param x defines the x coordinate of the translation
  77786. * @param y defines the y coordinate of the translation
  77787. * @param result defines the target matrix
  77788. */
  77789. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77790. /**
  77791. * Creates a scaling matrix and stores it in a target matrix
  77792. * @param x defines the x coordinate of the scaling
  77793. * @param y defines the y coordinate of the scaling
  77794. * @param result defines the target matrix
  77795. */
  77796. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77797. /**
  77798. * Creates a rotation matrix and stores it in a target matrix
  77799. * @param angle defines the rotation angle
  77800. * @param result defines the target matrix
  77801. */
  77802. static RotationToRef(angle: number, result: Matrix2D): void;
  77803. private static _TempPreTranslationMatrix;
  77804. private static _TempPostTranslationMatrix;
  77805. private static _TempRotationMatrix;
  77806. private static _TempScalingMatrix;
  77807. private static _TempCompose0;
  77808. private static _TempCompose1;
  77809. private static _TempCompose2;
  77810. /**
  77811. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77812. * @param tx defines the x coordinate of the translation
  77813. * @param ty defines the y coordinate of the translation
  77814. * @param angle defines the rotation angle
  77815. * @param scaleX defines the x coordinate of the scaling
  77816. * @param scaleY defines the y coordinate of the scaling
  77817. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77818. * @param result defines the target matrix
  77819. */
  77820. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77821. }
  77822. }
  77823. declare module BABYLON.GUI {
  77824. /**
  77825. * Class used to store 2D control sizes
  77826. */
  77827. export class Measure {
  77828. /** defines left coordinate */
  77829. left: number;
  77830. /** defines top coordinate */
  77831. top: number;
  77832. /** defines width dimension */
  77833. width: number;
  77834. /** defines height dimension */
  77835. height: number;
  77836. /**
  77837. * Creates a new measure
  77838. * @param left defines left coordinate
  77839. * @param top defines top coordinate
  77840. * @param width defines width dimension
  77841. * @param height defines height dimension
  77842. */
  77843. constructor(
  77844. /** defines left coordinate */
  77845. left: number,
  77846. /** defines top coordinate */
  77847. top: number,
  77848. /** defines width dimension */
  77849. width: number,
  77850. /** defines height dimension */
  77851. height: number);
  77852. /**
  77853. * Copy from another measure
  77854. * @param other defines the other measure to copy from
  77855. */
  77856. copyFrom(other: Measure): void;
  77857. /**
  77858. * Copy from a group of 4 floats
  77859. * @param left defines left coordinate
  77860. * @param top defines top coordinate
  77861. * @param width defines width dimension
  77862. * @param height defines height dimension
  77863. */
  77864. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77865. /**
  77866. * Computes the axis aligned bounding box measure for two given measures
  77867. * @param a Input measure
  77868. * @param b Input measure
  77869. * @param result the resulting bounding measure
  77870. */
  77871. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77872. /**
  77873. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77874. * @param transform the matrix to transform the measure before computing the AABB
  77875. * @param addX number to add to left
  77876. * @param addY number to add to top
  77877. * @param addWidth number to add to width
  77878. * @param addHeight number to add to height
  77879. * @param result the resulting AABB
  77880. */
  77881. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77882. /**
  77883. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77884. * @param transform the matrix to transform the measure before computing the AABB
  77885. * @param result the resulting AABB
  77886. */
  77887. transformToRef(transform: Matrix2D, result: Measure): void;
  77888. /**
  77889. * Check equality between this measure and another one
  77890. * @param other defines the other measures
  77891. * @returns true if both measures are equals
  77892. */
  77893. isEqualsTo(other: Measure): boolean;
  77894. /**
  77895. * Creates an empty measure
  77896. * @returns a new measure
  77897. */
  77898. static Empty(): Measure;
  77899. }
  77900. }
  77901. declare module BABYLON.GUI {
  77902. /**
  77903. * Interface used to define a control that can receive focus
  77904. */
  77905. export interface IFocusableControl {
  77906. /**
  77907. * Function called when the control receives the focus
  77908. */
  77909. onFocus(): void;
  77910. /**
  77911. * Function called when the control loses the focus
  77912. */
  77913. onBlur(): void;
  77914. /**
  77915. * Function called to let the control handle keyboard events
  77916. * @param evt defines the current keyboard event
  77917. */
  77918. processKeyboard(evt: KeyboardEvent): void;
  77919. /**
  77920. * Function called to get the list of controls that should not steal the focus from this control
  77921. * @returns an array of controls
  77922. */
  77923. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77924. }
  77925. /**
  77926. * Class used to create texture to support 2D GUI elements
  77927. * @see https://doc.babylonjs.com/how_to/gui
  77928. */
  77929. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77930. private _isDirty;
  77931. private _renderObserver;
  77932. private _resizeObserver;
  77933. private _preKeyboardObserver;
  77934. private _pointerMoveObserver;
  77935. private _pointerObserver;
  77936. private _canvasPointerOutObserver;
  77937. private _canvasBlurObserver;
  77938. private _background;
  77939. /** @hidden */
  77940. _rootContainer: Container;
  77941. /** @hidden */
  77942. _lastPickedControl: Control;
  77943. /** @hidden */
  77944. _lastControlOver: {
  77945. [pointerId: number]: Control;
  77946. };
  77947. /** @hidden */
  77948. _lastControlDown: {
  77949. [pointerId: number]: Control;
  77950. };
  77951. /** @hidden */
  77952. _capturingControl: {
  77953. [pointerId: number]: Control;
  77954. };
  77955. /** @hidden */
  77956. _shouldBlockPointer: boolean;
  77957. /** @hidden */
  77958. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77959. /** @hidden */
  77960. _linkedControls: Control[];
  77961. private _isFullscreen;
  77962. private _fullscreenViewport;
  77963. private _idealWidth;
  77964. private _idealHeight;
  77965. private _useSmallestIdeal;
  77966. private _renderAtIdealSize;
  77967. private _focusedControl;
  77968. private _blockNextFocusCheck;
  77969. private _renderScale;
  77970. private _rootElement;
  77971. private _cursorChanged;
  77972. private _defaultMousePointerId;
  77973. /** @hidden */
  77974. _numLayoutCalls: number;
  77975. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77976. get numLayoutCalls(): number;
  77977. /** @hidden */
  77978. _numRenderCalls: number;
  77979. /** Gets the number of render calls made the last time the ADT has been rendered */
  77980. get numRenderCalls(): number;
  77981. /**
  77982. * Define type to string to ensure compatibility across browsers
  77983. * Safari doesn't support DataTransfer constructor
  77984. */
  77985. private _clipboardData;
  77986. /**
  77987. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77988. */
  77989. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77990. /**
  77991. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77992. */
  77993. onControlPickedObservable: BABYLON.Observable<Control>;
  77994. /**
  77995. * BABYLON.Observable event triggered before layout is evaluated
  77996. */
  77997. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77998. /**
  77999. * BABYLON.Observable event triggered after the layout was evaluated
  78000. */
  78001. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78002. /**
  78003. * BABYLON.Observable event triggered before the texture is rendered
  78004. */
  78005. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78006. /**
  78007. * BABYLON.Observable event triggered after the texture was rendered
  78008. */
  78009. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78010. /**
  78011. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78012. */
  78013. premulAlpha: boolean;
  78014. /**
  78015. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78016. * Useful when you want more antialiasing
  78017. */
  78018. get renderScale(): number;
  78019. set renderScale(value: number);
  78020. /** Gets or sets the background color */
  78021. get background(): string;
  78022. set background(value: string);
  78023. /**
  78024. * Gets or sets the ideal width used to design controls.
  78025. * The GUI will then rescale everything accordingly
  78026. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78027. */
  78028. get idealWidth(): number;
  78029. set idealWidth(value: number);
  78030. /**
  78031. * Gets or sets the ideal height used to design controls.
  78032. * The GUI will then rescale everything accordingly
  78033. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78034. */
  78035. get idealHeight(): number;
  78036. set idealHeight(value: number);
  78037. /**
  78038. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78039. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78040. */
  78041. get useSmallestIdeal(): boolean;
  78042. set useSmallestIdeal(value: boolean);
  78043. /**
  78044. * Gets or sets a boolean indicating if adaptive scaling must be used
  78045. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78046. */
  78047. get renderAtIdealSize(): boolean;
  78048. set renderAtIdealSize(value: boolean);
  78049. /**
  78050. * Gets the ratio used when in "ideal mode"
  78051. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78052. * */
  78053. get idealRatio(): number;
  78054. /**
  78055. * Gets the underlying layer used to render the texture when in fullscreen mode
  78056. */
  78057. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78058. /**
  78059. * Gets the root container control
  78060. */
  78061. get rootContainer(): Container;
  78062. /**
  78063. * Returns an array containing the root container.
  78064. * This is mostly used to let the Inspector introspects the ADT
  78065. * @returns an array containing the rootContainer
  78066. */
  78067. getChildren(): Array<Container>;
  78068. /**
  78069. * Will return all controls that are inside this texture
  78070. * @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
  78071. * @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
  78072. * @return all child controls
  78073. */
  78074. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78075. /**
  78076. * Gets or sets the current focused control
  78077. */
  78078. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78079. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78080. /**
  78081. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78082. */
  78083. get isForeground(): boolean;
  78084. set isForeground(value: boolean);
  78085. /**
  78086. * Gets or set information about clipboardData
  78087. */
  78088. get clipboardData(): string;
  78089. set clipboardData(value: string);
  78090. /**
  78091. * Creates a new AdvancedDynamicTexture
  78092. * @param name defines the name of the texture
  78093. * @param width defines the width of the texture
  78094. * @param height defines the height of the texture
  78095. * @param scene defines the hosting scene
  78096. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78097. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78098. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78099. */
  78100. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78101. /**
  78102. * Get the current class name of the texture useful for serialization or dynamic coding.
  78103. * @returns "AdvancedDynamicTexture"
  78104. */
  78105. getClassName(): string;
  78106. /**
  78107. * Function used to execute a function on all controls
  78108. * @param func defines the function to execute
  78109. * @param container defines the container where controls belong. If null the root container will be used
  78110. */
  78111. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78112. private _useInvalidateRectOptimization;
  78113. /**
  78114. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78115. */
  78116. get useInvalidateRectOptimization(): boolean;
  78117. set useInvalidateRectOptimization(value: boolean);
  78118. private _invalidatedRectangle;
  78119. /**
  78120. * Invalidates a rectangle area on the gui texture
  78121. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78122. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78123. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78124. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78125. */
  78126. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78127. /**
  78128. * Marks the texture as dirty forcing a complete update
  78129. */
  78130. markAsDirty(): void;
  78131. /**
  78132. * Helper function used to create a new style
  78133. * @returns a new style
  78134. * @see https://doc.babylonjs.com/how_to/gui#styles
  78135. */
  78136. createStyle(): Style;
  78137. /**
  78138. * Adds a new control to the root container
  78139. * @param control defines the control to add
  78140. * @returns the current texture
  78141. */
  78142. addControl(control: Control): AdvancedDynamicTexture;
  78143. /**
  78144. * Removes a control from the root container
  78145. * @param control defines the control to remove
  78146. * @returns the current texture
  78147. */
  78148. removeControl(control: Control): AdvancedDynamicTexture;
  78149. /**
  78150. * Release all resources
  78151. */
  78152. dispose(): void;
  78153. private _onResize;
  78154. /** @hidden */
  78155. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78156. /**
  78157. * Get screen coordinates for a vector3
  78158. * @param position defines the position to project
  78159. * @param worldMatrix defines the world matrix to use
  78160. * @returns the projected position
  78161. */
  78162. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78163. private _checkUpdate;
  78164. private _clearMeasure;
  78165. private _render;
  78166. /** @hidden */
  78167. _changeCursor(cursor: string): void;
  78168. /** @hidden */
  78169. _registerLastControlDown(control: Control, pointerId: number): void;
  78170. private _doPicking;
  78171. /** @hidden */
  78172. _cleanControlAfterRemovalFromList(list: {
  78173. [pointerId: number]: Control;
  78174. }, control: Control): void;
  78175. /** @hidden */
  78176. _cleanControlAfterRemoval(control: Control): void;
  78177. /** Attach to all scene events required to support pointer events */
  78178. attach(): void;
  78179. /** @hidden */
  78180. private onClipboardCopy;
  78181. /** @hidden */
  78182. private onClipboardCut;
  78183. /** @hidden */
  78184. private onClipboardPaste;
  78185. /**
  78186. * Register the clipboard Events onto the canvas
  78187. */
  78188. registerClipboardEvents(): void;
  78189. /**
  78190. * Unregister the clipboard Events from the canvas
  78191. */
  78192. unRegisterClipboardEvents(): void;
  78193. /**
  78194. * Connect the texture to a hosting mesh to enable interactions
  78195. * @param mesh defines the mesh to attach to
  78196. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78197. */
  78198. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78199. /**
  78200. * Move the focus to a specific control
  78201. * @param control defines the control which will receive the focus
  78202. */
  78203. moveFocusToControl(control: IFocusableControl): void;
  78204. private _manageFocus;
  78205. private _attachToOnPointerOut;
  78206. private _attachToOnBlur;
  78207. /**
  78208. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78209. * @param mesh defines the mesh which will receive the texture
  78210. * @param width defines the texture width (1024 by default)
  78211. * @param height defines the texture height (1024 by default)
  78212. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78213. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78214. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78215. * @returns a new AdvancedDynamicTexture
  78216. */
  78217. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78218. /**
  78219. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78220. * In this mode the texture will rely on a layer for its rendering.
  78221. * This allows it to be treated like any other layer.
  78222. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78223. * LayerMask is set through advancedTexture.layer.layerMask
  78224. * @param name defines name for the texture
  78225. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78226. * @param scene defines the hsoting scene
  78227. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78228. * @returns a new AdvancedDynamicTexture
  78229. */
  78230. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78231. }
  78232. }
  78233. declare module BABYLON.GUI {
  78234. /**
  78235. * Root class used for all 2D controls
  78236. * @see https://doc.babylonjs.com/how_to/gui#controls
  78237. */
  78238. export class Control {
  78239. /** defines the name of the control */
  78240. name?: string | undefined;
  78241. /**
  78242. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78243. */
  78244. static AllowAlphaInheritance: boolean;
  78245. private _alpha;
  78246. private _alphaSet;
  78247. private _zIndex;
  78248. /** @hidden */
  78249. _host: AdvancedDynamicTexture;
  78250. /** Gets or sets the control parent */
  78251. parent: BABYLON.Nullable<Container>;
  78252. /** @hidden */
  78253. _currentMeasure: Measure;
  78254. private _fontFamily;
  78255. private _fontStyle;
  78256. private _fontWeight;
  78257. private _fontSize;
  78258. private _font;
  78259. /** @hidden */
  78260. _width: ValueAndUnit;
  78261. /** @hidden */
  78262. _height: ValueAndUnit;
  78263. /** @hidden */
  78264. protected _fontOffset: {
  78265. ascent: number;
  78266. height: number;
  78267. descent: number;
  78268. };
  78269. private _color;
  78270. private _style;
  78271. private _styleObserver;
  78272. /** @hidden */
  78273. protected _horizontalAlignment: number;
  78274. /** @hidden */
  78275. protected _verticalAlignment: number;
  78276. /** @hidden */
  78277. protected _isDirty: boolean;
  78278. /** @hidden */
  78279. protected _wasDirty: boolean;
  78280. /** @hidden */
  78281. _tempParentMeasure: Measure;
  78282. /** @hidden */
  78283. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78284. /** @hidden */
  78285. protected _cachedParentMeasure: Measure;
  78286. private _paddingLeft;
  78287. private _paddingRight;
  78288. private _paddingTop;
  78289. private _paddingBottom;
  78290. /** @hidden */
  78291. _left: ValueAndUnit;
  78292. /** @hidden */
  78293. _top: ValueAndUnit;
  78294. private _scaleX;
  78295. private _scaleY;
  78296. private _rotation;
  78297. private _transformCenterX;
  78298. private _transformCenterY;
  78299. /** @hidden */
  78300. _transformMatrix: Matrix2D;
  78301. /** @hidden */
  78302. protected _invertTransformMatrix: Matrix2D;
  78303. /** @hidden */
  78304. protected _transformedPosition: BABYLON.Vector2;
  78305. private _isMatrixDirty;
  78306. private _cachedOffsetX;
  78307. private _cachedOffsetY;
  78308. private _isVisible;
  78309. private _isHighlighted;
  78310. /** @hidden */
  78311. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78312. private _fontSet;
  78313. private _dummyVector2;
  78314. private _downCount;
  78315. private _enterCount;
  78316. private _doNotRender;
  78317. private _downPointerIds;
  78318. protected _isEnabled: boolean;
  78319. protected _disabledColor: string;
  78320. protected _disabledColorItem: string;
  78321. /** @hidden */
  78322. protected _rebuildLayout: boolean;
  78323. /** @hidden */
  78324. _customData: any;
  78325. /** @hidden */
  78326. _isClipped: boolean;
  78327. /** @hidden */
  78328. _automaticSize: boolean;
  78329. /** @hidden */
  78330. _tag: any;
  78331. /**
  78332. * 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
  78333. */
  78334. uniqueId: number;
  78335. /**
  78336. * Gets or sets an object used to store user defined information for the node
  78337. */
  78338. metadata: any;
  78339. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78340. isHitTestVisible: boolean;
  78341. /** Gets or sets a boolean indicating if the control can block pointer events */
  78342. isPointerBlocker: boolean;
  78343. /** Gets or sets a boolean indicating if the control can be focusable */
  78344. isFocusInvisible: boolean;
  78345. /**
  78346. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78347. * 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
  78348. */
  78349. clipChildren: boolean;
  78350. /**
  78351. * Gets or sets a boolean indicating that control content must be clipped
  78352. * 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
  78353. */
  78354. clipContent: boolean;
  78355. /**
  78356. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78357. */
  78358. useBitmapCache: boolean;
  78359. private _cacheData;
  78360. private _shadowOffsetX;
  78361. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78362. get shadowOffsetX(): number;
  78363. set shadowOffsetX(value: number);
  78364. private _shadowOffsetY;
  78365. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78366. get shadowOffsetY(): number;
  78367. set shadowOffsetY(value: number);
  78368. private _shadowBlur;
  78369. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78370. get shadowBlur(): number;
  78371. set shadowBlur(value: number);
  78372. private _shadowColor;
  78373. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78374. get shadowColor(): string;
  78375. set shadowColor(value: string);
  78376. /** Gets or sets the cursor to use when the control is hovered */
  78377. hoverCursor: string;
  78378. /** @hidden */
  78379. protected _linkOffsetX: ValueAndUnit;
  78380. /** @hidden */
  78381. protected _linkOffsetY: ValueAndUnit;
  78382. /** Gets the control type name */
  78383. get typeName(): string;
  78384. /**
  78385. * Get the current class name of the control.
  78386. * @returns current class name
  78387. */
  78388. getClassName(): string;
  78389. /**
  78390. * An event triggered when pointer wheel is scrolled
  78391. */
  78392. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78393. /**
  78394. * An event triggered when the pointer move over the control.
  78395. */
  78396. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78397. /**
  78398. * An event triggered when the pointer move out of the control.
  78399. */
  78400. onPointerOutObservable: BABYLON.Observable<Control>;
  78401. /**
  78402. * An event triggered when the pointer taps the control
  78403. */
  78404. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78405. /**
  78406. * An event triggered when pointer up
  78407. */
  78408. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78409. /**
  78410. * An event triggered when a control is clicked on
  78411. */
  78412. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78413. /**
  78414. * An event triggered when pointer enters the control
  78415. */
  78416. onPointerEnterObservable: BABYLON.Observable<Control>;
  78417. /**
  78418. * An event triggered when the control is marked as dirty
  78419. */
  78420. onDirtyObservable: BABYLON.Observable<Control>;
  78421. /**
  78422. * An event triggered before drawing the control
  78423. */
  78424. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78425. /**
  78426. * An event triggered after the control was drawn
  78427. */
  78428. onAfterDrawObservable: BABYLON.Observable<Control>;
  78429. /**
  78430. * An event triggered when the control has been disposed
  78431. */
  78432. onDisposeObservable: BABYLON.Observable<Control>;
  78433. /**
  78434. * Get the hosting AdvancedDynamicTexture
  78435. */
  78436. get host(): AdvancedDynamicTexture;
  78437. /** Gets or set information about font offsets (used to render and align text) */
  78438. get fontOffset(): {
  78439. ascent: number;
  78440. height: number;
  78441. descent: number;
  78442. };
  78443. set fontOffset(offset: {
  78444. ascent: number;
  78445. height: number;
  78446. descent: number;
  78447. });
  78448. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78449. get alpha(): number;
  78450. set alpha(value: number);
  78451. /**
  78452. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78453. */
  78454. get isHighlighted(): boolean;
  78455. set isHighlighted(value: boolean);
  78456. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78457. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78458. */
  78459. get scaleX(): number;
  78460. set scaleX(value: number);
  78461. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78462. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78463. */
  78464. get scaleY(): number;
  78465. set scaleY(value: number);
  78466. /** Gets or sets the rotation angle (0 by default)
  78467. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78468. */
  78469. get rotation(): number;
  78470. set rotation(value: number);
  78471. /** Gets or sets the transformation center on Y axis (0 by default)
  78472. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78473. */
  78474. get transformCenterY(): number;
  78475. set transformCenterY(value: number);
  78476. /** Gets or sets the transformation center on X axis (0 by default)
  78477. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78478. */
  78479. get transformCenterX(): number;
  78480. set transformCenterX(value: number);
  78481. /**
  78482. * Gets or sets the horizontal alignment
  78483. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78484. */
  78485. get horizontalAlignment(): number;
  78486. set horizontalAlignment(value: number);
  78487. /**
  78488. * Gets or sets the vertical alignment
  78489. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78490. */
  78491. get verticalAlignment(): number;
  78492. set verticalAlignment(value: number);
  78493. /**
  78494. * Gets or sets a fixed ratio for this control.
  78495. * When different from 0, the ratio is used to compute the "second" dimension.
  78496. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78497. * second dimension is computed as first dimension * fixedRatio
  78498. */
  78499. fixedRatio: number;
  78500. private _fixedRatioMasterIsWidth;
  78501. /**
  78502. * Gets or sets control width
  78503. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78504. */
  78505. get width(): string | number;
  78506. set width(value: string | number);
  78507. /**
  78508. * Gets or sets the control width in pixel
  78509. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78510. */
  78511. get widthInPixels(): number;
  78512. set widthInPixels(value: number);
  78513. /**
  78514. * Gets or sets control height
  78515. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78516. */
  78517. get height(): string | number;
  78518. set height(value: string | number);
  78519. /**
  78520. * Gets or sets control height in pixel
  78521. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78522. */
  78523. get heightInPixels(): number;
  78524. set heightInPixels(value: number);
  78525. /** Gets or set font family */
  78526. get fontFamily(): string;
  78527. set fontFamily(value: string);
  78528. /** Gets or sets font style */
  78529. get fontStyle(): string;
  78530. set fontStyle(value: string);
  78531. /** Gets or sets font weight */
  78532. get fontWeight(): string;
  78533. set fontWeight(value: string);
  78534. /**
  78535. * Gets or sets style
  78536. * @see https://doc.babylonjs.com/how_to/gui#styles
  78537. */
  78538. get style(): BABYLON.Nullable<Style>;
  78539. set style(value: BABYLON.Nullable<Style>);
  78540. /** @hidden */
  78541. get _isFontSizeInPercentage(): boolean;
  78542. /** Gets or sets font size in pixels */
  78543. get fontSizeInPixels(): number;
  78544. set fontSizeInPixels(value: number);
  78545. /** Gets or sets font size */
  78546. get fontSize(): string | number;
  78547. set fontSize(value: string | number);
  78548. /** Gets or sets foreground color */
  78549. get color(): string;
  78550. set color(value: string);
  78551. /** Gets or sets z index which is used to reorder controls on the z axis */
  78552. get zIndex(): number;
  78553. set zIndex(value: number);
  78554. /** Gets or sets a boolean indicating if the control can be rendered */
  78555. get notRenderable(): boolean;
  78556. set notRenderable(value: boolean);
  78557. /** Gets or sets a boolean indicating if the control is visible */
  78558. get isVisible(): boolean;
  78559. set isVisible(value: boolean);
  78560. /** Gets a boolean indicating that the control needs to update its rendering */
  78561. get isDirty(): boolean;
  78562. /**
  78563. * Gets the current linked mesh (or null if none)
  78564. */
  78565. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78566. /**
  78567. * Gets or sets a value indicating the padding to use on the left of the control
  78568. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78569. */
  78570. get paddingLeft(): string | number;
  78571. set paddingLeft(value: string | number);
  78572. /**
  78573. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78574. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78575. */
  78576. get paddingLeftInPixels(): number;
  78577. set paddingLeftInPixels(value: number);
  78578. /**
  78579. * Gets or sets a value indicating the padding to use on the right of the control
  78580. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78581. */
  78582. get paddingRight(): string | number;
  78583. set paddingRight(value: string | number);
  78584. /**
  78585. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78586. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78587. */
  78588. get paddingRightInPixels(): number;
  78589. set paddingRightInPixels(value: number);
  78590. /**
  78591. * Gets or sets a value indicating the padding to use on the top of the control
  78592. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78593. */
  78594. get paddingTop(): string | number;
  78595. set paddingTop(value: string | number);
  78596. /**
  78597. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78598. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78599. */
  78600. get paddingTopInPixels(): number;
  78601. set paddingTopInPixels(value: number);
  78602. /**
  78603. * Gets or sets a value indicating the padding to use on the bottom of the control
  78604. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78605. */
  78606. get paddingBottom(): string | number;
  78607. set paddingBottom(value: string | number);
  78608. /**
  78609. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78610. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78611. */
  78612. get paddingBottomInPixels(): number;
  78613. set paddingBottomInPixels(value: number);
  78614. /**
  78615. * Gets or sets a value indicating the left coordinate of the control
  78616. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78617. */
  78618. get left(): string | number;
  78619. set left(value: string | number);
  78620. /**
  78621. * Gets or sets a value indicating the left coordinate in pixels of the control
  78622. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78623. */
  78624. get leftInPixels(): number;
  78625. set leftInPixels(value: number);
  78626. /**
  78627. * Gets or sets a value indicating the top coordinate of the control
  78628. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78629. */
  78630. get top(): string | number;
  78631. set top(value: string | number);
  78632. /**
  78633. * Gets or sets a value indicating the top coordinate in pixels of the control
  78634. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78635. */
  78636. get topInPixels(): number;
  78637. set topInPixels(value: number);
  78638. /**
  78639. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78640. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78641. */
  78642. get linkOffsetX(): string | number;
  78643. set linkOffsetX(value: string | number);
  78644. /**
  78645. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78646. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78647. */
  78648. get linkOffsetXInPixels(): number;
  78649. set linkOffsetXInPixels(value: number);
  78650. /**
  78651. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78652. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78653. */
  78654. get linkOffsetY(): string | number;
  78655. set linkOffsetY(value: string | number);
  78656. /**
  78657. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78658. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78659. */
  78660. get linkOffsetYInPixels(): number;
  78661. set linkOffsetYInPixels(value: number);
  78662. /** Gets the center coordinate on X axis */
  78663. get centerX(): number;
  78664. /** Gets the center coordinate on Y axis */
  78665. get centerY(): number;
  78666. /** Gets or sets if control is Enabled*/
  78667. get isEnabled(): boolean;
  78668. set isEnabled(value: boolean);
  78669. /** Gets or sets background color of control if it's disabled*/
  78670. get disabledColor(): string;
  78671. set disabledColor(value: string);
  78672. /** Gets or sets front color of control if it's disabled*/
  78673. get disabledColorItem(): string;
  78674. set disabledColorItem(value: string);
  78675. /**
  78676. * Creates a new control
  78677. * @param name defines the name of the control
  78678. */
  78679. constructor(
  78680. /** defines the name of the control */
  78681. name?: string | undefined);
  78682. /** @hidden */
  78683. protected _getTypeName(): string;
  78684. /**
  78685. * Gets the first ascendant in the hierarchy of the given type
  78686. * @param className defines the required type
  78687. * @returns the ascendant or null if not found
  78688. */
  78689. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78690. /** @hidden */
  78691. _resetFontCache(): void;
  78692. /**
  78693. * Determines if a container is an ascendant of the current control
  78694. * @param container defines the container to look for
  78695. * @returns true if the container is one of the ascendant of the control
  78696. */
  78697. isAscendant(container: Control): boolean;
  78698. /**
  78699. * Gets coordinates in local control space
  78700. * @param globalCoordinates defines the coordinates to transform
  78701. * @returns the new coordinates in local space
  78702. */
  78703. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78704. /**
  78705. * Gets coordinates in local control space
  78706. * @param globalCoordinates defines the coordinates to transform
  78707. * @param result defines the target vector2 where to store the result
  78708. * @returns the current control
  78709. */
  78710. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78711. /**
  78712. * Gets coordinates in parent local control space
  78713. * @param globalCoordinates defines the coordinates to transform
  78714. * @returns the new coordinates in parent local space
  78715. */
  78716. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78717. /**
  78718. * Move the current control to a vector3 position projected onto the screen.
  78719. * @param position defines the target position
  78720. * @param scene defines the hosting scene
  78721. */
  78722. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78723. /**
  78724. * Will store all controls that have this control as ascendant in a given array
  78725. * @param results defines the array where to store the descendants
  78726. * @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
  78727. * @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
  78728. */
  78729. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78730. /**
  78731. * Will return all controls that have this control as ascendant
  78732. * @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
  78733. * @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
  78734. * @return all child controls
  78735. */
  78736. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78737. /**
  78738. * Link current control with a target mesh
  78739. * @param mesh defines the mesh to link with
  78740. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78741. */
  78742. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78743. /** @hidden */
  78744. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78745. /** @hidden */
  78746. _offsetLeft(offset: number): void;
  78747. /** @hidden */
  78748. _offsetTop(offset: number): void;
  78749. /** @hidden */
  78750. _markMatrixAsDirty(): void;
  78751. /** @hidden */
  78752. _flagDescendantsAsMatrixDirty(): void;
  78753. /** @hidden */
  78754. _intersectsRect(rect: Measure): boolean;
  78755. /** @hidden */
  78756. protected invalidateRect(): void;
  78757. /** @hidden */
  78758. _markAsDirty(force?: boolean): void;
  78759. /** @hidden */
  78760. _markAllAsDirty(): void;
  78761. /** @hidden */
  78762. _link(host: AdvancedDynamicTexture): void;
  78763. /** @hidden */
  78764. protected _transform(context?: CanvasRenderingContext2D): void;
  78765. /** @hidden */
  78766. _renderHighlight(context: CanvasRenderingContext2D): void;
  78767. /** @hidden */
  78768. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78769. /** @hidden */
  78770. protected _applyStates(context: CanvasRenderingContext2D): void;
  78771. /** @hidden */
  78772. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78773. /** @hidden */
  78774. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78775. protected _evaluateClippingState(parentMeasure: Measure): void;
  78776. /** @hidden */
  78777. _measure(): void;
  78778. /** @hidden */
  78779. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78780. /** @hidden */
  78781. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78782. /** @hidden */
  78783. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78784. /** @hidden */
  78785. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78786. private static _ClipMeasure;
  78787. private _tmpMeasureA;
  78788. private _clip;
  78789. /** @hidden */
  78790. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78791. /** @hidden */
  78792. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78793. /**
  78794. * Tests if a given coordinates belong to the current control
  78795. * @param x defines x coordinate to test
  78796. * @param y defines y coordinate to test
  78797. * @returns true if the coordinates are inside the control
  78798. */
  78799. contains(x: number, y: number): boolean;
  78800. /** @hidden */
  78801. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78802. /** @hidden */
  78803. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78804. /** @hidden */
  78805. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78806. /** @hidden */
  78807. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78808. /** @hidden */
  78809. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78810. /** @hidden */
  78811. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78812. /** @hidden */
  78813. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78814. /** @hidden */
  78815. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78816. /** @hidden */
  78817. _onCanvasBlur(): void;
  78818. /** @hidden */
  78819. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78820. private _prepareFont;
  78821. /** Releases associated resources */
  78822. dispose(): void;
  78823. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78824. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78825. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78826. private static _VERTICAL_ALIGNMENT_TOP;
  78827. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78828. private static _VERTICAL_ALIGNMENT_CENTER;
  78829. /** HORIZONTAL_ALIGNMENT_LEFT */
  78830. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78831. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78832. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78833. /** HORIZONTAL_ALIGNMENT_CENTER */
  78834. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78835. /** VERTICAL_ALIGNMENT_TOP */
  78836. static get VERTICAL_ALIGNMENT_TOP(): number;
  78837. /** VERTICAL_ALIGNMENT_BOTTOM */
  78838. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78839. /** VERTICAL_ALIGNMENT_CENTER */
  78840. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78841. private static _FontHeightSizes;
  78842. /** @hidden */
  78843. static _GetFontOffset(font: string): {
  78844. ascent: number;
  78845. height: number;
  78846. descent: number;
  78847. };
  78848. /**
  78849. * Creates a stack panel that can be used to render headers
  78850. * @param control defines the control to associate with the header
  78851. * @param text defines the text of the header
  78852. * @param size defines the size of the header
  78853. * @param options defines options used to configure the header
  78854. * @returns a new StackPanel
  78855. * @ignore
  78856. * @hidden
  78857. */
  78858. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78859. isHorizontal: boolean;
  78860. controlFirst: boolean;
  78861. }) => any;
  78862. /** @hidden */
  78863. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78864. }
  78865. }
  78866. declare module BABYLON.GUI {
  78867. /**
  78868. * Root class for 2D containers
  78869. * @see https://doc.babylonjs.com/how_to/gui#containers
  78870. */
  78871. export class Container extends Control {
  78872. name?: string | undefined;
  78873. /** @hidden */
  78874. _children: Control[];
  78875. /** @hidden */
  78876. protected _measureForChildren: Measure;
  78877. /** @hidden */
  78878. protected _background: string;
  78879. /** @hidden */
  78880. protected _adaptWidthToChildren: boolean;
  78881. /** @hidden */
  78882. protected _adaptHeightToChildren: boolean;
  78883. /**
  78884. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78885. */
  78886. logLayoutCycleErrors: boolean;
  78887. /**
  78888. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78889. */
  78890. maxLayoutCycle: number;
  78891. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78892. get adaptHeightToChildren(): boolean;
  78893. set adaptHeightToChildren(value: boolean);
  78894. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78895. get adaptWidthToChildren(): boolean;
  78896. set adaptWidthToChildren(value: boolean);
  78897. /** Gets or sets background color */
  78898. get background(): string;
  78899. set background(value: string);
  78900. /** Gets the list of children */
  78901. get children(): Control[];
  78902. /**
  78903. * Creates a new Container
  78904. * @param name defines the name of the container
  78905. */
  78906. constructor(name?: string | undefined);
  78907. protected _getTypeName(): string;
  78908. _flagDescendantsAsMatrixDirty(): void;
  78909. /**
  78910. * Gets a child using its name
  78911. * @param name defines the child name to look for
  78912. * @returns the child control if found
  78913. */
  78914. getChildByName(name: string): BABYLON.Nullable<Control>;
  78915. /**
  78916. * Gets a child using its type and its name
  78917. * @param name defines the child name to look for
  78918. * @param type defines the child type to look for
  78919. * @returns the child control if found
  78920. */
  78921. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78922. /**
  78923. * Search for a specific control in children
  78924. * @param control defines the control to look for
  78925. * @returns true if the control is in child list
  78926. */
  78927. containsControl(control: Control): boolean;
  78928. /**
  78929. * Adds a new control to the current container
  78930. * @param control defines the control to add
  78931. * @returns the current container
  78932. */
  78933. addControl(control: BABYLON.Nullable<Control>): Container;
  78934. /**
  78935. * Removes all controls from the current container
  78936. * @returns the current container
  78937. */
  78938. clearControls(): Container;
  78939. /**
  78940. * Removes a control from the current container
  78941. * @param control defines the control to remove
  78942. * @returns the current container
  78943. */
  78944. removeControl(control: Control): Container;
  78945. /** @hidden */
  78946. _reOrderControl(control: Control): void;
  78947. /** @hidden */
  78948. _offsetLeft(offset: number): void;
  78949. /** @hidden */
  78950. _offsetTop(offset: number): void;
  78951. /** @hidden */
  78952. _markAllAsDirty(): void;
  78953. /** @hidden */
  78954. protected _localDraw(context: CanvasRenderingContext2D): void;
  78955. /** @hidden */
  78956. _link(host: AdvancedDynamicTexture): void;
  78957. /** @hidden */
  78958. protected _beforeLayout(): void;
  78959. /** @hidden */
  78960. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78961. /** @hidden */
  78962. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78963. protected _postMeasure(): void;
  78964. /** @hidden */
  78965. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78966. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78967. /** @hidden */
  78968. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78969. /** @hidden */
  78970. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78971. /** Releases associated resources */
  78972. dispose(): void;
  78973. }
  78974. }
  78975. declare module BABYLON.GUI {
  78976. /** Class used to create rectangle container */
  78977. export class Rectangle extends Container {
  78978. name?: string | undefined;
  78979. private _thickness;
  78980. private _cornerRadius;
  78981. /** Gets or sets border thickness */
  78982. get thickness(): number;
  78983. set thickness(value: number);
  78984. /** Gets or sets the corner radius angle */
  78985. get cornerRadius(): number;
  78986. set cornerRadius(value: number);
  78987. /**
  78988. * Creates a new Rectangle
  78989. * @param name defines the control name
  78990. */
  78991. constructor(name?: string | undefined);
  78992. protected _getTypeName(): string;
  78993. protected _localDraw(context: CanvasRenderingContext2D): void;
  78994. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78995. private _drawRoundedRect;
  78996. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78997. }
  78998. }
  78999. declare module BABYLON.GUI {
  79000. /**
  79001. * Enum that determines the text-wrapping mode to use.
  79002. */
  79003. export enum TextWrapping {
  79004. /**
  79005. * Clip the text when it's larger than Control.width; this is the default mode.
  79006. */
  79007. Clip = 0,
  79008. /**
  79009. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79010. */
  79011. WordWrap = 1,
  79012. /**
  79013. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79014. */
  79015. Ellipsis = 2
  79016. }
  79017. /**
  79018. * Class used to create text block control
  79019. */
  79020. export class TextBlock extends Control {
  79021. /**
  79022. * Defines the name of the control
  79023. */
  79024. name?: string | undefined;
  79025. private _text;
  79026. private _textWrapping;
  79027. private _textHorizontalAlignment;
  79028. private _textVerticalAlignment;
  79029. private _lines;
  79030. private _resizeToFit;
  79031. private _lineSpacing;
  79032. private _outlineWidth;
  79033. private _outlineColor;
  79034. private _underline;
  79035. private _lineThrough;
  79036. /**
  79037. * An event triggered after the text is changed
  79038. */
  79039. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79040. /**
  79041. * An event triggered after the text was broken up into lines
  79042. */
  79043. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79044. /**
  79045. * Function used to split a string into words. By default, a string is split at each space character found
  79046. */
  79047. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79048. /**
  79049. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79050. */
  79051. get lines(): any[];
  79052. /**
  79053. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79054. */
  79055. get resizeToFit(): boolean;
  79056. /**
  79057. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79058. */
  79059. set resizeToFit(value: boolean);
  79060. /**
  79061. * Gets or sets a boolean indicating if text must be wrapped
  79062. */
  79063. get textWrapping(): TextWrapping | boolean;
  79064. /**
  79065. * Gets or sets a boolean indicating if text must be wrapped
  79066. */
  79067. set textWrapping(value: TextWrapping | boolean);
  79068. /**
  79069. * Gets or sets text to display
  79070. */
  79071. get text(): string;
  79072. /**
  79073. * Gets or sets text to display
  79074. */
  79075. set text(value: string);
  79076. /**
  79077. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79078. */
  79079. get textHorizontalAlignment(): number;
  79080. /**
  79081. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79082. */
  79083. set textHorizontalAlignment(value: number);
  79084. /**
  79085. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79086. */
  79087. get textVerticalAlignment(): number;
  79088. /**
  79089. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79090. */
  79091. set textVerticalAlignment(value: number);
  79092. /**
  79093. * Gets or sets line spacing value
  79094. */
  79095. set lineSpacing(value: string | number);
  79096. /**
  79097. * Gets or sets line spacing value
  79098. */
  79099. get lineSpacing(): string | number;
  79100. /**
  79101. * Gets or sets outlineWidth of the text to display
  79102. */
  79103. get outlineWidth(): number;
  79104. /**
  79105. * Gets or sets outlineWidth of the text to display
  79106. */
  79107. set outlineWidth(value: number);
  79108. /**
  79109. * Gets or sets a boolean indicating that text must have underline
  79110. */
  79111. get underline(): boolean;
  79112. /**
  79113. * Gets or sets a boolean indicating that text must have underline
  79114. */
  79115. set underline(value: boolean);
  79116. /**
  79117. * Gets or sets an boolean indicating that text must be crossed out
  79118. */
  79119. get lineThrough(): boolean;
  79120. /**
  79121. * Gets or sets an boolean indicating that text must be crossed out
  79122. */
  79123. set lineThrough(value: boolean);
  79124. /**
  79125. * Gets or sets outlineColor of the text to display
  79126. */
  79127. get outlineColor(): string;
  79128. /**
  79129. * Gets or sets outlineColor of the text to display
  79130. */
  79131. set outlineColor(value: string);
  79132. /**
  79133. * Creates a new TextBlock object
  79134. * @param name defines the name of the control
  79135. * @param text defines the text to display (emptry string by default)
  79136. */
  79137. constructor(
  79138. /**
  79139. * Defines the name of the control
  79140. */
  79141. name?: string | undefined, text?: string);
  79142. protected _getTypeName(): string;
  79143. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79144. private _drawText;
  79145. /** @hidden */
  79146. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79147. protected _applyStates(context: CanvasRenderingContext2D): void;
  79148. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79149. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79150. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79151. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79152. protected _renderLines(context: CanvasRenderingContext2D): void;
  79153. /**
  79154. * Given a width constraint applied on the text block, find the expected height
  79155. * @returns expected height
  79156. */
  79157. computeExpectedHeight(): number;
  79158. dispose(): void;
  79159. }
  79160. }
  79161. declare module BABYLON.GUI {
  79162. /**
  79163. * Class used to create 2D images
  79164. */
  79165. export class Image extends Control {
  79166. name?: string | undefined;
  79167. private _workingCanvas;
  79168. private _domImage;
  79169. private _imageWidth;
  79170. private _imageHeight;
  79171. private _loaded;
  79172. private _stretch;
  79173. private _source;
  79174. private _autoScale;
  79175. private _sourceLeft;
  79176. private _sourceTop;
  79177. private _sourceWidth;
  79178. private _sourceHeight;
  79179. private _svgAttributesComputationCompleted;
  79180. private _isSVG;
  79181. private _cellWidth;
  79182. private _cellHeight;
  79183. private _cellId;
  79184. private _populateNinePatchSlicesFromImage;
  79185. private _sliceLeft;
  79186. private _sliceRight;
  79187. private _sliceTop;
  79188. private _sliceBottom;
  79189. private _detectPointerOnOpaqueOnly;
  79190. private _imageDataCache;
  79191. /**
  79192. * BABYLON.Observable notified when the content is loaded
  79193. */
  79194. onImageLoadedObservable: BABYLON.Observable<Image>;
  79195. /**
  79196. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79197. */
  79198. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79199. /**
  79200. * Gets a boolean indicating that the content is loaded
  79201. */
  79202. get isLoaded(): boolean;
  79203. /**
  79204. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79205. */
  79206. get populateNinePatchSlicesFromImage(): boolean;
  79207. set populateNinePatchSlicesFromImage(value: boolean);
  79208. /**
  79209. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79210. * Beware using this as this will comsume more memory as the image has to be stored twice
  79211. */
  79212. get detectPointerOnOpaqueOnly(): boolean;
  79213. set detectPointerOnOpaqueOnly(value: boolean);
  79214. /**
  79215. * Gets or sets the left value for slicing (9-patch)
  79216. */
  79217. get sliceLeft(): number;
  79218. set sliceLeft(value: number);
  79219. /**
  79220. * Gets or sets the right value for slicing (9-patch)
  79221. */
  79222. get sliceRight(): number;
  79223. set sliceRight(value: number);
  79224. /**
  79225. * Gets or sets the top value for slicing (9-patch)
  79226. */
  79227. get sliceTop(): number;
  79228. set sliceTop(value: number);
  79229. /**
  79230. * Gets or sets the bottom value for slicing (9-patch)
  79231. */
  79232. get sliceBottom(): number;
  79233. set sliceBottom(value: number);
  79234. /**
  79235. * Gets or sets the left coordinate in the source image
  79236. */
  79237. get sourceLeft(): number;
  79238. set sourceLeft(value: number);
  79239. /**
  79240. * Gets or sets the top coordinate in the source image
  79241. */
  79242. get sourceTop(): number;
  79243. set sourceTop(value: number);
  79244. /**
  79245. * Gets or sets the width to capture in the source image
  79246. */
  79247. get sourceWidth(): number;
  79248. set sourceWidth(value: number);
  79249. /**
  79250. * Gets or sets the height to capture in the source image
  79251. */
  79252. get sourceHeight(): number;
  79253. set sourceHeight(value: number);
  79254. /** Indicates if the format of the image is SVG */
  79255. get isSVG(): boolean;
  79256. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79257. get svgAttributesComputationCompleted(): boolean;
  79258. /**
  79259. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79260. * @see https://doc.babylonjs.com/how_to/gui#image
  79261. */
  79262. get autoScale(): boolean;
  79263. set autoScale(value: boolean);
  79264. /** Gets or sets the streching mode used by the image */
  79265. get stretch(): number;
  79266. set stretch(value: number);
  79267. /** @hidden */
  79268. _rotate90(n: number, preserveProperties?: boolean): Image;
  79269. private _handleRotationForSVGImage;
  79270. private _rotate90SourceProperties;
  79271. /**
  79272. * Gets or sets the internal DOM image used to render the control
  79273. */
  79274. set domImage(value: HTMLImageElement);
  79275. get domImage(): HTMLImageElement;
  79276. private _onImageLoaded;
  79277. private _extractNinePatchSliceDataFromImage;
  79278. /**
  79279. * Gets or sets image source url
  79280. */
  79281. set source(value: BABYLON.Nullable<string>);
  79282. /**
  79283. * Checks for svg document with icon id present
  79284. */
  79285. private _svgCheck;
  79286. /**
  79287. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79288. * given external svg file and icon id
  79289. */
  79290. private _getSVGAttribs;
  79291. /**
  79292. * Gets or sets the cell width to use when animation sheet is enabled
  79293. * @see https://doc.babylonjs.com/how_to/gui#image
  79294. */
  79295. get cellWidth(): number;
  79296. set cellWidth(value: number);
  79297. /**
  79298. * Gets or sets the cell height to use when animation sheet is enabled
  79299. * @see https://doc.babylonjs.com/how_to/gui#image
  79300. */
  79301. get cellHeight(): number;
  79302. set cellHeight(value: number);
  79303. /**
  79304. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79305. * @see https://doc.babylonjs.com/how_to/gui#image
  79306. */
  79307. get cellId(): number;
  79308. set cellId(value: number);
  79309. /**
  79310. * Creates a new Image
  79311. * @param name defines the control name
  79312. * @param url defines the image url
  79313. */
  79314. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79315. /**
  79316. * Tests if a given coordinates belong to the current control
  79317. * @param x defines x coordinate to test
  79318. * @param y defines y coordinate to test
  79319. * @returns true if the coordinates are inside the control
  79320. */
  79321. contains(x: number, y: number): boolean;
  79322. protected _getTypeName(): string;
  79323. /** Force the control to synchronize with its content */
  79324. synchronizeSizeWithContent(): void;
  79325. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79326. private _prepareWorkingCanvasForOpaqueDetection;
  79327. private _drawImage;
  79328. _draw(context: CanvasRenderingContext2D): void;
  79329. private _renderCornerPatch;
  79330. private _renderNinePatch;
  79331. dispose(): void;
  79332. /** STRETCH_NONE */
  79333. static readonly STRETCH_NONE: number;
  79334. /** STRETCH_FILL */
  79335. static readonly STRETCH_FILL: number;
  79336. /** STRETCH_UNIFORM */
  79337. static readonly STRETCH_UNIFORM: number;
  79338. /** STRETCH_EXTEND */
  79339. static readonly STRETCH_EXTEND: number;
  79340. /** NINE_PATCH */
  79341. static readonly STRETCH_NINE_PATCH: number;
  79342. }
  79343. }
  79344. declare module BABYLON.GUI {
  79345. /**
  79346. * Class used to create 2D buttons
  79347. */
  79348. export class Button extends Rectangle {
  79349. name?: string | undefined;
  79350. /**
  79351. * Function called to generate a pointer enter animation
  79352. */
  79353. pointerEnterAnimation: () => void;
  79354. /**
  79355. * Function called to generate a pointer out animation
  79356. */
  79357. pointerOutAnimation: () => void;
  79358. /**
  79359. * Function called to generate a pointer down animation
  79360. */
  79361. pointerDownAnimation: () => void;
  79362. /**
  79363. * Function called to generate a pointer up animation
  79364. */
  79365. pointerUpAnimation: () => void;
  79366. /**
  79367. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79368. */
  79369. delegatePickingToChildren: boolean;
  79370. private _image;
  79371. /**
  79372. * Returns the image part of the button (if any)
  79373. */
  79374. get image(): BABYLON.Nullable<Image>;
  79375. private _textBlock;
  79376. /**
  79377. * Returns the image part of the button (if any)
  79378. */
  79379. get textBlock(): BABYLON.Nullable<TextBlock>;
  79380. /**
  79381. * Creates a new Button
  79382. * @param name defines the name of the button
  79383. */
  79384. constructor(name?: string | undefined);
  79385. protected _getTypeName(): string;
  79386. /** @hidden */
  79387. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79388. /** @hidden */
  79389. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79390. /** @hidden */
  79391. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79392. /** @hidden */
  79393. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79394. /** @hidden */
  79395. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79396. /**
  79397. * Creates a new button made with an image and a text
  79398. * @param name defines the name of the button
  79399. * @param text defines the text of the button
  79400. * @param imageUrl defines the url of the image
  79401. * @returns a new Button
  79402. */
  79403. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79404. /**
  79405. * Creates a new button made with an image
  79406. * @param name defines the name of the button
  79407. * @param imageUrl defines the url of the image
  79408. * @returns a new Button
  79409. */
  79410. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79411. /**
  79412. * Creates a new button made with a text
  79413. * @param name defines the name of the button
  79414. * @param text defines the text of the button
  79415. * @returns a new Button
  79416. */
  79417. static CreateSimpleButton(name: string, text: string): Button;
  79418. /**
  79419. * Creates a new button made with an image and a centered text
  79420. * @param name defines the name of the button
  79421. * @param text defines the text of the button
  79422. * @param imageUrl defines the url of the image
  79423. * @returns a new Button
  79424. */
  79425. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79426. }
  79427. }
  79428. declare module BABYLON.GUI {
  79429. /**
  79430. * Class used to create a 2D stack panel container
  79431. */
  79432. export class StackPanel extends Container {
  79433. name?: string | undefined;
  79434. private _isVertical;
  79435. private _manualWidth;
  79436. private _manualHeight;
  79437. private _doNotTrackManualChanges;
  79438. /**
  79439. * Gets or sets a boolean indicating that layou warnings should be ignored
  79440. */
  79441. ignoreLayoutWarnings: boolean;
  79442. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79443. get isVertical(): boolean;
  79444. set isVertical(value: boolean);
  79445. /**
  79446. * Gets or sets panel width.
  79447. * This value should not be set when in horizontal mode as it will be computed automatically
  79448. */
  79449. set width(value: string | number);
  79450. get width(): string | number;
  79451. /**
  79452. * Gets or sets panel height.
  79453. * This value should not be set when in vertical mode as it will be computed automatically
  79454. */
  79455. set height(value: string | number);
  79456. get height(): string | number;
  79457. /**
  79458. * Creates a new StackPanel
  79459. * @param name defines control name
  79460. */
  79461. constructor(name?: string | undefined);
  79462. protected _getTypeName(): string;
  79463. /** @hidden */
  79464. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79465. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79466. protected _postMeasure(): void;
  79467. }
  79468. }
  79469. declare module BABYLON.GUI {
  79470. /**
  79471. * Class used to represent a 2D checkbox
  79472. */
  79473. export class Checkbox extends Control {
  79474. name?: string | undefined;
  79475. private _isChecked;
  79476. private _background;
  79477. private _checkSizeRatio;
  79478. private _thickness;
  79479. /** Gets or sets border thickness */
  79480. get thickness(): number;
  79481. set thickness(value: number);
  79482. /**
  79483. * BABYLON.Observable raised when isChecked property changes
  79484. */
  79485. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79486. /** Gets or sets a value indicating the ratio between overall size and check size */
  79487. get checkSizeRatio(): number;
  79488. set checkSizeRatio(value: number);
  79489. /** Gets or sets background color */
  79490. get background(): string;
  79491. set background(value: string);
  79492. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79493. get isChecked(): boolean;
  79494. set isChecked(value: boolean);
  79495. /**
  79496. * Creates a new CheckBox
  79497. * @param name defines the control name
  79498. */
  79499. constructor(name?: string | undefined);
  79500. protected _getTypeName(): string;
  79501. /** @hidden */
  79502. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79503. /** @hidden */
  79504. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79505. /**
  79506. * Utility function to easily create a checkbox with a header
  79507. * @param title defines the label to use for the header
  79508. * @param onValueChanged defines the callback to call when value changes
  79509. * @returns a StackPanel containing the checkbox and a textBlock
  79510. */
  79511. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79512. }
  79513. }
  79514. declare module BABYLON.GUI {
  79515. /**
  79516. * Class used to store key control properties
  79517. */
  79518. export class KeyPropertySet {
  79519. /** Width */
  79520. width?: string;
  79521. /** Height */
  79522. height?: string;
  79523. /** Left padding */
  79524. paddingLeft?: string;
  79525. /** Right padding */
  79526. paddingRight?: string;
  79527. /** Top padding */
  79528. paddingTop?: string;
  79529. /** Bottom padding */
  79530. paddingBottom?: string;
  79531. /** Foreground color */
  79532. color?: string;
  79533. /** Background color */
  79534. background?: string;
  79535. }
  79536. /**
  79537. * Class used to create virtual keyboard
  79538. */
  79539. export class VirtualKeyboard extends StackPanel {
  79540. /** BABYLON.Observable raised when a key is pressed */
  79541. onKeyPressObservable: BABYLON.Observable<string>;
  79542. /** Gets or sets default key button width */
  79543. defaultButtonWidth: string;
  79544. /** Gets or sets default key button height */
  79545. defaultButtonHeight: string;
  79546. /** Gets or sets default key button left padding */
  79547. defaultButtonPaddingLeft: string;
  79548. /** Gets or sets default key button right padding */
  79549. defaultButtonPaddingRight: string;
  79550. /** Gets or sets default key button top padding */
  79551. defaultButtonPaddingTop: string;
  79552. /** Gets or sets default key button bottom padding */
  79553. defaultButtonPaddingBottom: string;
  79554. /** Gets or sets default key button foreground color */
  79555. defaultButtonColor: string;
  79556. /** Gets or sets default key button background color */
  79557. defaultButtonBackground: string;
  79558. /** Gets or sets shift button foreground color */
  79559. shiftButtonColor: string;
  79560. /** Gets or sets shift button thickness*/
  79561. selectedShiftThickness: number;
  79562. /** Gets shift key state */
  79563. shiftState: number;
  79564. protected _getTypeName(): string;
  79565. private _createKey;
  79566. /**
  79567. * Adds a new row of keys
  79568. * @param keys defines the list of keys to add
  79569. * @param propertySets defines the associated property sets
  79570. */
  79571. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79572. /**
  79573. * Set the shift key to a specific state
  79574. * @param shiftState defines the new shift state
  79575. */
  79576. applyShiftState(shiftState: number): void;
  79577. private _currentlyConnectedInputText;
  79578. private _connectedInputTexts;
  79579. private _onKeyPressObserver;
  79580. /** Gets the input text control currently attached to the keyboard */
  79581. get connectedInputText(): BABYLON.Nullable<InputText>;
  79582. /**
  79583. * Connects the keyboard with an input text control
  79584. *
  79585. * @param input defines the target control
  79586. */
  79587. connect(input: InputText): void;
  79588. /**
  79589. * Disconnects the keyboard from connected InputText controls
  79590. *
  79591. * @param input optionally defines a target control, otherwise all are disconnected
  79592. */
  79593. disconnect(input?: InputText): void;
  79594. private _removeConnectedInputObservables;
  79595. /**
  79596. * Release all resources
  79597. */
  79598. dispose(): void;
  79599. /**
  79600. * Creates a new keyboard using a default layout
  79601. *
  79602. * @param name defines control name
  79603. * @returns a new VirtualKeyboard
  79604. */
  79605. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79606. }
  79607. }
  79608. declare module BABYLON.GUI {
  79609. /**
  79610. * Class used to create input text control
  79611. */
  79612. export class InputText extends Control implements IFocusableControl {
  79613. name?: string | undefined;
  79614. private _text;
  79615. private _placeholderText;
  79616. private _background;
  79617. private _focusedBackground;
  79618. private _focusedColor;
  79619. private _placeholderColor;
  79620. private _thickness;
  79621. private _margin;
  79622. private _autoStretchWidth;
  79623. private _maxWidth;
  79624. private _isFocused;
  79625. private _blinkTimeout;
  79626. private _blinkIsEven;
  79627. private _cursorOffset;
  79628. private _scrollLeft;
  79629. private _textWidth;
  79630. private _clickedCoordinate;
  79631. private _deadKey;
  79632. private _addKey;
  79633. private _currentKey;
  79634. private _isTextHighlightOn;
  79635. private _textHighlightColor;
  79636. private _highligherOpacity;
  79637. private _highlightedText;
  79638. private _startHighlightIndex;
  79639. private _endHighlightIndex;
  79640. private _cursorIndex;
  79641. private _onFocusSelectAll;
  79642. private _isPointerDown;
  79643. private _onClipboardObserver;
  79644. private _onPointerDblTapObserver;
  79645. /** @hidden */
  79646. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79647. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79648. promptMessage: string;
  79649. /** Force disable prompt on mobile device */
  79650. disableMobilePrompt: boolean;
  79651. /** BABYLON.Observable raised when the text changes */
  79652. onTextChangedObservable: BABYLON.Observable<InputText>;
  79653. /** BABYLON.Observable raised just before an entered character is to be added */
  79654. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79655. /** BABYLON.Observable raised when the control gets the focus */
  79656. onFocusObservable: BABYLON.Observable<InputText>;
  79657. /** BABYLON.Observable raised when the control loses the focus */
  79658. onBlurObservable: BABYLON.Observable<InputText>;
  79659. /**Observable raised when the text is highlighted */
  79660. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79661. /**Observable raised when copy event is triggered */
  79662. onTextCopyObservable: BABYLON.Observable<InputText>;
  79663. /** BABYLON.Observable raised when cut event is triggered */
  79664. onTextCutObservable: BABYLON.Observable<InputText>;
  79665. /** BABYLON.Observable raised when paste event is triggered */
  79666. onTextPasteObservable: BABYLON.Observable<InputText>;
  79667. /** BABYLON.Observable raised when a key event was processed */
  79668. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79669. /** Gets or sets the maximum width allowed by the control */
  79670. get maxWidth(): string | number;
  79671. /** Gets the maximum width allowed by the control in pixels */
  79672. get maxWidthInPixels(): number;
  79673. set maxWidth(value: string | number);
  79674. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79675. get highligherOpacity(): number;
  79676. set highligherOpacity(value: number);
  79677. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79678. get onFocusSelectAll(): boolean;
  79679. set onFocusSelectAll(value: boolean);
  79680. /** Gets or sets the text hightlight color */
  79681. get textHighlightColor(): string;
  79682. set textHighlightColor(value: string);
  79683. /** Gets or sets control margin */
  79684. get margin(): string;
  79685. /** Gets control margin in pixels */
  79686. get marginInPixels(): number;
  79687. set margin(value: string);
  79688. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79689. get autoStretchWidth(): boolean;
  79690. set autoStretchWidth(value: boolean);
  79691. /** Gets or sets border thickness */
  79692. get thickness(): number;
  79693. set thickness(value: number);
  79694. /** Gets or sets the background color when focused */
  79695. get focusedBackground(): string;
  79696. set focusedBackground(value: string);
  79697. /** Gets or sets the background color when focused */
  79698. get focusedColor(): string;
  79699. set focusedColor(value: string);
  79700. /** Gets or sets the background color */
  79701. get background(): string;
  79702. set background(value: string);
  79703. /** Gets or sets the placeholder color */
  79704. get placeholderColor(): string;
  79705. set placeholderColor(value: string);
  79706. /** Gets or sets the text displayed when the control is empty */
  79707. get placeholderText(): string;
  79708. set placeholderText(value: string);
  79709. /** Gets or sets the dead key flag */
  79710. get deadKey(): boolean;
  79711. set deadKey(flag: boolean);
  79712. /** Gets or sets the highlight text */
  79713. get highlightedText(): string;
  79714. set highlightedText(text: string);
  79715. /** Gets or sets if the current key should be added */
  79716. get addKey(): boolean;
  79717. set addKey(flag: boolean);
  79718. /** Gets or sets the value of the current key being entered */
  79719. get currentKey(): string;
  79720. set currentKey(key: string);
  79721. /** Gets or sets the text displayed in the control */
  79722. get text(): string;
  79723. set text(value: string);
  79724. /** Gets or sets control width */
  79725. get width(): string | number;
  79726. set width(value: string | number);
  79727. /**
  79728. * Creates a new InputText
  79729. * @param name defines the control name
  79730. * @param text defines the text of the control
  79731. */
  79732. constructor(name?: string | undefined, text?: string);
  79733. /** @hidden */
  79734. onBlur(): void;
  79735. /** @hidden */
  79736. onFocus(): void;
  79737. protected _getTypeName(): string;
  79738. /**
  79739. * Function called to get the list of controls that should not steal the focus from this control
  79740. * @returns an array of controls
  79741. */
  79742. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79743. /** @hidden */
  79744. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79745. /** @hidden */
  79746. private _updateValueFromCursorIndex;
  79747. /** @hidden */
  79748. private _processDblClick;
  79749. /** @hidden */
  79750. private _selectAllText;
  79751. /**
  79752. * Handles the keyboard event
  79753. * @param evt Defines the KeyboardEvent
  79754. */
  79755. processKeyboard(evt: KeyboardEvent): void;
  79756. /** @hidden */
  79757. private _onCopyText;
  79758. /** @hidden */
  79759. private _onCutText;
  79760. /** @hidden */
  79761. private _onPasteText;
  79762. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79763. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79764. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79765. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79766. protected _beforeRenderText(text: string): string;
  79767. dispose(): void;
  79768. }
  79769. }
  79770. declare module BABYLON.GUI {
  79771. /**
  79772. * Class used to create a 2D grid container
  79773. */
  79774. export class Grid extends Container {
  79775. name?: string | undefined;
  79776. private _rowDefinitions;
  79777. private _columnDefinitions;
  79778. private _cells;
  79779. private _childControls;
  79780. /**
  79781. * Gets the number of columns
  79782. */
  79783. get columnCount(): number;
  79784. /**
  79785. * Gets the number of rows
  79786. */
  79787. get rowCount(): number;
  79788. /** Gets the list of children */
  79789. get children(): Control[];
  79790. /** Gets the list of cells (e.g. the containers) */
  79791. get cells(): {
  79792. [key: string]: Container;
  79793. };
  79794. /**
  79795. * Gets the definition of a specific row
  79796. * @param index defines the index of the row
  79797. * @returns the row definition
  79798. */
  79799. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79800. /**
  79801. * Gets the definition of a specific column
  79802. * @param index defines the index of the column
  79803. * @returns the column definition
  79804. */
  79805. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79806. /**
  79807. * Adds a new row to the grid
  79808. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79809. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79810. * @returns the current grid
  79811. */
  79812. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79813. /**
  79814. * Adds a new column to the grid
  79815. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79816. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79817. * @returns the current grid
  79818. */
  79819. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79820. /**
  79821. * Update a row definition
  79822. * @param index defines the index of the row to update
  79823. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79824. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79825. * @returns the current grid
  79826. */
  79827. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79828. /**
  79829. * Update a column definition
  79830. * @param index defines the index of the column to update
  79831. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79832. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79833. * @returns the current grid
  79834. */
  79835. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79836. /**
  79837. * Gets the list of children stored in a specific cell
  79838. * @param row defines the row to check
  79839. * @param column defines the column to check
  79840. * @returns the list of controls
  79841. */
  79842. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79843. /**
  79844. * Gets a string representing the child cell info (row x column)
  79845. * @param child defines the control to get info from
  79846. * @returns a string containing the child cell info (row x column)
  79847. */
  79848. getChildCellInfo(child: Control): string;
  79849. private _removeCell;
  79850. private _offsetCell;
  79851. /**
  79852. * Remove a column definition at specified index
  79853. * @param index defines the index of the column to remove
  79854. * @returns the current grid
  79855. */
  79856. removeColumnDefinition(index: number): Grid;
  79857. /**
  79858. * Remove a row definition at specified index
  79859. * @param index defines the index of the row to remove
  79860. * @returns the current grid
  79861. */
  79862. removeRowDefinition(index: number): Grid;
  79863. /**
  79864. * Adds a new control to the current grid
  79865. * @param control defines the control to add
  79866. * @param row defines the row where to add the control (0 by default)
  79867. * @param column defines the column where to add the control (0 by default)
  79868. * @returns the current grid
  79869. */
  79870. addControl(control: Control, row?: number, column?: number): Grid;
  79871. /**
  79872. * Removes a control from the current container
  79873. * @param control defines the control to remove
  79874. * @returns the current container
  79875. */
  79876. removeControl(control: Control): Container;
  79877. /**
  79878. * Creates a new Grid
  79879. * @param name defines control name
  79880. */
  79881. constructor(name?: string | undefined);
  79882. protected _getTypeName(): string;
  79883. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79884. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79885. _flagDescendantsAsMatrixDirty(): void;
  79886. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79887. /** Releases associated resources */
  79888. dispose(): void;
  79889. }
  79890. }
  79891. declare module BABYLON.GUI {
  79892. /** Class used to create color pickers */
  79893. export class ColorPicker extends Control {
  79894. name?: string | undefined;
  79895. private static _Epsilon;
  79896. private _colorWheelCanvas;
  79897. private _value;
  79898. private _tmpColor;
  79899. private _pointerStartedOnSquare;
  79900. private _pointerStartedOnWheel;
  79901. private _squareLeft;
  79902. private _squareTop;
  79903. private _squareSize;
  79904. private _h;
  79905. private _s;
  79906. private _v;
  79907. private _lastPointerDownID;
  79908. /**
  79909. * BABYLON.Observable raised when the value changes
  79910. */
  79911. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79912. /** Gets or sets the color of the color picker */
  79913. get value(): BABYLON.Color3;
  79914. set value(value: BABYLON.Color3);
  79915. /**
  79916. * Gets or sets control width
  79917. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79918. */
  79919. get width(): string | number;
  79920. set width(value: string | number);
  79921. /**
  79922. * Gets or sets control height
  79923. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79924. */
  79925. get height(): string | number;
  79926. /** Gets or sets control height */
  79927. set height(value: string | number);
  79928. /** Gets or sets control size */
  79929. get size(): string | number;
  79930. set size(value: string | number);
  79931. /**
  79932. * Creates a new ColorPicker
  79933. * @param name defines the control name
  79934. */
  79935. constructor(name?: string | undefined);
  79936. protected _getTypeName(): string;
  79937. /** @hidden */
  79938. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79939. private _updateSquareProps;
  79940. private _drawGradientSquare;
  79941. private _drawCircle;
  79942. private _createColorWheelCanvas;
  79943. /** @hidden */
  79944. _draw(context: CanvasRenderingContext2D): void;
  79945. private _pointerIsDown;
  79946. private _updateValueFromPointer;
  79947. private _isPointOnSquare;
  79948. private _isPointOnWheel;
  79949. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79950. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79951. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79952. _onCanvasBlur(): void;
  79953. /**
  79954. * This function expands the color picker by creating a color picker dialog with manual
  79955. * color value input and the ability to save colors into an array to be used later in
  79956. * subsequent launches of the dialogue.
  79957. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79958. * @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.
  79959. * @returns picked color as a hex string and the saved colors array as hex strings.
  79960. */
  79961. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79962. pickerWidth?: string;
  79963. pickerHeight?: string;
  79964. headerHeight?: string;
  79965. lastColor?: string;
  79966. swatchLimit?: number;
  79967. numSwatchesPerLine?: number;
  79968. savedColors?: Array<string>;
  79969. }): Promise<{
  79970. savedColors?: string[];
  79971. pickedColor: string;
  79972. }>;
  79973. }
  79974. }
  79975. declare module BABYLON.GUI {
  79976. /** Class used to create 2D ellipse containers */
  79977. export class Ellipse extends Container {
  79978. name?: string | undefined;
  79979. private _thickness;
  79980. /** Gets or sets border thickness */
  79981. get thickness(): number;
  79982. set thickness(value: number);
  79983. /**
  79984. * Creates a new Ellipse
  79985. * @param name defines the control name
  79986. */
  79987. constructor(name?: string | undefined);
  79988. protected _getTypeName(): string;
  79989. protected _localDraw(context: CanvasRenderingContext2D): void;
  79990. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79991. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79992. }
  79993. }
  79994. declare module BABYLON.GUI {
  79995. /**
  79996. * Class used to create a password control
  79997. */
  79998. export class InputPassword extends InputText {
  79999. protected _beforeRenderText(text: string): string;
  80000. }
  80001. }
  80002. declare module BABYLON.GUI {
  80003. /** Class used to render 2D lines */
  80004. export class Line extends Control {
  80005. name?: string | undefined;
  80006. private _lineWidth;
  80007. private _x1;
  80008. private _y1;
  80009. private _x2;
  80010. private _y2;
  80011. private _dash;
  80012. private _connectedControl;
  80013. private _connectedControlDirtyObserver;
  80014. /** Gets or sets the dash pattern */
  80015. get dash(): Array<number>;
  80016. set dash(value: Array<number>);
  80017. /** Gets or sets the control connected with the line end */
  80018. get connectedControl(): Control;
  80019. set connectedControl(value: Control);
  80020. /** Gets or sets start coordinates on X axis */
  80021. get x1(): string | number;
  80022. set x1(value: string | number);
  80023. /** Gets or sets start coordinates on Y axis */
  80024. get y1(): string | number;
  80025. set y1(value: string | number);
  80026. /** Gets or sets end coordinates on X axis */
  80027. get x2(): string | number;
  80028. set x2(value: string | number);
  80029. /** Gets or sets end coordinates on Y axis */
  80030. get y2(): string | number;
  80031. set y2(value: string | number);
  80032. /** Gets or sets line width */
  80033. get lineWidth(): number;
  80034. set lineWidth(value: number);
  80035. /** Gets or sets horizontal alignment */
  80036. set horizontalAlignment(value: number);
  80037. /** Gets or sets vertical alignment */
  80038. set verticalAlignment(value: number);
  80039. private get _effectiveX2();
  80040. private get _effectiveY2();
  80041. /**
  80042. * Creates a new Line
  80043. * @param name defines the control name
  80044. */
  80045. constructor(name?: string | undefined);
  80046. protected _getTypeName(): string;
  80047. _draw(context: CanvasRenderingContext2D): void;
  80048. _measure(): void;
  80049. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80050. /**
  80051. * Move one end of the line given 3D cartesian coordinates.
  80052. * @param position Targeted world position
  80053. * @param scene BABYLON.Scene
  80054. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80055. */
  80056. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80057. /**
  80058. * Move one end of the line to a position in screen absolute space.
  80059. * @param projectedPosition Position in screen absolute space (X, Y)
  80060. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80061. */
  80062. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80063. }
  80064. }
  80065. declare module BABYLON.GUI {
  80066. /**
  80067. * Class used to store a point for a MultiLine object.
  80068. * The point can be pure 2D coordinates, a mesh or a control
  80069. */
  80070. export class MultiLinePoint {
  80071. private _multiLine;
  80072. private _x;
  80073. private _y;
  80074. private _control;
  80075. private _mesh;
  80076. private _controlObserver;
  80077. private _meshObserver;
  80078. /** @hidden */
  80079. _point: BABYLON.Vector2;
  80080. /**
  80081. * Creates a new MultiLinePoint
  80082. * @param multiLine defines the source MultiLine object
  80083. */
  80084. constructor(multiLine: MultiLine);
  80085. /** Gets or sets x coordinate */
  80086. get x(): string | number;
  80087. set x(value: string | number);
  80088. /** Gets or sets y coordinate */
  80089. get y(): string | number;
  80090. set y(value: string | number);
  80091. /** Gets or sets the control associated with this point */
  80092. get control(): BABYLON.Nullable<Control>;
  80093. set control(value: BABYLON.Nullable<Control>);
  80094. /** Gets or sets the mesh associated with this point */
  80095. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80096. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80097. /** Resets links */
  80098. resetLinks(): void;
  80099. /**
  80100. * Gets a translation vector
  80101. * @returns the translation vector
  80102. */
  80103. translate(): BABYLON.Vector2;
  80104. private _translatePoint;
  80105. /** Release associated resources */
  80106. dispose(): void;
  80107. }
  80108. }
  80109. declare module BABYLON.GUI {
  80110. /**
  80111. * Class used to create multi line control
  80112. */
  80113. export class MultiLine extends Control {
  80114. name?: string | undefined;
  80115. private _lineWidth;
  80116. private _dash;
  80117. private _points;
  80118. private _minX;
  80119. private _minY;
  80120. private _maxX;
  80121. private _maxY;
  80122. /**
  80123. * Creates a new MultiLine
  80124. * @param name defines the control name
  80125. */
  80126. constructor(name?: string | undefined);
  80127. /** Gets or sets dash pattern */
  80128. get dash(): Array<number>;
  80129. set dash(value: Array<number>);
  80130. /**
  80131. * Gets point stored at specified index
  80132. * @param index defines the index to look for
  80133. * @returns the requested point if found
  80134. */
  80135. getAt(index: number): MultiLinePoint;
  80136. /** Function called when a point is updated */
  80137. onPointUpdate: () => void;
  80138. /**
  80139. * Adds new points to the point collection
  80140. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80141. * @returns the list of created MultiLinePoint
  80142. */
  80143. add(...items: (AbstractMesh | Control | {
  80144. x: string | number;
  80145. y: string | number;
  80146. })[]): MultiLinePoint[];
  80147. /**
  80148. * Adds a new point to the point collection
  80149. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80150. * @returns the created MultiLinePoint
  80151. */
  80152. push(item?: (AbstractMesh | Control | {
  80153. x: string | number;
  80154. y: string | number;
  80155. })): MultiLinePoint;
  80156. /**
  80157. * Remove a specific value or point from the active point collection
  80158. * @param value defines the value or point to remove
  80159. */
  80160. remove(value: number | MultiLinePoint): void;
  80161. /**
  80162. * Resets this object to initial state (no point)
  80163. */
  80164. reset(): void;
  80165. /**
  80166. * Resets all links
  80167. */
  80168. resetLinks(): void;
  80169. /** Gets or sets line width */
  80170. get lineWidth(): number;
  80171. set lineWidth(value: number);
  80172. set horizontalAlignment(value: number);
  80173. set verticalAlignment(value: number);
  80174. protected _getTypeName(): string;
  80175. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80176. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80177. _measure(): void;
  80178. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80179. dispose(): void;
  80180. }
  80181. }
  80182. declare module BABYLON.GUI {
  80183. /**
  80184. * Class used to create radio button controls
  80185. */
  80186. export class RadioButton extends Control {
  80187. name?: string | undefined;
  80188. private _isChecked;
  80189. private _background;
  80190. private _checkSizeRatio;
  80191. private _thickness;
  80192. /** Gets or sets border thickness */
  80193. get thickness(): number;
  80194. set thickness(value: number);
  80195. /** Gets or sets group name */
  80196. group: string;
  80197. /** BABYLON.Observable raised when isChecked is changed */
  80198. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80199. /** Gets or sets a value indicating the ratio between overall size and check size */
  80200. get checkSizeRatio(): number;
  80201. set checkSizeRatio(value: number);
  80202. /** Gets or sets background color */
  80203. get background(): string;
  80204. set background(value: string);
  80205. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80206. get isChecked(): boolean;
  80207. set isChecked(value: boolean);
  80208. /**
  80209. * Creates a new RadioButton
  80210. * @param name defines the control name
  80211. */
  80212. constructor(name?: string | undefined);
  80213. protected _getTypeName(): string;
  80214. _draw(context: CanvasRenderingContext2D): void;
  80215. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80216. /**
  80217. * Utility function to easily create a radio button with a header
  80218. * @param title defines the label to use for the header
  80219. * @param group defines the group to use for the radio button
  80220. * @param isChecked defines the initial state of the radio button
  80221. * @param onValueChanged defines the callback to call when value changes
  80222. * @returns a StackPanel containing the radio button and a textBlock
  80223. */
  80224. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80225. }
  80226. }
  80227. declare module BABYLON.GUI {
  80228. /**
  80229. * Class used to create slider controls
  80230. */
  80231. export class BaseSlider extends Control {
  80232. name?: string | undefined;
  80233. protected _thumbWidth: ValueAndUnit;
  80234. private _minimum;
  80235. private _maximum;
  80236. private _value;
  80237. private _isVertical;
  80238. protected _barOffset: ValueAndUnit;
  80239. private _isThumbClamped;
  80240. protected _displayThumb: boolean;
  80241. private _step;
  80242. private _lastPointerDownID;
  80243. protected _effectiveBarOffset: number;
  80244. protected _renderLeft: number;
  80245. protected _renderTop: number;
  80246. protected _renderWidth: number;
  80247. protected _renderHeight: number;
  80248. protected _backgroundBoxLength: number;
  80249. protected _backgroundBoxThickness: number;
  80250. protected _effectiveThumbThickness: number;
  80251. /** BABYLON.Observable raised when the sldier value changes */
  80252. onValueChangedObservable: BABYLON.Observable<number>;
  80253. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80254. get displayThumb(): boolean;
  80255. set displayThumb(value: boolean);
  80256. /** Gets or sets a step to apply to values (0 by default) */
  80257. get step(): number;
  80258. set step(value: number);
  80259. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80260. get barOffset(): string | number;
  80261. /** Gets main bar offset in pixels*/
  80262. get barOffsetInPixels(): number;
  80263. set barOffset(value: string | number);
  80264. /** Gets or sets thumb width */
  80265. get thumbWidth(): string | number;
  80266. /** Gets thumb width in pixels */
  80267. get thumbWidthInPixels(): number;
  80268. set thumbWidth(value: string | number);
  80269. /** Gets or sets minimum value */
  80270. get minimum(): number;
  80271. set minimum(value: number);
  80272. /** Gets or sets maximum value */
  80273. get maximum(): number;
  80274. set maximum(value: number);
  80275. /** Gets or sets current value */
  80276. get value(): number;
  80277. set value(value: number);
  80278. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80279. get isVertical(): boolean;
  80280. set isVertical(value: boolean);
  80281. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80282. get isThumbClamped(): boolean;
  80283. set isThumbClamped(value: boolean);
  80284. /**
  80285. * Creates a new BaseSlider
  80286. * @param name defines the control name
  80287. */
  80288. constructor(name?: string | undefined);
  80289. protected _getTypeName(): string;
  80290. protected _getThumbPosition(): number;
  80291. protected _getThumbThickness(type: string): number;
  80292. protected _prepareRenderingData(type: string): void;
  80293. private _pointerIsDown;
  80294. /** @hidden */
  80295. protected _updateValueFromPointer(x: number, y: number): void;
  80296. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80297. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80298. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80299. _onCanvasBlur(): void;
  80300. }
  80301. }
  80302. declare module BABYLON.GUI {
  80303. /**
  80304. * Class used to create slider controls
  80305. */
  80306. export class Slider extends BaseSlider {
  80307. name?: string | undefined;
  80308. private _background;
  80309. private _borderColor;
  80310. private _thumbColor;
  80311. private _isThumbCircle;
  80312. protected _displayValueBar: boolean;
  80313. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80314. get displayValueBar(): boolean;
  80315. set displayValueBar(value: boolean);
  80316. /** Gets or sets border color */
  80317. get borderColor(): string;
  80318. set borderColor(value: string);
  80319. /** Gets or sets background color */
  80320. get background(): string;
  80321. set background(value: string);
  80322. /** Gets or sets thumb's color */
  80323. get thumbColor(): string;
  80324. set thumbColor(value: string);
  80325. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80326. get isThumbCircle(): boolean;
  80327. set isThumbCircle(value: boolean);
  80328. /**
  80329. * Creates a new Slider
  80330. * @param name defines the control name
  80331. */
  80332. constructor(name?: string | undefined);
  80333. protected _getTypeName(): string;
  80334. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80335. }
  80336. }
  80337. declare module BABYLON.GUI {
  80338. /** Class used to create a RadioGroup
  80339. * which contains groups of radio buttons
  80340. */
  80341. export class SelectorGroup {
  80342. /** name of SelectorGroup */
  80343. name: string;
  80344. private _groupPanel;
  80345. private _selectors;
  80346. private _groupHeader;
  80347. /**
  80348. * Creates a new SelectorGroup
  80349. * @param name of group, used as a group heading
  80350. */
  80351. constructor(
  80352. /** name of SelectorGroup */
  80353. name: string);
  80354. /** Gets the groupPanel of the SelectorGroup */
  80355. get groupPanel(): StackPanel;
  80356. /** Gets the selectors array */
  80357. get selectors(): StackPanel[];
  80358. /** Gets and sets the group header */
  80359. get header(): string;
  80360. set header(label: string);
  80361. /** @hidden */
  80362. private _addGroupHeader;
  80363. /** @hidden*/
  80364. _getSelector(selectorNb: number): StackPanel | undefined;
  80365. /** Removes the selector at the given position
  80366. * @param selectorNb the position of the selector within the group
  80367. */
  80368. removeSelector(selectorNb: number): void;
  80369. }
  80370. /** Class used to create a CheckboxGroup
  80371. * which contains groups of checkbox buttons
  80372. */
  80373. export class CheckboxGroup extends SelectorGroup {
  80374. /** Adds a checkbox as a control
  80375. * @param text is the label for the selector
  80376. * @param func is the function called when the Selector is checked
  80377. * @param checked is true when Selector is checked
  80378. */
  80379. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80380. /** @hidden */
  80381. _setSelectorLabel(selectorNb: number, label: string): void;
  80382. /** @hidden */
  80383. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80384. /** @hidden */
  80385. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80386. /** @hidden */
  80387. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80388. }
  80389. /** Class used to create a RadioGroup
  80390. * which contains groups of radio buttons
  80391. */
  80392. export class RadioGroup extends SelectorGroup {
  80393. private _selectNb;
  80394. /** Adds a radio button as a control
  80395. * @param label is the label for the selector
  80396. * @param func is the function called when the Selector is checked
  80397. * @param checked is true when Selector is checked
  80398. */
  80399. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80400. /** @hidden */
  80401. _setSelectorLabel(selectorNb: number, label: string): void;
  80402. /** @hidden */
  80403. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80404. /** @hidden */
  80405. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80406. /** @hidden */
  80407. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80408. }
  80409. /** Class used to create a SliderGroup
  80410. * which contains groups of slider buttons
  80411. */
  80412. export class SliderGroup extends SelectorGroup {
  80413. /**
  80414. * Adds a slider to the SelectorGroup
  80415. * @param label is the label for the SliderBar
  80416. * @param func is the function called when the Slider moves
  80417. * @param unit is a string describing the units used, eg degrees or metres
  80418. * @param min is the minimum value for the Slider
  80419. * @param max is the maximum value for the Slider
  80420. * @param value is the start value for the Slider between min and max
  80421. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80422. */
  80423. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80424. /** @hidden */
  80425. _setSelectorLabel(selectorNb: number, label: string): void;
  80426. /** @hidden */
  80427. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80428. /** @hidden */
  80429. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80430. /** @hidden */
  80431. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80432. }
  80433. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80434. * @see https://doc.babylonjs.com/how_to/selector
  80435. */
  80436. export class SelectionPanel extends Rectangle {
  80437. /** name of SelectionPanel */
  80438. name: string;
  80439. /** an array of SelectionGroups */
  80440. groups: SelectorGroup[];
  80441. private _panel;
  80442. private _buttonColor;
  80443. private _buttonBackground;
  80444. private _headerColor;
  80445. private _barColor;
  80446. private _barHeight;
  80447. private _spacerHeight;
  80448. private _labelColor;
  80449. private _groups;
  80450. private _bars;
  80451. /**
  80452. * Creates a new SelectionPanel
  80453. * @param name of SelectionPanel
  80454. * @param groups is an array of SelectionGroups
  80455. */
  80456. constructor(
  80457. /** name of SelectionPanel */
  80458. name: string,
  80459. /** an array of SelectionGroups */
  80460. groups?: SelectorGroup[]);
  80461. protected _getTypeName(): string;
  80462. /** Gets the (stack) panel of the SelectionPanel */
  80463. get panel(): StackPanel;
  80464. /** Gets or sets the headerColor */
  80465. get headerColor(): string;
  80466. set headerColor(color: string);
  80467. private _setHeaderColor;
  80468. /** Gets or sets the button color */
  80469. get buttonColor(): string;
  80470. set buttonColor(color: string);
  80471. private _setbuttonColor;
  80472. /** Gets or sets the label color */
  80473. get labelColor(): string;
  80474. set labelColor(color: string);
  80475. private _setLabelColor;
  80476. /** Gets or sets the button background */
  80477. get buttonBackground(): string;
  80478. set buttonBackground(color: string);
  80479. private _setButtonBackground;
  80480. /** Gets or sets the color of separator bar */
  80481. get barColor(): string;
  80482. set barColor(color: string);
  80483. private _setBarColor;
  80484. /** Gets or sets the height of separator bar */
  80485. get barHeight(): string;
  80486. set barHeight(value: string);
  80487. private _setBarHeight;
  80488. /** Gets or sets the height of spacers*/
  80489. get spacerHeight(): string;
  80490. set spacerHeight(value: string);
  80491. private _setSpacerHeight;
  80492. /** Adds a bar between groups */
  80493. private _addSpacer;
  80494. /** Add a group to the selection panel
  80495. * @param group is the selector group to add
  80496. */
  80497. addGroup(group: SelectorGroup): void;
  80498. /** Remove the group from the given position
  80499. * @param groupNb is the position of the group in the list
  80500. */
  80501. removeGroup(groupNb: number): void;
  80502. /** Change a group header label
  80503. * @param label is the new group header label
  80504. * @param groupNb is the number of the group to relabel
  80505. * */
  80506. setHeaderName(label: string, groupNb: number): void;
  80507. /** Change selector label to the one given
  80508. * @param label is the new selector label
  80509. * @param groupNb is the number of the groupcontaining the selector
  80510. * @param selectorNb is the number of the selector within a group to relabel
  80511. * */
  80512. relabel(label: string, groupNb: number, selectorNb: number): void;
  80513. /** For a given group position remove the selector at the given position
  80514. * @param groupNb is the number of the group to remove the selector from
  80515. * @param selectorNb is the number of the selector within the group
  80516. */
  80517. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80518. /** For a given group position of correct type add a checkbox button
  80519. * @param groupNb is the number of the group to remove the selector from
  80520. * @param label is the label for the selector
  80521. * @param func is the function called when the Selector is checked
  80522. * @param checked is true when Selector is checked
  80523. */
  80524. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80525. /** For a given group position of correct type add a radio button
  80526. * @param groupNb is the number of the group to remove the selector from
  80527. * @param label is the label for the selector
  80528. * @param func is the function called when the Selector is checked
  80529. * @param checked is true when Selector is checked
  80530. */
  80531. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80532. /**
  80533. * For a given slider group add a slider
  80534. * @param groupNb is the number of the group to add the slider to
  80535. * @param label is the label for the Slider
  80536. * @param func is the function called when the Slider moves
  80537. * @param unit is a string describing the units used, eg degrees or metres
  80538. * @param min is the minimum value for the Slider
  80539. * @param max is the maximum value for the Slider
  80540. * @param value is the start value for the Slider between min and max
  80541. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80542. */
  80543. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80544. }
  80545. }
  80546. declare module BABYLON.GUI {
  80547. /**
  80548. * Class used to hold a the container for ScrollViewer
  80549. * @hidden
  80550. */
  80551. export class _ScrollViewerWindow extends Container {
  80552. parentClientWidth: number;
  80553. parentClientHeight: number;
  80554. private _freezeControls;
  80555. private _parentMeasure;
  80556. private _oldLeft;
  80557. private _oldTop;
  80558. get freezeControls(): boolean;
  80559. set freezeControls(value: boolean);
  80560. private _bucketWidth;
  80561. private _bucketHeight;
  80562. private _buckets;
  80563. private _bucketLen;
  80564. get bucketWidth(): number;
  80565. get bucketHeight(): number;
  80566. setBucketSizes(width: number, height: number): void;
  80567. private _useBuckets;
  80568. private _makeBuckets;
  80569. private _dispatchInBuckets;
  80570. private _updateMeasures;
  80571. private _updateChildrenMeasures;
  80572. private _restoreMeasures;
  80573. /**
  80574. * Creates a new ScrollViewerWindow
  80575. * @param name of ScrollViewerWindow
  80576. */
  80577. constructor(name?: string);
  80578. protected _getTypeName(): string;
  80579. /** @hidden */
  80580. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80581. /** @hidden */
  80582. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80583. private _scrollChildren;
  80584. private _scrollChildrenWithBuckets;
  80585. /** @hidden */
  80586. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80587. protected _postMeasure(): void;
  80588. }
  80589. }
  80590. declare module BABYLON.GUI {
  80591. /**
  80592. * Class used to create slider controls
  80593. */
  80594. export class ScrollBar extends BaseSlider {
  80595. name?: string | undefined;
  80596. private _background;
  80597. private _borderColor;
  80598. private _tempMeasure;
  80599. /** Gets or sets border color */
  80600. get borderColor(): string;
  80601. set borderColor(value: string);
  80602. /** Gets or sets background color */
  80603. get background(): string;
  80604. set background(value: string);
  80605. /**
  80606. * Creates a new Slider
  80607. * @param name defines the control name
  80608. */
  80609. constructor(name?: string | undefined);
  80610. protected _getTypeName(): string;
  80611. protected _getThumbThickness(): number;
  80612. _draw(context: CanvasRenderingContext2D): void;
  80613. private _first;
  80614. private _originX;
  80615. private _originY;
  80616. /** @hidden */
  80617. protected _updateValueFromPointer(x: number, y: number): void;
  80618. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80619. }
  80620. }
  80621. declare module BABYLON.GUI {
  80622. /**
  80623. * Class used to create slider controls
  80624. */
  80625. export class ImageScrollBar extends BaseSlider {
  80626. name?: string | undefined;
  80627. private _backgroundBaseImage;
  80628. private _backgroundImage;
  80629. private _thumbImage;
  80630. private _thumbBaseImage;
  80631. private _thumbLength;
  80632. private _thumbHeight;
  80633. private _barImageHeight;
  80634. private _tempMeasure;
  80635. /** Number of 90° rotation to apply on the images when in vertical mode */
  80636. num90RotationInVerticalMode: number;
  80637. /**
  80638. * Gets or sets the image used to render the background for horizontal bar
  80639. */
  80640. get backgroundImage(): Image;
  80641. set backgroundImage(value: Image);
  80642. /**
  80643. * Gets or sets the image used to render the thumb
  80644. */
  80645. get thumbImage(): Image;
  80646. set thumbImage(value: Image);
  80647. /**
  80648. * Gets or sets the length of the thumb
  80649. */
  80650. get thumbLength(): number;
  80651. set thumbLength(value: number);
  80652. /**
  80653. * Gets or sets the height of the thumb
  80654. */
  80655. get thumbHeight(): number;
  80656. set thumbHeight(value: number);
  80657. /**
  80658. * Gets or sets the height of the bar image
  80659. */
  80660. get barImageHeight(): number;
  80661. set barImageHeight(value: number);
  80662. /**
  80663. * Creates a new ImageScrollBar
  80664. * @param name defines the control name
  80665. */
  80666. constructor(name?: string | undefined);
  80667. protected _getTypeName(): string;
  80668. protected _getThumbThickness(): number;
  80669. _draw(context: CanvasRenderingContext2D): void;
  80670. private _first;
  80671. private _originX;
  80672. private _originY;
  80673. /** @hidden */
  80674. protected _updateValueFromPointer(x: number, y: number): void;
  80675. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80676. }
  80677. }
  80678. declare module BABYLON.GUI {
  80679. /**
  80680. * Class used to hold a viewer window and sliders in a grid
  80681. */
  80682. export class ScrollViewer extends Rectangle {
  80683. private _grid;
  80684. private _horizontalBarSpace;
  80685. private _verticalBarSpace;
  80686. private _dragSpace;
  80687. private _horizontalBar;
  80688. private _verticalBar;
  80689. private _barColor;
  80690. private _barBackground;
  80691. private _barImage;
  80692. private _horizontalBarImage;
  80693. private _verticalBarImage;
  80694. private _barBackgroundImage;
  80695. private _horizontalBarBackgroundImage;
  80696. private _verticalBarBackgroundImage;
  80697. private _barSize;
  80698. private _window;
  80699. private _pointerIsOver;
  80700. private _wheelPrecision;
  80701. private _onWheelObserver;
  80702. private _clientWidth;
  80703. private _clientHeight;
  80704. private _useImageBar;
  80705. private _thumbLength;
  80706. private _thumbHeight;
  80707. private _barImageHeight;
  80708. private _horizontalBarImageHeight;
  80709. private _verticalBarImageHeight;
  80710. private _oldWindowContentsWidth;
  80711. private _oldWindowContentsHeight;
  80712. /**
  80713. * Gets the horizontal scrollbar
  80714. */
  80715. get horizontalBar(): ScrollBar | ImageScrollBar;
  80716. /**
  80717. * Gets the vertical scrollbar
  80718. */
  80719. get verticalBar(): ScrollBar | ImageScrollBar;
  80720. /**
  80721. * Adds a new control to the current container
  80722. * @param control defines the control to add
  80723. * @returns the current container
  80724. */
  80725. addControl(control: BABYLON.Nullable<Control>): Container;
  80726. /**
  80727. * Removes a control from the current container
  80728. * @param control defines the control to remove
  80729. * @returns the current container
  80730. */
  80731. removeControl(control: Control): Container;
  80732. /** Gets the list of children */
  80733. get children(): Control[];
  80734. _flagDescendantsAsMatrixDirty(): void;
  80735. /**
  80736. * Freezes or unfreezes the controls in the window.
  80737. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80738. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80739. */
  80740. get freezeControls(): boolean;
  80741. set freezeControls(value: boolean);
  80742. /** Gets the bucket width */
  80743. get bucketWidth(): number;
  80744. /** Gets the bucket height */
  80745. get bucketHeight(): number;
  80746. /**
  80747. * Sets the bucket sizes.
  80748. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80749. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80750. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80751. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80752. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80753. * used), that's why it is not enabled by default.
  80754. * @param width width of the bucket
  80755. * @param height height of the bucket
  80756. */
  80757. setBucketSizes(width: number, height: number): void;
  80758. private _forceHorizontalBar;
  80759. private _forceVerticalBar;
  80760. /**
  80761. * Forces the horizontal scroll bar to be displayed
  80762. */
  80763. get forceHorizontalBar(): boolean;
  80764. set forceHorizontalBar(value: boolean);
  80765. /**
  80766. * Forces the vertical scroll bar to be displayed
  80767. */
  80768. get forceVerticalBar(): boolean;
  80769. set forceVerticalBar(value: boolean);
  80770. /**
  80771. * Creates a new ScrollViewer
  80772. * @param name of ScrollViewer
  80773. */
  80774. constructor(name?: string, isImageBased?: boolean);
  80775. /** Reset the scroll viewer window to initial size */
  80776. resetWindow(): void;
  80777. protected _getTypeName(): string;
  80778. private _buildClientSizes;
  80779. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80780. protected _postMeasure(): void;
  80781. /**
  80782. * Gets or sets the mouse wheel precision
  80783. * from 0 to 1 with a default value of 0.05
  80784. * */
  80785. get wheelPrecision(): number;
  80786. set wheelPrecision(value: number);
  80787. /** Gets or sets the scroll bar container background color */
  80788. get scrollBackground(): string;
  80789. set scrollBackground(color: string);
  80790. /** Gets or sets the bar color */
  80791. get barColor(): string;
  80792. set barColor(color: string);
  80793. /** Gets or sets the bar image */
  80794. get thumbImage(): Image;
  80795. set thumbImage(value: Image);
  80796. /** Gets or sets the horizontal bar image */
  80797. get horizontalThumbImage(): Image;
  80798. set horizontalThumbImage(value: Image);
  80799. /** Gets or sets the vertical bar image */
  80800. get verticalThumbImage(): Image;
  80801. set verticalThumbImage(value: Image);
  80802. /** Gets or sets the size of the bar */
  80803. get barSize(): number;
  80804. set barSize(value: number);
  80805. /** Gets or sets the length of the thumb */
  80806. get thumbLength(): number;
  80807. set thumbLength(value: number);
  80808. /** Gets or sets the height of the thumb */
  80809. get thumbHeight(): number;
  80810. set thumbHeight(value: number);
  80811. /** Gets or sets the height of the bar image */
  80812. get barImageHeight(): number;
  80813. set barImageHeight(value: number);
  80814. /** Gets or sets the height of the horizontal bar image */
  80815. get horizontalBarImageHeight(): number;
  80816. set horizontalBarImageHeight(value: number);
  80817. /** Gets or sets the height of the vertical bar image */
  80818. get verticalBarImageHeight(): number;
  80819. set verticalBarImageHeight(value: number);
  80820. /** Gets or sets the bar background */
  80821. get barBackground(): string;
  80822. set barBackground(color: string);
  80823. /** Gets or sets the bar background image */
  80824. get barImage(): Image;
  80825. set barImage(value: Image);
  80826. /** Gets or sets the horizontal bar background image */
  80827. get horizontalBarImage(): Image;
  80828. set horizontalBarImage(value: Image);
  80829. /** Gets or sets the vertical bar background image */
  80830. get verticalBarImage(): Image;
  80831. set verticalBarImage(value: Image);
  80832. private _setWindowPosition;
  80833. /** @hidden */
  80834. private _updateScroller;
  80835. _link(host: AdvancedDynamicTexture): void;
  80836. /** @hidden */
  80837. private _addBar;
  80838. /** @hidden */
  80839. private _attachWheel;
  80840. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80841. /** Releases associated resources */
  80842. dispose(): void;
  80843. }
  80844. }
  80845. declare module BABYLON.GUI {
  80846. /** Class used to render a grid */
  80847. export class DisplayGrid extends Control {
  80848. name?: string | undefined;
  80849. private _cellWidth;
  80850. private _cellHeight;
  80851. private _minorLineTickness;
  80852. private _minorLineColor;
  80853. private _majorLineTickness;
  80854. private _majorLineColor;
  80855. private _majorLineFrequency;
  80856. private _background;
  80857. private _displayMajorLines;
  80858. private _displayMinorLines;
  80859. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80860. get displayMinorLines(): boolean;
  80861. set displayMinorLines(value: boolean);
  80862. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80863. get displayMajorLines(): boolean;
  80864. set displayMajorLines(value: boolean);
  80865. /** Gets or sets background color (Black by default) */
  80866. get background(): string;
  80867. set background(value: string);
  80868. /** Gets or sets the width of each cell (20 by default) */
  80869. get cellWidth(): number;
  80870. set cellWidth(value: number);
  80871. /** Gets or sets the height of each cell (20 by default) */
  80872. get cellHeight(): number;
  80873. set cellHeight(value: number);
  80874. /** Gets or sets the tickness of minor lines (1 by default) */
  80875. get minorLineTickness(): number;
  80876. set minorLineTickness(value: number);
  80877. /** Gets or sets the color of minor lines (DarkGray by default) */
  80878. get minorLineColor(): string;
  80879. set minorLineColor(value: string);
  80880. /** Gets or sets the tickness of major lines (2 by default) */
  80881. get majorLineTickness(): number;
  80882. set majorLineTickness(value: number);
  80883. /** Gets or sets the color of major lines (White by default) */
  80884. get majorLineColor(): string;
  80885. set majorLineColor(value: string);
  80886. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80887. get majorLineFrequency(): number;
  80888. set majorLineFrequency(value: number);
  80889. /**
  80890. * Creates a new GridDisplayRectangle
  80891. * @param name defines the control name
  80892. */
  80893. constructor(name?: string | undefined);
  80894. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80895. protected _getTypeName(): string;
  80896. }
  80897. }
  80898. declare module BABYLON.GUI {
  80899. /**
  80900. * Class used to create slider controls based on images
  80901. */
  80902. export class ImageBasedSlider extends BaseSlider {
  80903. name?: string | undefined;
  80904. private _backgroundImage;
  80905. private _thumbImage;
  80906. private _valueBarImage;
  80907. private _tempMeasure;
  80908. get displayThumb(): boolean;
  80909. set displayThumb(value: boolean);
  80910. /**
  80911. * Gets or sets the image used to render the background
  80912. */
  80913. get backgroundImage(): Image;
  80914. set backgroundImage(value: Image);
  80915. /**
  80916. * Gets or sets the image used to render the value bar
  80917. */
  80918. get valueBarImage(): Image;
  80919. set valueBarImage(value: Image);
  80920. /**
  80921. * Gets or sets the image used to render the thumb
  80922. */
  80923. get thumbImage(): Image;
  80924. set thumbImage(value: Image);
  80925. /**
  80926. * Creates a new ImageBasedSlider
  80927. * @param name defines the control name
  80928. */
  80929. constructor(name?: string | undefined);
  80930. protected _getTypeName(): string;
  80931. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80932. }
  80933. }
  80934. declare module BABYLON.GUI {
  80935. /**
  80936. * Forcing an export so that this code will execute
  80937. * @hidden
  80938. */
  80939. const name = "Statics";
  80940. }
  80941. declare module BABYLON.GUI {
  80942. /**
  80943. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80944. */
  80945. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80946. /**
  80947. * Define the instrumented AdvancedDynamicTexture.
  80948. */
  80949. texture: AdvancedDynamicTexture;
  80950. private _captureRenderTime;
  80951. private _renderTime;
  80952. private _captureLayoutTime;
  80953. private _layoutTime;
  80954. private _onBeginRenderObserver;
  80955. private _onEndRenderObserver;
  80956. private _onBeginLayoutObserver;
  80957. private _onEndLayoutObserver;
  80958. /**
  80959. * Gets the perf counter used to capture render time
  80960. */
  80961. get renderTimeCounter(): BABYLON.PerfCounter;
  80962. /**
  80963. * Gets the perf counter used to capture layout time
  80964. */
  80965. get layoutTimeCounter(): BABYLON.PerfCounter;
  80966. /**
  80967. * Enable or disable the render time capture
  80968. */
  80969. get captureRenderTime(): boolean;
  80970. set captureRenderTime(value: boolean);
  80971. /**
  80972. * Enable or disable the layout time capture
  80973. */
  80974. get captureLayoutTime(): boolean;
  80975. set captureLayoutTime(value: boolean);
  80976. /**
  80977. * Instantiates a new advanced dynamic texture instrumentation.
  80978. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80979. * @param texture Defines the AdvancedDynamicTexture to instrument
  80980. */
  80981. constructor(
  80982. /**
  80983. * Define the instrumented AdvancedDynamicTexture.
  80984. */
  80985. texture: AdvancedDynamicTexture);
  80986. /**
  80987. * Dispose and release associated resources.
  80988. */
  80989. dispose(): void;
  80990. }
  80991. }
  80992. declare module BABYLON.GUI {
  80993. /**
  80994. * Class used to load GUI via XML.
  80995. */
  80996. export class XmlLoader {
  80997. private _nodes;
  80998. private _nodeTypes;
  80999. private _isLoaded;
  81000. private _objectAttributes;
  81001. private _parentClass;
  81002. /**
  81003. * Create a new xml loader
  81004. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81005. */
  81006. constructor(parentClass?: null);
  81007. private _getChainElement;
  81008. private _getClassAttribute;
  81009. private _createGuiElement;
  81010. private _parseGrid;
  81011. private _parseElement;
  81012. private _prepareSourceElement;
  81013. private _parseElementsFromSource;
  81014. private _parseXml;
  81015. /**
  81016. * Gets if the loading has finished.
  81017. * @returns whether the loading has finished or not
  81018. */
  81019. isLoaded(): boolean;
  81020. /**
  81021. * Gets a loaded node / control by id.
  81022. * @param id the Controls id set in the xml
  81023. * @returns element of type Control
  81024. */
  81025. getNodeById(id: string): any;
  81026. /**
  81027. * Gets all loaded nodes / controls
  81028. * @returns Array of controls
  81029. */
  81030. getNodes(): any;
  81031. /**
  81032. * Initiates the xml layout loading
  81033. * @param xmlFile defines the xml layout to load
  81034. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81035. * @param callback defines the callback called on layout load.
  81036. */
  81037. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81038. }
  81039. }
  81040. declare module BABYLON.GUI {
  81041. /**
  81042. * Class used to create containers for controls
  81043. */
  81044. export class Container3D extends Control3D {
  81045. private _blockLayout;
  81046. /**
  81047. * Gets the list of child controls
  81048. */
  81049. protected _children: Control3D[];
  81050. /**
  81051. * Gets the list of child controls
  81052. */
  81053. get children(): Array<Control3D>;
  81054. /**
  81055. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81056. * This is helpful to optimize layout operation when adding multiple children in a row
  81057. */
  81058. get blockLayout(): boolean;
  81059. set blockLayout(value: boolean);
  81060. /**
  81061. * Creates a new container
  81062. * @param name defines the container name
  81063. */
  81064. constructor(name?: string);
  81065. /**
  81066. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81067. * @returns the current container
  81068. */
  81069. updateLayout(): Container3D;
  81070. /**
  81071. * Gets a boolean indicating if the given control is in the children of this control
  81072. * @param control defines the control to check
  81073. * @returns true if the control is in the child list
  81074. */
  81075. containsControl(control: Control3D): boolean;
  81076. /**
  81077. * Adds a control to the children of this control
  81078. * @param control defines the control to add
  81079. * @returns the current container
  81080. */
  81081. addControl(control: Control3D): Container3D;
  81082. /**
  81083. * This function will be called everytime a new control is added
  81084. */
  81085. protected _arrangeChildren(): void;
  81086. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81087. /**
  81088. * Removes a control from the children of this control
  81089. * @param control defines the control to remove
  81090. * @returns the current container
  81091. */
  81092. removeControl(control: Control3D): Container3D;
  81093. protected _getTypeName(): string;
  81094. /**
  81095. * Releases all associated resources
  81096. */
  81097. dispose(): void;
  81098. /** Control rotation will remain unchanged */
  81099. static readonly UNSET_ORIENTATION: number;
  81100. /** Control will rotate to make it look at sphere central axis */
  81101. static readonly FACEORIGIN_ORIENTATION: number;
  81102. /** Control will rotate to make it look back at sphere central axis */
  81103. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81104. /** Control will rotate to look at z axis (0, 0, 1) */
  81105. static readonly FACEFORWARD_ORIENTATION: number;
  81106. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81107. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81108. }
  81109. }
  81110. declare module BABYLON.GUI {
  81111. /**
  81112. * Class used to manage 3D user interface
  81113. * @see https://doc.babylonjs.com/how_to/gui3d
  81114. */
  81115. export class GUI3DManager implements BABYLON.IDisposable {
  81116. private _scene;
  81117. private _sceneDisposeObserver;
  81118. private _utilityLayer;
  81119. private _rootContainer;
  81120. private _pointerObserver;
  81121. private _pointerOutObserver;
  81122. /** @hidden */
  81123. _lastPickedControl: Control3D;
  81124. /** @hidden */
  81125. _lastControlOver: {
  81126. [pointerId: number]: Control3D;
  81127. };
  81128. /** @hidden */
  81129. _lastControlDown: {
  81130. [pointerId: number]: Control3D;
  81131. };
  81132. /**
  81133. * BABYLON.Observable raised when the point picked by the pointer events changed
  81134. */
  81135. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81136. /** @hidden */
  81137. _sharedMaterials: {
  81138. [key: string]: BABYLON.Material;
  81139. };
  81140. /** Gets the hosting scene */
  81141. get scene(): BABYLON.Scene;
  81142. /** Gets associated utility layer */
  81143. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81144. /**
  81145. * Creates a new GUI3DManager
  81146. * @param scene
  81147. */
  81148. constructor(scene?: BABYLON.Scene);
  81149. private _handlePointerOut;
  81150. private _doPicking;
  81151. /**
  81152. * Gets the root container
  81153. */
  81154. get rootContainer(): Container3D;
  81155. /**
  81156. * Gets a boolean indicating if the given control is in the root child list
  81157. * @param control defines the control to check
  81158. * @returns true if the control is in the root child list
  81159. */
  81160. containsControl(control: Control3D): boolean;
  81161. /**
  81162. * Adds a control to the root child list
  81163. * @param control defines the control to add
  81164. * @returns the current manager
  81165. */
  81166. addControl(control: Control3D): GUI3DManager;
  81167. /**
  81168. * Removes a control from the root child list
  81169. * @param control defines the control to remove
  81170. * @returns the current container
  81171. */
  81172. removeControl(control: Control3D): GUI3DManager;
  81173. /**
  81174. * Releases all associated resources
  81175. */
  81176. dispose(): void;
  81177. }
  81178. }
  81179. declare module BABYLON.GUI {
  81180. /**
  81181. * Class used to transport BABYLON.Vector3 information for pointer events
  81182. */
  81183. export class Vector3WithInfo extends BABYLON.Vector3 {
  81184. /** defines the current mouse button index */
  81185. buttonIndex: number;
  81186. /**
  81187. * Creates a new Vector3WithInfo
  81188. * @param source defines the vector3 data to transport
  81189. * @param buttonIndex defines the current mouse button index
  81190. */
  81191. constructor(source: BABYLON.Vector3,
  81192. /** defines the current mouse button index */
  81193. buttonIndex?: number);
  81194. }
  81195. }
  81196. declare module BABYLON.GUI {
  81197. /**
  81198. * Class used as base class for controls
  81199. */
  81200. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81201. /** Defines the control name */
  81202. name?: string | undefined;
  81203. /** @hidden */
  81204. _host: GUI3DManager;
  81205. private _node;
  81206. private _downCount;
  81207. private _enterCount;
  81208. private _downPointerIds;
  81209. private _isVisible;
  81210. /** Gets or sets the control position in world space */
  81211. get position(): BABYLON.Vector3;
  81212. set position(value: BABYLON.Vector3);
  81213. /** Gets or sets the control scaling in world space */
  81214. get scaling(): BABYLON.Vector3;
  81215. set scaling(value: BABYLON.Vector3);
  81216. /** Callback used to start pointer enter animation */
  81217. pointerEnterAnimation: () => void;
  81218. /** Callback used to start pointer out animation */
  81219. pointerOutAnimation: () => void;
  81220. /** Callback used to start pointer down animation */
  81221. pointerDownAnimation: () => void;
  81222. /** Callback used to start pointer up animation */
  81223. pointerUpAnimation: () => void;
  81224. /**
  81225. * An event triggered when the pointer move over the control
  81226. */
  81227. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81228. /**
  81229. * An event triggered when the pointer move out of the control
  81230. */
  81231. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81232. /**
  81233. * An event triggered when the pointer taps the control
  81234. */
  81235. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81236. /**
  81237. * An event triggered when pointer is up
  81238. */
  81239. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81240. /**
  81241. * An event triggered when a control is clicked on (with a mouse)
  81242. */
  81243. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81244. /**
  81245. * An event triggered when pointer enters the control
  81246. */
  81247. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81248. /**
  81249. * Gets or sets the parent container
  81250. */
  81251. parent: BABYLON.Nullable<Container3D>;
  81252. private _behaviors;
  81253. /**
  81254. * Gets the list of attached behaviors
  81255. * @see https://doc.babylonjs.com/features/behaviour
  81256. */
  81257. get behaviors(): BABYLON.Behavior<Control3D>[];
  81258. /**
  81259. * Attach a behavior to the control
  81260. * @see https://doc.babylonjs.com/features/behaviour
  81261. * @param behavior defines the behavior to attach
  81262. * @returns the current control
  81263. */
  81264. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81265. /**
  81266. * Remove an attached behavior
  81267. * @see https://doc.babylonjs.com/features/behaviour
  81268. * @param behavior defines the behavior to attach
  81269. * @returns the current control
  81270. */
  81271. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81272. /**
  81273. * Gets an attached behavior by name
  81274. * @param name defines the name of the behavior to look for
  81275. * @see https://doc.babylonjs.com/features/behaviour
  81276. * @returns null if behavior was not found else the requested behavior
  81277. */
  81278. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81279. /** Gets or sets a boolean indicating if the control is visible */
  81280. get isVisible(): boolean;
  81281. set isVisible(value: boolean);
  81282. /**
  81283. * Creates a new control
  81284. * @param name defines the control name
  81285. */
  81286. constructor(
  81287. /** Defines the control name */
  81288. name?: string | undefined);
  81289. /**
  81290. * Gets a string representing the class name
  81291. */
  81292. get typeName(): string;
  81293. /**
  81294. * Get the current class name of the control.
  81295. * @returns current class name
  81296. */
  81297. getClassName(): string;
  81298. protected _getTypeName(): string;
  81299. /**
  81300. * Gets the transform node used by this control
  81301. */
  81302. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81303. /**
  81304. * Gets the mesh used to render this control
  81305. */
  81306. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81307. /**
  81308. * Link the control as child of the given node
  81309. * @param node defines the node to link to. Use null to unlink the control
  81310. * @returns the current control
  81311. */
  81312. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81313. /** @hidden **/
  81314. _prepareNode(scene: BABYLON.Scene): void;
  81315. /**
  81316. * Node creation.
  81317. * Can be overriden by children
  81318. * @param scene defines the scene where the node must be attached
  81319. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81320. */
  81321. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81322. /**
  81323. * Affect a material to the given mesh
  81324. * @param mesh defines the mesh which will represent the control
  81325. */
  81326. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81327. /** @hidden */
  81328. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81329. /** @hidden */
  81330. _onPointerEnter(target: Control3D): boolean;
  81331. /** @hidden */
  81332. _onPointerOut(target: Control3D): void;
  81333. /** @hidden */
  81334. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81335. /** @hidden */
  81336. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81337. /** @hidden */
  81338. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81339. /** @hidden */
  81340. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81341. /** @hidden */
  81342. _disposeNode(): void;
  81343. /**
  81344. * Releases all associated resources
  81345. */
  81346. dispose(): void;
  81347. }
  81348. }
  81349. declare module BABYLON.GUI {
  81350. /**
  81351. * Class used as a root to all buttons
  81352. */
  81353. export class AbstractButton3D extends Control3D {
  81354. /**
  81355. * Creates a new button
  81356. * @param name defines the control name
  81357. */
  81358. constructor(name?: string);
  81359. protected _getTypeName(): string;
  81360. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81361. }
  81362. }
  81363. declare module BABYLON.GUI {
  81364. /**
  81365. * Class used to create a button in 3D
  81366. */
  81367. export class Button3D extends AbstractButton3D {
  81368. /** @hidden */
  81369. protected _currentMaterial: BABYLON.Material;
  81370. private _facadeTexture;
  81371. private _content;
  81372. private _contentResolution;
  81373. private _contentScaleRatio;
  81374. /**
  81375. * Gets or sets the texture resolution used to render content (512 by default)
  81376. */
  81377. get contentResolution(): BABYLON.int;
  81378. set contentResolution(value: BABYLON.int);
  81379. /**
  81380. * Gets or sets the texture scale ratio used to render content (2 by default)
  81381. */
  81382. get contentScaleRatio(): number;
  81383. set contentScaleRatio(value: number);
  81384. protected _disposeFacadeTexture(): void;
  81385. protected _resetContent(): void;
  81386. /**
  81387. * Creates a new button
  81388. * @param name defines the control name
  81389. */
  81390. constructor(name?: string);
  81391. /**
  81392. * Gets or sets the GUI 2D content used to display the button's facade
  81393. */
  81394. get content(): Control;
  81395. set content(value: Control);
  81396. /**
  81397. * Apply the facade texture (created from the content property).
  81398. * This function can be overloaded by child classes
  81399. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81400. */
  81401. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81402. protected _getTypeName(): string;
  81403. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81404. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81405. /**
  81406. * Releases all associated resources
  81407. */
  81408. dispose(): void;
  81409. }
  81410. }
  81411. declare module BABYLON.GUI {
  81412. /**
  81413. * Abstract class used to create a container panel deployed on the surface of a volume
  81414. */
  81415. export abstract class VolumeBasedPanel extends Container3D {
  81416. private _columns;
  81417. private _rows;
  81418. private _rowThenColum;
  81419. private _orientation;
  81420. protected _cellWidth: number;
  81421. protected _cellHeight: number;
  81422. /**
  81423. * Gets or sets the distance between elements
  81424. */
  81425. margin: number;
  81426. /**
  81427. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81428. * | Value | Type | Description |
  81429. * | ----- | ----------------------------------- | ----------- |
  81430. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81431. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81432. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81433. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81434. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81435. */
  81436. get orientation(): number;
  81437. set orientation(value: number);
  81438. /**
  81439. * Gets or sets the number of columns requested (10 by default).
  81440. * The panel will automatically compute the number of rows based on number of child controls.
  81441. */
  81442. get columns(): BABYLON.int;
  81443. set columns(value: BABYLON.int);
  81444. /**
  81445. * Gets or sets a the number of rows requested.
  81446. * The panel will automatically compute the number of columns based on number of child controls.
  81447. */
  81448. get rows(): BABYLON.int;
  81449. set rows(value: BABYLON.int);
  81450. /**
  81451. * Creates new VolumeBasedPanel
  81452. */
  81453. constructor();
  81454. protected _arrangeChildren(): void;
  81455. /** Child classes must implement this function to provide correct control positioning */
  81456. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81457. /** Child classes can implement this function to provide additional processing */
  81458. protected _finalProcessing(): void;
  81459. }
  81460. }
  81461. declare module BABYLON.GUI {
  81462. /**
  81463. * Class used to create a container panel deployed on the surface of a cylinder
  81464. */
  81465. export class CylinderPanel extends VolumeBasedPanel {
  81466. private _radius;
  81467. /**
  81468. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81469. */
  81470. get radius(): BABYLON.float;
  81471. set radius(value: BABYLON.float);
  81472. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81473. private _cylindricalMapping;
  81474. }
  81475. }
  81476. declare module BABYLON.GUI {
  81477. /** @hidden */
  81478. export var fluentVertexShader: {
  81479. name: string;
  81480. shader: string;
  81481. };
  81482. }
  81483. declare module BABYLON.GUI {
  81484. /** @hidden */
  81485. export var fluentPixelShader: {
  81486. name: string;
  81487. shader: string;
  81488. };
  81489. }
  81490. declare module BABYLON.GUI {
  81491. /** @hidden */
  81492. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81493. INNERGLOW: boolean;
  81494. BORDER: boolean;
  81495. HOVERLIGHT: boolean;
  81496. TEXTURE: boolean;
  81497. constructor();
  81498. }
  81499. /**
  81500. * Class used to render controls with fluent desgin
  81501. */
  81502. export class FluentMaterial extends BABYLON.PushMaterial {
  81503. /**
  81504. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81505. */
  81506. innerGlowColorIntensity: number;
  81507. /**
  81508. * Gets or sets the inner glow color (white by default)
  81509. */
  81510. innerGlowColor: BABYLON.Color3;
  81511. /**
  81512. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81513. */
  81514. albedoColor: BABYLON.Color3;
  81515. /**
  81516. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81517. */
  81518. renderBorders: boolean;
  81519. /**
  81520. * Gets or sets border width (default is 0.5)
  81521. */
  81522. borderWidth: number;
  81523. /**
  81524. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81525. */
  81526. edgeSmoothingValue: number;
  81527. /**
  81528. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81529. */
  81530. borderMinValue: number;
  81531. /**
  81532. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81533. */
  81534. renderHoverLight: boolean;
  81535. /**
  81536. * Gets or sets the radius used to render the hover light (default is 1.0)
  81537. */
  81538. hoverRadius: number;
  81539. /**
  81540. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81541. */
  81542. hoverColor: BABYLON.Color4;
  81543. /**
  81544. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81545. */
  81546. hoverPosition: BABYLON.Vector3;
  81547. private _albedoTexture;
  81548. /** Gets or sets the texture to use for albedo color */
  81549. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81550. /**
  81551. * Creates a new Fluent material
  81552. * @param name defines the name of the material
  81553. * @param scene defines the hosting scene
  81554. */
  81555. constructor(name: string, scene: BABYLON.Scene);
  81556. needAlphaBlending(): boolean;
  81557. needAlphaTesting(): boolean;
  81558. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81559. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81560. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81561. getActiveTextures(): BABYLON.BaseTexture[];
  81562. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81563. dispose(forceDisposeEffect?: boolean): void;
  81564. clone(name: string): FluentMaterial;
  81565. serialize(): any;
  81566. getClassName(): string;
  81567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81568. }
  81569. }
  81570. declare module BABYLON.GUI {
  81571. /**
  81572. * Class used to create a holographic button in 3D
  81573. */
  81574. export class HolographicButton extends Button3D {
  81575. private _backPlate;
  81576. private _textPlate;
  81577. private _frontPlate;
  81578. private _text;
  81579. private _imageUrl;
  81580. private _shareMaterials;
  81581. private _frontMaterial;
  81582. private _backMaterial;
  81583. private _plateMaterial;
  81584. private _pickedPointObserver;
  81585. private _tooltipFade;
  81586. private _tooltipTextBlock;
  81587. private _tooltipTexture;
  81588. private _tooltipMesh;
  81589. private _tooltipHoverObserver;
  81590. private _tooltipOutObserver;
  81591. private _disposeTooltip;
  81592. /**
  81593. * Rendering ground id of all the mesh in the button
  81594. */
  81595. set renderingGroupId(id: number);
  81596. get renderingGroupId(): number;
  81597. /**
  81598. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81599. */
  81600. set tooltipText(text: BABYLON.Nullable<string>);
  81601. get tooltipText(): BABYLON.Nullable<string>;
  81602. /**
  81603. * Gets or sets text for the button
  81604. */
  81605. get text(): string;
  81606. set text(value: string);
  81607. /**
  81608. * Gets or sets the image url for the button
  81609. */
  81610. get imageUrl(): string;
  81611. set imageUrl(value: string);
  81612. /**
  81613. * Gets the back material used by this button
  81614. */
  81615. get backMaterial(): FluentMaterial;
  81616. /**
  81617. * Gets the front material used by this button
  81618. */
  81619. get frontMaterial(): FluentMaterial;
  81620. /**
  81621. * Gets the plate material used by this button
  81622. */
  81623. get plateMaterial(): BABYLON.StandardMaterial;
  81624. /**
  81625. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81626. */
  81627. get shareMaterials(): boolean;
  81628. /**
  81629. * Creates a new button
  81630. * @param name defines the control name
  81631. */
  81632. constructor(name?: string, shareMaterials?: boolean);
  81633. protected _getTypeName(): string;
  81634. private _rebuildContent;
  81635. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81636. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81637. private _createBackMaterial;
  81638. private _createFrontMaterial;
  81639. private _createPlateMaterial;
  81640. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81641. /**
  81642. * Releases all associated resources
  81643. */
  81644. dispose(): void;
  81645. }
  81646. }
  81647. declare module BABYLON.GUI {
  81648. /**
  81649. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81650. */
  81651. export class MeshButton3D extends Button3D {
  81652. /** @hidden */
  81653. protected _currentMesh: BABYLON.Mesh;
  81654. /**
  81655. * Creates a new 3D button based on a mesh
  81656. * @param mesh mesh to become a 3D button
  81657. * @param name defines the control name
  81658. */
  81659. constructor(mesh: BABYLON.Mesh, name?: string);
  81660. protected _getTypeName(): string;
  81661. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81662. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81663. }
  81664. }
  81665. declare module BABYLON.GUI {
  81666. /**
  81667. * Class used to create a container panel deployed on the surface of a plane
  81668. */
  81669. export class PlanePanel extends VolumeBasedPanel {
  81670. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81671. }
  81672. }
  81673. declare module BABYLON.GUI {
  81674. /**
  81675. * Class used to create a container panel where items get randomized planar mapping
  81676. */
  81677. export class ScatterPanel extends VolumeBasedPanel {
  81678. private _iteration;
  81679. /**
  81680. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81681. */
  81682. get iteration(): BABYLON.float;
  81683. set iteration(value: BABYLON.float);
  81684. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81685. private _scatterMapping;
  81686. protected _finalProcessing(): void;
  81687. }
  81688. }
  81689. declare module BABYLON.GUI {
  81690. /**
  81691. * Class used to create a container panel deployed on the surface of a sphere
  81692. */
  81693. export class SpherePanel extends VolumeBasedPanel {
  81694. private _radius;
  81695. /**
  81696. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81697. */
  81698. get radius(): BABYLON.float;
  81699. set radius(value: BABYLON.float);
  81700. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81701. private _sphericalMapping;
  81702. }
  81703. }
  81704. declare module BABYLON.GUI {
  81705. /**
  81706. * Class used to create a stack panel in 3D on XY plane
  81707. */
  81708. export class StackPanel3D extends Container3D {
  81709. private _isVertical;
  81710. /**
  81711. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81712. */
  81713. get isVertical(): boolean;
  81714. set isVertical(value: boolean);
  81715. /**
  81716. * Gets or sets the distance between elements
  81717. */
  81718. margin: number;
  81719. /**
  81720. * Creates new StackPanel
  81721. * @param isVertical
  81722. */
  81723. constructor(isVertical?: boolean);
  81724. protected _arrangeChildren(): void;
  81725. }
  81726. }
  81727. declare module BABYLON {
  81728. /**
  81729. * Configuration for glTF validation
  81730. */
  81731. export interface IGLTFValidationConfiguration {
  81732. /**
  81733. * The url of the glTF validator.
  81734. */
  81735. url: string;
  81736. }
  81737. /**
  81738. * glTF validation
  81739. */
  81740. export class GLTFValidation {
  81741. /**
  81742. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81743. */
  81744. static Configuration: IGLTFValidationConfiguration;
  81745. private static _LoadScriptPromise;
  81746. /**
  81747. * Validate a glTF asset using the glTF-Validator.
  81748. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81749. * @param rootUrl The root url for the glTF
  81750. * @param fileName The file name for the glTF
  81751. * @param getExternalResource The callback to get external resources for the glTF validator
  81752. * @returns A promise that resolves with the glTF validation results once complete
  81753. */
  81754. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81755. }
  81756. }
  81757. declare module BABYLON {
  81758. /**
  81759. * Mode that determines the coordinate system to use.
  81760. */
  81761. export enum GLTFLoaderCoordinateSystemMode {
  81762. /**
  81763. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81764. */
  81765. AUTO = 0,
  81766. /**
  81767. * Sets the useRightHandedSystem flag on the scene.
  81768. */
  81769. FORCE_RIGHT_HANDED = 1
  81770. }
  81771. /**
  81772. * Mode that determines what animations will start.
  81773. */
  81774. export enum GLTFLoaderAnimationStartMode {
  81775. /**
  81776. * No animation will start.
  81777. */
  81778. NONE = 0,
  81779. /**
  81780. * The first animation will start.
  81781. */
  81782. FIRST = 1,
  81783. /**
  81784. * All animations will start.
  81785. */
  81786. ALL = 2
  81787. }
  81788. /**
  81789. * Interface that contains the data for the glTF asset.
  81790. */
  81791. export interface IGLTFLoaderData {
  81792. /**
  81793. * The object that represents the glTF JSON.
  81794. */
  81795. json: Object;
  81796. /**
  81797. * The BIN chunk of a binary glTF.
  81798. */
  81799. bin: Nullable<IDataBuffer>;
  81800. }
  81801. /**
  81802. * Interface for extending the loader.
  81803. */
  81804. export interface IGLTFLoaderExtension {
  81805. /**
  81806. * The name of this extension.
  81807. */
  81808. readonly name: string;
  81809. /**
  81810. * Defines whether this extension is enabled.
  81811. */
  81812. enabled: boolean;
  81813. /**
  81814. * Defines the order of this extension.
  81815. * The loader sorts the extensions using these values when loading.
  81816. */
  81817. order?: number;
  81818. }
  81819. /**
  81820. * Loader state.
  81821. */
  81822. export enum GLTFLoaderState {
  81823. /**
  81824. * The asset is loading.
  81825. */
  81826. LOADING = 0,
  81827. /**
  81828. * The asset is ready for rendering.
  81829. */
  81830. READY = 1,
  81831. /**
  81832. * The asset is completely loaded.
  81833. */
  81834. COMPLETE = 2
  81835. }
  81836. /** @hidden */
  81837. export interface IImportMeshAsyncOutput {
  81838. meshes: AbstractMesh[];
  81839. geometries: Geometry[];
  81840. particleSystems: IParticleSystem[];
  81841. skeletons: Skeleton[];
  81842. animationGroups: AnimationGroup[];
  81843. lights: Light[];
  81844. transformNodes: TransformNode[];
  81845. }
  81846. /** @hidden */
  81847. export interface IGLTFLoader extends IDisposable {
  81848. readonly state: Nullable<GLTFLoaderState>;
  81849. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81850. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81851. }
  81852. /**
  81853. * File loader for loading glTF files into a scene.
  81854. */
  81855. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81856. /** @hidden */
  81857. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81858. /** @hidden */
  81859. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81860. /**
  81861. * Raised when the asset has been parsed
  81862. */
  81863. onParsedObservable: Observable<IGLTFLoaderData>;
  81864. private _onParsedObserver;
  81865. /**
  81866. * Raised when the asset has been parsed
  81867. */
  81868. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81869. /**
  81870. * 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.
  81871. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81872. * Defaults to true.
  81873. * @hidden
  81874. */
  81875. static IncrementalLoading: boolean;
  81876. /**
  81877. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81878. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81879. * @hidden
  81880. */
  81881. static HomogeneousCoordinates: boolean;
  81882. /**
  81883. * The coordinate system mode. Defaults to AUTO.
  81884. */
  81885. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81886. /**
  81887. * The animation start mode. Defaults to FIRST.
  81888. */
  81889. animationStartMode: GLTFLoaderAnimationStartMode;
  81890. /**
  81891. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81892. */
  81893. compileMaterials: boolean;
  81894. /**
  81895. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81896. */
  81897. useClipPlane: boolean;
  81898. /**
  81899. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81900. */
  81901. compileShadowGenerators: boolean;
  81902. /**
  81903. * Defines if the Alpha blended materials are only applied as coverage.
  81904. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81905. * If true, no extra effects are applied to transparent pixels.
  81906. */
  81907. transparencyAsCoverage: boolean;
  81908. /**
  81909. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81910. * Enabling will disable offline support and glTF validator.
  81911. * Defaults to false.
  81912. */
  81913. useRangeRequests: boolean;
  81914. /**
  81915. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81916. */
  81917. createInstances: boolean;
  81918. /**
  81919. * 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.
  81920. */
  81921. alwaysComputeBoundingBox: boolean;
  81922. /**
  81923. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81924. */
  81925. loadAllMaterials: boolean;
  81926. /**
  81927. * Function called before loading a url referenced by the asset.
  81928. */
  81929. preprocessUrlAsync: (url: string) => Promise<string>;
  81930. /**
  81931. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81932. * 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, ...)
  81933. */
  81934. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81935. private _onMeshLoadedObserver;
  81936. /**
  81937. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81938. * 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, ...)
  81939. */
  81940. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81941. /**
  81942. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81943. */
  81944. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81945. private _onTextureLoadedObserver;
  81946. /**
  81947. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81948. */
  81949. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81950. /**
  81951. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81952. */
  81953. readonly onMaterialLoadedObservable: Observable<Material>;
  81954. private _onMaterialLoadedObserver;
  81955. /**
  81956. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81957. */
  81958. set onMaterialLoaded(callback: (material: Material) => void);
  81959. /**
  81960. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81961. */
  81962. readonly onCameraLoadedObservable: Observable<Camera>;
  81963. private _onCameraLoadedObserver;
  81964. /**
  81965. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81966. */
  81967. set onCameraLoaded(callback: (camera: Camera) => void);
  81968. /**
  81969. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81970. * For assets with LODs, raised when all of the LODs are complete.
  81971. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81972. */
  81973. readonly onCompleteObservable: Observable<void>;
  81974. private _onCompleteObserver;
  81975. /**
  81976. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81977. * For assets with LODs, raised when all of the LODs are complete.
  81978. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81979. */
  81980. set onComplete(callback: () => void);
  81981. /**
  81982. * Observable raised when an error occurs.
  81983. */
  81984. readonly onErrorObservable: Observable<any>;
  81985. private _onErrorObserver;
  81986. /**
  81987. * Callback raised when an error occurs.
  81988. */
  81989. set onError(callback: (reason: any) => void);
  81990. /**
  81991. * Observable raised after the loader is disposed.
  81992. */
  81993. readonly onDisposeObservable: Observable<void>;
  81994. private _onDisposeObserver;
  81995. /**
  81996. * Callback raised after the loader is disposed.
  81997. */
  81998. set onDispose(callback: () => void);
  81999. /**
  82000. * Observable raised after a loader extension is created.
  82001. * Set additional options for a loader extension in this event.
  82002. */
  82003. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82004. private _onExtensionLoadedObserver;
  82005. /**
  82006. * Callback raised after a loader extension is created.
  82007. */
  82008. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82009. /**
  82010. * Defines if the loader logging is enabled.
  82011. */
  82012. get loggingEnabled(): boolean;
  82013. set loggingEnabled(value: boolean);
  82014. /**
  82015. * Defines if the loader should capture performance counters.
  82016. */
  82017. get capturePerformanceCounters(): boolean;
  82018. set capturePerformanceCounters(value: boolean);
  82019. /**
  82020. * Defines if the loader should validate the asset.
  82021. */
  82022. validate: boolean;
  82023. /**
  82024. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82025. */
  82026. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82027. private _onValidatedObserver;
  82028. /**
  82029. * Callback raised after a loader extension is created.
  82030. */
  82031. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82032. private _loader;
  82033. private _progressCallback?;
  82034. private _requests;
  82035. private static magicBase64Encoded;
  82036. /**
  82037. * Name of the loader ("gltf")
  82038. */
  82039. name: string;
  82040. /** @hidden */
  82041. extensions: ISceneLoaderPluginExtensions;
  82042. /**
  82043. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82044. */
  82045. dispose(): void;
  82046. /** @hidden */
  82047. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82048. /** @hidden */
  82049. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82050. /** @hidden */
  82051. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82052. meshes: AbstractMesh[];
  82053. particleSystems: IParticleSystem[];
  82054. skeletons: Skeleton[];
  82055. animationGroups: AnimationGroup[];
  82056. }>;
  82057. /** @hidden */
  82058. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82059. /** @hidden */
  82060. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82061. /** @hidden */
  82062. canDirectLoad(data: string): boolean;
  82063. /** @hidden */
  82064. directLoad(scene: Scene, data: string): Promise<any>;
  82065. /**
  82066. * The callback that allows custom handling of the root url based on the response url.
  82067. * @param rootUrl the original root url
  82068. * @param responseURL the response url if available
  82069. * @returns the new root url
  82070. */
  82071. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82072. /** @hidden */
  82073. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82074. /**
  82075. * The loader state or null if the loader is not active.
  82076. */
  82077. get loaderState(): Nullable<GLTFLoaderState>;
  82078. /**
  82079. * Returns a promise that resolves when the asset is completely loaded.
  82080. * @returns a promise that resolves when the asset is completely loaded.
  82081. */
  82082. whenCompleteAsync(): Promise<void>;
  82083. /** @hidden */
  82084. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82085. /** @hidden */
  82086. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82087. private _onProgress;
  82088. private _validate;
  82089. private _getLoader;
  82090. private _parseJson;
  82091. private _unpackBinaryAsync;
  82092. private _unpackBinaryV1Async;
  82093. private _unpackBinaryV2Async;
  82094. private static _parseVersion;
  82095. private static _compareVersion;
  82096. private static readonly _logSpaces;
  82097. private _logIndentLevel;
  82098. private _loggingEnabled;
  82099. /** @hidden */
  82100. _log: (message: string) => void;
  82101. /** @hidden */
  82102. _logOpen(message: string): void;
  82103. /** @hidden */
  82104. _logClose(): void;
  82105. private _logEnabled;
  82106. private _logDisabled;
  82107. private _capturePerformanceCounters;
  82108. /** @hidden */
  82109. _startPerformanceCounter: (counterName: string) => void;
  82110. /** @hidden */
  82111. _endPerformanceCounter: (counterName: string) => void;
  82112. private _startPerformanceCounterEnabled;
  82113. private _startPerformanceCounterDisabled;
  82114. private _endPerformanceCounterEnabled;
  82115. private _endPerformanceCounterDisabled;
  82116. }
  82117. }
  82118. declare module BABYLON.GLTF1 {
  82119. /**
  82120. * Enums
  82121. * @hidden
  82122. */
  82123. export enum EComponentType {
  82124. BYTE = 5120,
  82125. UNSIGNED_BYTE = 5121,
  82126. SHORT = 5122,
  82127. UNSIGNED_SHORT = 5123,
  82128. FLOAT = 5126
  82129. }
  82130. /** @hidden */
  82131. export enum EShaderType {
  82132. FRAGMENT = 35632,
  82133. VERTEX = 35633
  82134. }
  82135. /** @hidden */
  82136. export enum EParameterType {
  82137. BYTE = 5120,
  82138. UNSIGNED_BYTE = 5121,
  82139. SHORT = 5122,
  82140. UNSIGNED_SHORT = 5123,
  82141. INT = 5124,
  82142. UNSIGNED_INT = 5125,
  82143. FLOAT = 5126,
  82144. FLOAT_VEC2 = 35664,
  82145. FLOAT_VEC3 = 35665,
  82146. FLOAT_VEC4 = 35666,
  82147. INT_VEC2 = 35667,
  82148. INT_VEC3 = 35668,
  82149. INT_VEC4 = 35669,
  82150. BOOL = 35670,
  82151. BOOL_VEC2 = 35671,
  82152. BOOL_VEC3 = 35672,
  82153. BOOL_VEC4 = 35673,
  82154. FLOAT_MAT2 = 35674,
  82155. FLOAT_MAT3 = 35675,
  82156. FLOAT_MAT4 = 35676,
  82157. SAMPLER_2D = 35678
  82158. }
  82159. /** @hidden */
  82160. export enum ETextureWrapMode {
  82161. CLAMP_TO_EDGE = 33071,
  82162. MIRRORED_REPEAT = 33648,
  82163. REPEAT = 10497
  82164. }
  82165. /** @hidden */
  82166. export enum ETextureFilterType {
  82167. NEAREST = 9728,
  82168. LINEAR = 9728,
  82169. NEAREST_MIPMAP_NEAREST = 9984,
  82170. LINEAR_MIPMAP_NEAREST = 9985,
  82171. NEAREST_MIPMAP_LINEAR = 9986,
  82172. LINEAR_MIPMAP_LINEAR = 9987
  82173. }
  82174. /** @hidden */
  82175. export enum ETextureFormat {
  82176. ALPHA = 6406,
  82177. RGB = 6407,
  82178. RGBA = 6408,
  82179. LUMINANCE = 6409,
  82180. LUMINANCE_ALPHA = 6410
  82181. }
  82182. /** @hidden */
  82183. export enum ECullingType {
  82184. FRONT = 1028,
  82185. BACK = 1029,
  82186. FRONT_AND_BACK = 1032
  82187. }
  82188. /** @hidden */
  82189. export enum EBlendingFunction {
  82190. ZERO = 0,
  82191. ONE = 1,
  82192. SRC_COLOR = 768,
  82193. ONE_MINUS_SRC_COLOR = 769,
  82194. DST_COLOR = 774,
  82195. ONE_MINUS_DST_COLOR = 775,
  82196. SRC_ALPHA = 770,
  82197. ONE_MINUS_SRC_ALPHA = 771,
  82198. DST_ALPHA = 772,
  82199. ONE_MINUS_DST_ALPHA = 773,
  82200. CONSTANT_COLOR = 32769,
  82201. ONE_MINUS_CONSTANT_COLOR = 32770,
  82202. CONSTANT_ALPHA = 32771,
  82203. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82204. SRC_ALPHA_SATURATE = 776
  82205. }
  82206. /** @hidden */
  82207. export interface IGLTFProperty {
  82208. extensions?: {
  82209. [key: string]: any;
  82210. };
  82211. extras?: Object;
  82212. }
  82213. /** @hidden */
  82214. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82215. name?: string;
  82216. }
  82217. /** @hidden */
  82218. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82219. bufferView: string;
  82220. byteOffset: number;
  82221. byteStride: number;
  82222. count: number;
  82223. type: string;
  82224. componentType: EComponentType;
  82225. max?: number[];
  82226. min?: number[];
  82227. name?: string;
  82228. }
  82229. /** @hidden */
  82230. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82231. buffer: string;
  82232. byteOffset: number;
  82233. byteLength: number;
  82234. byteStride: number;
  82235. target?: number;
  82236. }
  82237. /** @hidden */
  82238. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82239. uri: string;
  82240. byteLength?: number;
  82241. type?: string;
  82242. }
  82243. /** @hidden */
  82244. export interface IGLTFShader extends IGLTFChildRootProperty {
  82245. uri: string;
  82246. type: EShaderType;
  82247. }
  82248. /** @hidden */
  82249. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82250. attributes: string[];
  82251. fragmentShader: string;
  82252. vertexShader: string;
  82253. }
  82254. /** @hidden */
  82255. export interface IGLTFTechniqueParameter {
  82256. type: number;
  82257. count?: number;
  82258. semantic?: string;
  82259. node?: string;
  82260. value?: number | boolean | string | Array<any>;
  82261. source?: string;
  82262. babylonValue?: any;
  82263. }
  82264. /** @hidden */
  82265. export interface IGLTFTechniqueCommonProfile {
  82266. lightingModel: string;
  82267. texcoordBindings: Object;
  82268. parameters?: Array<any>;
  82269. }
  82270. /** @hidden */
  82271. export interface IGLTFTechniqueStatesFunctions {
  82272. blendColor?: number[];
  82273. blendEquationSeparate?: number[];
  82274. blendFuncSeparate?: number[];
  82275. colorMask: boolean[];
  82276. cullFace: number[];
  82277. }
  82278. /** @hidden */
  82279. export interface IGLTFTechniqueStates {
  82280. enable: number[];
  82281. functions: IGLTFTechniqueStatesFunctions;
  82282. }
  82283. /** @hidden */
  82284. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82285. parameters: {
  82286. [key: string]: IGLTFTechniqueParameter;
  82287. };
  82288. program: string;
  82289. attributes: {
  82290. [key: string]: string;
  82291. };
  82292. uniforms: {
  82293. [key: string]: string;
  82294. };
  82295. states: IGLTFTechniqueStates;
  82296. }
  82297. /** @hidden */
  82298. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82299. technique?: string;
  82300. values: string[];
  82301. }
  82302. /** @hidden */
  82303. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82304. attributes: {
  82305. [key: string]: string;
  82306. };
  82307. indices: string;
  82308. material: string;
  82309. mode?: number;
  82310. }
  82311. /** @hidden */
  82312. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82313. primitives: IGLTFMeshPrimitive[];
  82314. }
  82315. /** @hidden */
  82316. export interface IGLTFImage extends IGLTFChildRootProperty {
  82317. uri: string;
  82318. }
  82319. /** @hidden */
  82320. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82321. magFilter?: number;
  82322. minFilter?: number;
  82323. wrapS?: number;
  82324. wrapT?: number;
  82325. }
  82326. /** @hidden */
  82327. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82328. sampler: string;
  82329. source: string;
  82330. format?: ETextureFormat;
  82331. internalFormat?: ETextureFormat;
  82332. target?: number;
  82333. type?: number;
  82334. babylonTexture?: Texture;
  82335. }
  82336. /** @hidden */
  82337. export interface IGLTFAmbienLight {
  82338. color?: number[];
  82339. }
  82340. /** @hidden */
  82341. export interface IGLTFDirectionalLight {
  82342. color?: number[];
  82343. }
  82344. /** @hidden */
  82345. export interface IGLTFPointLight {
  82346. color?: number[];
  82347. constantAttenuation?: number;
  82348. linearAttenuation?: number;
  82349. quadraticAttenuation?: number;
  82350. }
  82351. /** @hidden */
  82352. export interface IGLTFSpotLight {
  82353. color?: number[];
  82354. constantAttenuation?: number;
  82355. fallOfAngle?: number;
  82356. fallOffExponent?: number;
  82357. linearAttenuation?: number;
  82358. quadraticAttenuation?: number;
  82359. }
  82360. /** @hidden */
  82361. export interface IGLTFLight extends IGLTFChildRootProperty {
  82362. type: string;
  82363. }
  82364. /** @hidden */
  82365. export interface IGLTFCameraOrthographic {
  82366. xmag: number;
  82367. ymag: number;
  82368. zfar: number;
  82369. znear: number;
  82370. }
  82371. /** @hidden */
  82372. export interface IGLTFCameraPerspective {
  82373. aspectRatio: number;
  82374. yfov: number;
  82375. zfar: number;
  82376. znear: number;
  82377. }
  82378. /** @hidden */
  82379. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82380. type: string;
  82381. }
  82382. /** @hidden */
  82383. export interface IGLTFAnimationChannelTarget {
  82384. id: string;
  82385. path: string;
  82386. }
  82387. /** @hidden */
  82388. export interface IGLTFAnimationChannel {
  82389. sampler: string;
  82390. target: IGLTFAnimationChannelTarget;
  82391. }
  82392. /** @hidden */
  82393. export interface IGLTFAnimationSampler {
  82394. input: string;
  82395. output: string;
  82396. interpolation?: string;
  82397. }
  82398. /** @hidden */
  82399. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82400. channels?: IGLTFAnimationChannel[];
  82401. parameters?: {
  82402. [key: string]: string;
  82403. };
  82404. samplers?: {
  82405. [key: string]: IGLTFAnimationSampler;
  82406. };
  82407. }
  82408. /** @hidden */
  82409. export interface IGLTFNodeInstanceSkin {
  82410. skeletons: string[];
  82411. skin: string;
  82412. meshes: string[];
  82413. }
  82414. /** @hidden */
  82415. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82416. bindShapeMatrix: number[];
  82417. inverseBindMatrices: string;
  82418. jointNames: string[];
  82419. babylonSkeleton?: Skeleton;
  82420. }
  82421. /** @hidden */
  82422. export interface IGLTFNode extends IGLTFChildRootProperty {
  82423. camera?: string;
  82424. children: string[];
  82425. skin?: string;
  82426. jointName?: string;
  82427. light?: string;
  82428. matrix: number[];
  82429. mesh?: string;
  82430. meshes?: string[];
  82431. rotation?: number[];
  82432. scale?: number[];
  82433. translation?: number[];
  82434. babylonNode?: Node;
  82435. }
  82436. /** @hidden */
  82437. export interface IGLTFScene extends IGLTFChildRootProperty {
  82438. nodes: string[];
  82439. }
  82440. /** @hidden */
  82441. export interface IGLTFRuntime {
  82442. extensions: {
  82443. [key: string]: any;
  82444. };
  82445. accessors: {
  82446. [key: string]: IGLTFAccessor;
  82447. };
  82448. buffers: {
  82449. [key: string]: IGLTFBuffer;
  82450. };
  82451. bufferViews: {
  82452. [key: string]: IGLTFBufferView;
  82453. };
  82454. meshes: {
  82455. [key: string]: IGLTFMesh;
  82456. };
  82457. lights: {
  82458. [key: string]: IGLTFLight;
  82459. };
  82460. cameras: {
  82461. [key: string]: IGLTFCamera;
  82462. };
  82463. nodes: {
  82464. [key: string]: IGLTFNode;
  82465. };
  82466. images: {
  82467. [key: string]: IGLTFImage;
  82468. };
  82469. textures: {
  82470. [key: string]: IGLTFTexture;
  82471. };
  82472. shaders: {
  82473. [key: string]: IGLTFShader;
  82474. };
  82475. programs: {
  82476. [key: string]: IGLTFProgram;
  82477. };
  82478. samplers: {
  82479. [key: string]: IGLTFSampler;
  82480. };
  82481. techniques: {
  82482. [key: string]: IGLTFTechnique;
  82483. };
  82484. materials: {
  82485. [key: string]: IGLTFMaterial;
  82486. };
  82487. animations: {
  82488. [key: string]: IGLTFAnimation;
  82489. };
  82490. skins: {
  82491. [key: string]: IGLTFSkins;
  82492. };
  82493. currentScene?: Object;
  82494. scenes: {
  82495. [key: string]: IGLTFScene;
  82496. };
  82497. extensionsUsed: string[];
  82498. extensionsRequired?: string[];
  82499. buffersCount: number;
  82500. shaderscount: number;
  82501. scene: Scene;
  82502. rootUrl: string;
  82503. loadedBufferCount: number;
  82504. loadedBufferViews: {
  82505. [name: string]: ArrayBufferView;
  82506. };
  82507. loadedShaderCount: number;
  82508. importOnlyMeshes: boolean;
  82509. importMeshesNames?: string[];
  82510. dummyNodes: Node[];
  82511. forAssetContainer: boolean;
  82512. }
  82513. /** @hidden */
  82514. export interface INodeToRoot {
  82515. bone: Bone;
  82516. node: IGLTFNode;
  82517. id: string;
  82518. }
  82519. /** @hidden */
  82520. export interface IJointNode {
  82521. node: IGLTFNode;
  82522. id: string;
  82523. }
  82524. }
  82525. declare module BABYLON.GLTF1 {
  82526. /**
  82527. * Utils functions for GLTF
  82528. * @hidden
  82529. */
  82530. export class GLTFUtils {
  82531. /**
  82532. * Sets the given "parameter" matrix
  82533. * @param scene: the Scene object
  82534. * @param source: the source node where to pick the matrix
  82535. * @param parameter: the GLTF technique parameter
  82536. * @param uniformName: the name of the shader's uniform
  82537. * @param shaderMaterial: the shader material
  82538. */
  82539. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82540. /**
  82541. * Sets the given "parameter" matrix
  82542. * @param shaderMaterial: the shader material
  82543. * @param uniform: the name of the shader's uniform
  82544. * @param value: the value of the uniform
  82545. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82546. */
  82547. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82548. /**
  82549. * Returns the wrap mode of the texture
  82550. * @param mode: the mode value
  82551. */
  82552. static GetWrapMode(mode: number): number;
  82553. /**
  82554. * Returns the byte stride giving an accessor
  82555. * @param accessor: the GLTF accessor objet
  82556. */
  82557. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82558. /**
  82559. * Returns the texture filter mode giving a mode value
  82560. * @param mode: the filter mode value
  82561. */
  82562. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82563. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82564. /**
  82565. * Returns a buffer from its accessor
  82566. * @param gltfRuntime: the GLTF runtime
  82567. * @param accessor: the GLTF accessor
  82568. */
  82569. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82570. /**
  82571. * Decodes a buffer view into a string
  82572. * @param view: the buffer view
  82573. */
  82574. static DecodeBufferToText(view: ArrayBufferView): string;
  82575. /**
  82576. * Returns the default material of gltf. Related to
  82577. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82578. * @param scene: the Babylon.js scene
  82579. */
  82580. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82581. private static _DefaultMaterial;
  82582. }
  82583. }
  82584. declare module BABYLON.GLTF1 {
  82585. /**
  82586. * Implementation of the base glTF spec
  82587. * @hidden
  82588. */
  82589. export class GLTFLoaderBase {
  82590. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82591. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82592. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82593. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82594. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82595. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82596. }
  82597. /**
  82598. * glTF V1 Loader
  82599. * @hidden
  82600. */
  82601. export class GLTFLoader implements IGLTFLoader {
  82602. static Extensions: {
  82603. [name: string]: GLTFLoaderExtension;
  82604. };
  82605. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82606. state: Nullable<GLTFLoaderState>;
  82607. dispose(): void;
  82608. private _importMeshAsync;
  82609. /**
  82610. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82611. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82612. * @param scene the scene the meshes should be added to
  82613. * @param forAssetContainer defines if the entities must be stored in the scene
  82614. * @param data gltf data containing information of the meshes in a loaded file
  82615. * @param rootUrl root url to load from
  82616. * @param onProgress event that fires when loading progress has occured
  82617. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82618. */
  82619. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82620. private _loadAsync;
  82621. /**
  82622. * Imports all objects from a loaded gltf file and adds them to the scene
  82623. * @param scene the scene the objects should be added to
  82624. * @param data gltf data containing information of the meshes in a loaded file
  82625. * @param rootUrl root url to load from
  82626. * @param onProgress event that fires when loading progress has occured
  82627. * @returns a promise which completes when objects have been loaded to the scene
  82628. */
  82629. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82630. private _loadShadersAsync;
  82631. private _loadBuffersAsync;
  82632. private _createNodes;
  82633. }
  82634. /** @hidden */
  82635. export abstract class GLTFLoaderExtension {
  82636. private _name;
  82637. constructor(name: string);
  82638. get name(): string;
  82639. /**
  82640. * Defines an override for loading the runtime
  82641. * Return true to stop further extensions from loading the runtime
  82642. */
  82643. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82644. /**
  82645. * Defines an onverride for creating gltf runtime
  82646. * Return true to stop further extensions from creating the runtime
  82647. */
  82648. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82649. /**
  82650. * Defines an override for loading buffers
  82651. * Return true to stop further extensions from loading this buffer
  82652. */
  82653. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82654. /**
  82655. * Defines an override for loading texture buffers
  82656. * Return true to stop further extensions from loading this texture data
  82657. */
  82658. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82659. /**
  82660. * Defines an override for creating textures
  82661. * Return true to stop further extensions from loading this texture
  82662. */
  82663. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82664. /**
  82665. * Defines an override for loading shader strings
  82666. * Return true to stop further extensions from loading this shader data
  82667. */
  82668. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82669. /**
  82670. * Defines an override for loading materials
  82671. * Return true to stop further extensions from loading this material
  82672. */
  82673. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82674. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82675. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82676. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82677. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82678. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82679. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82680. private static LoadTextureBufferAsync;
  82681. private static CreateTextureAsync;
  82682. private static ApplyExtensions;
  82683. }
  82684. }
  82685. declare module BABYLON.GLTF1 {
  82686. /** @hidden */
  82687. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82688. private _bin;
  82689. constructor();
  82690. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82691. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82692. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82693. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82694. }
  82695. }
  82696. declare module BABYLON.GLTF1 {
  82697. /** @hidden */
  82698. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82699. constructor();
  82700. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82701. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82702. private _loadTexture;
  82703. }
  82704. }
  82705. declare module BABYLON.GLTF2.Loader {
  82706. /**
  82707. * Loader interface with an index field.
  82708. */
  82709. export interface IArrayItem {
  82710. /**
  82711. * The index of this item in the array.
  82712. */
  82713. index: number;
  82714. }
  82715. /**
  82716. * Loader interface with additional members.
  82717. */
  82718. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82719. /** @hidden */
  82720. _data?: Promise<ArrayBufferView>;
  82721. /** @hidden */
  82722. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82723. }
  82724. /**
  82725. * Loader interface with additional members.
  82726. */
  82727. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82728. }
  82729. /** @hidden */
  82730. export interface _IAnimationSamplerData {
  82731. input: Float32Array;
  82732. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82733. output: Float32Array;
  82734. }
  82735. /**
  82736. * Loader interface with additional members.
  82737. */
  82738. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82739. /** @hidden */
  82740. _data?: Promise<_IAnimationSamplerData>;
  82741. }
  82742. /**
  82743. * Loader interface with additional members.
  82744. */
  82745. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82746. channels: IAnimationChannel[];
  82747. samplers: IAnimationSampler[];
  82748. /** @hidden */
  82749. _babylonAnimationGroup?: AnimationGroup;
  82750. }
  82751. /**
  82752. * Loader interface with additional members.
  82753. */
  82754. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82755. /** @hidden */
  82756. _data?: Promise<ArrayBufferView>;
  82757. }
  82758. /**
  82759. * Loader interface with additional members.
  82760. */
  82761. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82762. /** @hidden */
  82763. _data?: Promise<ArrayBufferView>;
  82764. /** @hidden */
  82765. _babylonBuffer?: Promise<Buffer>;
  82766. }
  82767. /**
  82768. * Loader interface with additional members.
  82769. */
  82770. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82771. }
  82772. /**
  82773. * Loader interface with additional members.
  82774. */
  82775. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82776. /** @hidden */
  82777. _data?: Promise<ArrayBufferView>;
  82778. }
  82779. /**
  82780. * Loader interface with additional members.
  82781. */
  82782. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82783. }
  82784. /**
  82785. * Loader interface with additional members.
  82786. */
  82787. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82788. }
  82789. /**
  82790. * Loader interface with additional members.
  82791. */
  82792. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82793. baseColorTexture?: ITextureInfo;
  82794. metallicRoughnessTexture?: ITextureInfo;
  82795. }
  82796. /**
  82797. * Loader interface with additional members.
  82798. */
  82799. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82800. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82801. normalTexture?: IMaterialNormalTextureInfo;
  82802. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82803. emissiveTexture?: ITextureInfo;
  82804. /** @hidden */
  82805. _data?: {
  82806. [babylonDrawMode: number]: {
  82807. babylonMaterial: Material;
  82808. babylonMeshes: AbstractMesh[];
  82809. promise: Promise<void>;
  82810. };
  82811. };
  82812. }
  82813. /**
  82814. * Loader interface with additional members.
  82815. */
  82816. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82817. primitives: IMeshPrimitive[];
  82818. }
  82819. /**
  82820. * Loader interface with additional members.
  82821. */
  82822. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82823. /** @hidden */
  82824. _instanceData?: {
  82825. babylonSourceMesh: Mesh;
  82826. promise: Promise<any>;
  82827. };
  82828. }
  82829. /**
  82830. * Loader interface with additional members.
  82831. */
  82832. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82833. /**
  82834. * The parent glTF node.
  82835. */
  82836. parent?: INode;
  82837. /** @hidden */
  82838. _babylonTransformNode?: TransformNode;
  82839. /** @hidden */
  82840. _primitiveBabylonMeshes?: AbstractMesh[];
  82841. /** @hidden */
  82842. _babylonBones?: Bone[];
  82843. /** @hidden */
  82844. _numMorphTargets?: number;
  82845. }
  82846. /** @hidden */
  82847. export interface _ISamplerData {
  82848. noMipMaps: boolean;
  82849. samplingMode: number;
  82850. wrapU: number;
  82851. wrapV: number;
  82852. }
  82853. /**
  82854. * Loader interface with additional members.
  82855. */
  82856. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82857. /** @hidden */
  82858. _data?: _ISamplerData;
  82859. }
  82860. /**
  82861. * Loader interface with additional members.
  82862. */
  82863. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82864. }
  82865. /**
  82866. * Loader interface with additional members.
  82867. */
  82868. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82869. /** @hidden */
  82870. _data?: {
  82871. babylonSkeleton: Skeleton;
  82872. promise: Promise<void>;
  82873. };
  82874. }
  82875. /**
  82876. * Loader interface with additional members.
  82877. */
  82878. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82879. /** @hidden */
  82880. _textureInfo: ITextureInfo;
  82881. }
  82882. /**
  82883. * Loader interface with additional members.
  82884. */
  82885. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82886. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  82887. nonColorData?: boolean;
  82888. }
  82889. /**
  82890. * Loader interface with additional members.
  82891. */
  82892. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82893. accessors?: IAccessor[];
  82894. animations?: IAnimation[];
  82895. buffers?: IBuffer[];
  82896. bufferViews?: IBufferView[];
  82897. cameras?: ICamera[];
  82898. images?: IImage[];
  82899. materials?: IMaterial[];
  82900. meshes?: IMesh[];
  82901. nodes?: INode[];
  82902. samplers?: ISampler[];
  82903. scenes?: IScene[];
  82904. skins?: ISkin[];
  82905. textures?: ITexture[];
  82906. }
  82907. }
  82908. declare module BABYLON.GLTF2 {
  82909. /**
  82910. * Interface for a glTF loader extension.
  82911. */
  82912. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82913. /**
  82914. * Called after the loader state changes to LOADING.
  82915. */
  82916. onLoading?(): void;
  82917. /**
  82918. * Called after the loader state changes to READY.
  82919. */
  82920. onReady?(): void;
  82921. /**
  82922. * Define this method to modify the default behavior when loading scenes.
  82923. * @param context The context when loading the asset
  82924. * @param scene The glTF scene property
  82925. * @returns A promise that resolves when the load is complete or null if not handled
  82926. */
  82927. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82928. /**
  82929. * Define this method to modify the default behavior when loading nodes.
  82930. * @param context The context when loading the asset
  82931. * @param node The glTF node property
  82932. * @param assign A function called synchronously after parsing the glTF properties
  82933. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82934. */
  82935. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82936. /**
  82937. * Define this method to modify the default behavior when loading cameras.
  82938. * @param context The context when loading the asset
  82939. * @param camera The glTF camera property
  82940. * @param assign A function called synchronously after parsing the glTF properties
  82941. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82942. */
  82943. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82944. /**
  82945. * @hidden
  82946. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82947. * @param context The context when loading the asset
  82948. * @param primitive The glTF mesh primitive property
  82949. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82950. */
  82951. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82952. /**
  82953. * @hidden
  82954. * Define this method to modify the default behavior when loading data for mesh primitives.
  82955. * @param context The context when loading the asset
  82956. * @param name The mesh name when loading the asset
  82957. * @param node The glTF node when loading the asset
  82958. * @param mesh The glTF mesh when loading the asset
  82959. * @param primitive The glTF mesh primitive property
  82960. * @param assign A function called synchronously after parsing the glTF properties
  82961. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82962. */
  82963. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82964. /**
  82965. * @hidden
  82966. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82967. * @param context The context when loading the asset
  82968. * @param material The glTF material property
  82969. * @param assign A function called synchronously after parsing the glTF properties
  82970. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82971. */
  82972. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82973. /**
  82974. * Define this method to modify the default behavior when creating materials.
  82975. * @param context The context when loading the asset
  82976. * @param material The glTF material property
  82977. * @param babylonDrawMode The draw mode for the Babylon material
  82978. * @returns The Babylon material or null if not handled
  82979. */
  82980. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82981. /**
  82982. * Define this method to modify the default behavior when loading material properties.
  82983. * @param context The context when loading the asset
  82984. * @param material The glTF material property
  82985. * @param babylonMaterial The Babylon material
  82986. * @returns A promise that resolves when the load is complete or null if not handled
  82987. */
  82988. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82989. /**
  82990. * Define this method to modify the default behavior when loading texture infos.
  82991. * @param context The context when loading the asset
  82992. * @param textureInfo The glTF texture info property
  82993. * @param assign A function called synchronously after parsing the glTF properties
  82994. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82995. */
  82996. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82997. /**
  82998. * @hidden
  82999. * Define this method to modify the default behavior when loading textures.
  83000. * @param context The context when loading the asset
  83001. * @param texture The glTF texture property
  83002. * @param assign A function called synchronously after parsing the glTF properties
  83003. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83004. */
  83005. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83006. /**
  83007. * Define this method to modify the default behavior when loading animations.
  83008. * @param context The context when loading the asset
  83009. * @param animation The glTF animation property
  83010. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83011. */
  83012. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83013. /**
  83014. * @hidden
  83015. * Define this method to modify the default behavior when loading skins.
  83016. * @param context The context when loading the asset
  83017. * @param node The glTF node property
  83018. * @param skin The glTF skin property
  83019. * @returns A promise that resolves when the load is complete or null if not handled
  83020. */
  83021. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83022. /**
  83023. * @hidden
  83024. * Define this method to modify the default behavior when loading uris.
  83025. * @param context The context when loading the asset
  83026. * @param property The glTF property associated with the uri
  83027. * @param uri The uri to load
  83028. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83029. */
  83030. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83031. /**
  83032. * Define this method to modify the default behavior when loading buffer views.
  83033. * @param context The context when loading the asset
  83034. * @param bufferView The glTF buffer view property
  83035. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83036. */
  83037. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83038. /**
  83039. * Define this method to modify the default behavior when loading buffers.
  83040. * @param context The context when loading the asset
  83041. * @param buffer The glTF buffer property
  83042. * @param byteOffset The byte offset to load
  83043. * @param byteLength The byte length to load
  83044. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83045. */
  83046. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83047. }
  83048. }
  83049. declare module BABYLON.GLTF2 {
  83050. /**
  83051. * Helper class for working with arrays when loading the glTF asset
  83052. */
  83053. export class ArrayItem {
  83054. /**
  83055. * Gets an item from the given array.
  83056. * @param context The context when loading the asset
  83057. * @param array The array to get the item from
  83058. * @param index The index to the array
  83059. * @returns The array item
  83060. */
  83061. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83062. /**
  83063. * Assign an `index` field to each item of the given array.
  83064. * @param array The array of items
  83065. */
  83066. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83067. }
  83068. /**
  83069. * The glTF 2.0 loader
  83070. */
  83071. export class GLTFLoader implements IGLTFLoader {
  83072. /** @hidden */
  83073. _completePromises: Promise<any>[];
  83074. /** @hidden */
  83075. _forAssetContainer: boolean;
  83076. /** Storage */
  83077. _babylonLights: Light[];
  83078. /** @hidden */
  83079. _disableInstancedMesh: number;
  83080. private _disposed;
  83081. private _parent;
  83082. private _state;
  83083. private _extensions;
  83084. private _rootUrl;
  83085. private _fileName;
  83086. private _uniqueRootUrl;
  83087. private _gltf;
  83088. private _bin;
  83089. private _babylonScene;
  83090. private _rootBabylonMesh;
  83091. private _defaultBabylonMaterialData;
  83092. private static _RegisteredExtensions;
  83093. /**
  83094. * The default glTF sampler.
  83095. */
  83096. static readonly DefaultSampler: ISampler;
  83097. /**
  83098. * Registers a loader extension.
  83099. * @param name The name of the loader extension.
  83100. * @param factory The factory function that creates the loader extension.
  83101. */
  83102. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83103. /**
  83104. * Unregisters a loader extension.
  83105. * @param name The name of the loader extension.
  83106. * @returns A boolean indicating whether the extension has been unregistered
  83107. */
  83108. static UnregisterExtension(name: string): boolean;
  83109. /**
  83110. * The loader state.
  83111. */
  83112. get state(): Nullable<GLTFLoaderState>;
  83113. /**
  83114. * The object that represents the glTF JSON.
  83115. */
  83116. get gltf(): IGLTF;
  83117. /**
  83118. * The BIN chunk of a binary glTF.
  83119. */
  83120. get bin(): Nullable<IDataBuffer>;
  83121. /**
  83122. * The parent file loader.
  83123. */
  83124. get parent(): GLTFFileLoader;
  83125. /**
  83126. * The Babylon scene when loading the asset.
  83127. */
  83128. get babylonScene(): Scene;
  83129. /**
  83130. * The root Babylon mesh when loading the asset.
  83131. */
  83132. get rootBabylonMesh(): Mesh;
  83133. /** @hidden */
  83134. constructor(parent: GLTFFileLoader);
  83135. /** @hidden */
  83136. dispose(): void;
  83137. /** @hidden */
  83138. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83139. /** @hidden */
  83140. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83141. private _loadAsync;
  83142. private _loadData;
  83143. private _setupData;
  83144. private _loadExtensions;
  83145. private _checkExtensions;
  83146. private _setState;
  83147. private _createRootNode;
  83148. /**
  83149. * Loads a glTF scene.
  83150. * @param context The context when loading the asset
  83151. * @param scene The glTF scene property
  83152. * @returns A promise that resolves when the load is complete
  83153. */
  83154. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83155. private _forEachPrimitive;
  83156. private _getGeometries;
  83157. private _getMeshes;
  83158. private _getTransformNodes;
  83159. private _getSkeletons;
  83160. private _getAnimationGroups;
  83161. private _startAnimations;
  83162. /**
  83163. * Loads a glTF node.
  83164. * @param context The context when loading the asset
  83165. * @param node The glTF node property
  83166. * @param assign A function called synchronously after parsing the glTF properties
  83167. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83168. */
  83169. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83170. private _loadMeshAsync;
  83171. /**
  83172. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83173. * @param context The context when loading the asset
  83174. * @param name The mesh name when loading the asset
  83175. * @param node The glTF node when loading the asset
  83176. * @param mesh The glTF mesh when loading the asset
  83177. * @param primitive The glTF mesh primitive property
  83178. * @param assign A function called synchronously after parsing the glTF properties
  83179. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83180. */
  83181. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83182. private _loadVertexDataAsync;
  83183. private _createMorphTargets;
  83184. private _loadMorphTargetsAsync;
  83185. private _loadMorphTargetVertexDataAsync;
  83186. private static _LoadTransform;
  83187. private _loadSkinAsync;
  83188. private _loadBones;
  83189. private _loadBone;
  83190. private _loadSkinInverseBindMatricesDataAsync;
  83191. private _updateBoneMatrices;
  83192. private _getNodeMatrix;
  83193. /**
  83194. * Loads a glTF camera.
  83195. * @param context The context when loading the asset
  83196. * @param camera The glTF camera property
  83197. * @param assign A function called synchronously after parsing the glTF properties
  83198. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83199. */
  83200. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83201. private _loadAnimationsAsync;
  83202. /**
  83203. * Loads a glTF animation.
  83204. * @param context The context when loading the asset
  83205. * @param animation The glTF animation property
  83206. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83207. */
  83208. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83209. /**
  83210. * @hidden Loads a glTF animation channel.
  83211. * @param context The context when loading the asset
  83212. * @param animationContext The context of the animation when loading the asset
  83213. * @param animation The glTF animation property
  83214. * @param channel The glTF animation channel property
  83215. * @param babylonAnimationGroup The babylon animation group property
  83216. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83217. * @returns A void promise when the channel load is complete
  83218. */
  83219. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83220. private _loadAnimationSamplerAsync;
  83221. private _loadBufferAsync;
  83222. /**
  83223. * Loads a glTF buffer view.
  83224. * @param context The context when loading the asset
  83225. * @param bufferView The glTF buffer view property
  83226. * @returns A promise that resolves with the loaded data when the load is complete
  83227. */
  83228. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83229. private _loadAccessorAsync;
  83230. /** @hidden */
  83231. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83232. private _loadIndicesAccessorAsync;
  83233. private _loadVertexBufferViewAsync;
  83234. private _loadVertexAccessorAsync;
  83235. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83236. /** @hidden */
  83237. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83238. private _createDefaultMaterial;
  83239. /**
  83240. * Creates a Babylon material from a glTF material.
  83241. * @param context The context when loading the asset
  83242. * @param material The glTF material property
  83243. * @param babylonDrawMode The draw mode for the Babylon material
  83244. * @returns The Babylon material
  83245. */
  83246. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83247. /**
  83248. * Loads properties from a glTF material into a Babylon material.
  83249. * @param context The context when loading the asset
  83250. * @param material The glTF material property
  83251. * @param babylonMaterial The Babylon material
  83252. * @returns A promise that resolves when the load is complete
  83253. */
  83254. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83255. /**
  83256. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83257. * @param context The context when loading the asset
  83258. * @param material The glTF material property
  83259. * @param babylonMaterial The Babylon material
  83260. * @returns A promise that resolves when the load is complete
  83261. */
  83262. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83263. /**
  83264. * Loads the alpha properties from a glTF material into a Babylon material.
  83265. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83266. * @param context The context when loading the asset
  83267. * @param material The glTF material property
  83268. * @param babylonMaterial The Babylon material
  83269. */
  83270. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83271. /**
  83272. * Loads a glTF texture info.
  83273. * @param context The context when loading the asset
  83274. * @param textureInfo The glTF texture info property
  83275. * @param assign A function called synchronously after parsing the glTF properties
  83276. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83277. */
  83278. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83279. /** @hidden */
  83280. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83281. /** @hidden */
  83282. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83283. private _loadSampler;
  83284. /**
  83285. * Loads a glTF image.
  83286. * @param context The context when loading the asset
  83287. * @param image The glTF image property
  83288. * @returns A promise that resolves with the loaded data when the load is complete
  83289. */
  83290. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83291. /**
  83292. * Loads a glTF uri.
  83293. * @param context The context when loading the asset
  83294. * @param property The glTF property associated with the uri
  83295. * @param uri The base64 or relative uri
  83296. * @returns A promise that resolves with the loaded data when the load is complete
  83297. */
  83298. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83299. /**
  83300. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83301. * @param babylonObject the Babylon object with metadata
  83302. * @param pointer the JSON pointer
  83303. */
  83304. static AddPointerMetadata(babylonObject: {
  83305. metadata: any;
  83306. }, pointer: string): void;
  83307. private static _GetTextureWrapMode;
  83308. private static _GetTextureSamplingMode;
  83309. private static _GetTypedArrayConstructor;
  83310. private static _GetTypedArray;
  83311. private static _GetNumComponents;
  83312. private static _ValidateUri;
  83313. /** @hidden */
  83314. static _GetDrawMode(context: string, mode: number | undefined): number;
  83315. private _compileMaterialsAsync;
  83316. private _compileShadowGeneratorsAsync;
  83317. private _forEachExtensions;
  83318. private _applyExtensions;
  83319. private _extensionsOnLoading;
  83320. private _extensionsOnReady;
  83321. private _extensionsLoadSceneAsync;
  83322. private _extensionsLoadNodeAsync;
  83323. private _extensionsLoadCameraAsync;
  83324. private _extensionsLoadVertexDataAsync;
  83325. private _extensionsLoadMeshPrimitiveAsync;
  83326. private _extensionsLoadMaterialAsync;
  83327. private _extensionsCreateMaterial;
  83328. private _extensionsLoadMaterialPropertiesAsync;
  83329. private _extensionsLoadTextureInfoAsync;
  83330. private _extensionsLoadTextureAsync;
  83331. private _extensionsLoadAnimationAsync;
  83332. private _extensionsLoadSkinAsync;
  83333. private _extensionsLoadUriAsync;
  83334. private _extensionsLoadBufferViewAsync;
  83335. private _extensionsLoadBufferAsync;
  83336. /**
  83337. * Helper method called by a loader extension to load an glTF extension.
  83338. * @param context The context when loading the asset
  83339. * @param property The glTF property to load the extension from
  83340. * @param extensionName The name of the extension to load
  83341. * @param actionAsync The action to run
  83342. * @returns The promise returned by actionAsync or null if the extension does not exist
  83343. */
  83344. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83345. /**
  83346. * Helper method called by a loader extension to load a glTF extra.
  83347. * @param context The context when loading the asset
  83348. * @param property The glTF property to load the extra from
  83349. * @param extensionName The name of the extension to load
  83350. * @param actionAsync The action to run
  83351. * @returns The promise returned by actionAsync or null if the extra does not exist
  83352. */
  83353. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83354. /**
  83355. * Checks for presence of an extension.
  83356. * @param name The name of the extension to check
  83357. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83358. */
  83359. isExtensionUsed(name: string): boolean;
  83360. /**
  83361. * Increments the indentation level and logs a message.
  83362. * @param message The message to log
  83363. */
  83364. logOpen(message: string): void;
  83365. /**
  83366. * Decrements the indentation level.
  83367. */
  83368. logClose(): void;
  83369. /**
  83370. * Logs a message
  83371. * @param message The message to log
  83372. */
  83373. log(message: string): void;
  83374. /**
  83375. * Starts a performance counter.
  83376. * @param counterName The name of the performance counter
  83377. */
  83378. startPerformanceCounter(counterName: string): void;
  83379. /**
  83380. * Ends a performance counter.
  83381. * @param counterName The name of the performance counter
  83382. */
  83383. endPerformanceCounter(counterName: string): void;
  83384. }
  83385. }
  83386. declare module BABYLON.GLTF2.Loader.Extensions {
  83387. /** @hidden */
  83388. interface IEXTLightsImageBased_LightImageBased {
  83389. _babylonTexture?: BaseTexture;
  83390. _loaded?: Promise<void>;
  83391. }
  83392. /**
  83393. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83394. */
  83395. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83396. /**
  83397. * The name of this extension.
  83398. */
  83399. readonly name: string;
  83400. /**
  83401. * Defines whether this extension is enabled.
  83402. */
  83403. enabled: boolean;
  83404. private _loader;
  83405. private _lights?;
  83406. /** @hidden */
  83407. constructor(loader: GLTFLoader);
  83408. /** @hidden */
  83409. dispose(): void;
  83410. /** @hidden */
  83411. onLoading(): void;
  83412. /** @hidden */
  83413. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83414. private _loadLightAsync;
  83415. }
  83416. }
  83417. declare module BABYLON.GLTF2.Loader.Extensions {
  83418. /**
  83419. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83420. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83421. * !!! Experimental Extension Subject to Changes !!!
  83422. */
  83423. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83424. /**
  83425. * The name of this extension.
  83426. */
  83427. readonly name: string;
  83428. /**
  83429. * Defines whether this extension is enabled.
  83430. */
  83431. enabled: boolean;
  83432. private _loader;
  83433. /** @hidden */
  83434. constructor(loader: GLTFLoader);
  83435. /** @hidden */
  83436. dispose(): void;
  83437. /** @hidden */
  83438. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83439. }
  83440. }
  83441. declare module BABYLON.GLTF2.Loader.Extensions {
  83442. /**
  83443. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83444. */
  83445. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83446. /** The name of this extension. */
  83447. readonly name: string;
  83448. /** Defines whether this extension is enabled. */
  83449. enabled: boolean;
  83450. private _loader;
  83451. /** @hidden */
  83452. constructor(loader: GLTFLoader);
  83453. /** @hidden */
  83454. dispose(): void;
  83455. /** @hidden */
  83456. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83457. }
  83458. }
  83459. declare module BABYLON.GLTF2.Loader.Extensions {
  83460. /**
  83461. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83462. */
  83463. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83464. /**
  83465. * The name of this extension.
  83466. */
  83467. readonly name: string;
  83468. /**
  83469. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83470. */
  83471. dracoCompression?: DracoCompression;
  83472. /**
  83473. * Defines whether this extension is enabled.
  83474. */
  83475. enabled: boolean;
  83476. private _loader;
  83477. /** @hidden */
  83478. constructor(loader: GLTFLoader);
  83479. /** @hidden */
  83480. dispose(): void;
  83481. /** @hidden */
  83482. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83483. }
  83484. }
  83485. declare module BABYLON.GLTF2.Loader.Extensions {
  83486. /**
  83487. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83488. */
  83489. export class KHR_lights implements IGLTFLoaderExtension {
  83490. /**
  83491. * The name of this extension.
  83492. */
  83493. readonly name: string;
  83494. /**
  83495. * Defines whether this extension is enabled.
  83496. */
  83497. enabled: boolean;
  83498. private _loader;
  83499. private _lights?;
  83500. /** @hidden */
  83501. constructor(loader: GLTFLoader);
  83502. /** @hidden */
  83503. dispose(): void;
  83504. /** @hidden */
  83505. onLoading(): void;
  83506. /** @hidden */
  83507. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83508. }
  83509. }
  83510. declare module BABYLON.GLTF2.Loader.Extensions {
  83511. /**
  83512. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83513. */
  83514. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83515. /**
  83516. * The name of this extension.
  83517. */
  83518. readonly name: string;
  83519. /**
  83520. * Defines whether this extension is enabled.
  83521. */
  83522. enabled: boolean;
  83523. /**
  83524. * Defines a number that determines the order the extensions are applied.
  83525. */
  83526. order: number;
  83527. private _loader;
  83528. /** @hidden */
  83529. constructor(loader: GLTFLoader);
  83530. /** @hidden */
  83531. dispose(): void;
  83532. /** @hidden */
  83533. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83534. private _loadSpecularGlossinessPropertiesAsync;
  83535. }
  83536. }
  83537. declare module BABYLON.GLTF2.Loader.Extensions {
  83538. /**
  83539. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83540. */
  83541. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83542. /**
  83543. * The name of this extension.
  83544. */
  83545. readonly name: string;
  83546. /**
  83547. * Defines whether this extension is enabled.
  83548. */
  83549. enabled: boolean;
  83550. /**
  83551. * Defines a number that determines the order the extensions are applied.
  83552. */
  83553. order: number;
  83554. private _loader;
  83555. /** @hidden */
  83556. constructor(loader: GLTFLoader);
  83557. /** @hidden */
  83558. dispose(): void;
  83559. /** @hidden */
  83560. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83561. private _loadUnlitPropertiesAsync;
  83562. }
  83563. }
  83564. declare module BABYLON.GLTF2.Loader.Extensions {
  83565. /**
  83566. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83567. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83568. */
  83569. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83570. /**
  83571. * The name of this extension.
  83572. */
  83573. readonly name: string;
  83574. /**
  83575. * Defines whether this extension is enabled.
  83576. */
  83577. enabled: boolean;
  83578. /**
  83579. * Defines a number that determines the order the extensions are applied.
  83580. */
  83581. order: number;
  83582. private _loader;
  83583. /** @hidden */
  83584. constructor(loader: GLTFLoader);
  83585. /** @hidden */
  83586. dispose(): void;
  83587. /** @hidden */
  83588. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83589. private _loadClearCoatPropertiesAsync;
  83590. }
  83591. }
  83592. declare module BABYLON.GLTF2.Loader.Extensions {
  83593. /**
  83594. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83595. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83596. * !!! Experimental Extension Subject to Changes !!!
  83597. */
  83598. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83599. /**
  83600. * The name of this extension.
  83601. */
  83602. readonly name: string;
  83603. /**
  83604. * Defines whether this extension is enabled.
  83605. */
  83606. enabled: boolean;
  83607. /**
  83608. * Defines a number that determines the order the extensions are applied.
  83609. */
  83610. order: number;
  83611. private _loader;
  83612. /** @hidden */
  83613. constructor(loader: GLTFLoader);
  83614. /** @hidden */
  83615. dispose(): void;
  83616. /** @hidden */
  83617. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83618. private _loadSheenPropertiesAsync;
  83619. }
  83620. }
  83621. declare module BABYLON.GLTF2.Loader.Extensions {
  83622. /**
  83623. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83624. * !!! Experimental Extension Subject to Changes !!!
  83625. */
  83626. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83627. /**
  83628. * The name of this extension.
  83629. */
  83630. readonly name: string;
  83631. /**
  83632. * Defines whether this extension is enabled.
  83633. */
  83634. enabled: boolean;
  83635. /**
  83636. * Defines a number that determines the order the extensions are applied.
  83637. */
  83638. order: number;
  83639. private _loader;
  83640. /** @hidden */
  83641. constructor(loader: GLTFLoader);
  83642. /** @hidden */
  83643. dispose(): void;
  83644. /** @hidden */
  83645. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83646. private _loadSpecularPropertiesAsync;
  83647. }
  83648. }
  83649. declare module BABYLON.GLTF2.Loader.Extensions {
  83650. /**
  83651. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83652. * !!! Experimental Extension Subject to Changes !!!
  83653. */
  83654. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83655. /**
  83656. * Default ior Value from the spec.
  83657. */
  83658. private static readonly _DEFAULT_IOR;
  83659. /**
  83660. * The name of this extension.
  83661. */
  83662. readonly name: string;
  83663. /**
  83664. * Defines whether this extension is enabled.
  83665. */
  83666. enabled: boolean;
  83667. /**
  83668. * Defines a number that determines the order the extensions are applied.
  83669. */
  83670. order: number;
  83671. private _loader;
  83672. /** @hidden */
  83673. constructor(loader: GLTFLoader);
  83674. /** @hidden */
  83675. dispose(): void;
  83676. /** @hidden */
  83677. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83678. private _loadIorPropertiesAsync;
  83679. }
  83680. }
  83681. declare module BABYLON.GLTF2.Loader.Extensions {
  83682. /**
  83683. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83684. * !!! Experimental Extension Subject to Changes !!!
  83685. */
  83686. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83687. /**
  83688. * The name of this extension.
  83689. */
  83690. readonly name: string;
  83691. /**
  83692. * Defines whether this extension is enabled.
  83693. */
  83694. enabled: boolean;
  83695. private _loader;
  83696. private _variants?;
  83697. /** @hidden */
  83698. constructor(loader: GLTFLoader);
  83699. /** @hidden */
  83700. dispose(): void;
  83701. /**
  83702. * Gets the list of available variant names for this asset.
  83703. * @param rootMesh The glTF root mesh
  83704. * @returns the list of all the variant names for this model
  83705. */
  83706. static GetAvailableVariants(rootMesh: Mesh): string[];
  83707. /**
  83708. * Gets the list of available variant names for this asset.
  83709. * @param rootMesh The glTF root mesh
  83710. * @returns the list of all the variant names for this model
  83711. */
  83712. getAvailableVariants(rootMesh: Mesh): string[];
  83713. /**
  83714. * Select a variant given a variant name or a list of variant names.
  83715. * @param rootMesh The glTF root mesh
  83716. * @param variantName The variant name(s) to select.
  83717. */
  83718. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83719. /**
  83720. * Select a variant given a variant name or a list of variant names.
  83721. * @param rootMesh The glTF root mesh
  83722. * @param variantName The variant name(s) to select.
  83723. */
  83724. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83725. /**
  83726. * Reset back to the original before selecting a variant.
  83727. * @param rootMesh The glTF root mesh
  83728. */
  83729. static Reset(rootMesh: Mesh): void;
  83730. /**
  83731. * Reset back to the original before selecting a variant.
  83732. * @param rootMesh The glTF root mesh
  83733. */
  83734. reset(rootMesh: Mesh): void;
  83735. /**
  83736. * Gets the last selected variant name(s) or null if original.
  83737. * @param rootMesh The glTF root mesh
  83738. * @returns The selected variant name(s).
  83739. */
  83740. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83741. /**
  83742. * Gets the last selected variant name(s) or null if original.
  83743. * @param rootMesh The glTF root mesh
  83744. * @returns The selected variant name(s).
  83745. */
  83746. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83747. private static _GetExtensionMetadata;
  83748. /** @hidden */
  83749. onLoading(): void;
  83750. /** @hidden */
  83751. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83752. }
  83753. }
  83754. declare module BABYLON.GLTF2.Loader.Extensions {
  83755. /**
  83756. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83757. * !!! Experimental Extension Subject to Changes !!!
  83758. */
  83759. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83760. /**
  83761. * The name of this extension.
  83762. */
  83763. readonly name: string;
  83764. /**
  83765. * Defines whether this extension is enabled.
  83766. */
  83767. enabled: boolean;
  83768. /**
  83769. * Defines a number that determines the order the extensions are applied.
  83770. */
  83771. order: number;
  83772. private _loader;
  83773. /** @hidden */
  83774. constructor(loader: GLTFLoader);
  83775. /** @hidden */
  83776. dispose(): void;
  83777. /** @hidden */
  83778. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83779. private _loadTransparentPropertiesAsync;
  83780. }
  83781. }
  83782. declare module BABYLON.GLTF2.Loader.Extensions {
  83783. /**
  83784. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83785. */
  83786. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83787. /**
  83788. * The name of this extension.
  83789. */
  83790. readonly name: string;
  83791. /**
  83792. * Defines whether this extension is enabled.
  83793. */
  83794. enabled: boolean;
  83795. /** @hidden */
  83796. constructor(loader: GLTFLoader);
  83797. /** @hidden */
  83798. dispose(): void;
  83799. }
  83800. }
  83801. declare module BABYLON.GLTF2.Loader.Extensions {
  83802. /**
  83803. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83804. * !!! Experimental Extension Subject to Changes !!!
  83805. */
  83806. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83807. /** The name of this extension. */
  83808. readonly name: string;
  83809. /** Defines whether this extension is enabled. */
  83810. enabled: boolean;
  83811. private _loader;
  83812. /** @hidden */
  83813. constructor(loader: GLTFLoader);
  83814. /** @hidden */
  83815. dispose(): void;
  83816. /** @hidden */
  83817. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83818. }
  83819. }
  83820. declare module BABYLON.GLTF2.Loader.Extensions {
  83821. /**
  83822. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83823. */
  83824. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83825. /**
  83826. * The name of this extension.
  83827. */
  83828. readonly name: string;
  83829. /**
  83830. * Defines whether this extension is enabled.
  83831. */
  83832. enabled: boolean;
  83833. private _loader;
  83834. /** @hidden */
  83835. constructor(loader: GLTFLoader);
  83836. /** @hidden */
  83837. dispose(): void;
  83838. /** @hidden */
  83839. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83840. }
  83841. }
  83842. declare module BABYLON.GLTF2.Loader.Extensions {
  83843. /**
  83844. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83845. * !!! Experimental Extension Subject to Changes !!!
  83846. */
  83847. export class KHR_xmp implements IGLTFLoaderExtension {
  83848. /**
  83849. * The name of this extension.
  83850. */
  83851. readonly name: string;
  83852. /**
  83853. * Defines whether this extension is enabled.
  83854. */
  83855. enabled: boolean;
  83856. /**
  83857. * Defines a number that determines the order the extensions are applied.
  83858. */
  83859. order: number;
  83860. private _loader;
  83861. /** @hidden */
  83862. constructor(loader: GLTFLoader);
  83863. /** @hidden */
  83864. dispose(): void;
  83865. /**
  83866. * Called after the loader state changes to LOADING.
  83867. */
  83868. onLoading(): void;
  83869. }
  83870. }
  83871. declare module BABYLON.GLTF2.Loader.Extensions {
  83872. /**
  83873. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83874. */
  83875. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83876. /**
  83877. * The name of this extension.
  83878. */
  83879. readonly name: string;
  83880. /**
  83881. * Defines whether this extension is enabled.
  83882. */
  83883. enabled: boolean;
  83884. private _loader;
  83885. private _clips;
  83886. private _emitters;
  83887. /** @hidden */
  83888. constructor(loader: GLTFLoader);
  83889. /** @hidden */
  83890. dispose(): void;
  83891. /** @hidden */
  83892. onLoading(): void;
  83893. /** @hidden */
  83894. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83895. /** @hidden */
  83896. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83897. /** @hidden */
  83898. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83899. private _loadClipAsync;
  83900. private _loadEmitterAsync;
  83901. private _getEventAction;
  83902. private _loadAnimationEventAsync;
  83903. }
  83904. }
  83905. declare module BABYLON.GLTF2.Loader.Extensions {
  83906. /**
  83907. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83908. */
  83909. export class MSFT_lod implements IGLTFLoaderExtension {
  83910. /**
  83911. * The name of this extension.
  83912. */
  83913. readonly name: string;
  83914. /**
  83915. * Defines whether this extension is enabled.
  83916. */
  83917. enabled: boolean;
  83918. /**
  83919. * Defines a number that determines the order the extensions are applied.
  83920. */
  83921. order: number;
  83922. /**
  83923. * Maximum number of LODs to load, starting from the lowest LOD.
  83924. */
  83925. maxLODsToLoad: number;
  83926. /**
  83927. * Observable raised when all node LODs of one level are loaded.
  83928. * The event data is the index of the loaded LOD starting from zero.
  83929. * Dispose the loader to cancel the loading of the next level of LODs.
  83930. */
  83931. onNodeLODsLoadedObservable: Observable<number>;
  83932. /**
  83933. * Observable raised when all material LODs of one level are loaded.
  83934. * The event data is the index of the loaded LOD starting from zero.
  83935. * Dispose the loader to cancel the loading of the next level of LODs.
  83936. */
  83937. onMaterialLODsLoadedObservable: Observable<number>;
  83938. private _loader;
  83939. private _bufferLODs;
  83940. private _nodeIndexLOD;
  83941. private _nodeSignalLODs;
  83942. private _nodePromiseLODs;
  83943. private _nodeBufferLODs;
  83944. private _materialIndexLOD;
  83945. private _materialSignalLODs;
  83946. private _materialPromiseLODs;
  83947. private _materialBufferLODs;
  83948. /** @hidden */
  83949. constructor(loader: GLTFLoader);
  83950. /** @hidden */
  83951. dispose(): void;
  83952. /** @hidden */
  83953. onReady(): void;
  83954. /** @hidden */
  83955. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83956. /** @hidden */
  83957. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83958. /** @hidden */
  83959. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83960. /** @hidden */
  83961. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83962. /** @hidden */
  83963. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83964. private _loadBufferLOD;
  83965. /**
  83966. * Gets an array of LOD properties from lowest to highest.
  83967. */
  83968. private _getLODs;
  83969. private _disposeTransformNode;
  83970. private _disposeMaterials;
  83971. }
  83972. }
  83973. declare module BABYLON.GLTF2.Loader.Extensions {
  83974. /** @hidden */
  83975. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83976. readonly name: string;
  83977. enabled: boolean;
  83978. private _loader;
  83979. constructor(loader: GLTFLoader);
  83980. dispose(): void;
  83981. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83982. }
  83983. }
  83984. declare module BABYLON.GLTF2.Loader.Extensions {
  83985. /** @hidden */
  83986. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83987. readonly name: string;
  83988. enabled: boolean;
  83989. private _loader;
  83990. constructor(loader: GLTFLoader);
  83991. dispose(): void;
  83992. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83993. }
  83994. }
  83995. declare module BABYLON.GLTF2.Loader.Extensions {
  83996. /**
  83997. * Store glTF extras (if present) in BJS objects' metadata
  83998. */
  83999. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84000. /**
  84001. * The name of this extension.
  84002. */
  84003. readonly name: string;
  84004. /**
  84005. * Defines whether this extension is enabled.
  84006. */
  84007. enabled: boolean;
  84008. private _loader;
  84009. private _assignExtras;
  84010. /** @hidden */
  84011. constructor(loader: GLTFLoader);
  84012. /** @hidden */
  84013. dispose(): void;
  84014. /** @hidden */
  84015. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84016. /** @hidden */
  84017. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84018. /** @hidden */
  84019. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84020. }
  84021. }
  84022. declare module BABYLON {
  84023. /**
  84024. * Class reading and parsing the MTL file bundled with the obj file.
  84025. */
  84026. export class MTLFileLoader {
  84027. /**
  84028. * Invert Y-Axis of referenced textures on load
  84029. */
  84030. static INVERT_TEXTURE_Y: boolean;
  84031. /**
  84032. * All material loaded from the mtl will be set here
  84033. */
  84034. materials: StandardMaterial[];
  84035. /**
  84036. * This function will read the mtl file and create each material described inside
  84037. * This function could be improve by adding :
  84038. * -some component missing (Ni, Tf...)
  84039. * -including the specific options available
  84040. *
  84041. * @param scene defines the scene the material will be created in
  84042. * @param data defines the mtl data to parse
  84043. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84044. * @param forAssetContainer defines if the material should be registered in the scene
  84045. */
  84046. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84047. /**
  84048. * Gets the texture for the material.
  84049. *
  84050. * If the material is imported from input file,
  84051. * We sanitize the url to ensure it takes the textre from aside the material.
  84052. *
  84053. * @param rootUrl The root url to load from
  84054. * @param value The value stored in the mtl
  84055. * @return The Texture
  84056. */
  84057. private static _getTexture;
  84058. }
  84059. }
  84060. declare module BABYLON {
  84061. /**
  84062. * Options for loading OBJ/MTL files
  84063. */
  84064. type MeshLoadOptions = {
  84065. /**
  84066. * Defines if UVs are optimized by default during load.
  84067. */
  84068. OptimizeWithUV: boolean;
  84069. /**
  84070. * Defines custom scaling of UV coordinates of loaded meshes.
  84071. */
  84072. UVScaling: Vector2;
  84073. /**
  84074. * Invert model on y-axis (does a model scaling inversion)
  84075. */
  84076. InvertY: boolean;
  84077. /**
  84078. * Invert Y-Axis of referenced textures on load
  84079. */
  84080. InvertTextureY: boolean;
  84081. /**
  84082. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84083. */
  84084. ImportVertexColors: boolean;
  84085. /**
  84086. * Compute the normals for the model, even if normals are present in the file.
  84087. */
  84088. ComputeNormals: boolean;
  84089. /**
  84090. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84091. */
  84092. SkipMaterials: boolean;
  84093. /**
  84094. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84095. */
  84096. MaterialLoadingFailsSilently: boolean;
  84097. };
  84098. /**
  84099. * OBJ file type loader.
  84100. * This is a babylon scene loader plugin.
  84101. */
  84102. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84103. /**
  84104. * Defines if UVs are optimized by default during load.
  84105. */
  84106. static OPTIMIZE_WITH_UV: boolean;
  84107. /**
  84108. * Invert model on y-axis (does a model scaling inversion)
  84109. */
  84110. static INVERT_Y: boolean;
  84111. /**
  84112. * Invert Y-Axis of referenced textures on load
  84113. */
  84114. static get INVERT_TEXTURE_Y(): boolean;
  84115. static set INVERT_TEXTURE_Y(value: boolean);
  84116. /**
  84117. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84118. */
  84119. static IMPORT_VERTEX_COLORS: boolean;
  84120. /**
  84121. * Compute the normals for the model, even if normals are present in the file.
  84122. */
  84123. static COMPUTE_NORMALS: boolean;
  84124. /**
  84125. * Defines custom scaling of UV coordinates of loaded meshes.
  84126. */
  84127. static UV_SCALING: Vector2;
  84128. /**
  84129. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84130. */
  84131. static SKIP_MATERIALS: boolean;
  84132. /**
  84133. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84134. *
  84135. * Defaults to true for backwards compatibility.
  84136. */
  84137. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84138. /**
  84139. * Defines the name of the plugin.
  84140. */
  84141. name: string;
  84142. /**
  84143. * Defines the extension the plugin is able to load.
  84144. */
  84145. extensions: string;
  84146. /** @hidden */
  84147. obj: RegExp;
  84148. /** @hidden */
  84149. group: RegExp;
  84150. /** @hidden */
  84151. mtllib: RegExp;
  84152. /** @hidden */
  84153. usemtl: RegExp;
  84154. /** @hidden */
  84155. smooth: RegExp;
  84156. /** @hidden */
  84157. vertexPattern: RegExp;
  84158. /** @hidden */
  84159. normalPattern: RegExp;
  84160. /** @hidden */
  84161. uvPattern: RegExp;
  84162. /** @hidden */
  84163. facePattern1: RegExp;
  84164. /** @hidden */
  84165. facePattern2: RegExp;
  84166. /** @hidden */
  84167. facePattern3: RegExp;
  84168. /** @hidden */
  84169. facePattern4: RegExp;
  84170. /** @hidden */
  84171. facePattern5: RegExp;
  84172. private _forAssetContainer;
  84173. private _meshLoadOptions;
  84174. /**
  84175. * Creates loader for .OBJ files
  84176. *
  84177. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84178. */
  84179. constructor(meshLoadOptions?: MeshLoadOptions);
  84180. private static get currentMeshLoadOptions();
  84181. /**
  84182. * Calls synchronously the MTL file attached to this obj.
  84183. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84184. * Without this function materials are not displayed in the first frame (but displayed after).
  84185. * In consequence it is impossible to get material information in your HTML file
  84186. *
  84187. * @param url The URL of the MTL file
  84188. * @param rootUrl
  84189. * @param onSuccess Callback function to be called when the MTL file is loaded
  84190. * @private
  84191. */
  84192. private _loadMTL;
  84193. /**
  84194. * Instantiates a OBJ file loader plugin.
  84195. * @returns the created plugin
  84196. */
  84197. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84198. /**
  84199. * If the data string can be loaded directly.
  84200. *
  84201. * @param data string containing the file data
  84202. * @returns if the data can be loaded directly
  84203. */
  84204. canDirectLoad(data: string): boolean;
  84205. /**
  84206. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84207. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84208. * @param scene the scene the meshes should be added to
  84209. * @param data the OBJ data to load
  84210. * @param rootUrl root url to load from
  84211. * @param onProgress event that fires when loading progress has occured
  84212. * @param fileName Defines the name of the file to load
  84213. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84214. */
  84215. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84216. meshes: AbstractMesh[];
  84217. particleSystems: IParticleSystem[];
  84218. skeletons: Skeleton[];
  84219. animationGroups: AnimationGroup[];
  84220. }>;
  84221. /**
  84222. * Imports all objects from the loaded OBJ data and adds them to the scene
  84223. * @param scene the scene the objects should be added to
  84224. * @param data the OBJ data to load
  84225. * @param rootUrl root url to load from
  84226. * @param onProgress event that fires when loading progress has occured
  84227. * @param fileName Defines the name of the file to load
  84228. * @returns a promise which completes when objects have been loaded to the scene
  84229. */
  84230. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84231. /**
  84232. * Load into an asset container.
  84233. * @param scene The scene to load into
  84234. * @param data The data to import
  84235. * @param rootUrl The root url for scene and resources
  84236. * @param onProgress The callback when the load progresses
  84237. * @param fileName Defines the name of the file to load
  84238. * @returns The loaded asset container
  84239. */
  84240. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84241. /**
  84242. * Read the OBJ file and create an Array of meshes.
  84243. * Each mesh contains all information given by the OBJ and the MTL file.
  84244. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84245. *
  84246. * @param meshesNames
  84247. * @param scene Scene The scene where are displayed the data
  84248. * @param data String The content of the obj file
  84249. * @param rootUrl String The path to the folder
  84250. * @returns Array<AbstractMesh>
  84251. * @private
  84252. */
  84253. private _parseSolid;
  84254. }
  84255. }
  84256. declare module BABYLON {
  84257. /**
  84258. * STL file type loader.
  84259. * This is a babylon scene loader plugin.
  84260. */
  84261. export class STLFileLoader implements ISceneLoaderPlugin {
  84262. /** @hidden */
  84263. solidPattern: RegExp;
  84264. /** @hidden */
  84265. facetsPattern: RegExp;
  84266. /** @hidden */
  84267. normalPattern: RegExp;
  84268. /** @hidden */
  84269. vertexPattern: RegExp;
  84270. /**
  84271. * Defines the name of the plugin.
  84272. */
  84273. name: string;
  84274. /**
  84275. * Defines the extensions the stl loader is able to load.
  84276. * force data to come in as an ArrayBuffer
  84277. * we'll convert to string if it looks like it's an ASCII .stl
  84278. */
  84279. extensions: ISceneLoaderPluginExtensions;
  84280. /**
  84281. * Import meshes into a scene.
  84282. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84283. * @param scene The scene to import into
  84284. * @param data The data to import
  84285. * @param rootUrl The root url for scene and resources
  84286. * @param meshes The meshes array to import into
  84287. * @param particleSystems The particle systems array to import into
  84288. * @param skeletons The skeletons array to import into
  84289. * @param onError The callback when import fails
  84290. * @returns True if successful or false otherwise
  84291. */
  84292. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84293. /**
  84294. * Load into a scene.
  84295. * @param scene The scene to load into
  84296. * @param data The data to import
  84297. * @param rootUrl The root url for scene and resources
  84298. * @param onError The callback when import fails
  84299. * @returns true if successful or false otherwise
  84300. */
  84301. load(scene: Scene, data: any, rootUrl: string): boolean;
  84302. /**
  84303. * Load into an asset container.
  84304. * @param scene The scene to load into
  84305. * @param data The data to import
  84306. * @param rootUrl The root url for scene and resources
  84307. * @param onError The callback when import fails
  84308. * @returns The loaded asset container
  84309. */
  84310. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84311. private _isBinary;
  84312. private _parseBinary;
  84313. private _parseASCII;
  84314. }
  84315. }
  84316. declare module BABYLON {
  84317. /**
  84318. * Class for generating OBJ data from a Babylon scene.
  84319. */
  84320. export class OBJExport {
  84321. /**
  84322. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84323. * @param mesh defines the list of meshes to serialize
  84324. * @param materials defines if materials should be exported
  84325. * @param matlibname defines the name of the associated mtl file
  84326. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84327. * @returns the OBJ content
  84328. */
  84329. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84330. /**
  84331. * Exports the material(s) of a mesh in .MTL file format (text)
  84332. * @param mesh defines the mesh to extract the material from
  84333. * @returns the mtl content
  84334. */
  84335. static MTL(mesh: Mesh): string;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /** @hidden */
  84340. export var __IGLTFExporterExtension: number;
  84341. /**
  84342. * Interface for extending the exporter
  84343. * @hidden
  84344. */
  84345. export interface IGLTFExporterExtension {
  84346. /**
  84347. * The name of this extension
  84348. */
  84349. readonly name: string;
  84350. /**
  84351. * Defines whether this extension is enabled
  84352. */
  84353. enabled: boolean;
  84354. /**
  84355. * Defines whether this extension is required
  84356. */
  84357. required: boolean;
  84358. }
  84359. }
  84360. declare module BABYLON.GLTF2.Exporter {
  84361. /** @hidden */
  84362. export var __IGLTFExporterExtensionV2: number;
  84363. /**
  84364. * Interface for a glTF exporter extension
  84365. * @hidden
  84366. */
  84367. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84368. /**
  84369. * Define this method to modify the default behavior before exporting a texture
  84370. * @param context The context when loading the asset
  84371. * @param babylonTexture The Babylon.js texture
  84372. * @param mimeType The mime-type of the generated image
  84373. * @returns A promise that resolves with the exported texture
  84374. */
  84375. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84376. /**
  84377. * Define this method to get notified when a texture info is created
  84378. * @param context The context when loading the asset
  84379. * @param textureInfo The glTF texture info
  84380. * @param babylonTexture The Babylon.js texture
  84381. */
  84382. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84383. /**
  84384. * Define this method to modify the default behavior when exporting texture info
  84385. * @param context The context when loading the asset
  84386. * @param meshPrimitive glTF mesh primitive
  84387. * @param babylonSubMesh Babylon submesh
  84388. * @param binaryWriter glTF serializer binary writer instance
  84389. * @returns nullable IMeshPrimitive promise
  84390. */
  84391. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84392. /**
  84393. * Define this method to modify the default behavior when exporting a node
  84394. * @param context The context when exporting the node
  84395. * @param node glTF node
  84396. * @param babylonNode BabylonJS node
  84397. * @returns nullable INode promise
  84398. */
  84399. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84400. [key: number]: number;
  84401. }): Promise<Nullable<INode>>;
  84402. /**
  84403. * Define this method to modify the default behavior when exporting a material
  84404. * @param material glTF material
  84405. * @param babylonMaterial BabylonJS material
  84406. * @returns nullable IMaterial promise
  84407. */
  84408. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84409. /**
  84410. * Define this method to return additional textures to export from a material
  84411. * @param material glTF material
  84412. * @param babylonMaterial BabylonJS material
  84413. * @returns List of textures
  84414. */
  84415. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84416. /** Gets a boolean indicating that this extension was used */
  84417. wasUsed: boolean;
  84418. /** Gets a boolean indicating that this extension is required for the file to work */
  84419. required: boolean;
  84420. /**
  84421. * Called after the exporter state changes to EXPORTING
  84422. */
  84423. onExporting?(): void;
  84424. }
  84425. }
  84426. declare module BABYLON.GLTF2.Exporter {
  84427. /**
  84428. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84429. * @hidden
  84430. */
  84431. export class _GLTFMaterialExporter {
  84432. /**
  84433. * Represents the dielectric specular values for R, G and B
  84434. */
  84435. private static readonly _DielectricSpecular;
  84436. /**
  84437. * Allows the maximum specular power to be defined for material calculations
  84438. */
  84439. private static readonly _MaxSpecularPower;
  84440. /**
  84441. * Mapping to store textures
  84442. */
  84443. private _textureMap;
  84444. /**
  84445. * Numeric tolerance value
  84446. */
  84447. private static readonly _Epsilon;
  84448. /**
  84449. * Reference to the glTF Exporter
  84450. */
  84451. private _exporter;
  84452. constructor(exporter: _Exporter);
  84453. /**
  84454. * Specifies if two colors are approximately equal in value
  84455. * @param color1 first color to compare to
  84456. * @param color2 second color to compare to
  84457. * @param epsilon threshold value
  84458. */
  84459. private static FuzzyEquals;
  84460. /**
  84461. * Gets the materials from a Babylon scene and converts them to glTF materials
  84462. * @param scene babylonjs scene
  84463. * @param mimeType texture mime type
  84464. * @param images array of images
  84465. * @param textures array of textures
  84466. * @param materials array of materials
  84467. * @param imageData mapping of texture names to base64 textures
  84468. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84469. */
  84470. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84471. /**
  84472. * Makes a copy of the glTF material without the texture parameters
  84473. * @param originalMaterial original glTF material
  84474. * @returns glTF material without texture parameters
  84475. */
  84476. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84477. /**
  84478. * Specifies if the material has any texture parameters present
  84479. * @param material glTF Material
  84480. * @returns boolean specifying if texture parameters are present
  84481. */
  84482. _hasTexturesPresent(material: IMaterial): boolean;
  84483. /**
  84484. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84485. * @param babylonStandardMaterial
  84486. * @returns glTF Metallic Roughness Material representation
  84487. */
  84488. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84489. /**
  84490. * Computes the metallic factor
  84491. * @param diffuse diffused value
  84492. * @param specular specular value
  84493. * @param oneMinusSpecularStrength one minus the specular strength
  84494. * @returns metallic value
  84495. */
  84496. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84497. /**
  84498. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84499. * @param glTFMaterial glTF material
  84500. * @param babylonMaterial Babylon material
  84501. */
  84502. private static _SetAlphaMode;
  84503. /**
  84504. * Converts a Babylon Standard Material to a glTF Material
  84505. * @param babylonStandardMaterial BJS Standard Material
  84506. * @param mimeType mime type to use for the textures
  84507. * @param images array of glTF image interfaces
  84508. * @param textures array of glTF texture interfaces
  84509. * @param materials array of glTF material interfaces
  84510. * @param imageData map of image file name to data
  84511. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84512. */
  84513. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84514. private _finishMaterial;
  84515. /**
  84516. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84517. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84518. * @param mimeType mime type to use for the textures
  84519. * @param images array of glTF image interfaces
  84520. * @param textures array of glTF texture interfaces
  84521. * @param materials array of glTF material interfaces
  84522. * @param imageData map of image file name to data
  84523. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84524. */
  84525. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84526. /**
  84527. * Converts an image typed array buffer to a base64 image
  84528. * @param buffer typed array buffer
  84529. * @param width width of the image
  84530. * @param height height of the image
  84531. * @param mimeType mimetype of the image
  84532. * @returns base64 image string
  84533. */
  84534. private _createBase64FromCanvasAsync;
  84535. /**
  84536. * Generates a white texture based on the specified width and height
  84537. * @param width width of the texture in pixels
  84538. * @param height height of the texture in pixels
  84539. * @param scene babylonjs scene
  84540. * @returns white texture
  84541. */
  84542. private _createWhiteTexture;
  84543. /**
  84544. * 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
  84545. * @param texture1 first texture to resize
  84546. * @param texture2 second texture to resize
  84547. * @param scene babylonjs scene
  84548. * @returns resized textures or null
  84549. */
  84550. private _resizeTexturesToSameDimensions;
  84551. /**
  84552. * Converts an array of pixels to a Float32Array
  84553. * Throws an error if the pixel format is not supported
  84554. * @param pixels - array buffer containing pixel values
  84555. * @returns Float32 of pixels
  84556. */
  84557. private _convertPixelArrayToFloat32;
  84558. /**
  84559. * Convert Specular Glossiness Textures to Metallic Roughness
  84560. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84561. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84562. * @param diffuseTexture texture used to store diffuse information
  84563. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84564. * @param factors specular glossiness material factors
  84565. * @param mimeType the mime type to use for the texture
  84566. * @returns pbr metallic roughness interface or null
  84567. */
  84568. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84569. /**
  84570. * Converts specular glossiness material properties to metallic roughness
  84571. * @param specularGlossiness interface with specular glossiness material properties
  84572. * @returns interface with metallic roughness material properties
  84573. */
  84574. private _convertSpecularGlossinessToMetallicRoughness;
  84575. /**
  84576. * Calculates the surface reflectance, independent of lighting conditions
  84577. * @param color Color source to calculate brightness from
  84578. * @returns number representing the perceived brightness, or zero if color is undefined
  84579. */
  84580. private _getPerceivedBrightness;
  84581. /**
  84582. * Returns the maximum color component value
  84583. * @param color
  84584. * @returns maximum color component value, or zero if color is null or undefined
  84585. */
  84586. private _getMaxComponent;
  84587. /**
  84588. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84589. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84590. * @param mimeType mime type to use for the textures
  84591. * @param images array of glTF image interfaces
  84592. * @param textures array of glTF texture interfaces
  84593. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84594. * @param imageData map of image file name to data
  84595. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84596. * @returns glTF PBR Metallic Roughness factors
  84597. */
  84598. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84599. private _getGLTFTextureSampler;
  84600. private _getGLTFTextureWrapMode;
  84601. private _getGLTFTextureWrapModesSampler;
  84602. /**
  84603. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84604. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84605. * @param mimeType mime type to use for the textures
  84606. * @param images array of glTF image interfaces
  84607. * @param textures array of glTF texture interfaces
  84608. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84609. * @param imageData map of image file name to data
  84610. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84611. * @returns glTF PBR Metallic Roughness factors
  84612. */
  84613. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84614. /**
  84615. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84616. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84617. * @param mimeType mime type to use for the textures
  84618. * @param images array of glTF image interfaces
  84619. * @param textures array of glTF texture interfaces
  84620. * @param materials array of glTF material interfaces
  84621. * @param imageData map of image file name to data
  84622. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84623. */
  84624. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84625. private setMetallicRoughnessPbrMaterial;
  84626. private getPixelsFromTexture;
  84627. /**
  84628. * Extracts a texture from a Babylon texture into file data and glTF data
  84629. * @param babylonTexture Babylon texture to extract
  84630. * @param mimeType Mime Type of the babylonTexture
  84631. * @return glTF texture info, or null if the texture format is not supported
  84632. */
  84633. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84634. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84635. /**
  84636. * Builds a texture from base64 string
  84637. * @param base64Texture base64 texture string
  84638. * @param baseTextureName Name to use for the texture
  84639. * @param mimeType image mime type for the texture
  84640. * @param images array of images
  84641. * @param textures array of textures
  84642. * @param imageData map of image data
  84643. * @returns glTF texture info, or null if the texture format is not supported
  84644. */
  84645. private _getTextureInfoFromBase64;
  84646. }
  84647. }
  84648. declare module BABYLON {
  84649. /**
  84650. * Class for holding and downloading glTF file data
  84651. */
  84652. export class GLTFData {
  84653. /**
  84654. * Object which contains the file name as the key and its data as the value
  84655. */
  84656. glTFFiles: {
  84657. [fileName: string]: string | Blob;
  84658. };
  84659. /**
  84660. * Initializes the glTF file object
  84661. */
  84662. constructor();
  84663. /**
  84664. * Downloads the glTF data as files based on their names and data
  84665. */
  84666. downloadFiles(): void;
  84667. }
  84668. }
  84669. declare module BABYLON {
  84670. /**
  84671. * Holds a collection of exporter options and parameters
  84672. */
  84673. export interface IExportOptions {
  84674. /**
  84675. * Function which indicates whether a babylon node should be exported or not
  84676. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84677. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84678. */
  84679. shouldExportNode?(node: Node): boolean;
  84680. /**
  84681. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84682. * @param metadata source metadata to read from
  84683. * @returns the data to store to glTF node extras
  84684. */
  84685. metadataSelector?(metadata: any): any;
  84686. /**
  84687. * The sample rate to bake animation curves
  84688. */
  84689. animationSampleRate?: number;
  84690. /**
  84691. * Begin serialization without waiting for the scene to be ready
  84692. */
  84693. exportWithoutWaitingForScene?: boolean;
  84694. /**
  84695. * Indicates if coordinate system swapping root nodes should be included in export
  84696. */
  84697. includeCoordinateSystemConversionNodes?: boolean;
  84698. }
  84699. /**
  84700. * Class for generating glTF data from a Babylon scene.
  84701. */
  84702. export class GLTF2Export {
  84703. /**
  84704. * Exports the geometry of the scene to .gltf file format asynchronously
  84705. * @param scene Babylon scene with scene hierarchy information
  84706. * @param filePrefix File prefix to use when generating the glTF file
  84707. * @param options Exporter options
  84708. * @returns Returns an object with a .gltf file and associates texture names
  84709. * as keys and their data and paths as values
  84710. */
  84711. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84712. private static _PreExportAsync;
  84713. private static _PostExportAsync;
  84714. /**
  84715. * Exports the geometry of the scene to .glb file format asychronously
  84716. * @param scene Babylon scene with scene hierarchy information
  84717. * @param filePrefix File prefix to use when generating glb file
  84718. * @param options Exporter options
  84719. * @returns Returns an object with a .glb filename as key and data as value
  84720. */
  84721. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84722. }
  84723. }
  84724. declare module BABYLON.GLTF2.Exporter {
  84725. /**
  84726. * @hidden
  84727. */
  84728. export class _GLTFUtilities {
  84729. /**
  84730. * Creates a buffer view based on the supplied arguments
  84731. * @param bufferIndex index value of the specified buffer
  84732. * @param byteOffset byte offset value
  84733. * @param byteLength byte length of the bufferView
  84734. * @param byteStride byte distance between conequential elements
  84735. * @param name name of the buffer view
  84736. * @returns bufferView for glTF
  84737. */
  84738. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84739. /**
  84740. * Creates an accessor based on the supplied arguments
  84741. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84742. * @param name The name of the accessor
  84743. * @param type The type of the accessor
  84744. * @param componentType The datatype of components in the attribute
  84745. * @param count The number of attributes referenced by this accessor
  84746. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84747. * @param min Minimum value of each component in this attribute
  84748. * @param max Maximum value of each component in this attribute
  84749. * @returns accessor for glTF
  84750. */
  84751. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84752. /**
  84753. * Calculates the minimum and maximum values of an array of position floats
  84754. * @param positions Positions array of a mesh
  84755. * @param vertexStart Starting vertex offset to calculate min and max values
  84756. * @param vertexCount Number of vertices to check for min and max values
  84757. * @returns min number array and max number array
  84758. */
  84759. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84760. min: number[];
  84761. max: number[];
  84762. };
  84763. /**
  84764. * Converts a new right-handed Vector3
  84765. * @param vector vector3 array
  84766. * @returns right-handed Vector3
  84767. */
  84768. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84769. /**
  84770. * Converts a Vector3 to right-handed
  84771. * @param vector Vector3 to convert to right-handed
  84772. */
  84773. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84774. /**
  84775. * Converts a three element number array to right-handed
  84776. * @param vector number array to convert to right-handed
  84777. */
  84778. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84779. /**
  84780. * Converts a new right-handed Vector3
  84781. * @param vector vector3 array
  84782. * @returns right-handed Vector3
  84783. */
  84784. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84785. /**
  84786. * Converts a Vector3 to right-handed
  84787. * @param vector Vector3 to convert to right-handed
  84788. */
  84789. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84790. /**
  84791. * Converts a three element number array to right-handed
  84792. * @param vector number array to convert to right-handed
  84793. */
  84794. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84795. /**
  84796. * Converts a Vector4 to right-handed
  84797. * @param vector Vector4 to convert to right-handed
  84798. */
  84799. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84800. /**
  84801. * Converts a Vector4 to right-handed
  84802. * @param vector Vector4 to convert to right-handed
  84803. */
  84804. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84805. /**
  84806. * Converts a Quaternion to right-handed
  84807. * @param quaternion Source quaternion to convert to right-handed
  84808. */
  84809. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84810. /**
  84811. * Converts a Quaternion to right-handed
  84812. * @param quaternion Source quaternion to convert to right-handed
  84813. */
  84814. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84815. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84816. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84817. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84818. }
  84819. }
  84820. declare module BABYLON.GLTF2.Exporter {
  84821. /**
  84822. * Converts Babylon Scene into glTF 2.0.
  84823. * @hidden
  84824. */
  84825. export class _Exporter {
  84826. /**
  84827. * Stores the glTF to export
  84828. */
  84829. _glTF: IGLTF;
  84830. /**
  84831. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84832. */
  84833. _bufferViews: IBufferView[];
  84834. /**
  84835. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84836. */
  84837. _accessors: IAccessor[];
  84838. /**
  84839. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84840. */
  84841. _nodes: INode[];
  84842. /**
  84843. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84844. */
  84845. private _scenes;
  84846. /**
  84847. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84848. */
  84849. private _meshes;
  84850. /**
  84851. * Stores all the generated material information, which represents the appearance of each primitive
  84852. */
  84853. _materials: IMaterial[];
  84854. _materialMap: {
  84855. [materialID: number]: number;
  84856. };
  84857. /**
  84858. * Stores all the generated texture information, which is referenced by glTF materials
  84859. */
  84860. _textures: ITexture[];
  84861. /**
  84862. * Stores all the generated image information, which is referenced by glTF textures
  84863. */
  84864. _images: IImage[];
  84865. /**
  84866. * Stores all the texture samplers
  84867. */
  84868. _samplers: ISampler[];
  84869. /**
  84870. * Stores all the generated glTF skins
  84871. */
  84872. _skins: ISkin[];
  84873. /**
  84874. * Stores all the generated animation samplers, which is referenced by glTF animations
  84875. */
  84876. /**
  84877. * Stores the animations for glTF models
  84878. */
  84879. private _animations;
  84880. /**
  84881. * Stores the total amount of bytes stored in the glTF buffer
  84882. */
  84883. private _totalByteLength;
  84884. /**
  84885. * Stores a reference to the Babylon scene containing the source geometry and material information
  84886. */
  84887. _babylonScene: Scene;
  84888. /**
  84889. * Stores a map of the image data, where the key is the file name and the value
  84890. * is the image data
  84891. */
  84892. _imageData: {
  84893. [fileName: string]: {
  84894. data: Uint8Array;
  84895. mimeType: ImageMimeType;
  84896. };
  84897. };
  84898. protected _orderedImageData: Array<{
  84899. data: Uint8Array;
  84900. mimeType: ImageMimeType;
  84901. }>;
  84902. /**
  84903. * Stores a map of the unique id of a node to its index in the node array
  84904. */
  84905. _nodeMap: {
  84906. [key: number]: number;
  84907. };
  84908. /**
  84909. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84910. */
  84911. _convertToRightHandedSystem: boolean;
  84912. /**
  84913. * Specifies if a Babylon node should be converted to right-handed on export
  84914. */
  84915. _convertToRightHandedSystemMap: {
  84916. [nodeId: number]: boolean;
  84917. };
  84918. _includeCoordinateSystemConversionNodes: boolean;
  84919. /**
  84920. * Baked animation sample rate
  84921. */
  84922. private _animationSampleRate;
  84923. private _options;
  84924. private _localEngine;
  84925. _glTFMaterialExporter: _GLTFMaterialExporter;
  84926. private _extensions;
  84927. private static _ExtensionNames;
  84928. private static _ExtensionFactories;
  84929. private _applyExtension;
  84930. private _applyExtensions;
  84931. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84932. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84933. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84934. [key: number]: number;
  84935. }): Promise<Nullable<INode>>;
  84936. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84937. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84938. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84939. private _forEachExtensions;
  84940. private _extensionsOnExporting;
  84941. /**
  84942. * Load glTF serializer extensions
  84943. */
  84944. private _loadExtensions;
  84945. /**
  84946. * Creates a glTF Exporter instance, which can accept optional exporter options
  84947. * @param babylonScene Babylon scene object
  84948. * @param options Options to modify the behavior of the exporter
  84949. */
  84950. constructor(babylonScene: Scene, options?: IExportOptions);
  84951. dispose(): void;
  84952. /**
  84953. * Registers a glTF exporter extension
  84954. * @param name Name of the extension to export
  84955. * @param factory The factory function that creates the exporter extension
  84956. */
  84957. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84958. /**
  84959. * Un-registers an exporter extension
  84960. * @param name The name fo the exporter extension
  84961. * @returns A boolean indicating whether the extension has been un-registered
  84962. */
  84963. static UnregisterExtension(name: string): boolean;
  84964. /**
  84965. * Lazy load a local engine
  84966. */
  84967. _getLocalEngine(): Engine;
  84968. private reorderIndicesBasedOnPrimitiveMode;
  84969. /**
  84970. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84971. * clock-wise during export to glTF
  84972. * @param submesh BabylonJS submesh
  84973. * @param primitiveMode Primitive mode of the mesh
  84974. * @param sideOrientation the winding order of the submesh
  84975. * @param vertexBufferKind The type of vertex attribute
  84976. * @param meshAttributeArray The vertex attribute data
  84977. * @param byteOffset The offset to the binary data
  84978. * @param binaryWriter The binary data for the glTF file
  84979. * @param convertToRightHandedSystem Converts the values to right-handed
  84980. */
  84981. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84982. /**
  84983. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84984. * clock-wise during export to glTF
  84985. * @param submesh BabylonJS submesh
  84986. * @param primitiveMode Primitive mode of the mesh
  84987. * @param sideOrientation the winding order of the submesh
  84988. * @param vertexBufferKind The type of vertex attribute
  84989. * @param meshAttributeArray The vertex attribute data
  84990. * @param byteOffset The offset to the binary data
  84991. * @param binaryWriter The binary data for the glTF file
  84992. * @param convertToRightHandedSystem Converts the values to right-handed
  84993. */
  84994. private reorderTriangleFillMode;
  84995. /**
  84996. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84997. * clock-wise during export to glTF
  84998. * @param submesh BabylonJS submesh
  84999. * @param primitiveMode Primitive mode of the mesh
  85000. * @param sideOrientation the winding order of the submesh
  85001. * @param vertexBufferKind The type of vertex attribute
  85002. * @param meshAttributeArray The vertex attribute data
  85003. * @param byteOffset The offset to the binary data
  85004. * @param binaryWriter The binary data for the glTF file
  85005. * @param convertToRightHandedSystem Converts the values to right-handed
  85006. */
  85007. private reorderTriangleStripDrawMode;
  85008. /**
  85009. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85010. * clock-wise during export to glTF
  85011. * @param submesh BabylonJS submesh
  85012. * @param primitiveMode Primitive mode of the mesh
  85013. * @param sideOrientation the winding order of the submesh
  85014. * @param vertexBufferKind The type of vertex attribute
  85015. * @param meshAttributeArray The vertex attribute data
  85016. * @param byteOffset The offset to the binary data
  85017. * @param binaryWriter The binary data for the glTF file
  85018. * @param convertToRightHandedSystem Converts the values to right-handed
  85019. */
  85020. private reorderTriangleFanMode;
  85021. /**
  85022. * Writes the vertex attribute data to binary
  85023. * @param vertices The vertices to write to the binary writer
  85024. * @param byteOffset The offset into the binary writer to overwrite binary data
  85025. * @param vertexAttributeKind The vertex attribute type
  85026. * @param meshAttributeArray The vertex attribute data
  85027. * @param binaryWriter The writer containing the binary data
  85028. * @param convertToRightHandedSystem Converts the values to right-handed
  85029. */
  85030. private writeVertexAttributeData;
  85031. /**
  85032. * Writes mesh attribute data to a data buffer
  85033. * Returns the bytelength of the data
  85034. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85035. * @param meshAttributeArray Array containing the attribute data
  85036. * @param byteStride Specifies the space between data
  85037. * @param binaryWriter The buffer to write the binary data to
  85038. * @param convertToRightHandedSystem Converts the values to right-handed
  85039. */
  85040. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85041. /**
  85042. * Writes mesh attribute data to a data buffer
  85043. * Returns the bytelength of the data
  85044. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85045. * @param meshAttributeArray Array containing the attribute data
  85046. * @param byteStride Specifies the space between data
  85047. * @param binaryWriter The buffer to write the binary data to
  85048. * @param convertToRightHandedSystem Converts the values to right-handed
  85049. */
  85050. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85051. /**
  85052. * Generates glTF json data
  85053. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85054. * @param glTFPrefix Text to use when prefixing a glTF file
  85055. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85056. * @returns json data as string
  85057. */
  85058. private generateJSON;
  85059. /**
  85060. * Generates data for .gltf and .bin files based on the glTF prefix string
  85061. * @param glTFPrefix Text to use when prefixing a glTF file
  85062. * @param dispose Dispose the exporter
  85063. * @returns GLTFData with glTF file data
  85064. */
  85065. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85066. /**
  85067. * Creates a binary buffer for glTF
  85068. * @returns array buffer for binary data
  85069. */
  85070. private _generateBinaryAsync;
  85071. /**
  85072. * Pads the number to a multiple of 4
  85073. * @param num number to pad
  85074. * @returns padded number
  85075. */
  85076. private _getPadding;
  85077. /**
  85078. * @hidden
  85079. */
  85080. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85081. /**
  85082. * Sets the TRS for each node
  85083. * @param node glTF Node for storing the transformation data
  85084. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85085. * @param convertToRightHandedSystem Converts the values to right-handed
  85086. */
  85087. private setNodeTransformation;
  85088. private getVertexBufferFromMesh;
  85089. /**
  85090. * Creates a bufferview based on the vertices type for the Babylon mesh
  85091. * @param kind Indicates the type of vertices data
  85092. * @param componentType Indicates the numerical type used to store the data
  85093. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85094. * @param binaryWriter The buffer to write the bufferview data to
  85095. * @param convertToRightHandedSystem Converts the values to right-handed
  85096. */
  85097. private createBufferViewKind;
  85098. /**
  85099. * Creates a bufferview based on the vertices type for the Babylon mesh
  85100. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85101. * @param babylonMorphTarget the morph target to be exported
  85102. * @param binaryWriter The buffer to write the bufferview data to
  85103. * @param convertToRightHandedSystem Converts the values to right-handed
  85104. */
  85105. private setMorphTargetAttributes;
  85106. /**
  85107. * The primitive mode of the Babylon mesh
  85108. * @param babylonMesh The BabylonJS mesh
  85109. */
  85110. private getMeshPrimitiveMode;
  85111. /**
  85112. * Sets the primitive mode of the glTF mesh primitive
  85113. * @param meshPrimitive glTF mesh primitive
  85114. * @param primitiveMode The primitive mode
  85115. */
  85116. private setPrimitiveMode;
  85117. /**
  85118. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85119. * @param meshPrimitive glTF mesh primitive
  85120. * @param attributeKind vertex attribute
  85121. * @returns boolean specifying if uv coordinates are present
  85122. */
  85123. private setAttributeKind;
  85124. /**
  85125. * Sets data for the primitive attributes of each submesh
  85126. * @param mesh glTF Mesh object to store the primitive attribute information
  85127. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85128. * @param binaryWriter Buffer to write the attribute data to
  85129. * @param convertToRightHandedSystem Converts the values to right-handed
  85130. */
  85131. private setPrimitiveAttributesAsync;
  85132. /**
  85133. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85134. * @param node The node to check
  85135. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85136. */
  85137. private isBabylonCoordinateSystemConvertingNode;
  85138. /**
  85139. * Creates a glTF scene based on the array of meshes
  85140. * Returns the the total byte offset
  85141. * @param babylonScene Babylon scene to get the mesh data from
  85142. * @param binaryWriter Buffer to write binary data to
  85143. */
  85144. private createSceneAsync;
  85145. /**
  85146. * Creates a mapping of Node unique id to node index and handles animations
  85147. * @param babylonScene Babylon Scene
  85148. * @param nodes Babylon transform nodes
  85149. * @param binaryWriter Buffer to write binary data to
  85150. * @returns Node mapping of unique id to index
  85151. */
  85152. private createNodeMapAndAnimationsAsync;
  85153. /**
  85154. * Creates a glTF node from a Babylon mesh
  85155. * @param babylonMesh Source Babylon mesh
  85156. * @param binaryWriter Buffer for storing geometry data
  85157. * @param convertToRightHandedSystem Converts the values to right-handed
  85158. * @param nodeMap Node mapping of unique id to glTF node index
  85159. * @returns glTF node
  85160. */
  85161. private createNodeAsync;
  85162. /**
  85163. * Creates a glTF skin from a Babylon skeleton
  85164. * @param babylonScene Babylon Scene
  85165. * @param nodes Babylon transform nodes
  85166. * @param binaryWriter Buffer to write binary data to
  85167. * @returns Node mapping of unique id to index
  85168. */
  85169. private createSkinsAsync;
  85170. }
  85171. /**
  85172. * @hidden
  85173. *
  85174. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85175. */
  85176. export class _BinaryWriter {
  85177. /**
  85178. * Array buffer which stores all binary data
  85179. */
  85180. private _arrayBuffer;
  85181. /**
  85182. * View of the array buffer
  85183. */
  85184. private _dataView;
  85185. /**
  85186. * byte offset of data in array buffer
  85187. */
  85188. private _byteOffset;
  85189. /**
  85190. * Initialize binary writer with an initial byte length
  85191. * @param byteLength Initial byte length of the array buffer
  85192. */
  85193. constructor(byteLength: number);
  85194. /**
  85195. * Resize the array buffer to the specified byte length
  85196. * @param byteLength
  85197. */
  85198. private resizeBuffer;
  85199. /**
  85200. * Get an array buffer with the length of the byte offset
  85201. * @returns ArrayBuffer resized to the byte offset
  85202. */
  85203. getArrayBuffer(): ArrayBuffer;
  85204. /**
  85205. * Get the byte offset of the array buffer
  85206. * @returns byte offset
  85207. */
  85208. getByteOffset(): number;
  85209. /**
  85210. * Stores an UInt8 in the array buffer
  85211. * @param entry
  85212. * @param byteOffset If defined, specifies where to set the value as an offset.
  85213. */
  85214. setUInt8(entry: number, byteOffset?: number): void;
  85215. /**
  85216. * Stores an UInt16 in the array buffer
  85217. * @param entry
  85218. * @param byteOffset If defined, specifies where to set the value as an offset.
  85219. */
  85220. setUInt16(entry: number, byteOffset?: number): void;
  85221. /**
  85222. * Gets an UInt32 in the array buffer
  85223. * @param entry
  85224. * @param byteOffset If defined, specifies where to set the value as an offset.
  85225. */
  85226. getUInt32(byteOffset: number): number;
  85227. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85228. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85229. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85230. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85231. /**
  85232. * Stores a Float32 in the array buffer
  85233. * @param entry
  85234. */
  85235. setFloat32(entry: number, byteOffset?: number): void;
  85236. /**
  85237. * Stores an UInt32 in the array buffer
  85238. * @param entry
  85239. * @param byteOffset If defined, specifies where to set the value as an offset.
  85240. */
  85241. setUInt32(entry: number, byteOffset?: number): void;
  85242. }
  85243. }
  85244. declare module BABYLON.GLTF2.Exporter {
  85245. /**
  85246. * @hidden
  85247. * Interface to store animation data.
  85248. */
  85249. export interface _IAnimationData {
  85250. /**
  85251. * Keyframe data.
  85252. */
  85253. inputs: number[];
  85254. /**
  85255. * Value data.
  85256. */
  85257. outputs: number[][];
  85258. /**
  85259. * Animation interpolation data.
  85260. */
  85261. samplerInterpolation: AnimationSamplerInterpolation;
  85262. /**
  85263. * Minimum keyframe value.
  85264. */
  85265. inputsMin: number;
  85266. /**
  85267. * Maximum keyframe value.
  85268. */
  85269. inputsMax: number;
  85270. }
  85271. /**
  85272. * @hidden
  85273. */
  85274. export interface _IAnimationInfo {
  85275. /**
  85276. * The target channel for the animation
  85277. */
  85278. animationChannelTargetPath: AnimationChannelTargetPath;
  85279. /**
  85280. * The glTF accessor type for the data.
  85281. */
  85282. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85283. /**
  85284. * Specifies if quaternions should be used.
  85285. */
  85286. useQuaternion: boolean;
  85287. }
  85288. /**
  85289. * @hidden
  85290. * Utility class for generating glTF animation data from BabylonJS.
  85291. */
  85292. export class _GLTFAnimation {
  85293. /**
  85294. * @ignore
  85295. *
  85296. * Creates glTF channel animation from BabylonJS animation.
  85297. * @param babylonTransformNode - BabylonJS mesh.
  85298. * @param animation - animation.
  85299. * @param animationChannelTargetPath - The target animation channel.
  85300. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85301. * @param useQuaternion - Specifies if quaternions are used.
  85302. * @returns nullable IAnimationData
  85303. */
  85304. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85305. private static _DeduceAnimationInfo;
  85306. /**
  85307. * @ignore
  85308. * Create node animations from the transform node animations
  85309. * @param babylonNode
  85310. * @param runtimeGLTFAnimation
  85311. * @param idleGLTFAnimations
  85312. * @param nodeMap
  85313. * @param nodes
  85314. * @param binaryWriter
  85315. * @param bufferViews
  85316. * @param accessors
  85317. * @param convertToRightHandedSystem
  85318. * @param animationSampleRate
  85319. */
  85320. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85321. [key: number]: number;
  85322. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85323. /**
  85324. * @ignore
  85325. * Create individual morph animations from the mesh's morph target animation tracks
  85326. * @param babylonNode
  85327. * @param runtimeGLTFAnimation
  85328. * @param idleGLTFAnimations
  85329. * @param nodeMap
  85330. * @param nodes
  85331. * @param binaryWriter
  85332. * @param bufferViews
  85333. * @param accessors
  85334. * @param convertToRightHandedSystem
  85335. * @param animationSampleRate
  85336. */
  85337. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85338. [key: number]: number;
  85339. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85340. /**
  85341. * @ignore
  85342. * Create node and morph animations from the animation groups
  85343. * @param babylonScene
  85344. * @param glTFAnimations
  85345. * @param nodeMap
  85346. * @param nodes
  85347. * @param binaryWriter
  85348. * @param bufferViews
  85349. * @param accessors
  85350. * @param convertToRightHandedSystemMap
  85351. * @param animationSampleRate
  85352. */
  85353. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85354. [key: number]: number;
  85355. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85356. [nodeId: number]: boolean;
  85357. }, animationSampleRate: number): void;
  85358. private static AddAnimation;
  85359. /**
  85360. * Create a baked animation
  85361. * @param babylonTransformNode BabylonJS mesh
  85362. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85363. * @param animationChannelTargetPath animation target channel
  85364. * @param minFrame minimum animation frame
  85365. * @param maxFrame maximum animation frame
  85366. * @param fps frames per second of the animation
  85367. * @param inputs input key frames of the animation
  85368. * @param outputs output key frame data of the animation
  85369. * @param convertToRightHandedSystem converts the values to right-handed
  85370. * @param useQuaternion specifies if quaternions should be used
  85371. */
  85372. private static _CreateBakedAnimation;
  85373. private static _ConvertFactorToVector3OrQuaternion;
  85374. private static _SetInterpolatedValue;
  85375. /**
  85376. * Creates linear animation from the animation key frames
  85377. * @param babylonTransformNode BabylonJS mesh
  85378. * @param animation BabylonJS animation
  85379. * @param animationChannelTargetPath The target animation channel
  85380. * @param frameDelta The difference between the last and first frame of the animation
  85381. * @param inputs Array to store the key frame times
  85382. * @param outputs Array to store the key frame data
  85383. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85384. * @param useQuaternion Specifies if quaternions are used in the animation
  85385. */
  85386. private static _CreateLinearOrStepAnimation;
  85387. /**
  85388. * Creates cubic spline animation from the animation key frames
  85389. * @param babylonTransformNode BabylonJS mesh
  85390. * @param animation BabylonJS animation
  85391. * @param animationChannelTargetPath The target animation channel
  85392. * @param frameDelta The difference between the last and first frame of the animation
  85393. * @param inputs Array to store the key frame times
  85394. * @param outputs Array to store the key frame data
  85395. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85396. * @param useQuaternion Specifies if quaternions are used in the animation
  85397. */
  85398. private static _CreateCubicSplineAnimation;
  85399. private static _GetBasePositionRotationOrScale;
  85400. /**
  85401. * Adds a key frame value
  85402. * @param keyFrame
  85403. * @param animation
  85404. * @param outputs
  85405. * @param animationChannelTargetPath
  85406. * @param basePositionRotationOrScale
  85407. * @param convertToRightHandedSystem
  85408. * @param useQuaternion
  85409. */
  85410. private static _AddKeyframeValue;
  85411. /**
  85412. * Determine the interpolation based on the key frames
  85413. * @param keyFrames
  85414. * @param animationChannelTargetPath
  85415. * @param useQuaternion
  85416. */
  85417. private static _DeduceInterpolation;
  85418. /**
  85419. * Adds an input tangent or output tangent to the output data
  85420. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85421. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85422. * @param outputs The animation data by keyframe
  85423. * @param animationChannelTargetPath The target animation channel
  85424. * @param interpolation The interpolation type
  85425. * @param keyFrame The key frame with the animation data
  85426. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85427. * @param useQuaternion Specifies if quaternions are used
  85428. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85429. */
  85430. private static AddSplineTangent;
  85431. /**
  85432. * Get the minimum and maximum key frames' frame values
  85433. * @param keyFrames animation key frames
  85434. * @returns the minimum and maximum key frame value
  85435. */
  85436. private static calculateMinMaxKeyFrames;
  85437. }
  85438. }
  85439. declare module BABYLON.GLTF2.Exporter {
  85440. /** @hidden */
  85441. export var textureTransformPixelShader: {
  85442. name: string;
  85443. shader: string;
  85444. };
  85445. }
  85446. declare module BABYLON.GLTF2.Exporter.Extensions {
  85447. /**
  85448. * @hidden
  85449. */
  85450. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85451. private _recordedTextures;
  85452. /** Name of this extension */
  85453. readonly name: string;
  85454. /** Defines whether this extension is enabled */
  85455. enabled: boolean;
  85456. /** Defines whether this extension is required */
  85457. required: boolean;
  85458. /** Reference to the glTF exporter */
  85459. private _wasUsed;
  85460. constructor(exporter: _Exporter);
  85461. dispose(): void;
  85462. /** @hidden */
  85463. get wasUsed(): boolean;
  85464. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85465. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85466. /**
  85467. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85468. * @param babylonTexture
  85469. * @param offset
  85470. * @param rotation
  85471. * @param scale
  85472. * @param scene
  85473. */
  85474. private _textureTransformTextureAsync;
  85475. }
  85476. }
  85477. declare module BABYLON.GLTF2.Exporter.Extensions {
  85478. /**
  85479. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85480. */
  85481. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85482. /** The name of this extension. */
  85483. readonly name: string;
  85484. /** Defines whether this extension is enabled. */
  85485. enabled: boolean;
  85486. /** Defines whether this extension is required */
  85487. required: boolean;
  85488. /** Reference to the glTF exporter */
  85489. private _exporter;
  85490. private _lights;
  85491. /** @hidden */
  85492. constructor(exporter: _Exporter);
  85493. /** @hidden */
  85494. dispose(): void;
  85495. /** @hidden */
  85496. get wasUsed(): boolean;
  85497. /** @hidden */
  85498. onExporting(): void;
  85499. /**
  85500. * Define this method to modify the default behavior when exporting a node
  85501. * @param context The context when exporting the node
  85502. * @param node glTF node
  85503. * @param babylonNode BabylonJS node
  85504. * @param nodeMap Node mapping of unique id to glTF node index
  85505. * @returns nullable INode promise
  85506. */
  85507. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85508. [key: number]: number;
  85509. }): Promise<Nullable<INode>>;
  85510. }
  85511. }
  85512. declare module BABYLON.GLTF2.Exporter.Extensions {
  85513. /**
  85514. * @hidden
  85515. */
  85516. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85517. /** Name of this extension */
  85518. readonly name: string;
  85519. /** Defines whether this extension is enabled */
  85520. enabled: boolean;
  85521. /** Defines whether this extension is required */
  85522. required: boolean;
  85523. /** Reference to the glTF exporter */
  85524. private _textureInfos;
  85525. private _exportedTextures;
  85526. private _wasUsed;
  85527. constructor(exporter: _Exporter);
  85528. dispose(): void;
  85529. /** @hidden */
  85530. get wasUsed(): boolean;
  85531. private _getTextureIndex;
  85532. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85533. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85534. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85535. }
  85536. }
  85537. declare module BABYLON.GLTF2.Exporter.Extensions {
  85538. /**
  85539. * @hidden
  85540. */
  85541. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85542. /** Name of this extension */
  85543. readonly name: string;
  85544. /** Defines whether this extension is enabled */
  85545. enabled: boolean;
  85546. /** Defines whether this extension is required */
  85547. required: boolean;
  85548. private _wasUsed;
  85549. constructor(exporter: _Exporter);
  85550. /** @hidden */
  85551. get wasUsed(): boolean;
  85552. dispose(): void;
  85553. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85554. }
  85555. }
  85556. declare module BABYLON {
  85557. /**
  85558. * Class for generating STL data from a Babylon scene.
  85559. */
  85560. export class STLExport {
  85561. /**
  85562. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85563. * @param meshes list defines the mesh to serialize
  85564. * @param download triggers the automatic download of the file.
  85565. * @param fileName changes the downloads fileName.
  85566. * @param binary changes the STL to a binary type.
  85567. * @param isLittleEndian toggle for binary type exporter.
  85568. * @returns the STL as UTF8 string
  85569. */
  85570. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85571. }
  85572. }
  85573. declare module "babylonjs-gltf2interface" {
  85574. export = BABYLON.GLTF2;
  85575. }
  85576. /**
  85577. * Module for glTF 2.0 Interface
  85578. */
  85579. declare module BABYLON.GLTF2 {
  85580. /**
  85581. * The datatype of the components in the attribute
  85582. */
  85583. const enum AccessorComponentType {
  85584. /**
  85585. * Byte
  85586. */
  85587. BYTE = 5120,
  85588. /**
  85589. * Unsigned Byte
  85590. */
  85591. UNSIGNED_BYTE = 5121,
  85592. /**
  85593. * Short
  85594. */
  85595. SHORT = 5122,
  85596. /**
  85597. * Unsigned Short
  85598. */
  85599. UNSIGNED_SHORT = 5123,
  85600. /**
  85601. * Unsigned Int
  85602. */
  85603. UNSIGNED_INT = 5125,
  85604. /**
  85605. * Float
  85606. */
  85607. FLOAT = 5126,
  85608. }
  85609. /**
  85610. * Specifies if the attirbute is a scalar, vector, or matrix
  85611. */
  85612. const enum AccessorType {
  85613. /**
  85614. * Scalar
  85615. */
  85616. SCALAR = "SCALAR",
  85617. /**
  85618. * Vector2
  85619. */
  85620. VEC2 = "VEC2",
  85621. /**
  85622. * Vector3
  85623. */
  85624. VEC3 = "VEC3",
  85625. /**
  85626. * Vector4
  85627. */
  85628. VEC4 = "VEC4",
  85629. /**
  85630. * Matrix2x2
  85631. */
  85632. MAT2 = "MAT2",
  85633. /**
  85634. * Matrix3x3
  85635. */
  85636. MAT3 = "MAT3",
  85637. /**
  85638. * Matrix4x4
  85639. */
  85640. MAT4 = "MAT4",
  85641. }
  85642. /**
  85643. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85644. */
  85645. const enum AnimationChannelTargetPath {
  85646. /**
  85647. * Translation
  85648. */
  85649. TRANSLATION = "translation",
  85650. /**
  85651. * Rotation
  85652. */
  85653. ROTATION = "rotation",
  85654. /**
  85655. * Scale
  85656. */
  85657. SCALE = "scale",
  85658. /**
  85659. * Weights
  85660. */
  85661. WEIGHTS = "weights",
  85662. }
  85663. /**
  85664. * Interpolation algorithm
  85665. */
  85666. const enum AnimationSamplerInterpolation {
  85667. /**
  85668. * The animated values are linearly interpolated between keyframes
  85669. */
  85670. LINEAR = "LINEAR",
  85671. /**
  85672. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85673. */
  85674. STEP = "STEP",
  85675. /**
  85676. * The animation's interpolation is computed using a cubic spline with specified tangents
  85677. */
  85678. CUBICSPLINE = "CUBICSPLINE",
  85679. }
  85680. /**
  85681. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85682. */
  85683. const enum CameraType {
  85684. /**
  85685. * A perspective camera containing properties to create a perspective projection matrix
  85686. */
  85687. PERSPECTIVE = "perspective",
  85688. /**
  85689. * An orthographic camera containing properties to create an orthographic projection matrix
  85690. */
  85691. ORTHOGRAPHIC = "orthographic",
  85692. }
  85693. /**
  85694. * The mime-type of the image
  85695. */
  85696. const enum ImageMimeType {
  85697. /**
  85698. * JPEG Mime-type
  85699. */
  85700. JPEG = "image/jpeg",
  85701. /**
  85702. * PNG Mime-type
  85703. */
  85704. PNG = "image/png",
  85705. }
  85706. /**
  85707. * The alpha rendering mode of the material
  85708. */
  85709. const enum MaterialAlphaMode {
  85710. /**
  85711. * The alpha value is ignored and the rendered output is fully opaque
  85712. */
  85713. OPAQUE = "OPAQUE",
  85714. /**
  85715. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85716. */
  85717. MASK = "MASK",
  85718. /**
  85719. * 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)
  85720. */
  85721. BLEND = "BLEND",
  85722. }
  85723. /**
  85724. * The type of the primitives to render
  85725. */
  85726. const enum MeshPrimitiveMode {
  85727. /**
  85728. * Points
  85729. */
  85730. POINTS = 0,
  85731. /**
  85732. * Lines
  85733. */
  85734. LINES = 1,
  85735. /**
  85736. * Line Loop
  85737. */
  85738. LINE_LOOP = 2,
  85739. /**
  85740. * Line Strip
  85741. */
  85742. LINE_STRIP = 3,
  85743. /**
  85744. * Triangles
  85745. */
  85746. TRIANGLES = 4,
  85747. /**
  85748. * Triangle Strip
  85749. */
  85750. TRIANGLE_STRIP = 5,
  85751. /**
  85752. * Triangle Fan
  85753. */
  85754. TRIANGLE_FAN = 6,
  85755. }
  85756. /**
  85757. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85758. */
  85759. const enum TextureMagFilter {
  85760. /**
  85761. * Nearest
  85762. */
  85763. NEAREST = 9728,
  85764. /**
  85765. * Linear
  85766. */
  85767. LINEAR = 9729,
  85768. }
  85769. /**
  85770. * Minification filter. All valid values correspond to WebGL enums
  85771. */
  85772. const enum TextureMinFilter {
  85773. /**
  85774. * Nearest
  85775. */
  85776. NEAREST = 9728,
  85777. /**
  85778. * Linear
  85779. */
  85780. LINEAR = 9729,
  85781. /**
  85782. * Nearest Mip-Map Nearest
  85783. */
  85784. NEAREST_MIPMAP_NEAREST = 9984,
  85785. /**
  85786. * Linear Mipmap Nearest
  85787. */
  85788. LINEAR_MIPMAP_NEAREST = 9985,
  85789. /**
  85790. * Nearest Mipmap Linear
  85791. */
  85792. NEAREST_MIPMAP_LINEAR = 9986,
  85793. /**
  85794. * Linear Mipmap Linear
  85795. */
  85796. LINEAR_MIPMAP_LINEAR = 9987,
  85797. }
  85798. /**
  85799. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85800. */
  85801. const enum TextureWrapMode {
  85802. /**
  85803. * Clamp to Edge
  85804. */
  85805. CLAMP_TO_EDGE = 33071,
  85806. /**
  85807. * Mirrored Repeat
  85808. */
  85809. MIRRORED_REPEAT = 33648,
  85810. /**
  85811. * Repeat
  85812. */
  85813. REPEAT = 10497,
  85814. }
  85815. /**
  85816. * glTF Property
  85817. */
  85818. interface IProperty {
  85819. /**
  85820. * Dictionary object with extension-specific objects
  85821. */
  85822. extensions?: {
  85823. [key: string]: any;
  85824. };
  85825. /**
  85826. * Application-Specific data
  85827. */
  85828. extras?: any;
  85829. }
  85830. /**
  85831. * glTF Child of Root Property
  85832. */
  85833. interface IChildRootProperty extends IProperty {
  85834. /**
  85835. * The user-defined name of this object
  85836. */
  85837. name?: string;
  85838. }
  85839. /**
  85840. * Indices of those attributes that deviate from their initialization value
  85841. */
  85842. interface IAccessorSparseIndices extends IProperty {
  85843. /**
  85844. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85845. */
  85846. bufferView: number;
  85847. /**
  85848. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85849. */
  85850. byteOffset?: number;
  85851. /**
  85852. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85853. */
  85854. componentType: AccessorComponentType;
  85855. }
  85856. /**
  85857. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85858. */
  85859. interface IAccessorSparseValues extends IProperty {
  85860. /**
  85861. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85862. */
  85863. bufferView: number;
  85864. /**
  85865. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85866. */
  85867. byteOffset?: number;
  85868. }
  85869. /**
  85870. * Sparse storage of attributes that deviate from their initialization value
  85871. */
  85872. interface IAccessorSparse extends IProperty {
  85873. /**
  85874. * The number of attributes encoded in this sparse accessor
  85875. */
  85876. count: number;
  85877. /**
  85878. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85879. */
  85880. indices: IAccessorSparseIndices;
  85881. /**
  85882. * 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
  85883. */
  85884. values: IAccessorSparseValues;
  85885. }
  85886. /**
  85887. * 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
  85888. */
  85889. interface IAccessor extends IChildRootProperty {
  85890. /**
  85891. * The index of the bufferview
  85892. */
  85893. bufferView?: number;
  85894. /**
  85895. * The offset relative to the start of the bufferView in bytes
  85896. */
  85897. byteOffset?: number;
  85898. /**
  85899. * The datatype of components in the attribute
  85900. */
  85901. componentType: AccessorComponentType;
  85902. /**
  85903. * Specifies whether integer data values should be normalized
  85904. */
  85905. normalized?: boolean;
  85906. /**
  85907. * The number of attributes referenced by this accessor
  85908. */
  85909. count: number;
  85910. /**
  85911. * Specifies if the attribute is a scalar, vector, or matrix
  85912. */
  85913. type: AccessorType;
  85914. /**
  85915. * Maximum value of each component in this attribute
  85916. */
  85917. max?: number[];
  85918. /**
  85919. * Minimum value of each component in this attribute
  85920. */
  85921. min?: number[];
  85922. /**
  85923. * Sparse storage of attributes that deviate from their initialization value
  85924. */
  85925. sparse?: IAccessorSparse;
  85926. }
  85927. /**
  85928. * Targets an animation's sampler at a node's property
  85929. */
  85930. interface IAnimationChannel extends IProperty {
  85931. /**
  85932. * The index of a sampler in this animation used to compute the value for the target
  85933. */
  85934. sampler: number;
  85935. /**
  85936. * The index of the node and TRS property to target
  85937. */
  85938. target: IAnimationChannelTarget;
  85939. }
  85940. /**
  85941. * The index of the node and TRS property that an animation channel targets
  85942. */
  85943. interface IAnimationChannelTarget extends IProperty {
  85944. /**
  85945. * The index of the node to target
  85946. */
  85947. node: number;
  85948. /**
  85949. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85950. */
  85951. path: AnimationChannelTargetPath;
  85952. }
  85953. /**
  85954. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85955. */
  85956. interface IAnimationSampler extends IProperty {
  85957. /**
  85958. * The index of an accessor containing keyframe input values, e.g., time
  85959. */
  85960. input: number;
  85961. /**
  85962. * Interpolation algorithm
  85963. */
  85964. interpolation?: AnimationSamplerInterpolation;
  85965. /**
  85966. * The index of an accessor, containing keyframe output values
  85967. */
  85968. output: number;
  85969. }
  85970. /**
  85971. * A keyframe animation
  85972. */
  85973. interface IAnimation extends IChildRootProperty {
  85974. /**
  85975. * An array of channels, each of which targets an animation's sampler at a node's property
  85976. */
  85977. channels: IAnimationChannel[];
  85978. /**
  85979. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85980. */
  85981. samplers: IAnimationSampler[];
  85982. }
  85983. /**
  85984. * Metadata about the glTF asset
  85985. */
  85986. interface IAsset extends IChildRootProperty {
  85987. /**
  85988. * A copyright message suitable for display to credit the content creator
  85989. */
  85990. copyright?: string;
  85991. /**
  85992. * Tool that generated this glTF model. Useful for debugging
  85993. */
  85994. generator?: string;
  85995. /**
  85996. * The glTF version that this asset targets
  85997. */
  85998. version: string;
  85999. /**
  86000. * The minimum glTF version that this asset targets
  86001. */
  86002. minVersion?: string;
  86003. }
  86004. /**
  86005. * A buffer points to binary geometry, animation, or skins
  86006. */
  86007. interface IBuffer extends IChildRootProperty {
  86008. /**
  86009. * 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
  86010. */
  86011. uri?: string;
  86012. /**
  86013. * The length of the buffer in bytes
  86014. */
  86015. byteLength: number;
  86016. }
  86017. /**
  86018. * A view into a buffer generally representing a subset of the buffer
  86019. */
  86020. interface IBufferView extends IChildRootProperty {
  86021. /**
  86022. * The index of the buffer
  86023. */
  86024. buffer: number;
  86025. /**
  86026. * The offset into the buffer in bytes
  86027. */
  86028. byteOffset?: number;
  86029. /**
  86030. * The lenth of the bufferView in bytes
  86031. */
  86032. byteLength: number;
  86033. /**
  86034. * The stride, in bytes
  86035. */
  86036. byteStride?: number;
  86037. }
  86038. /**
  86039. * An orthographic camera containing properties to create an orthographic projection matrix
  86040. */
  86041. interface ICameraOrthographic extends IProperty {
  86042. /**
  86043. * The floating-point horizontal magnification of the view. Must not be zero
  86044. */
  86045. xmag: number;
  86046. /**
  86047. * The floating-point vertical magnification of the view. Must not be zero
  86048. */
  86049. ymag: number;
  86050. /**
  86051. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86052. */
  86053. zfar: number;
  86054. /**
  86055. * The floating-point distance to the near clipping plane
  86056. */
  86057. znear: number;
  86058. }
  86059. /**
  86060. * A perspective camera containing properties to create a perspective projection matrix
  86061. */
  86062. interface ICameraPerspective extends IProperty {
  86063. /**
  86064. * The floating-point aspect ratio of the field of view
  86065. */
  86066. aspectRatio?: number;
  86067. /**
  86068. * The floating-point vertical field of view in radians
  86069. */
  86070. yfov: number;
  86071. /**
  86072. * The floating-point distance to the far clipping plane
  86073. */
  86074. zfar?: number;
  86075. /**
  86076. * The floating-point distance to the near clipping plane
  86077. */
  86078. znear: number;
  86079. }
  86080. /**
  86081. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86082. */
  86083. interface ICamera extends IChildRootProperty {
  86084. /**
  86085. * An orthographic camera containing properties to create an orthographic projection matrix
  86086. */
  86087. orthographic?: ICameraOrthographic;
  86088. /**
  86089. * A perspective camera containing properties to create a perspective projection matrix
  86090. */
  86091. perspective?: ICameraPerspective;
  86092. /**
  86093. * Specifies if the camera uses a perspective or orthographic projection
  86094. */
  86095. type: CameraType;
  86096. }
  86097. /**
  86098. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86099. */
  86100. interface IImage extends IChildRootProperty {
  86101. /**
  86102. * 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
  86103. */
  86104. uri?: string;
  86105. /**
  86106. * The image's MIME type
  86107. */
  86108. mimeType?: ImageMimeType;
  86109. /**
  86110. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86111. */
  86112. bufferView?: number;
  86113. }
  86114. /**
  86115. * Material Normal Texture Info
  86116. */
  86117. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86118. /**
  86119. * The scalar multiplier applied to each normal vector of the normal texture
  86120. */
  86121. scale?: number;
  86122. }
  86123. /**
  86124. * Material Occlusion Texture Info
  86125. */
  86126. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86127. /**
  86128. * A scalar multiplier controlling the amount of occlusion applied
  86129. */
  86130. strength?: number;
  86131. }
  86132. /**
  86133. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86134. */
  86135. interface IMaterialPbrMetallicRoughness {
  86136. /**
  86137. * The material's base color factor
  86138. */
  86139. baseColorFactor?: number[];
  86140. /**
  86141. * The base color texture
  86142. */
  86143. baseColorTexture?: ITextureInfo;
  86144. /**
  86145. * The metalness of the material
  86146. */
  86147. metallicFactor?: number;
  86148. /**
  86149. * The roughness of the material
  86150. */
  86151. roughnessFactor?: number;
  86152. /**
  86153. * The metallic-roughness texture
  86154. */
  86155. metallicRoughnessTexture?: ITextureInfo;
  86156. }
  86157. /**
  86158. * The material appearance of a primitive
  86159. */
  86160. interface IMaterial extends IChildRootProperty {
  86161. /**
  86162. * 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
  86163. */
  86164. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86165. /**
  86166. * The normal map texture
  86167. */
  86168. normalTexture?: IMaterialNormalTextureInfo;
  86169. /**
  86170. * The occlusion map texture
  86171. */
  86172. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86173. /**
  86174. * The emissive map texture
  86175. */
  86176. emissiveTexture?: ITextureInfo;
  86177. /**
  86178. * 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
  86179. */
  86180. emissiveFactor?: number[];
  86181. /**
  86182. * The alpha rendering mode of the material
  86183. */
  86184. alphaMode?: MaterialAlphaMode;
  86185. /**
  86186. * The alpha cutoff value of the material
  86187. */
  86188. alphaCutoff?: number;
  86189. /**
  86190. * Specifies whether the material is double sided
  86191. */
  86192. doubleSided?: boolean;
  86193. }
  86194. /**
  86195. * Geometry to be rendered with the given material
  86196. */
  86197. interface IMeshPrimitive extends IProperty {
  86198. /**
  86199. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86200. */
  86201. attributes: {
  86202. [name: string]: number;
  86203. };
  86204. /**
  86205. * The index of the accessor that contains the indices
  86206. */
  86207. indices?: number;
  86208. /**
  86209. * The index of the material to apply to this primitive when rendering
  86210. */
  86211. material?: number;
  86212. /**
  86213. * The type of primitives to render. All valid values correspond to WebGL enums
  86214. */
  86215. mode?: MeshPrimitiveMode;
  86216. /**
  86217. * 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
  86218. */
  86219. targets?: {
  86220. [name: string]: number;
  86221. }[];
  86222. }
  86223. /**
  86224. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86225. */
  86226. interface IMesh extends IChildRootProperty {
  86227. /**
  86228. * An array of primitives, each defining geometry to be rendered with a material
  86229. */
  86230. primitives: IMeshPrimitive[];
  86231. /**
  86232. * Array of weights to be applied to the Morph Targets
  86233. */
  86234. weights?: number[];
  86235. }
  86236. /**
  86237. * A node in the node hierarchy
  86238. */
  86239. interface INode extends IChildRootProperty {
  86240. /**
  86241. * The index of the camera referenced by this node
  86242. */
  86243. camera?: number;
  86244. /**
  86245. * The indices of this node's children
  86246. */
  86247. children?: number[];
  86248. /**
  86249. * The index of the skin referenced by this node
  86250. */
  86251. skin?: number;
  86252. /**
  86253. * A floating-point 4x4 transformation matrix stored in column-major order
  86254. */
  86255. matrix?: number[];
  86256. /**
  86257. * The index of the mesh in this node
  86258. */
  86259. mesh?: number;
  86260. /**
  86261. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86262. */
  86263. rotation?: number[];
  86264. /**
  86265. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86266. */
  86267. scale?: number[];
  86268. /**
  86269. * The node's translation along the x, y, and z axes
  86270. */
  86271. translation?: number[];
  86272. /**
  86273. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86274. */
  86275. weights?: number[];
  86276. }
  86277. /**
  86278. * Texture sampler properties for filtering and wrapping modes
  86279. */
  86280. interface ISampler extends IChildRootProperty {
  86281. /**
  86282. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86283. */
  86284. magFilter?: TextureMagFilter;
  86285. /**
  86286. * Minification filter. All valid values correspond to WebGL enums
  86287. */
  86288. minFilter?: TextureMinFilter;
  86289. /**
  86290. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86291. */
  86292. wrapS?: TextureWrapMode;
  86293. /**
  86294. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86295. */
  86296. wrapT?: TextureWrapMode;
  86297. }
  86298. /**
  86299. * The root nodes of a scene
  86300. */
  86301. interface IScene extends IChildRootProperty {
  86302. /**
  86303. * The indices of each root node
  86304. */
  86305. nodes: number[];
  86306. }
  86307. /**
  86308. * Joints and matrices defining a skin
  86309. */
  86310. interface ISkin extends IChildRootProperty {
  86311. /**
  86312. * 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
  86313. */
  86314. inverseBindMatrices?: number;
  86315. /**
  86316. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86317. */
  86318. skeleton?: number;
  86319. /**
  86320. * 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)
  86321. */
  86322. joints: number[];
  86323. }
  86324. /**
  86325. * A texture and its sampler
  86326. */
  86327. interface ITexture extends IChildRootProperty {
  86328. /**
  86329. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86330. */
  86331. sampler?: number;
  86332. /**
  86333. * The index of the image used by this texture
  86334. */
  86335. source: number;
  86336. }
  86337. /**
  86338. * Reference to a texture
  86339. */
  86340. interface ITextureInfo extends IProperty {
  86341. /**
  86342. * The index of the texture
  86343. */
  86344. index: number;
  86345. /**
  86346. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86347. */
  86348. texCoord?: number;
  86349. }
  86350. /**
  86351. * The root object for a glTF asset
  86352. */
  86353. interface IGLTF extends IProperty {
  86354. /**
  86355. * An array of accessors. An accessor is a typed view into a bufferView
  86356. */
  86357. accessors?: IAccessor[];
  86358. /**
  86359. * An array of keyframe animations
  86360. */
  86361. animations?: IAnimation[];
  86362. /**
  86363. * Metadata about the glTF asset
  86364. */
  86365. asset: IAsset;
  86366. /**
  86367. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86368. */
  86369. buffers?: IBuffer[];
  86370. /**
  86371. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86372. */
  86373. bufferViews?: IBufferView[];
  86374. /**
  86375. * An array of cameras
  86376. */
  86377. cameras?: ICamera[];
  86378. /**
  86379. * Names of glTF extensions used somewhere in this asset
  86380. */
  86381. extensionsUsed?: string[];
  86382. /**
  86383. * Names of glTF extensions required to properly load this asset
  86384. */
  86385. extensionsRequired?: string[];
  86386. /**
  86387. * An array of images. An image defines data used to create a texture
  86388. */
  86389. images?: IImage[];
  86390. /**
  86391. * An array of materials. A material defines the appearance of a primitive
  86392. */
  86393. materials?: IMaterial[];
  86394. /**
  86395. * An array of meshes. A mesh is a set of primitives to be rendered
  86396. */
  86397. meshes?: IMesh[];
  86398. /**
  86399. * An array of nodes
  86400. */
  86401. nodes?: INode[];
  86402. /**
  86403. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86404. */
  86405. samplers?: ISampler[];
  86406. /**
  86407. * The index of the default scene
  86408. */
  86409. scene?: number;
  86410. /**
  86411. * An array of scenes
  86412. */
  86413. scenes?: IScene[];
  86414. /**
  86415. * An array of skins. A skin is defined by joints and matrices
  86416. */
  86417. skins?: ISkin[];
  86418. /**
  86419. * An array of textures
  86420. */
  86421. textures?: ITexture[];
  86422. }
  86423. /**
  86424. * The glTF validation results
  86425. * @ignore
  86426. */
  86427. interface IGLTFValidationResults {
  86428. info: {
  86429. generator: string;
  86430. hasAnimations: boolean;
  86431. hasDefaultScene: boolean;
  86432. hasMaterials: boolean;
  86433. hasMorphTargets: boolean;
  86434. hasSkins: boolean;
  86435. hasTextures: boolean;
  86436. maxAttributesUsed: number;
  86437. primitivesCount: number
  86438. };
  86439. issues: {
  86440. messages: Array<string>;
  86441. numErrors: number;
  86442. numHints: number;
  86443. numInfos: number;
  86444. numWarnings: number;
  86445. truncated: boolean
  86446. };
  86447. mimeType: string;
  86448. uri: string;
  86449. validatedAt: string;
  86450. validatorVersion: string;
  86451. }
  86452. /**
  86453. * The glTF validation options
  86454. */
  86455. interface IGLTFValidationOptions {
  86456. /** Uri to use */
  86457. uri?: string;
  86458. /** Function used to load external resources */
  86459. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86460. /** Boolean indicating that we need to validate accessor data */
  86461. validateAccessorData?: boolean;
  86462. /** max number of issues allowed */
  86463. maxIssues?: number;
  86464. /** Ignored issues */
  86465. ignoredIssues?: Array<string>;
  86466. /** Value to override severy settings */
  86467. severityOverrides?: Object;
  86468. }
  86469. /**
  86470. * The glTF validator object
  86471. * @ignore
  86472. */
  86473. interface IGLTFValidator {
  86474. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86475. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86476. }
  86477. /**
  86478. * Interfaces from the EXT_lights_image_based extension
  86479. */
  86480. /** @hidden */
  86481. interface IEXTLightsImageBased_LightReferenceImageBased {
  86482. light: number;
  86483. }
  86484. /** @hidden */
  86485. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86486. intensity: number;
  86487. rotation: number[];
  86488. specularImageSize: number;
  86489. specularImages: number[][];
  86490. irradianceCoefficients: number[][];
  86491. }
  86492. /** @hidden */
  86493. interface IEXTLightsImageBased {
  86494. lights: IEXTLightsImageBased_LightImageBased[];
  86495. }
  86496. /**
  86497. * Interfaces from the EXT_mesh_gpu_instancing extension
  86498. * !!! Experimental Extension Subject to Changes !!!
  86499. */
  86500. /** @hidden */
  86501. interface IEXTMeshGpuInstancing {
  86502. mesh?: number;
  86503. attributes: { [name: string]: number };
  86504. }
  86505. /**
  86506. * Interfaces from the KHR_draco_mesh_compression extension
  86507. */
  86508. /** @hidden */
  86509. interface IKHRDracoMeshCompression {
  86510. bufferView: number;
  86511. attributes: { [name: string]: number };
  86512. }
  86513. /**
  86514. * Interfaces from the KHR_lights_punctual extension
  86515. */
  86516. /** @hidden */
  86517. const enum IKHRLightsPunctual_LightType {
  86518. DIRECTIONAL = "directional",
  86519. POINT = "point",
  86520. SPOT = "spot"
  86521. }
  86522. /** @hidden */
  86523. interface IKHRLightsPunctual_LightReference {
  86524. light: number;
  86525. }
  86526. /** @hidden */
  86527. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86528. type: IKHRLightsPunctual_LightType;
  86529. color?: number[];
  86530. intensity?: number;
  86531. range?: number;
  86532. spot?: {
  86533. innerConeAngle?: number;
  86534. outerConeAngle?: number;
  86535. };
  86536. }
  86537. /** @hidden */
  86538. interface IKHRLightsPunctual {
  86539. lights: IKHRLightsPunctual_Light[];
  86540. }
  86541. /**
  86542. * Interfaces from the KHR_materials_clearcoat extension
  86543. * !!! Experimental Extension Subject to Changes !!!
  86544. */
  86545. /** @hidden */
  86546. interface IKHRMaterialsClearcoat {
  86547. clearcoatFactor: number;
  86548. clearcoatTexture: ITextureInfo;
  86549. clearcoatRoughnessFactor: number;
  86550. clearcoatRoughnessTexture: ITextureInfo;
  86551. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86552. }
  86553. /**
  86554. * Interfaces from the KHR_materials_ior extension
  86555. * !!! Experimental Extension Subject to Changes !!!
  86556. */
  86557. /** @hidden */
  86558. interface IKHRMaterialsIor {
  86559. ior: number;
  86560. }
  86561. /**
  86562. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86563. */
  86564. /** @hidden */
  86565. interface IKHRMaterialsPbrSpecularGlossiness {
  86566. diffuseFactor: number[];
  86567. diffuseTexture: ITextureInfo;
  86568. specularFactor: number[];
  86569. glossinessFactor: number;
  86570. specularGlossinessTexture: ITextureInfo;
  86571. }
  86572. /**
  86573. * Interfaces from the KHR_materials_sheen extension
  86574. * !!! Experimental Extension Subject to Changes !!!
  86575. */
  86576. /** @hidden */
  86577. interface IKHRMaterialsSheen {
  86578. sheenColorFactor?: number[];
  86579. sheenColorTexture?: ITextureInfo;
  86580. sheenRoughnessFactor?: number;
  86581. sheenRoughnessTexture?: ITextureInfo;
  86582. }
  86583. /**
  86584. * Interfaces from the KHR_materials_specular extension
  86585. * !!! Experimental Extension Subject to Changes !!!
  86586. */
  86587. /** @hidden */
  86588. interface IKHRMaterialsSpecular {
  86589. specularFactor: number;
  86590. specularColorFactor: number[];
  86591. specularTexture: ITextureInfo;
  86592. }
  86593. /**
  86594. * Interfaces from the KHR_materials_transmission extension
  86595. * !!! Experimental Extension Subject to Changes !!!
  86596. */
  86597. /** @hidden */
  86598. interface IKHRMaterialsTransmission {
  86599. transmissionFactor?: number;
  86600. transmissionTexture?: ITextureInfo;
  86601. }
  86602. /**
  86603. * Interfaces from the KHR_materials_variants extension
  86604. * !!! Experimental Extension Subject to Changes !!!
  86605. */
  86606. /** @hidden */
  86607. interface IKHRMaterialVariants_Mapping extends IProperty {
  86608. mappings: Array<{
  86609. variants: number[];
  86610. material: number;
  86611. }>;
  86612. }
  86613. /** @hidden */
  86614. interface IKHRMaterialVariants_Variant extends IProperty {
  86615. name: string;
  86616. }
  86617. /** @hidden */
  86618. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86619. variants: Array<IKHRMaterialVariants_Variant>;
  86620. }
  86621. /**
  86622. * Interfaces from the KHR_texture_basisu extension
  86623. * !!! Experimental Extension Subject to Changes !!!
  86624. */
  86625. /** @hidden */
  86626. interface IKHRTextureBasisU {
  86627. source: number;
  86628. }
  86629. /**
  86630. * Interfaces from the EXT_texture_webp extension
  86631. */
  86632. /** @hidden */
  86633. interface IEXTTextureWebP {
  86634. source: number;
  86635. }
  86636. /**
  86637. * Interfaces from the KHR_texture_transform extension
  86638. */
  86639. /** @hidden */
  86640. interface IKHRTextureTransform {
  86641. offset?: number[];
  86642. rotation?: number;
  86643. scale?: number[];
  86644. texCoord?: number;
  86645. }
  86646. /**
  86647. * Interfaces from the KHR_xmp extension
  86648. * !!! Experimental Extension Subject to Changes !!!
  86649. */
  86650. /** @hidden */
  86651. interface IKHRXmp_Data {
  86652. [key: string]: unknown;
  86653. }
  86654. /** @hidden */
  86655. interface IKHRXmp_Gltf {
  86656. packets: IKHRXmp_Data[];
  86657. }
  86658. /** @hidden */
  86659. interface IKHRXmp_Node {
  86660. packet: number;
  86661. }
  86662. /**
  86663. * Interfaces from the MSFT_audio_emitter extension
  86664. */
  86665. /** @hidden */
  86666. interface IMSFTAudioEmitter_ClipReference {
  86667. clip: number;
  86668. weight?: number;
  86669. }
  86670. /** @hidden */
  86671. interface IMSFTAudioEmitter_EmittersReference {
  86672. emitters: number[];
  86673. }
  86674. /** @hidden */
  86675. const enum IMSFTAudioEmitter_DistanceModel {
  86676. linear = "linear",
  86677. inverse = "inverse",
  86678. exponential = "exponential",
  86679. }
  86680. /** @hidden */
  86681. interface IMSFTAudioEmitter_Emitter {
  86682. name?: string;
  86683. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86684. refDistance?: number;
  86685. maxDistance?: number;
  86686. rolloffFactor?: number;
  86687. innerAngle?: number;
  86688. outerAngle?: number;
  86689. loop?: boolean;
  86690. volume?: number;
  86691. clips: IMSFTAudioEmitter_ClipReference[];
  86692. }
  86693. /** @hidden */
  86694. const enum IMSFTAudioEmitter_AudioMimeType {
  86695. WAV = "audio/wav",
  86696. }
  86697. /** @hidden */
  86698. interface IMSFTAudioEmitter_Clip extends IProperty {
  86699. uri?: string;
  86700. bufferView?: number;
  86701. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86702. }
  86703. /** @hidden */
  86704. const enum IMSFTAudioEmitter_AnimationEventAction {
  86705. play = "play",
  86706. pause = "pause",
  86707. stop = "stop",
  86708. }
  86709. /** @hidden */
  86710. interface IMSFTAudioEmitter_AnimationEvent {
  86711. action: IMSFTAudioEmitter_AnimationEventAction;
  86712. emitter: number;
  86713. time: number;
  86714. startOffset?: number;
  86715. }
  86716. /**
  86717. * Interfaces from the MSFT_lod extension
  86718. */
  86719. /** @hidden */
  86720. interface IMSFTLOD {
  86721. ids: number[];
  86722. }
  86723. }
  86724. declare module BABYLON {
  86725. /** @hidden */
  86726. export var cellPixelShader: {
  86727. name: string;
  86728. shader: string;
  86729. };
  86730. }
  86731. declare module BABYLON {
  86732. /** @hidden */
  86733. export var cellVertexShader: {
  86734. name: string;
  86735. shader: string;
  86736. };
  86737. }
  86738. declare module BABYLON {
  86739. export class CellMaterial extends BABYLON.PushMaterial {
  86740. private _diffuseTexture;
  86741. diffuseTexture: BABYLON.BaseTexture;
  86742. diffuseColor: BABYLON.Color3;
  86743. _computeHighLevel: boolean;
  86744. computeHighLevel: boolean;
  86745. private _disableLighting;
  86746. disableLighting: boolean;
  86747. private _maxSimultaneousLights;
  86748. maxSimultaneousLights: number;
  86749. constructor(name: string, scene: BABYLON.Scene);
  86750. needAlphaBlending(): boolean;
  86751. needAlphaTesting(): boolean;
  86752. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86753. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86754. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86755. getAnimatables(): BABYLON.IAnimatable[];
  86756. getActiveTextures(): BABYLON.BaseTexture[];
  86757. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86758. dispose(forceDisposeEffect?: boolean): void;
  86759. getClassName(): string;
  86760. clone(name: string): CellMaterial;
  86761. serialize(): any;
  86762. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86763. }
  86764. }
  86765. declare module BABYLON {
  86766. export class CustomShaderStructure {
  86767. FragmentStore: string;
  86768. VertexStore: string;
  86769. constructor();
  86770. }
  86771. export class ShaderSpecialParts {
  86772. constructor();
  86773. Fragment_Begin: string;
  86774. Fragment_Definitions: string;
  86775. Fragment_MainBegin: string;
  86776. Fragment_Custom_Diffuse: string;
  86777. Fragment_Before_Lights: string;
  86778. Fragment_Before_Fog: string;
  86779. Fragment_Custom_Alpha: string;
  86780. Fragment_Before_FragColor: string;
  86781. Vertex_Begin: string;
  86782. Vertex_Definitions: string;
  86783. Vertex_MainBegin: string;
  86784. Vertex_Before_PositionUpdated: string;
  86785. Vertex_Before_NormalUpdated: string;
  86786. Vertex_After_WorldPosComputed: string;
  86787. Vertex_MainEnd: string;
  86788. }
  86789. export class CustomMaterial extends BABYLON.StandardMaterial {
  86790. static ShaderIndexer: number;
  86791. CustomParts: ShaderSpecialParts;
  86792. _isCreatedShader: boolean;
  86793. _createdShaderName: string;
  86794. _customUniform: string[];
  86795. _newUniforms: string[];
  86796. _newUniformInstances: {
  86797. [name: string]: any;
  86798. };
  86799. _newSamplerInstances: {
  86800. [name: string]: BABYLON.Texture;
  86801. };
  86802. _customAttributes: string[];
  86803. FragmentShader: string;
  86804. VertexShader: string;
  86805. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86806. ReviewUniform(name: string, arr: string[]): string[];
  86807. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86808. constructor(name: string, scene: BABYLON.Scene);
  86809. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86810. AddAttribute(name: string): CustomMaterial;
  86811. Fragment_Begin(shaderPart: string): CustomMaterial;
  86812. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86813. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86814. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86815. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86816. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86817. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86818. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86819. Vertex_Begin(shaderPart: string): CustomMaterial;
  86820. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86821. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86822. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86823. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86824. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86825. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86826. }
  86827. }
  86828. declare module BABYLON {
  86829. export class ShaderAlebdoParts {
  86830. constructor();
  86831. Fragment_Begin: string;
  86832. Fragment_Definitions: string;
  86833. Fragment_MainBegin: string;
  86834. Fragment_Custom_Albedo: string;
  86835. Fragment_Before_Lights: string;
  86836. Fragment_Custom_MetallicRoughness: string;
  86837. Fragment_Custom_MicroSurface: string;
  86838. Fragment_Before_Fog: string;
  86839. Fragment_Custom_Alpha: string;
  86840. Fragment_Before_FragColor: string;
  86841. Vertex_Begin: string;
  86842. Vertex_Definitions: string;
  86843. Vertex_MainBegin: string;
  86844. Vertex_Before_PositionUpdated: string;
  86845. Vertex_Before_NormalUpdated: string;
  86846. Vertex_After_WorldPosComputed: string;
  86847. Vertex_MainEnd: string;
  86848. }
  86849. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86850. static ShaderIndexer: number;
  86851. CustomParts: ShaderAlebdoParts;
  86852. _isCreatedShader: boolean;
  86853. _createdShaderName: string;
  86854. _customUniform: string[];
  86855. _newUniforms: string[];
  86856. _newUniformInstances: {
  86857. [name: string]: any;
  86858. };
  86859. _newSamplerInstances: {
  86860. [name: string]: BABYLON.Texture;
  86861. };
  86862. _customAttributes: string[];
  86863. FragmentShader: string;
  86864. VertexShader: string;
  86865. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86866. ReviewUniform(name: string, arr: string[]): string[];
  86867. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86868. constructor(name: string, scene: BABYLON.Scene);
  86869. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86870. AddAttribute(name: string): PBRCustomMaterial;
  86871. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86872. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86873. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86874. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86875. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86876. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86877. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86878. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86879. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86880. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86881. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86882. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86883. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86884. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86885. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86886. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86887. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86888. }
  86889. }
  86890. declare module BABYLON {
  86891. /** @hidden */
  86892. export var firePixelShader: {
  86893. name: string;
  86894. shader: string;
  86895. };
  86896. }
  86897. declare module BABYLON {
  86898. /** @hidden */
  86899. export var fireVertexShader: {
  86900. name: string;
  86901. shader: string;
  86902. };
  86903. }
  86904. declare module BABYLON {
  86905. export class FireMaterial extends BABYLON.PushMaterial {
  86906. private _diffuseTexture;
  86907. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86908. private _distortionTexture;
  86909. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86910. private _opacityTexture;
  86911. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86912. diffuseColor: BABYLON.Color3;
  86913. speed: number;
  86914. private _scaledDiffuse;
  86915. private _lastTime;
  86916. constructor(name: string, scene: BABYLON.Scene);
  86917. needAlphaBlending(): boolean;
  86918. needAlphaTesting(): boolean;
  86919. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86922. getAnimatables(): BABYLON.IAnimatable[];
  86923. getActiveTextures(): BABYLON.BaseTexture[];
  86924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86925. getClassName(): string;
  86926. dispose(forceDisposeEffect?: boolean): void;
  86927. clone(name: string): FireMaterial;
  86928. serialize(): any;
  86929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86930. }
  86931. }
  86932. declare module BABYLON {
  86933. /** @hidden */
  86934. export var furPixelShader: {
  86935. name: string;
  86936. shader: string;
  86937. };
  86938. }
  86939. declare module BABYLON {
  86940. /** @hidden */
  86941. export var furVertexShader: {
  86942. name: string;
  86943. shader: string;
  86944. };
  86945. }
  86946. declare module BABYLON {
  86947. export class FurMaterial extends BABYLON.PushMaterial {
  86948. private _diffuseTexture;
  86949. diffuseTexture: BABYLON.BaseTexture;
  86950. private _heightTexture;
  86951. heightTexture: BABYLON.BaseTexture;
  86952. diffuseColor: BABYLON.Color3;
  86953. furLength: number;
  86954. furAngle: number;
  86955. furColor: BABYLON.Color3;
  86956. furOffset: number;
  86957. furSpacing: number;
  86958. furGravity: BABYLON.Vector3;
  86959. furSpeed: number;
  86960. furDensity: number;
  86961. furOcclusion: number;
  86962. furTexture: BABYLON.DynamicTexture;
  86963. private _disableLighting;
  86964. disableLighting: boolean;
  86965. private _maxSimultaneousLights;
  86966. maxSimultaneousLights: number;
  86967. highLevelFur: boolean;
  86968. _meshes: BABYLON.AbstractMesh[];
  86969. private _furTime;
  86970. constructor(name: string, scene: BABYLON.Scene);
  86971. get furTime(): number;
  86972. set furTime(furTime: number);
  86973. needAlphaBlending(): boolean;
  86974. needAlphaTesting(): boolean;
  86975. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86976. updateFur(): void;
  86977. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86978. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86979. getAnimatables(): BABYLON.IAnimatable[];
  86980. getActiveTextures(): BABYLON.BaseTexture[];
  86981. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86982. dispose(forceDisposeEffect?: boolean): void;
  86983. clone(name: string): FurMaterial;
  86984. serialize(): any;
  86985. getClassName(): string;
  86986. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86987. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86988. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86989. }
  86990. }
  86991. declare module BABYLON {
  86992. /** @hidden */
  86993. export var gradientPixelShader: {
  86994. name: string;
  86995. shader: string;
  86996. };
  86997. }
  86998. declare module BABYLON {
  86999. /** @hidden */
  87000. export var gradientVertexShader: {
  87001. name: string;
  87002. shader: string;
  87003. };
  87004. }
  87005. declare module BABYLON {
  87006. export class GradientMaterial extends BABYLON.PushMaterial {
  87007. private _maxSimultaneousLights;
  87008. maxSimultaneousLights: number;
  87009. topColor: BABYLON.Color3;
  87010. topColorAlpha: number;
  87011. bottomColor: BABYLON.Color3;
  87012. bottomColorAlpha: number;
  87013. offset: number;
  87014. scale: number;
  87015. smoothness: number;
  87016. private _disableLighting;
  87017. disableLighting: boolean;
  87018. constructor(name: string, scene: BABYLON.Scene);
  87019. needAlphaBlending(): boolean;
  87020. needAlphaTesting(): boolean;
  87021. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87022. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87023. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87024. getAnimatables(): BABYLON.IAnimatable[];
  87025. dispose(forceDisposeEffect?: boolean): void;
  87026. clone(name: string): GradientMaterial;
  87027. serialize(): any;
  87028. getClassName(): string;
  87029. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87030. }
  87031. }
  87032. declare module BABYLON {
  87033. /** @hidden */
  87034. export var gridPixelShader: {
  87035. name: string;
  87036. shader: string;
  87037. };
  87038. }
  87039. declare module BABYLON {
  87040. /** @hidden */
  87041. export var gridVertexShader: {
  87042. name: string;
  87043. shader: string;
  87044. };
  87045. }
  87046. declare module BABYLON {
  87047. /**
  87048. * The grid materials allows you to wrap any shape with a grid.
  87049. * Colors are customizable.
  87050. */
  87051. export class GridMaterial extends BABYLON.PushMaterial {
  87052. /**
  87053. * Main color of the grid (e.g. between lines)
  87054. */
  87055. mainColor: BABYLON.Color3;
  87056. /**
  87057. * Color of the grid lines.
  87058. */
  87059. lineColor: BABYLON.Color3;
  87060. /**
  87061. * The scale of the grid compared to unit.
  87062. */
  87063. gridRatio: number;
  87064. /**
  87065. * Allows setting an offset for the grid lines.
  87066. */
  87067. gridOffset: BABYLON.Vector3;
  87068. /**
  87069. * The frequency of thicker lines.
  87070. */
  87071. majorUnitFrequency: number;
  87072. /**
  87073. * The visibility of minor units in the grid.
  87074. */
  87075. minorUnitVisibility: number;
  87076. /**
  87077. * The grid opacity outside of the lines.
  87078. */
  87079. opacity: number;
  87080. /**
  87081. * Determine RBG output is premultiplied by alpha value.
  87082. */
  87083. preMultiplyAlpha: boolean;
  87084. private _opacityTexture;
  87085. opacityTexture: BABYLON.BaseTexture;
  87086. private _gridControl;
  87087. /**
  87088. * constructor
  87089. * @param name The name given to the material in order to identify it afterwards.
  87090. * @param scene The scene the material is used in.
  87091. */
  87092. constructor(name: string, scene: BABYLON.Scene);
  87093. /**
  87094. * Returns wehter or not the grid requires alpha blending.
  87095. */
  87096. needAlphaBlending(): boolean;
  87097. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87098. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87099. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87100. /**
  87101. * Dispose the material and its associated resources.
  87102. * @param forceDisposeEffect will also dispose the used effect when true
  87103. */
  87104. dispose(forceDisposeEffect?: boolean): void;
  87105. clone(name: string): GridMaterial;
  87106. serialize(): any;
  87107. getClassName(): string;
  87108. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87109. }
  87110. }
  87111. declare module BABYLON {
  87112. /** @hidden */
  87113. export var lavaPixelShader: {
  87114. name: string;
  87115. shader: string;
  87116. };
  87117. }
  87118. declare module BABYLON {
  87119. /** @hidden */
  87120. export var lavaVertexShader: {
  87121. name: string;
  87122. shader: string;
  87123. };
  87124. }
  87125. declare module BABYLON {
  87126. export class LavaMaterial extends BABYLON.PushMaterial {
  87127. private _diffuseTexture;
  87128. diffuseTexture: BABYLON.BaseTexture;
  87129. noiseTexture: BABYLON.BaseTexture;
  87130. fogColor: BABYLON.Color3;
  87131. speed: number;
  87132. movingSpeed: number;
  87133. lowFrequencySpeed: number;
  87134. fogDensity: number;
  87135. private _lastTime;
  87136. diffuseColor: BABYLON.Color3;
  87137. private _disableLighting;
  87138. disableLighting: boolean;
  87139. private _unlit;
  87140. unlit: boolean;
  87141. private _maxSimultaneousLights;
  87142. maxSimultaneousLights: number;
  87143. private _scaledDiffuse;
  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): LavaMaterial;
  87155. serialize(): any;
  87156. getClassName(): string;
  87157. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87158. }
  87159. }
  87160. declare module BABYLON {
  87161. /** @hidden */
  87162. export var mixPixelShader: {
  87163. name: string;
  87164. shader: string;
  87165. };
  87166. }
  87167. declare module BABYLON {
  87168. /** @hidden */
  87169. export var mixVertexShader: {
  87170. name: string;
  87171. shader: string;
  87172. };
  87173. }
  87174. declare module BABYLON {
  87175. export class MixMaterial extends BABYLON.PushMaterial {
  87176. /**
  87177. * Mix textures
  87178. */
  87179. private _mixTexture1;
  87180. mixTexture1: BABYLON.BaseTexture;
  87181. private _mixTexture2;
  87182. mixTexture2: BABYLON.BaseTexture;
  87183. /**
  87184. * Diffuse textures
  87185. */
  87186. private _diffuseTexture1;
  87187. diffuseTexture1: BABYLON.Texture;
  87188. private _diffuseTexture2;
  87189. diffuseTexture2: BABYLON.Texture;
  87190. private _diffuseTexture3;
  87191. diffuseTexture3: BABYLON.Texture;
  87192. private _diffuseTexture4;
  87193. diffuseTexture4: BABYLON.Texture;
  87194. private _diffuseTexture5;
  87195. diffuseTexture5: BABYLON.Texture;
  87196. private _diffuseTexture6;
  87197. diffuseTexture6: BABYLON.Texture;
  87198. private _diffuseTexture7;
  87199. diffuseTexture7: BABYLON.Texture;
  87200. private _diffuseTexture8;
  87201. diffuseTexture8: BABYLON.Texture;
  87202. /**
  87203. * Uniforms
  87204. */
  87205. diffuseColor: BABYLON.Color3;
  87206. specularColor: BABYLON.Color3;
  87207. specularPower: number;
  87208. private _disableLighting;
  87209. disableLighting: boolean;
  87210. private _maxSimultaneousLights;
  87211. maxSimultaneousLights: number;
  87212. constructor(name: string, scene: BABYLON.Scene);
  87213. needAlphaBlending(): boolean;
  87214. needAlphaTesting(): boolean;
  87215. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87216. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87217. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87218. getAnimatables(): BABYLON.IAnimatable[];
  87219. getActiveTextures(): BABYLON.BaseTexture[];
  87220. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87221. dispose(forceDisposeEffect?: boolean): void;
  87222. clone(name: string): MixMaterial;
  87223. serialize(): any;
  87224. getClassName(): string;
  87225. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87226. }
  87227. }
  87228. declare module BABYLON {
  87229. /** @hidden */
  87230. export var normalPixelShader: {
  87231. name: string;
  87232. shader: string;
  87233. };
  87234. }
  87235. declare module BABYLON {
  87236. /** @hidden */
  87237. export var normalVertexShader: {
  87238. name: string;
  87239. shader: string;
  87240. };
  87241. }
  87242. declare module BABYLON {
  87243. export class NormalMaterial extends BABYLON.PushMaterial {
  87244. private _diffuseTexture;
  87245. diffuseTexture: BABYLON.BaseTexture;
  87246. diffuseColor: BABYLON.Color3;
  87247. private _disableLighting;
  87248. disableLighting: boolean;
  87249. private _maxSimultaneousLights;
  87250. maxSimultaneousLights: number;
  87251. constructor(name: string, scene: BABYLON.Scene);
  87252. needAlphaBlending(): boolean;
  87253. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87254. needAlphaTesting(): boolean;
  87255. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87256. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87257. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87258. getAnimatables(): BABYLON.IAnimatable[];
  87259. getActiveTextures(): BABYLON.BaseTexture[];
  87260. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87261. dispose(forceDisposeEffect?: boolean): void;
  87262. clone(name: string): NormalMaterial;
  87263. serialize(): any;
  87264. getClassName(): string;
  87265. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87266. }
  87267. }
  87268. declare module BABYLON {
  87269. /** @hidden */
  87270. export var shadowOnlyPixelShader: {
  87271. name: string;
  87272. shader: string;
  87273. };
  87274. }
  87275. declare module BABYLON {
  87276. /** @hidden */
  87277. export var shadowOnlyVertexShader: {
  87278. name: string;
  87279. shader: string;
  87280. };
  87281. }
  87282. declare module BABYLON {
  87283. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87284. private _activeLight;
  87285. private _needAlphaBlending;
  87286. constructor(name: string, scene: BABYLON.Scene);
  87287. shadowColor: BABYLON.Color3;
  87288. needAlphaBlending(): boolean;
  87289. needAlphaTesting(): boolean;
  87290. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87291. get activeLight(): BABYLON.IShadowLight;
  87292. set activeLight(light: BABYLON.IShadowLight);
  87293. private _getFirstShadowLightForMesh;
  87294. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87295. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87296. clone(name: string): ShadowOnlyMaterial;
  87297. serialize(): any;
  87298. getClassName(): string;
  87299. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87300. }
  87301. }
  87302. declare module BABYLON {
  87303. /** @hidden */
  87304. export var simplePixelShader: {
  87305. name: string;
  87306. shader: string;
  87307. };
  87308. }
  87309. declare module BABYLON {
  87310. /** @hidden */
  87311. export var simpleVertexShader: {
  87312. name: string;
  87313. shader: string;
  87314. };
  87315. }
  87316. declare module BABYLON {
  87317. export class SimpleMaterial extends BABYLON.PushMaterial {
  87318. private _diffuseTexture;
  87319. diffuseTexture: BABYLON.BaseTexture;
  87320. diffuseColor: BABYLON.Color3;
  87321. private _disableLighting;
  87322. disableLighting: boolean;
  87323. private _maxSimultaneousLights;
  87324. maxSimultaneousLights: number;
  87325. constructor(name: string, scene: BABYLON.Scene);
  87326. needAlphaBlending(): boolean;
  87327. needAlphaTesting(): boolean;
  87328. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87329. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87330. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87331. getAnimatables(): BABYLON.IAnimatable[];
  87332. getActiveTextures(): BABYLON.BaseTexture[];
  87333. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87334. dispose(forceDisposeEffect?: boolean): void;
  87335. clone(name: string): SimpleMaterial;
  87336. serialize(): any;
  87337. getClassName(): string;
  87338. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87339. }
  87340. }
  87341. declare module BABYLON {
  87342. /** @hidden */
  87343. export var skyPixelShader: {
  87344. name: string;
  87345. shader: string;
  87346. };
  87347. }
  87348. declare module BABYLON {
  87349. /** @hidden */
  87350. export var skyVertexShader: {
  87351. name: string;
  87352. shader: string;
  87353. };
  87354. }
  87355. declare module BABYLON {
  87356. /**
  87357. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87358. * @see https://doc.babylonjs.com/extensions/sky
  87359. */
  87360. export class SkyMaterial extends BABYLON.PushMaterial {
  87361. /**
  87362. * Defines the overall luminance of sky in interval ]0, 1[.
  87363. */
  87364. luminance: number;
  87365. /**
  87366. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87367. */
  87368. turbidity: number;
  87369. /**
  87370. * Defines the sky appearance (light intensity).
  87371. */
  87372. rayleigh: number;
  87373. /**
  87374. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87375. */
  87376. mieCoefficient: number;
  87377. /**
  87378. * Defines the amount of haze particles following the Mie scattering theory.
  87379. */
  87380. mieDirectionalG: number;
  87381. /**
  87382. * Defines the distance of the sun according to the active scene camera.
  87383. */
  87384. distance: number;
  87385. /**
  87386. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87387. * "inclined".
  87388. */
  87389. inclination: number;
  87390. /**
  87391. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87392. * an object direction and a reference direction.
  87393. */
  87394. azimuth: number;
  87395. /**
  87396. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87397. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87398. */
  87399. sunPosition: BABYLON.Vector3;
  87400. /**
  87401. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87402. * .sunPosition property.
  87403. */
  87404. useSunPosition: boolean;
  87405. /**
  87406. * Defines an offset vector used to get a horizon offset.
  87407. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87408. */
  87409. cameraOffset: BABYLON.Vector3;
  87410. private _cameraPosition;
  87411. /**
  87412. * Instantiates a new sky material.
  87413. * This material allows to create dynamic and texture free
  87414. * effects for skyboxes by taking care of the atmosphere state.
  87415. * @see https://doc.babylonjs.com/extensions/sky
  87416. * @param name Define the name of the material in the scene
  87417. * @param scene Define the scene the material belong to
  87418. */
  87419. constructor(name: string, scene: BABYLON.Scene);
  87420. /**
  87421. * Specifies if the material will require alpha blending
  87422. * @returns a boolean specifying if alpha blending is needed
  87423. */
  87424. needAlphaBlending(): boolean;
  87425. /**
  87426. * Specifies if this material should be rendered in alpha test mode
  87427. * @returns false as the sky material doesn't need alpha testing.
  87428. */
  87429. needAlphaTesting(): boolean;
  87430. /**
  87431. * Get the texture used for alpha test purpose.
  87432. * @returns null as the sky material has no texture.
  87433. */
  87434. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87435. /**
  87436. * Get if the submesh is ready to be used and all its information available.
  87437. * Child classes can use it to update shaders
  87438. * @param mesh defines the mesh to check
  87439. * @param subMesh defines which submesh to check
  87440. * @param useInstances specifies that instances should be used
  87441. * @returns a boolean indicating that the submesh is ready or not
  87442. */
  87443. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87444. /**
  87445. * Binds the submesh to this material by preparing the effect and shader to draw
  87446. * @param world defines the world transformation matrix
  87447. * @param mesh defines the mesh containing the submesh
  87448. * @param subMesh defines the submesh to bind the material to
  87449. */
  87450. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87451. /**
  87452. * Get the list of animatables in the material.
  87453. * @returns the list of animatables object used in the material
  87454. */
  87455. getAnimatables(): BABYLON.IAnimatable[];
  87456. /**
  87457. * Disposes the material
  87458. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87459. */
  87460. dispose(forceDisposeEffect?: boolean): void;
  87461. /**
  87462. * Makes a duplicate of the material, and gives it a new name
  87463. * @param name defines the new name for the duplicated material
  87464. * @returns the cloned material
  87465. */
  87466. clone(name: string): SkyMaterial;
  87467. /**
  87468. * Serializes this material in a JSON representation
  87469. * @returns the serialized material object
  87470. */
  87471. serialize(): any;
  87472. /**
  87473. * Gets the current class name of the material e.g. "SkyMaterial"
  87474. * Mainly use in serialization.
  87475. * @returns the class name
  87476. */
  87477. getClassName(): string;
  87478. /**
  87479. * Creates a sky material from parsed material data
  87480. * @param source defines the JSON representation of the material
  87481. * @param scene defines the hosting scene
  87482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87483. * @returns a new sky material
  87484. */
  87485. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87486. }
  87487. }
  87488. declare module BABYLON {
  87489. /** @hidden */
  87490. export var terrainPixelShader: {
  87491. name: string;
  87492. shader: string;
  87493. };
  87494. }
  87495. declare module BABYLON {
  87496. /** @hidden */
  87497. export var terrainVertexShader: {
  87498. name: string;
  87499. shader: string;
  87500. };
  87501. }
  87502. declare module BABYLON {
  87503. export class TerrainMaterial extends BABYLON.PushMaterial {
  87504. private _mixTexture;
  87505. mixTexture: BABYLON.BaseTexture;
  87506. private _diffuseTexture1;
  87507. diffuseTexture1: BABYLON.Texture;
  87508. private _diffuseTexture2;
  87509. diffuseTexture2: BABYLON.Texture;
  87510. private _diffuseTexture3;
  87511. diffuseTexture3: BABYLON.Texture;
  87512. private _bumpTexture1;
  87513. bumpTexture1: BABYLON.Texture;
  87514. private _bumpTexture2;
  87515. bumpTexture2: BABYLON.Texture;
  87516. private _bumpTexture3;
  87517. bumpTexture3: BABYLON.Texture;
  87518. diffuseColor: BABYLON.Color3;
  87519. specularColor: BABYLON.Color3;
  87520. specularPower: number;
  87521. private _disableLighting;
  87522. disableLighting: boolean;
  87523. private _maxSimultaneousLights;
  87524. maxSimultaneousLights: number;
  87525. constructor(name: string, scene: BABYLON.Scene);
  87526. needAlphaBlending(): boolean;
  87527. needAlphaTesting(): boolean;
  87528. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87529. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87530. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87531. getAnimatables(): BABYLON.IAnimatable[];
  87532. getActiveTextures(): BABYLON.BaseTexture[];
  87533. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87534. dispose(forceDisposeEffect?: boolean): void;
  87535. clone(name: string): TerrainMaterial;
  87536. serialize(): any;
  87537. getClassName(): string;
  87538. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87539. }
  87540. }
  87541. declare module BABYLON {
  87542. /** @hidden */
  87543. export var triplanarPixelShader: {
  87544. name: string;
  87545. shader: string;
  87546. };
  87547. }
  87548. declare module BABYLON {
  87549. /** @hidden */
  87550. export var triplanarVertexShader: {
  87551. name: string;
  87552. shader: string;
  87553. };
  87554. }
  87555. declare module BABYLON {
  87556. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87557. mixTexture: BABYLON.BaseTexture;
  87558. private _diffuseTextureX;
  87559. diffuseTextureX: BABYLON.BaseTexture;
  87560. private _diffuseTextureY;
  87561. diffuseTextureY: BABYLON.BaseTexture;
  87562. private _diffuseTextureZ;
  87563. diffuseTextureZ: BABYLON.BaseTexture;
  87564. private _normalTextureX;
  87565. normalTextureX: BABYLON.BaseTexture;
  87566. private _normalTextureY;
  87567. normalTextureY: BABYLON.BaseTexture;
  87568. private _normalTextureZ;
  87569. normalTextureZ: BABYLON.BaseTexture;
  87570. tileSize: number;
  87571. diffuseColor: BABYLON.Color3;
  87572. specularColor: BABYLON.Color3;
  87573. specularPower: number;
  87574. private _disableLighting;
  87575. disableLighting: boolean;
  87576. private _maxSimultaneousLights;
  87577. maxSimultaneousLights: number;
  87578. constructor(name: string, scene: BABYLON.Scene);
  87579. needAlphaBlending(): boolean;
  87580. needAlphaTesting(): boolean;
  87581. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87582. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87583. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87584. getAnimatables(): BABYLON.IAnimatable[];
  87585. getActiveTextures(): BABYLON.BaseTexture[];
  87586. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87587. dispose(forceDisposeEffect?: boolean): void;
  87588. clone(name: string): TriPlanarMaterial;
  87589. serialize(): any;
  87590. getClassName(): string;
  87591. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87592. }
  87593. }
  87594. declare module BABYLON {
  87595. /** @hidden */
  87596. export var waterPixelShader: {
  87597. name: string;
  87598. shader: string;
  87599. };
  87600. }
  87601. declare module BABYLON {
  87602. /** @hidden */
  87603. export var waterVertexShader: {
  87604. name: string;
  87605. shader: string;
  87606. };
  87607. }
  87608. declare module BABYLON {
  87609. export class WaterMaterial extends BABYLON.PushMaterial {
  87610. renderTargetSize: BABYLON.Vector2;
  87611. private _bumpTexture;
  87612. bumpTexture: BABYLON.BaseTexture;
  87613. diffuseColor: BABYLON.Color3;
  87614. specularColor: BABYLON.Color3;
  87615. specularPower: number;
  87616. private _disableLighting;
  87617. disableLighting: boolean;
  87618. private _maxSimultaneousLights;
  87619. maxSimultaneousLights: number;
  87620. /**
  87621. * Defines the wind force.
  87622. */
  87623. windForce: number;
  87624. /**
  87625. * Defines the direction of the wind in the plane (X, Z).
  87626. */
  87627. windDirection: BABYLON.Vector2;
  87628. /**
  87629. * Defines the height of the waves.
  87630. */
  87631. waveHeight: number;
  87632. /**
  87633. * Defines the bump height related to the bump map.
  87634. */
  87635. bumpHeight: number;
  87636. /**
  87637. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87638. */
  87639. private _bumpSuperimpose;
  87640. bumpSuperimpose: boolean;
  87641. /**
  87642. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87643. */
  87644. private _fresnelSeparate;
  87645. fresnelSeparate: boolean;
  87646. /**
  87647. * Defines wether or not bump Wwves modify the reflection.
  87648. */
  87649. private _bumpAffectsReflection;
  87650. bumpAffectsReflection: boolean;
  87651. /**
  87652. * Defines the water color blended with the refraction (near).
  87653. */
  87654. waterColor: BABYLON.Color3;
  87655. /**
  87656. * Defines the blend factor related to the water color.
  87657. */
  87658. colorBlendFactor: number;
  87659. /**
  87660. * Defines the water color blended with the reflection (far).
  87661. */
  87662. waterColor2: BABYLON.Color3;
  87663. /**
  87664. * Defines the blend factor related to the water color (reflection, far).
  87665. */
  87666. colorBlendFactor2: number;
  87667. /**
  87668. * Defines the maximum length of a wave.
  87669. */
  87670. waveLength: number;
  87671. /**
  87672. * Defines the waves speed.
  87673. */
  87674. waveSpeed: number;
  87675. /**
  87676. * 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.
  87677. */
  87678. waveCount: number;
  87679. /**
  87680. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87681. * will avoid calculating useless pixels in the pixel shader of the water material.
  87682. */
  87683. disableClipPlane: boolean;
  87684. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87685. private _mesh;
  87686. private _refractionRTT;
  87687. private _reflectionRTT;
  87688. private _reflectionTransform;
  87689. private _lastTime;
  87690. private _lastDeltaTime;
  87691. private _useLogarithmicDepth;
  87692. private _waitingRenderList;
  87693. private _imageProcessingConfiguration;
  87694. private _imageProcessingObserver;
  87695. /**
  87696. * Gets a boolean indicating that current material needs to register RTT
  87697. */
  87698. get hasRenderTargetTextures(): boolean;
  87699. /**
  87700. * Constructor
  87701. */
  87702. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87703. get useLogarithmicDepth(): boolean;
  87704. set useLogarithmicDepth(value: boolean);
  87705. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87706. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87707. addToRenderList(node: any): void;
  87708. enableRenderTargets(enable: boolean): void;
  87709. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87710. get renderTargetsEnabled(): boolean;
  87711. needAlphaBlending(): boolean;
  87712. needAlphaTesting(): boolean;
  87713. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87714. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87715. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87716. private _createRenderTargets;
  87717. getAnimatables(): BABYLON.IAnimatable[];
  87718. getActiveTextures(): BABYLON.BaseTexture[];
  87719. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87720. dispose(forceDisposeEffect?: boolean): void;
  87721. clone(name: string): WaterMaterial;
  87722. serialize(): any;
  87723. getClassName(): string;
  87724. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87725. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87726. }
  87727. }
  87728. declare module BABYLON {
  87729. /** @hidden */
  87730. export var asciiartPixelShader: {
  87731. name: string;
  87732. shader: string;
  87733. };
  87734. }
  87735. declare module BABYLON {
  87736. /**
  87737. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87738. *
  87739. * It basically takes care rendering the font front the given font size to a texture.
  87740. * This is used later on in the postprocess.
  87741. */
  87742. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87743. private _font;
  87744. private _text;
  87745. private _charSize;
  87746. /**
  87747. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87748. */
  87749. get charSize(): number;
  87750. /**
  87751. * Create a new instance of the Ascii Art FontTexture class
  87752. * @param name the name of the texture
  87753. * @param font the font to use, use the W3C CSS notation
  87754. * @param text the caracter set to use in the rendering.
  87755. * @param scene the scene that owns the texture
  87756. */
  87757. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87758. /**
  87759. * Gets the max char width of a font.
  87760. * @param font the font to use, use the W3C CSS notation
  87761. * @return the max char width
  87762. */
  87763. private getFontWidth;
  87764. /**
  87765. * Gets the max char height of a font.
  87766. * @param font the font to use, use the W3C CSS notation
  87767. * @return the max char height
  87768. */
  87769. private getFontHeight;
  87770. /**
  87771. * Clones the current AsciiArtTexture.
  87772. * @return the clone of the texture.
  87773. */
  87774. clone(): AsciiArtFontTexture;
  87775. /**
  87776. * Parses a json object representing the texture and returns an instance of it.
  87777. * @param source the source JSON representation
  87778. * @param scene the scene to create the texture for
  87779. * @return the parsed texture
  87780. */
  87781. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87782. }
  87783. /**
  87784. * Option available in the Ascii Art Post Process.
  87785. */
  87786. export interface IAsciiArtPostProcessOptions {
  87787. /**
  87788. * The font to use following the w3c font definition.
  87789. */
  87790. font?: string;
  87791. /**
  87792. * The character set to use in the postprocess.
  87793. */
  87794. characterSet?: string;
  87795. /**
  87796. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87797. * This number is defined between 0 and 1;
  87798. */
  87799. mixToTile?: number;
  87800. /**
  87801. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87802. * This number is defined between 0 and 1;
  87803. */
  87804. mixToNormal?: number;
  87805. }
  87806. /**
  87807. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87808. *
  87809. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87810. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87811. */
  87812. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87813. /**
  87814. * The font texture used to render the char in the post process.
  87815. */
  87816. private _asciiArtFontTexture;
  87817. /**
  87818. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87819. * This number is defined between 0 and 1;
  87820. */
  87821. mixToTile: number;
  87822. /**
  87823. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87824. * This number is defined between 0 and 1;
  87825. */
  87826. mixToNormal: number;
  87827. /**
  87828. * Instantiates a new Ascii Art Post Process.
  87829. * @param name the name to give to the postprocess
  87830. * @camera the camera to apply the post process to.
  87831. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87832. */
  87833. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87834. }
  87835. }
  87836. declare module BABYLON {
  87837. /** @hidden */
  87838. export var digitalrainPixelShader: {
  87839. name: string;
  87840. shader: string;
  87841. };
  87842. }
  87843. declare module BABYLON {
  87844. /**
  87845. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87846. *
  87847. * It basically takes care rendering the font front the given font size to a texture.
  87848. * This is used later on in the postprocess.
  87849. */
  87850. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87851. private _font;
  87852. private _text;
  87853. private _charSize;
  87854. /**
  87855. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87856. */
  87857. get charSize(): number;
  87858. /**
  87859. * Create a new instance of the Digital Rain FontTexture class
  87860. * @param name the name of the texture
  87861. * @param font the font to use, use the W3C CSS notation
  87862. * @param text the caracter set to use in the rendering.
  87863. * @param scene the scene that owns the texture
  87864. */
  87865. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87866. /**
  87867. * Gets the max char width of a font.
  87868. * @param font the font to use, use the W3C CSS notation
  87869. * @return the max char width
  87870. */
  87871. private getFontWidth;
  87872. /**
  87873. * Gets the max char height of a font.
  87874. * @param font the font to use, use the W3C CSS notation
  87875. * @return the max char height
  87876. */
  87877. private getFontHeight;
  87878. /**
  87879. * Clones the current DigitalRainFontTexture.
  87880. * @return the clone of the texture.
  87881. */
  87882. clone(): DigitalRainFontTexture;
  87883. /**
  87884. * Parses a json object representing the texture and returns an instance of it.
  87885. * @param source the source JSON representation
  87886. * @param scene the scene to create the texture for
  87887. * @return the parsed texture
  87888. */
  87889. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87890. }
  87891. /**
  87892. * Option available in the Digital Rain Post Process.
  87893. */
  87894. export interface IDigitalRainPostProcessOptions {
  87895. /**
  87896. * The font to use following the w3c font definition.
  87897. */
  87898. font?: string;
  87899. /**
  87900. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87901. * This number is defined between 0 and 1;
  87902. */
  87903. mixToTile?: number;
  87904. /**
  87905. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87906. * This number is defined between 0 and 1;
  87907. */
  87908. mixToNormal?: number;
  87909. }
  87910. /**
  87911. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87912. *
  87913. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87914. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87915. */
  87916. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87917. /**
  87918. * The font texture used to render the char in the post process.
  87919. */
  87920. private _digitalRainFontTexture;
  87921. /**
  87922. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87923. * This number is defined between 0 and 1;
  87924. */
  87925. mixToTile: number;
  87926. /**
  87927. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87928. * This number is defined between 0 and 1;
  87929. */
  87930. mixToNormal: number;
  87931. /**
  87932. * Instantiates a new Digital Rain Post Process.
  87933. * @param name the name to give to the postprocess
  87934. * @camera the camera to apply the post process to.
  87935. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87936. */
  87937. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87938. }
  87939. }
  87940. declare module BABYLON {
  87941. /** @hidden */
  87942. export var brickProceduralTexturePixelShader: {
  87943. name: string;
  87944. shader: string;
  87945. };
  87946. }
  87947. declare module BABYLON {
  87948. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87949. private _numberOfBricksHeight;
  87950. private _numberOfBricksWidth;
  87951. private _jointColor;
  87952. private _brickColor;
  87953. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87954. updateShaderUniforms(): void;
  87955. get numberOfBricksHeight(): number;
  87956. set numberOfBricksHeight(value: number);
  87957. get numberOfBricksWidth(): number;
  87958. set numberOfBricksWidth(value: number);
  87959. get jointColor(): BABYLON.Color3;
  87960. set jointColor(value: BABYLON.Color3);
  87961. get brickColor(): BABYLON.Color3;
  87962. set brickColor(value: BABYLON.Color3);
  87963. /**
  87964. * Serializes this brick procedural texture
  87965. * @returns a serialized brick procedural texture object
  87966. */
  87967. serialize(): any;
  87968. /**
  87969. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87970. * @param parsedTexture defines parsed texture data
  87971. * @param scene defines the current scene
  87972. * @param rootUrl defines the root URL containing brick procedural texture information
  87973. * @returns a parsed Brick Procedural BABYLON.Texture
  87974. */
  87975. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87976. }
  87977. }
  87978. declare module BABYLON {
  87979. /** @hidden */
  87980. export var cloudProceduralTexturePixelShader: {
  87981. name: string;
  87982. shader: string;
  87983. };
  87984. }
  87985. declare module BABYLON {
  87986. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87987. private _skyColor;
  87988. private _cloudColor;
  87989. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87990. updateShaderUniforms(): void;
  87991. get skyColor(): BABYLON.Color4;
  87992. set skyColor(value: BABYLON.Color4);
  87993. get cloudColor(): BABYLON.Color4;
  87994. set cloudColor(value: BABYLON.Color4);
  87995. /**
  87996. * Serializes this cloud procedural texture
  87997. * @returns a serialized cloud procedural texture object
  87998. */
  87999. serialize(): any;
  88000. /**
  88001. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88002. * @param parsedTexture defines parsed texture data
  88003. * @param scene defines the current scene
  88004. * @param rootUrl defines the root URL containing cloud procedural texture information
  88005. * @returns a parsed Cloud Procedural BABYLON.Texture
  88006. */
  88007. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88008. }
  88009. }
  88010. declare module BABYLON {
  88011. /** @hidden */
  88012. export var fireProceduralTexturePixelShader: {
  88013. name: string;
  88014. shader: string;
  88015. };
  88016. }
  88017. declare module BABYLON {
  88018. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88019. private _time;
  88020. private _speed;
  88021. private _autoGenerateTime;
  88022. private _fireColors;
  88023. private _alphaThreshold;
  88024. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88025. updateShaderUniforms(): void;
  88026. render(useCameraPostProcess?: boolean): void;
  88027. static get PurpleFireColors(): BABYLON.Color3[];
  88028. static get GreenFireColors(): BABYLON.Color3[];
  88029. static get RedFireColors(): BABYLON.Color3[];
  88030. static get BlueFireColors(): BABYLON.Color3[];
  88031. get autoGenerateTime(): boolean;
  88032. set autoGenerateTime(value: boolean);
  88033. get fireColors(): BABYLON.Color3[];
  88034. set fireColors(value: BABYLON.Color3[]);
  88035. get time(): number;
  88036. set time(value: number);
  88037. get speed(): BABYLON.Vector2;
  88038. set speed(value: BABYLON.Vector2);
  88039. get alphaThreshold(): number;
  88040. set alphaThreshold(value: number);
  88041. /**
  88042. * Serializes this fire procedural texture
  88043. * @returns a serialized fire procedural texture object
  88044. */
  88045. serialize(): any;
  88046. /**
  88047. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88048. * @param parsedTexture defines parsed texture data
  88049. * @param scene defines the current scene
  88050. * @param rootUrl defines the root URL containing fire procedural texture information
  88051. * @returns a parsed Fire Procedural BABYLON.Texture
  88052. */
  88053. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88054. }
  88055. }
  88056. declare module BABYLON {
  88057. /** @hidden */
  88058. export var grassProceduralTexturePixelShader: {
  88059. name: string;
  88060. shader: string;
  88061. };
  88062. }
  88063. declare module BABYLON {
  88064. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88065. private _grassColors;
  88066. private _groundColor;
  88067. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88068. updateShaderUniforms(): void;
  88069. get grassColors(): BABYLON.Color3[];
  88070. set grassColors(value: BABYLON.Color3[]);
  88071. get groundColor(): BABYLON.Color3;
  88072. set groundColor(value: BABYLON.Color3);
  88073. /**
  88074. * Serializes this grass procedural texture
  88075. * @returns a serialized grass procedural texture object
  88076. */
  88077. serialize(): any;
  88078. /**
  88079. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88080. * @param parsedTexture defines parsed texture data
  88081. * @param scene defines the current scene
  88082. * @param rootUrl defines the root URL containing grass procedural texture information
  88083. * @returns a parsed Grass Procedural BABYLON.Texture
  88084. */
  88085. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88086. }
  88087. }
  88088. declare module BABYLON {
  88089. /** @hidden */
  88090. export var marbleProceduralTexturePixelShader: {
  88091. name: string;
  88092. shader: string;
  88093. };
  88094. }
  88095. declare module BABYLON {
  88096. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88097. private _numberOfTilesHeight;
  88098. private _numberOfTilesWidth;
  88099. private _amplitude;
  88100. private _jointColor;
  88101. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88102. updateShaderUniforms(): void;
  88103. get numberOfTilesHeight(): number;
  88104. set numberOfTilesHeight(value: number);
  88105. get amplitude(): number;
  88106. set amplitude(value: number);
  88107. get numberOfTilesWidth(): number;
  88108. set numberOfTilesWidth(value: number);
  88109. get jointColor(): BABYLON.Color3;
  88110. set jointColor(value: BABYLON.Color3);
  88111. /**
  88112. * Serializes this marble procedural texture
  88113. * @returns a serialized marble procedural texture object
  88114. */
  88115. serialize(): any;
  88116. /**
  88117. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88118. * @param parsedTexture defines parsed texture data
  88119. * @param scene defines the current scene
  88120. * @param rootUrl defines the root URL containing marble procedural texture information
  88121. * @returns a parsed Marble Procedural BABYLON.Texture
  88122. */
  88123. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88124. }
  88125. }
  88126. declare module BABYLON {
  88127. /** @hidden */
  88128. export var normalMapProceduralTexturePixelShader: {
  88129. name: string;
  88130. shader: string;
  88131. };
  88132. }
  88133. declare module BABYLON {
  88134. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88135. private _baseTexture;
  88136. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88137. updateShaderUniforms(): void;
  88138. render(useCameraPostProcess?: boolean): void;
  88139. resize(size: any, generateMipMaps: any): void;
  88140. get baseTexture(): BABYLON.Texture;
  88141. set baseTexture(texture: BABYLON.Texture);
  88142. /**
  88143. * Serializes this normal map procedural texture
  88144. * @returns a serialized normal map procedural texture object
  88145. */
  88146. serialize(): any;
  88147. /**
  88148. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88149. * @param parsedTexture defines parsed texture data
  88150. * @param scene defines the current scene
  88151. * @param rootUrl defines the root URL containing normal map procedural texture information
  88152. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88153. */
  88154. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88155. }
  88156. }
  88157. declare module BABYLON {
  88158. /** @hidden */
  88159. export var perlinNoiseProceduralTexturePixelShader: {
  88160. name: string;
  88161. shader: string;
  88162. };
  88163. }
  88164. declare module BABYLON {
  88165. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88166. time: number;
  88167. timeScale: number;
  88168. translationSpeed: number;
  88169. private _currentTranslation;
  88170. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88171. updateShaderUniforms(): void;
  88172. render(useCameraPostProcess?: boolean): void;
  88173. resize(size: any, generateMipMaps: any): void;
  88174. /**
  88175. * Serializes this perlin noise procedural texture
  88176. * @returns a serialized perlin noise procedural texture object
  88177. */
  88178. serialize(): any;
  88179. /**
  88180. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88181. * @param parsedTexture defines parsed texture data
  88182. * @param scene defines the current scene
  88183. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88184. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88185. */
  88186. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88187. }
  88188. }
  88189. declare module BABYLON {
  88190. /** @hidden */
  88191. export var roadProceduralTexturePixelShader: {
  88192. name: string;
  88193. shader: string;
  88194. };
  88195. }
  88196. declare module BABYLON {
  88197. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88198. private _roadColor;
  88199. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88200. updateShaderUniforms(): void;
  88201. get roadColor(): BABYLON.Color3;
  88202. set roadColor(value: BABYLON.Color3);
  88203. /**
  88204. * Serializes this road procedural texture
  88205. * @returns a serialized road procedural texture object
  88206. */
  88207. serialize(): any;
  88208. /**
  88209. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88210. * @param parsedTexture defines parsed texture data
  88211. * @param scene defines the current scene
  88212. * @param rootUrl defines the root URL containing road procedural texture information
  88213. * @returns a parsed Road Procedural BABYLON.Texture
  88214. */
  88215. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88216. }
  88217. }
  88218. declare module BABYLON {
  88219. /** @hidden */
  88220. export var starfieldProceduralTexturePixelShader: {
  88221. name: string;
  88222. shader: string;
  88223. };
  88224. }
  88225. declare module BABYLON {
  88226. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88227. private _time;
  88228. private _alpha;
  88229. private _beta;
  88230. private _zoom;
  88231. private _formuparam;
  88232. private _stepsize;
  88233. private _tile;
  88234. private _brightness;
  88235. private _darkmatter;
  88236. private _distfading;
  88237. private _saturation;
  88238. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88239. updateShaderUniforms(): void;
  88240. get time(): number;
  88241. set time(value: number);
  88242. get alpha(): number;
  88243. set alpha(value: number);
  88244. get beta(): number;
  88245. set beta(value: number);
  88246. get formuparam(): number;
  88247. set formuparam(value: number);
  88248. get stepsize(): number;
  88249. set stepsize(value: number);
  88250. get zoom(): number;
  88251. set zoom(value: number);
  88252. get tile(): number;
  88253. set tile(value: number);
  88254. get brightness(): number;
  88255. set brightness(value: number);
  88256. get darkmatter(): number;
  88257. set darkmatter(value: number);
  88258. get distfading(): number;
  88259. set distfading(value: number);
  88260. get saturation(): number;
  88261. set saturation(value: number);
  88262. /**
  88263. * Serializes this starfield procedural texture
  88264. * @returns a serialized starfield procedural texture object
  88265. */
  88266. serialize(): any;
  88267. /**
  88268. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88269. * @param parsedTexture defines parsed texture data
  88270. * @param scene defines the current scene
  88271. * @param rootUrl defines the root URL containing startfield procedural texture information
  88272. * @returns a parsed Starfield Procedural BABYLON.Texture
  88273. */
  88274. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88275. }
  88276. }
  88277. declare module BABYLON {
  88278. /** @hidden */
  88279. export var woodProceduralTexturePixelShader: {
  88280. name: string;
  88281. shader: string;
  88282. };
  88283. }
  88284. declare module BABYLON {
  88285. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88286. private _ampScale;
  88287. private _woodColor;
  88288. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88289. updateShaderUniforms(): void;
  88290. get ampScale(): number;
  88291. set ampScale(value: number);
  88292. get woodColor(): BABYLON.Color3;
  88293. set woodColor(value: BABYLON.Color3);
  88294. /**
  88295. * Serializes this wood procedural texture
  88296. * @returns a serialized wood procedural texture object
  88297. */
  88298. serialize(): any;
  88299. /**
  88300. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88301. * @param parsedTexture defines parsed texture data
  88302. * @param scene defines the current scene
  88303. * @param rootUrl defines the root URL containing wood procedural texture information
  88304. * @returns a parsed Wood Procedural BABYLON.Texture
  88305. */
  88306. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88307. }
  88308. }