documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4619. /**
  4620. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4621. * This function works in left handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4630. * This function works in left handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5160. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6411. */
  6412. attachControl(noPreventDefault?: boolean): void;
  6413. /**
  6414. * Detach the current controls from the specified dom element.
  6415. */
  6416. detachControl(): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedToElement: boolean;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Class used to host copy specific utilities
  7783. */
  7784. export class CopyTools {
  7785. /**
  7786. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  7787. * @param texture defines the texture to read pixels from
  7788. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7789. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7790. * @returns The base64 encoded string or null
  7791. */
  7792. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. /**
  7797. * Define options used to create a depth texture
  7798. */
  7799. export class DepthTextureCreationOptions {
  7800. /** Specifies whether or not a stencil should be allocated in the texture */
  7801. generateStencil?: boolean;
  7802. /** Specifies whether or not bilinear filtering is enable on the texture */
  7803. bilinearFiltering?: boolean;
  7804. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7805. comparisonFunction?: number;
  7806. /** Specifies if the created texture is a cube texture */
  7807. isCube?: boolean;
  7808. }
  7809. }
  7810. declare module BABYLON {
  7811. interface ThinEngine {
  7812. /**
  7813. * Creates a depth stencil cube texture.
  7814. * This is only available in WebGL 2.
  7815. * @param size The size of face edge in the cube texture.
  7816. * @param options The options defining the cube texture.
  7817. * @returns The cube texture
  7818. */
  7819. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7820. /**
  7821. * Creates a cube texture
  7822. * @param rootUrl defines the url where the files to load is located
  7823. * @param scene defines the current scene
  7824. * @param files defines the list of files to load (1 per face)
  7825. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7826. * @param onLoad defines an optional callback raised when the texture is loaded
  7827. * @param onError defines an optional callback raised if there is an issue to load the texture
  7828. * @param format defines the format of the data
  7829. * @param forcedExtension defines the extension to use to pick the right loader
  7830. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7833. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7834. * @param loaderOptions options to be passed to the loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7838. /**
  7839. * Creates a cube texture
  7840. * @param rootUrl defines the url where the files to load is located
  7841. * @param scene defines the current scene
  7842. * @param files defines the list of files to load (1 per face)
  7843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7844. * @param onLoad defines an optional callback raised when the texture is loaded
  7845. * @param onError defines an optional callback raised if there is an issue to load the texture
  7846. * @param format defines the format of the data
  7847. * @param forcedExtension defines the extension to use to pick the right loader
  7848. * @returns the cube texture as an InternalTexture
  7849. */
  7850. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7851. /**
  7852. * Creates a cube texture
  7853. * @param rootUrl defines the url where the files to load is located
  7854. * @param scene defines the current scene
  7855. * @param files defines the list of files to load (1 per face)
  7856. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7857. * @param onLoad defines an optional callback raised when the texture is loaded
  7858. * @param onError defines an optional callback raised if there is an issue to load the texture
  7859. * @param format defines the format of the data
  7860. * @param forcedExtension defines the extension to use to pick the right loader
  7861. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7862. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7863. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7864. * @returns the cube texture as an InternalTexture
  7865. */
  7866. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7867. /** @hidden */
  7868. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7869. /** @hidden */
  7870. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7871. /** @hidden */
  7872. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7873. /** @hidden */
  7874. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7875. /**
  7876. * @hidden
  7877. */
  7878. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Class for creating a cube texture
  7884. */
  7885. export class CubeTexture extends BaseTexture {
  7886. private _delayedOnLoad;
  7887. /**
  7888. * Observable triggered once the texture has been loaded.
  7889. */
  7890. onLoadObservable: Observable<CubeTexture>;
  7891. /**
  7892. * The url of the texture
  7893. */
  7894. url: string;
  7895. /**
  7896. * Gets or sets the center of the bounding box associated with the cube texture.
  7897. * It must define where the camera used to render the texture was set
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. boundingBoxPosition: Vector3;
  7901. private _boundingBoxSize;
  7902. /**
  7903. * Gets or sets the size of the bounding box associated with the cube texture
  7904. * When defined, the cubemap will switch to local mode
  7905. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7906. * @example https://www.babylonjs-playground.com/#RNASML
  7907. */
  7908. set boundingBoxSize(value: Vector3);
  7909. /**
  7910. * Returns the bounding box size
  7911. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7912. */
  7913. get boundingBoxSize(): Vector3;
  7914. protected _rotationY: number;
  7915. /**
  7916. * Sets texture matrix rotation angle around Y axis in radians.
  7917. */
  7918. set rotationY(value: number);
  7919. /**
  7920. * Gets texture matrix rotation angle around Y axis radians.
  7921. */
  7922. get rotationY(): number;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. private _noMipmap;
  7928. private _files;
  7929. protected _forcedExtension: Nullable<string>;
  7930. private _extensions;
  7931. private _textureMatrix;
  7932. private _format;
  7933. private _createPolynomials;
  7934. private _loaderOptions;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @param loaderOptions options to be passed to the loader
  7969. * @return the cube texture
  7970. */
  7971. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7972. /**
  7973. * Get the current class name of the texture useful for serialization or dynamic coding.
  7974. * @returns "CubeTexture"
  7975. */
  7976. getClassName(): string;
  7977. /**
  7978. * Update the url (and optional buffer) of this texture if url was null during construction.
  7979. * @param url the url of the texture
  7980. * @param forcedExtension defines the extension to use
  7981. * @param onLoad callback called when the texture is loaded (defaults to null)
  7982. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7983. */
  7984. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7985. /**
  7986. * Delays loading of the cube texture
  7987. * @param forcedExtension defines the extension to use
  7988. */
  7989. delayLoad(forcedExtension?: string): void;
  7990. /**
  7991. * Returns the reflection texture matrix
  7992. * @returns the reflection texture matrix
  7993. */
  7994. getReflectionTextureMatrix(): Matrix;
  7995. /**
  7996. * Sets the reflection texture matrix
  7997. * @param value Reflection texture matrix
  7998. */
  7999. setReflectionTextureMatrix(value: Matrix): void;
  8000. /**
  8001. * Parses text to create a cube texture
  8002. * @param parsedTexture define the serialized text to read from
  8003. * @param scene defines the hosting scene
  8004. * @param rootUrl defines the root url of the cube texture
  8005. * @returns a cube texture
  8006. */
  8007. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8008. /**
  8009. * Makes a clone, or deep copy, of the cube texture
  8010. * @returns a new cube texture
  8011. */
  8012. clone(): CubeTexture;
  8013. }
  8014. }
  8015. declare module BABYLON {
  8016. /**
  8017. * Manages the defines for the Material
  8018. */
  8019. export class MaterialDefines {
  8020. /** @hidden */
  8021. protected _keys: string[];
  8022. private _isDirty;
  8023. /** @hidden */
  8024. _renderId: number;
  8025. /** @hidden */
  8026. _areLightsDirty: boolean;
  8027. /** @hidden */
  8028. _areLightsDisposed: boolean;
  8029. /** @hidden */
  8030. _areAttributesDirty: boolean;
  8031. /** @hidden */
  8032. _areTexturesDirty: boolean;
  8033. /** @hidden */
  8034. _areFresnelDirty: boolean;
  8035. /** @hidden */
  8036. _areMiscDirty: boolean;
  8037. /** @hidden */
  8038. _arePrePassDirty: boolean;
  8039. /** @hidden */
  8040. _areImageProcessingDirty: boolean;
  8041. /** @hidden */
  8042. _normals: boolean;
  8043. /** @hidden */
  8044. _uvs: boolean;
  8045. /** @hidden */
  8046. _needNormals: boolean;
  8047. /** @hidden */
  8048. _needUVs: boolean;
  8049. [id: string]: any;
  8050. /**
  8051. * Specifies if the material needs to be re-calculated
  8052. */
  8053. get isDirty(): boolean;
  8054. /**
  8055. * Marks the material to indicate that it has been re-calculated
  8056. */
  8057. markAsProcessed(): void;
  8058. /**
  8059. * Marks the material to indicate that it needs to be re-calculated
  8060. */
  8061. markAsUnprocessed(): void;
  8062. /**
  8063. * Marks the material to indicate all of its defines need to be re-calculated
  8064. */
  8065. markAllAsDirty(): void;
  8066. /**
  8067. * Marks the material to indicate that image processing needs to be re-calculated
  8068. */
  8069. markAsImageProcessingDirty(): void;
  8070. /**
  8071. * Marks the material to indicate the lights need to be re-calculated
  8072. * @param disposed Defines whether the light is dirty due to dispose or not
  8073. */
  8074. markAsLightDirty(disposed?: boolean): void;
  8075. /**
  8076. * Marks the attribute state as changed
  8077. */
  8078. markAsAttributesDirty(): void;
  8079. /**
  8080. * Marks the texture state as changed
  8081. */
  8082. markAsTexturesDirty(): void;
  8083. /**
  8084. * Marks the fresnel state as changed
  8085. */
  8086. markAsFresnelDirty(): void;
  8087. /**
  8088. * Marks the misc state as changed
  8089. */
  8090. markAsMiscDirty(): void;
  8091. /**
  8092. * Marks the prepass state as changed
  8093. */
  8094. markAsPrePassDirty(): void;
  8095. /**
  8096. * Rebuilds the material defines
  8097. */
  8098. rebuild(): void;
  8099. /**
  8100. * Specifies if two material defines are equal
  8101. * @param other - A material define instance to compare to
  8102. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8103. */
  8104. isEqual(other: MaterialDefines): boolean;
  8105. /**
  8106. * Clones this instance's defines to another instance
  8107. * @param other - material defines to clone values to
  8108. */
  8109. cloneTo(other: MaterialDefines): void;
  8110. /**
  8111. * Resets the material define values
  8112. */
  8113. reset(): void;
  8114. /**
  8115. * Converts the material define values to a string
  8116. * @returns - String of material define information
  8117. */
  8118. toString(): string;
  8119. }
  8120. }
  8121. declare module BABYLON {
  8122. /**
  8123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8125. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8127. */
  8128. export class ColorCurves {
  8129. private _dirty;
  8130. private _tempColor;
  8131. private _globalCurve;
  8132. private _highlightsCurve;
  8133. private _midtonesCurve;
  8134. private _shadowsCurve;
  8135. private _positiveCurve;
  8136. private _negativeCurve;
  8137. private _globalHue;
  8138. private _globalDensity;
  8139. private _globalSaturation;
  8140. private _globalExposure;
  8141. /**
  8142. * Gets the global Hue value.
  8143. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8144. */
  8145. get globalHue(): number;
  8146. /**
  8147. * Sets the global Hue value.
  8148. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8149. */
  8150. set globalHue(value: number);
  8151. /**
  8152. * Gets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get globalDensity(): number;
  8157. /**
  8158. * Sets the global Density value.
  8159. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set globalDensity(value: number);
  8163. /**
  8164. * Gets the global Saturation value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8166. */
  8167. get globalSaturation(): number;
  8168. /**
  8169. * Sets the global Saturation value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8171. */
  8172. set globalSaturation(value: number);
  8173. /**
  8174. * Gets the global Exposure value.
  8175. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8176. */
  8177. get globalExposure(): number;
  8178. /**
  8179. * Sets the global Exposure value.
  8180. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8181. */
  8182. set globalExposure(value: number);
  8183. private _highlightsHue;
  8184. private _highlightsDensity;
  8185. private _highlightsSaturation;
  8186. private _highlightsExposure;
  8187. /**
  8188. * Gets the highlights Hue value.
  8189. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8190. */
  8191. get highlightsHue(): number;
  8192. /**
  8193. * Sets the highlights Hue value.
  8194. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8195. */
  8196. set highlightsHue(value: number);
  8197. /**
  8198. * Gets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get highlightsDensity(): number;
  8203. /**
  8204. * Sets the highlights Density value.
  8205. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set highlightsDensity(value: number);
  8209. /**
  8210. * Gets the highlights Saturation value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8212. */
  8213. get highlightsSaturation(): number;
  8214. /**
  8215. * Sets the highlights Saturation value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8217. */
  8218. set highlightsSaturation(value: number);
  8219. /**
  8220. * Gets the highlights Exposure value.
  8221. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8222. */
  8223. get highlightsExposure(): number;
  8224. /**
  8225. * Sets the highlights Exposure value.
  8226. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8227. */
  8228. set highlightsExposure(value: number);
  8229. private _midtonesHue;
  8230. private _midtonesDensity;
  8231. private _midtonesSaturation;
  8232. private _midtonesExposure;
  8233. /**
  8234. * Gets the midtones Hue value.
  8235. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8236. */
  8237. get midtonesHue(): number;
  8238. /**
  8239. * Sets the midtones Hue value.
  8240. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8241. */
  8242. set midtonesHue(value: number);
  8243. /**
  8244. * Gets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. get midtonesDensity(): number;
  8249. /**
  8250. * Sets the midtones Density value.
  8251. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8252. * Values less than zero provide a filter of opposite hue.
  8253. */
  8254. set midtonesDensity(value: number);
  8255. /**
  8256. * Gets the midtones Saturation value.
  8257. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8258. */
  8259. get midtonesSaturation(): number;
  8260. /**
  8261. * Sets the midtones Saturation value.
  8262. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8263. */
  8264. set midtonesSaturation(value: number);
  8265. /**
  8266. * Gets the midtones Exposure value.
  8267. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8268. */
  8269. get midtonesExposure(): number;
  8270. /**
  8271. * Sets the midtones Exposure value.
  8272. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8273. */
  8274. set midtonesExposure(value: number);
  8275. private _shadowsHue;
  8276. private _shadowsDensity;
  8277. private _shadowsSaturation;
  8278. private _shadowsExposure;
  8279. /**
  8280. * Gets the shadows Hue value.
  8281. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8282. */
  8283. get shadowsHue(): number;
  8284. /**
  8285. * Sets the shadows Hue value.
  8286. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8287. */
  8288. set shadowsHue(value: number);
  8289. /**
  8290. * Gets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. get shadowsDensity(): number;
  8295. /**
  8296. * Sets the shadows Density value.
  8297. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8298. * Values less than zero provide a filter of opposite hue.
  8299. */
  8300. set shadowsDensity(value: number);
  8301. /**
  8302. * Gets the shadows Saturation value.
  8303. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8304. */
  8305. get shadowsSaturation(): number;
  8306. /**
  8307. * Sets the shadows Saturation value.
  8308. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8309. */
  8310. set shadowsSaturation(value: number);
  8311. /**
  8312. * Gets the shadows Exposure value.
  8313. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8314. */
  8315. get shadowsExposure(): number;
  8316. /**
  8317. * Sets the shadows Exposure value.
  8318. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8319. */
  8320. set shadowsExposure(value: number);
  8321. /**
  8322. * Returns the class name
  8323. * @returns The class name
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Binds the color curves to the shader.
  8328. * @param colorCurves The color curve to bind
  8329. * @param effect The effect to bind to
  8330. * @param positiveUniform The positive uniform shader parameter
  8331. * @param neutralUniform The neutral uniform shader parameter
  8332. * @param negativeUniform The negative uniform shader parameter
  8333. */
  8334. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8335. /**
  8336. * Prepare the list of uniforms associated with the ColorCurves effects.
  8337. * @param uniformsList The list of uniforms used in the effect
  8338. */
  8339. static PrepareUniforms(uniformsList: string[]): void;
  8340. /**
  8341. * Returns color grading data based on a hue, density, saturation and exposure value.
  8342. * @param filterHue The hue of the color filter.
  8343. * @param filterDensity The density of the color filter.
  8344. * @param saturation The saturation.
  8345. * @param exposure The exposure.
  8346. * @param result The result data container.
  8347. */
  8348. private getColorGradingDataToRef;
  8349. /**
  8350. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8351. * @param value The input slider value in range [-100,100].
  8352. * @returns Adjusted value.
  8353. */
  8354. private static applyColorGradingSliderNonlinear;
  8355. /**
  8356. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8357. * @param hue The hue (H) input.
  8358. * @param saturation The saturation (S) input.
  8359. * @param brightness The brightness (B) input.
  8360. * @result An RGBA color represented as Vector4.
  8361. */
  8362. private static fromHSBToRef;
  8363. /**
  8364. * Returns a value clamped between min and max
  8365. * @param value The value to clamp
  8366. * @param min The minimum of value
  8367. * @param max The maximum of value
  8368. * @returns The clamped value.
  8369. */
  8370. private static clamp;
  8371. /**
  8372. * Clones the current color curve instance.
  8373. * @return The cloned curves
  8374. */
  8375. clone(): ColorCurves;
  8376. /**
  8377. * Serializes the current color curve instance to a json representation.
  8378. * @return a JSON representation
  8379. */
  8380. serialize(): any;
  8381. /**
  8382. * Parses the color curve from a json representation.
  8383. * @param source the JSON source to parse
  8384. * @return The parsed curves
  8385. */
  8386. static Parse(source: any): ColorCurves;
  8387. }
  8388. }
  8389. declare module BABYLON {
  8390. /**
  8391. * Interface to follow in your material defines to integrate easily the
  8392. * Image proccessing functions.
  8393. * @hidden
  8394. */
  8395. export interface IImageProcessingConfigurationDefines {
  8396. IMAGEPROCESSING: boolean;
  8397. VIGNETTE: boolean;
  8398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8399. VIGNETTEBLENDMODEOPAQUE: boolean;
  8400. TONEMAPPING: boolean;
  8401. TONEMAPPING_ACES: boolean;
  8402. CONTRAST: boolean;
  8403. EXPOSURE: boolean;
  8404. COLORCURVES: boolean;
  8405. COLORGRADING: boolean;
  8406. COLORGRADING3D: boolean;
  8407. SAMPLER3DGREENDEPTH: boolean;
  8408. SAMPLER3DBGRMAP: boolean;
  8409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8410. }
  8411. /**
  8412. * @hidden
  8413. */
  8414. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8415. IMAGEPROCESSING: boolean;
  8416. VIGNETTE: boolean;
  8417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8418. VIGNETTEBLENDMODEOPAQUE: boolean;
  8419. TONEMAPPING: boolean;
  8420. TONEMAPPING_ACES: boolean;
  8421. CONTRAST: boolean;
  8422. COLORCURVES: boolean;
  8423. COLORGRADING: boolean;
  8424. COLORGRADING3D: boolean;
  8425. SAMPLER3DGREENDEPTH: boolean;
  8426. SAMPLER3DBGRMAP: boolean;
  8427. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8428. EXPOSURE: boolean;
  8429. constructor();
  8430. }
  8431. /**
  8432. * This groups together the common properties used for image processing either in direct forward pass
  8433. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8434. * or not.
  8435. */
  8436. export class ImageProcessingConfiguration {
  8437. /**
  8438. * Default tone mapping applied in BabylonJS.
  8439. */
  8440. static readonly TONEMAPPING_STANDARD: number;
  8441. /**
  8442. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8443. * to other engines rendering to increase portability.
  8444. */
  8445. static readonly TONEMAPPING_ACES: number;
  8446. /**
  8447. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8448. */
  8449. colorCurves: Nullable<ColorCurves>;
  8450. private _colorCurvesEnabled;
  8451. /**
  8452. * Gets wether the color curves effect is enabled.
  8453. */
  8454. get colorCurvesEnabled(): boolean;
  8455. /**
  8456. * Sets wether the color curves effect is enabled.
  8457. */
  8458. set colorCurvesEnabled(value: boolean);
  8459. private _colorGradingTexture;
  8460. /**
  8461. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8462. */
  8463. get colorGradingTexture(): Nullable<BaseTexture>;
  8464. /**
  8465. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8466. */
  8467. set colorGradingTexture(value: Nullable<BaseTexture>);
  8468. private _colorGradingEnabled;
  8469. /**
  8470. * Gets wether the color grading effect is enabled.
  8471. */
  8472. get colorGradingEnabled(): boolean;
  8473. /**
  8474. * Sets wether the color grading effect is enabled.
  8475. */
  8476. set colorGradingEnabled(value: boolean);
  8477. private _colorGradingWithGreenDepth;
  8478. /**
  8479. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8480. */
  8481. get colorGradingWithGreenDepth(): boolean;
  8482. /**
  8483. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8484. */
  8485. set colorGradingWithGreenDepth(value: boolean);
  8486. private _colorGradingBGR;
  8487. /**
  8488. * Gets wether the color grading texture contains BGR values.
  8489. */
  8490. get colorGradingBGR(): boolean;
  8491. /**
  8492. * Sets wether the color grading texture contains BGR values.
  8493. */
  8494. set colorGradingBGR(value: boolean);
  8495. /** @hidden */
  8496. _exposure: number;
  8497. /**
  8498. * Gets the Exposure used in the effect.
  8499. */
  8500. get exposure(): number;
  8501. /**
  8502. * Sets the Exposure used in the effect.
  8503. */
  8504. set exposure(value: number);
  8505. private _toneMappingEnabled;
  8506. /**
  8507. * Gets wether the tone mapping effect is enabled.
  8508. */
  8509. get toneMappingEnabled(): boolean;
  8510. /**
  8511. * Sets wether the tone mapping effect is enabled.
  8512. */
  8513. set toneMappingEnabled(value: boolean);
  8514. private _toneMappingType;
  8515. /**
  8516. * Gets the type of tone mapping effect.
  8517. */
  8518. get toneMappingType(): number;
  8519. /**
  8520. * Sets the type of tone mapping effect used in BabylonJS.
  8521. */
  8522. set toneMappingType(value: number);
  8523. protected _contrast: number;
  8524. /**
  8525. * Gets the contrast used in the effect.
  8526. */
  8527. get contrast(): number;
  8528. /**
  8529. * Sets the contrast used in the effect.
  8530. */
  8531. set contrast(value: number);
  8532. /**
  8533. * Vignette stretch size.
  8534. */
  8535. vignetteStretch: number;
  8536. /**
  8537. * Vignette centre X Offset.
  8538. */
  8539. vignetteCentreX: number;
  8540. /**
  8541. * Vignette centre Y Offset.
  8542. */
  8543. vignetteCentreY: number;
  8544. /**
  8545. * Vignette weight or intensity of the vignette effect.
  8546. */
  8547. vignetteWeight: number;
  8548. /**
  8549. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8550. * if vignetteEnabled is set to true.
  8551. */
  8552. vignetteColor: Color4;
  8553. /**
  8554. * Camera field of view used by the Vignette effect.
  8555. */
  8556. vignetteCameraFov: number;
  8557. private _vignetteBlendMode;
  8558. /**
  8559. * Gets the vignette blend mode allowing different kind of effect.
  8560. */
  8561. get vignetteBlendMode(): number;
  8562. /**
  8563. * Sets the vignette blend mode allowing different kind of effect.
  8564. */
  8565. set vignetteBlendMode(value: number);
  8566. private _vignetteEnabled;
  8567. /**
  8568. * Gets wether the vignette effect is enabled.
  8569. */
  8570. get vignetteEnabled(): boolean;
  8571. /**
  8572. * Sets wether the vignette effect is enabled.
  8573. */
  8574. set vignetteEnabled(value: boolean);
  8575. private _applyByPostProcess;
  8576. /**
  8577. * Gets wether the image processing is applied through a post process or not.
  8578. */
  8579. get applyByPostProcess(): boolean;
  8580. /**
  8581. * Sets wether the image processing is applied through a post process or not.
  8582. */
  8583. set applyByPostProcess(value: boolean);
  8584. private _isEnabled;
  8585. /**
  8586. * Gets wether the image processing is enabled or not.
  8587. */
  8588. get isEnabled(): boolean;
  8589. /**
  8590. * Sets wether the image processing is enabled or not.
  8591. */
  8592. set isEnabled(value: boolean);
  8593. /**
  8594. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8595. */
  8596. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8597. /**
  8598. * Method called each time the image processing information changes requires to recompile the effect.
  8599. */
  8600. protected _updateParameters(): void;
  8601. /**
  8602. * Gets the current class name.
  8603. * @return "ImageProcessingConfiguration"
  8604. */
  8605. getClassName(): string;
  8606. /**
  8607. * Prepare the list of uniforms associated with the Image Processing effects.
  8608. * @param uniforms The list of uniforms used in the effect
  8609. * @param defines the list of defines currently in use
  8610. */
  8611. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8612. /**
  8613. * Prepare the list of samplers associated with the Image Processing effects.
  8614. * @param samplersList The list of uniforms used in the effect
  8615. * @param defines the list of defines currently in use
  8616. */
  8617. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8618. /**
  8619. * Prepare the list of defines associated to the shader.
  8620. * @param defines the list of defines to complete
  8621. * @param forPostProcess Define if we are currently in post process mode or not
  8622. */
  8623. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8624. /**
  8625. * Returns true if all the image processing information are ready.
  8626. * @returns True if ready, otherwise, false
  8627. */
  8628. isReady(): boolean;
  8629. /**
  8630. * Binds the image processing to the shader.
  8631. * @param effect The effect to bind to
  8632. * @param overrideAspectRatio Override the aspect ratio of the effect
  8633. */
  8634. bind(effect: Effect, overrideAspectRatio?: number): void;
  8635. /**
  8636. * Clones the current image processing instance.
  8637. * @return The cloned image processing
  8638. */
  8639. clone(): ImageProcessingConfiguration;
  8640. /**
  8641. * Serializes the current image processing instance to a json representation.
  8642. * @return a JSON representation
  8643. */
  8644. serialize(): any;
  8645. /**
  8646. * Parses the image processing from a json representation.
  8647. * @param source the JSON source to parse
  8648. * @return The parsed image processing
  8649. */
  8650. static Parse(source: any): ImageProcessingConfiguration;
  8651. private static _VIGNETTEMODE_MULTIPLY;
  8652. private static _VIGNETTEMODE_OPAQUE;
  8653. /**
  8654. * Used to apply the vignette as a mix with the pixel color.
  8655. */
  8656. static get VIGNETTEMODE_MULTIPLY(): number;
  8657. /**
  8658. * Used to apply the vignette as a replacement of the pixel color.
  8659. */
  8660. static get VIGNETTEMODE_OPAQUE(): number;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /** @hidden */
  8665. export var postprocessVertexShader: {
  8666. name: string;
  8667. shader: string;
  8668. };
  8669. }
  8670. declare module BABYLON {
  8671. /**
  8672. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8673. */
  8674. export type RenderTargetTextureSize = number | {
  8675. width: number;
  8676. height: number;
  8677. layers?: number;
  8678. };
  8679. interface ThinEngine {
  8680. /**
  8681. * Creates a new render target texture
  8682. * @param size defines the size of the texture
  8683. * @param options defines the options used to create the texture
  8684. * @returns a new render target texture stored in an InternalTexture
  8685. */
  8686. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8687. /**
  8688. * Creates a depth stencil texture.
  8689. * This is only available in WebGL 2 or with the depth texture extension available.
  8690. * @param size The size of face edge in the texture.
  8691. * @param options The options defining the texture.
  8692. * @returns The texture
  8693. */
  8694. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8695. /** @hidden */
  8696. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Defines the kind of connection point for node based material
  8702. */
  8703. export enum NodeMaterialBlockConnectionPointTypes {
  8704. /** Float */
  8705. Float = 1,
  8706. /** Int */
  8707. Int = 2,
  8708. /** Vector2 */
  8709. Vector2 = 4,
  8710. /** Vector3 */
  8711. Vector3 = 8,
  8712. /** Vector4 */
  8713. Vector4 = 16,
  8714. /** Color3 */
  8715. Color3 = 32,
  8716. /** Color4 */
  8717. Color4 = 64,
  8718. /** Matrix */
  8719. Matrix = 128,
  8720. /** Custom object */
  8721. Object = 256,
  8722. /** Detect type based on connection */
  8723. AutoDetect = 1024,
  8724. /** Output type that will be defined by input type */
  8725. BasedOnInput = 2048
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Enum used to define the target of a block
  8731. */
  8732. export enum NodeMaterialBlockTargets {
  8733. /** Vertex shader */
  8734. Vertex = 1,
  8735. /** Fragment shader */
  8736. Fragment = 2,
  8737. /** Neutral */
  8738. Neutral = 4,
  8739. /** Vertex and Fragment */
  8740. VertexAndFragment = 3
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8746. */
  8747. export enum NodeMaterialBlockConnectionPointMode {
  8748. /** Value is an uniform */
  8749. Uniform = 0,
  8750. /** Value is a mesh attribute */
  8751. Attribute = 1,
  8752. /** Value is a varying between vertex and fragment shaders */
  8753. Varying = 2,
  8754. /** Mode is undefined */
  8755. Undefined = 3
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * Enum used to define system values e.g. values automatically provided by the system
  8761. */
  8762. export enum NodeMaterialSystemValues {
  8763. /** World */
  8764. World = 1,
  8765. /** View */
  8766. View = 2,
  8767. /** Projection */
  8768. Projection = 3,
  8769. /** ViewProjection */
  8770. ViewProjection = 4,
  8771. /** WorldView */
  8772. WorldView = 5,
  8773. /** WorldViewProjection */
  8774. WorldViewProjection = 6,
  8775. /** CameraPosition */
  8776. CameraPosition = 7,
  8777. /** Fog Color */
  8778. FogColor = 8,
  8779. /** Delta time */
  8780. DeltaTime = 9
  8781. }
  8782. }
  8783. declare module BABYLON {
  8784. /** Defines supported spaces */
  8785. export enum Space {
  8786. /** Local (object) space */
  8787. LOCAL = 0,
  8788. /** World space */
  8789. WORLD = 1,
  8790. /** Bone space */
  8791. BONE = 2
  8792. }
  8793. /** Defines the 3 main axes */
  8794. export class Axis {
  8795. /** X axis */
  8796. static X: Vector3;
  8797. /** Y axis */
  8798. static Y: Vector3;
  8799. /** Z axis */
  8800. static Z: Vector3;
  8801. }
  8802. /**
  8803. * Defines cartesian components.
  8804. */
  8805. export enum Coordinate {
  8806. /** X axis */
  8807. X = 0,
  8808. /** Y axis */
  8809. Y = 1,
  8810. /** Z axis */
  8811. Z = 2
  8812. }
  8813. }
  8814. declare module BABYLON {
  8815. /**
  8816. * Represents a camera frustum
  8817. */
  8818. export class Frustum {
  8819. /**
  8820. * Gets the planes representing the frustum
  8821. * @param transform matrix to be applied to the returned planes
  8822. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8823. */
  8824. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8825. /**
  8826. * Gets the near frustum plane transformed by the transform matrix
  8827. * @param transform transformation matrix to be applied to the resulting frustum plane
  8828. * @param frustumPlane the resuling frustum plane
  8829. */
  8830. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8831. /**
  8832. * Gets the far frustum plane transformed by the transform matrix
  8833. * @param transform transformation matrix to be applied to the resulting frustum plane
  8834. * @param frustumPlane the resuling frustum plane
  8835. */
  8836. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8837. /**
  8838. * Gets the left frustum plane transformed by the transform matrix
  8839. * @param transform transformation matrix to be applied to the resulting frustum plane
  8840. * @param frustumPlane the resuling frustum plane
  8841. */
  8842. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8843. /**
  8844. * Gets the right frustum plane transformed by the transform matrix
  8845. * @param transform transformation matrix to be applied to the resulting frustum plane
  8846. * @param frustumPlane the resuling frustum plane
  8847. */
  8848. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8849. /**
  8850. * Gets the top frustum plane transformed by the transform matrix
  8851. * @param transform transformation matrix to be applied to the resulting frustum plane
  8852. * @param frustumPlane the resuling frustum plane
  8853. */
  8854. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8855. /**
  8856. * Gets the bottom frustum plane transformed by the transform matrix
  8857. * @param transform transformation matrix to be applied to the resulting frustum plane
  8858. * @param frustumPlane the resuling frustum plane
  8859. */
  8860. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8861. /**
  8862. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8863. * @param transform transformation matrix to be applied to the resulting frustum planes
  8864. * @param frustumPlanes the resuling frustum planes
  8865. */
  8866. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8867. }
  8868. }
  8869. declare module BABYLON {
  8870. /**
  8871. * Interface for the size containing width and height
  8872. */
  8873. export interface ISize {
  8874. /**
  8875. * Width
  8876. */
  8877. width: number;
  8878. /**
  8879. * Heighht
  8880. */
  8881. height: number;
  8882. }
  8883. /**
  8884. * Size containing widht and height
  8885. */
  8886. export class Size implements ISize {
  8887. /**
  8888. * Width
  8889. */
  8890. width: number;
  8891. /**
  8892. * Height
  8893. */
  8894. height: number;
  8895. /**
  8896. * Creates a Size object from the given width and height (floats).
  8897. * @param width width of the new size
  8898. * @param height height of the new size
  8899. */
  8900. constructor(width: number, height: number);
  8901. /**
  8902. * Returns a string with the Size width and height
  8903. * @returns a string with the Size width and height
  8904. */
  8905. toString(): string;
  8906. /**
  8907. * "Size"
  8908. * @returns the string "Size"
  8909. */
  8910. getClassName(): string;
  8911. /**
  8912. * Returns the Size hash code.
  8913. * @returns a hash code for a unique width and height
  8914. */
  8915. getHashCode(): number;
  8916. /**
  8917. * Updates the current size from the given one.
  8918. * @param src the given size
  8919. */
  8920. copyFrom(src: Size): void;
  8921. /**
  8922. * Updates in place the current Size from the given floats.
  8923. * @param width width of the new size
  8924. * @param height height of the new size
  8925. * @returns the updated Size.
  8926. */
  8927. copyFromFloats(width: number, height: number): Size;
  8928. /**
  8929. * Updates in place the current Size from the given floats.
  8930. * @param width width to set
  8931. * @param height height to set
  8932. * @returns the updated Size.
  8933. */
  8934. set(width: number, height: number): Size;
  8935. /**
  8936. * Multiplies the width and height by numbers
  8937. * @param w factor to multiple the width by
  8938. * @param h factor to multiple the height by
  8939. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8940. */
  8941. multiplyByFloats(w: number, h: number): Size;
  8942. /**
  8943. * Clones the size
  8944. * @returns a new Size copied from the given one.
  8945. */
  8946. clone(): Size;
  8947. /**
  8948. * True if the current Size and the given one width and height are strictly equal.
  8949. * @param other the other size to compare against
  8950. * @returns True if the current Size and the given one width and height are strictly equal.
  8951. */
  8952. equals(other: Size): boolean;
  8953. /**
  8954. * The surface of the Size : width * height (float).
  8955. */
  8956. get surface(): number;
  8957. /**
  8958. * Create a new size of zero
  8959. * @returns a new Size set to (0.0, 0.0)
  8960. */
  8961. static Zero(): Size;
  8962. /**
  8963. * Sums the width and height of two sizes
  8964. * @param otherSize size to add to this size
  8965. * @returns a new Size set as the addition result of the current Size and the given one.
  8966. */
  8967. add(otherSize: Size): Size;
  8968. /**
  8969. * Subtracts the width and height of two
  8970. * @param otherSize size to subtract to this size
  8971. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8972. */
  8973. subtract(otherSize: Size): Size;
  8974. /**
  8975. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8976. * @param start starting size to lerp between
  8977. * @param end end size to lerp between
  8978. * @param amount amount to lerp between the start and end values
  8979. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8980. */
  8981. static Lerp(start: Size, end: Size, amount: number): Size;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Contains position and normal vectors for a vertex
  8987. */
  8988. export class PositionNormalVertex {
  8989. /** the position of the vertex (defaut: 0,0,0) */
  8990. position: Vector3;
  8991. /** the normal of the vertex (defaut: 0,1,0) */
  8992. normal: Vector3;
  8993. /**
  8994. * Creates a PositionNormalVertex
  8995. * @param position the position of the vertex (defaut: 0,0,0)
  8996. * @param normal the normal of the vertex (defaut: 0,1,0)
  8997. */
  8998. constructor(
  8999. /** the position of the vertex (defaut: 0,0,0) */
  9000. position?: Vector3,
  9001. /** the normal of the vertex (defaut: 0,1,0) */
  9002. normal?: Vector3);
  9003. /**
  9004. * Clones the PositionNormalVertex
  9005. * @returns the cloned PositionNormalVertex
  9006. */
  9007. clone(): PositionNormalVertex;
  9008. }
  9009. /**
  9010. * Contains position, normal and uv vectors for a vertex
  9011. */
  9012. export class PositionNormalTextureVertex {
  9013. /** the position of the vertex (defaut: 0,0,0) */
  9014. position: Vector3;
  9015. /** the normal of the vertex (defaut: 0,1,0) */
  9016. normal: Vector3;
  9017. /** the uv of the vertex (default: 0,0) */
  9018. uv: Vector2;
  9019. /**
  9020. * Creates a PositionNormalTextureVertex
  9021. * @param position the position of the vertex (defaut: 0,0,0)
  9022. * @param normal the normal of the vertex (defaut: 0,1,0)
  9023. * @param uv the uv of the vertex (default: 0,0)
  9024. */
  9025. constructor(
  9026. /** the position of the vertex (defaut: 0,0,0) */
  9027. position?: Vector3,
  9028. /** the normal of the vertex (defaut: 0,1,0) */
  9029. normal?: Vector3,
  9030. /** the uv of the vertex (default: 0,0) */
  9031. uv?: Vector2);
  9032. /**
  9033. * Clones the PositionNormalTextureVertex
  9034. * @returns the cloned PositionNormalTextureVertex
  9035. */
  9036. clone(): PositionNormalTextureVertex;
  9037. }
  9038. }
  9039. declare module BABYLON {
  9040. /**
  9041. * Enum defining the type of animations supported by InputBlock
  9042. */
  9043. export enum AnimatedInputBlockTypes {
  9044. /** No animation */
  9045. None = 0,
  9046. /** Time based animation. Will only work for floats */
  9047. Time = 1
  9048. }
  9049. }
  9050. declare module BABYLON {
  9051. /**
  9052. * Interface describing all the common properties and methods a shadow light needs to implement.
  9053. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9054. * as well as binding the different shadow properties to the effects.
  9055. */
  9056. export interface IShadowLight extends Light {
  9057. /**
  9058. * The light id in the scene (used in scene.findLighById for instance)
  9059. */
  9060. id: string;
  9061. /**
  9062. * The position the shdow will be casted from.
  9063. */
  9064. position: Vector3;
  9065. /**
  9066. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9067. */
  9068. direction: Vector3;
  9069. /**
  9070. * The transformed position. Position of the light in world space taking parenting in account.
  9071. */
  9072. transformedPosition: Vector3;
  9073. /**
  9074. * The transformed direction. Direction of the light in world space taking parenting in account.
  9075. */
  9076. transformedDirection: Vector3;
  9077. /**
  9078. * The friendly name of the light in the scene.
  9079. */
  9080. name: string;
  9081. /**
  9082. * Defines the shadow projection clipping minimum z value.
  9083. */
  9084. shadowMinZ: number;
  9085. /**
  9086. * Defines the shadow projection clipping maximum z value.
  9087. */
  9088. shadowMaxZ: number;
  9089. /**
  9090. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9091. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9092. */
  9093. computeTransformedInformation(): boolean;
  9094. /**
  9095. * Gets the scene the light belongs to.
  9096. * @returns The scene
  9097. */
  9098. getScene(): Scene;
  9099. /**
  9100. * Callback defining a custom Projection Matrix Builder.
  9101. * This can be used to override the default projection matrix computation.
  9102. */
  9103. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9104. /**
  9105. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9106. * @param matrix The materix to updated with the projection information
  9107. * @param viewMatrix The transform matrix of the light
  9108. * @param renderList The list of mesh to render in the map
  9109. * @returns The current light
  9110. */
  9111. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9112. /**
  9113. * Gets the current depth scale used in ESM.
  9114. * @returns The scale
  9115. */
  9116. getDepthScale(): number;
  9117. /**
  9118. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9119. * @returns true if a cube texture needs to be use
  9120. */
  9121. needCube(): boolean;
  9122. /**
  9123. * Detects if the projection matrix requires to be recomputed this frame.
  9124. * @returns true if it requires to be recomputed otherwise, false.
  9125. */
  9126. needProjectionMatrixCompute(): boolean;
  9127. /**
  9128. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9129. */
  9130. forceProjectionMatrixCompute(): void;
  9131. /**
  9132. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9133. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9134. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9135. */
  9136. getShadowDirection(faceIndex?: number): Vector3;
  9137. /**
  9138. * Gets the minZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the min for
  9140. * @returns the depth min z
  9141. */
  9142. getDepthMinZ(activeCamera: Camera): number;
  9143. /**
  9144. * Gets the maxZ used for shadow according to both the scene and the light.
  9145. * @param activeCamera The camera we are returning the max for
  9146. * @returns the depth max z
  9147. */
  9148. getDepthMaxZ(activeCamera: Camera): number;
  9149. }
  9150. /**
  9151. * Base implementation IShadowLight
  9152. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9153. */
  9154. export abstract class ShadowLight extends Light implements IShadowLight {
  9155. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9156. protected _position: Vector3;
  9157. protected _setPosition(value: Vector3): void;
  9158. /**
  9159. * Sets the position the shadow will be casted from. Also use as the light position for both
  9160. * point and spot lights.
  9161. */
  9162. get position(): Vector3;
  9163. /**
  9164. * Sets the position the shadow will be casted from. Also use as the light position for both
  9165. * point and spot lights.
  9166. */
  9167. set position(value: Vector3);
  9168. protected _direction: Vector3;
  9169. protected _setDirection(value: Vector3): void;
  9170. /**
  9171. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9172. * Also use as the light direction on spot and directional lights.
  9173. */
  9174. get direction(): Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9177. * Also use as the light direction on spot and directional lights.
  9178. */
  9179. set direction(value: Vector3);
  9180. protected _shadowMinZ: number;
  9181. /**
  9182. * Gets the shadow projection clipping minimum z value.
  9183. */
  9184. get shadowMinZ(): number;
  9185. /**
  9186. * Sets the shadow projection clipping minimum z value.
  9187. */
  9188. set shadowMinZ(value: number);
  9189. protected _shadowMaxZ: number;
  9190. /**
  9191. * Sets the shadow projection clipping maximum z value.
  9192. */
  9193. get shadowMaxZ(): number;
  9194. /**
  9195. * Gets the shadow projection clipping maximum z value.
  9196. */
  9197. set shadowMaxZ(value: number);
  9198. /**
  9199. * Callback defining a custom Projection Matrix Builder.
  9200. * This can be used to override the default projection matrix computation.
  9201. */
  9202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9203. /**
  9204. * The transformed position. Position of the light in world space taking parenting in account.
  9205. */
  9206. transformedPosition: Vector3;
  9207. /**
  9208. * The transformed direction. Direction of the light in world space taking parenting in account.
  9209. */
  9210. transformedDirection: Vector3;
  9211. private _needProjectionMatrixCompute;
  9212. /**
  9213. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9214. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9215. */
  9216. computeTransformedInformation(): boolean;
  9217. /**
  9218. * Return the depth scale used for the shadow map.
  9219. * @returns the depth scale.
  9220. */
  9221. getDepthScale(): number;
  9222. /**
  9223. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9224. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9225. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9226. */
  9227. getShadowDirection(faceIndex?: number): Vector3;
  9228. /**
  9229. * Returns the ShadowLight absolute position in the World.
  9230. * @returns the position vector in world space
  9231. */
  9232. getAbsolutePosition(): Vector3;
  9233. /**
  9234. * Sets the ShadowLight direction toward the passed target.
  9235. * @param target The point to target in local space
  9236. * @returns the updated ShadowLight direction
  9237. */
  9238. setDirectionToTarget(target: Vector3): Vector3;
  9239. /**
  9240. * Returns the light rotation in euler definition.
  9241. * @returns the x y z rotation in local space.
  9242. */
  9243. getRotation(): Vector3;
  9244. /**
  9245. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9246. * @returns true if a cube texture needs to be use
  9247. */
  9248. needCube(): boolean;
  9249. /**
  9250. * Detects if the projection matrix requires to be recomputed this frame.
  9251. * @returns true if it requires to be recomputed otherwise, false.
  9252. */
  9253. needProjectionMatrixCompute(): boolean;
  9254. /**
  9255. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9256. */
  9257. forceProjectionMatrixCompute(): void;
  9258. /** @hidden */
  9259. _initCache(): void;
  9260. /** @hidden */
  9261. _isSynchronized(): boolean;
  9262. /**
  9263. * Computes the world matrix of the node
  9264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9265. * @returns the world matrix
  9266. */
  9267. computeWorldMatrix(force?: boolean): Matrix;
  9268. /**
  9269. * Gets the minZ used for shadow according to both the scene and the light.
  9270. * @param activeCamera The camera we are returning the min for
  9271. * @returns the depth min z
  9272. */
  9273. getDepthMinZ(activeCamera: Camera): number;
  9274. /**
  9275. * Gets the maxZ used for shadow according to both the scene and the light.
  9276. * @param activeCamera The camera we are returning the max for
  9277. * @returns the depth max z
  9278. */
  9279. getDepthMaxZ(activeCamera: Camera): number;
  9280. /**
  9281. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9282. * @param matrix The materix to updated with the projection information
  9283. * @param viewMatrix The transform matrix of the light
  9284. * @param renderList The list of mesh to render in the map
  9285. * @returns The current light
  9286. */
  9287. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9288. }
  9289. }
  9290. declare module BABYLON {
  9291. /** @hidden */
  9292. export var packingFunctions: {
  9293. name: string;
  9294. shader: string;
  9295. };
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. export var bayerDitherFunctions: {
  9300. name: string;
  9301. shader: string;
  9302. };
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var shadowMapFragmentDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var clipPlaneFragmentDeclaration: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var clipPlaneFragment: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var shadowMapFragment: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var shadowMapPixelShader: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var bonesDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var morphTargetsVertexGlobalDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var morphTargetsVertexDeclaration: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var instancesDeclaration: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var helperFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var shadowMapVertexDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var clipPlaneVertexDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var morphTargetsVertex: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /** @hidden */
  9397. export var instancesVertex: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module BABYLON {
  9403. /** @hidden */
  9404. export var bonesVertex: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module BABYLON {
  9410. /** @hidden */
  9411. export var shadowMapVertexNormalBias: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module BABYLON {
  9417. /** @hidden */
  9418. export var shadowMapVertexMetric: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module BABYLON {
  9424. /** @hidden */
  9425. export var clipPlaneVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module BABYLON {
  9431. /** @hidden */
  9432. export var shadowMapVertexShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module BABYLON {
  9438. /** @hidden */
  9439. export var depthBoxBlurPixelShader: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module BABYLON {
  9445. /** @hidden */
  9446. export var shadowMapFragmentSoftTransparentShadow: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module BABYLON {
  9452. /**
  9453. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9454. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9455. */
  9456. export class EffectFallbacks implements IEffectFallbacks {
  9457. private _defines;
  9458. private _currentRank;
  9459. private _maxRank;
  9460. private _mesh;
  9461. /**
  9462. * Removes the fallback from the bound mesh.
  9463. */
  9464. unBindMesh(): void;
  9465. /**
  9466. * Adds a fallback on the specified property.
  9467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9468. * @param define The name of the define in the shader
  9469. */
  9470. addFallback(rank: number, define: string): void;
  9471. /**
  9472. * Sets the mesh to use CPU skinning when needing to fallback.
  9473. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9474. * @param mesh The mesh to use the fallbacks.
  9475. */
  9476. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9477. /**
  9478. * Checks to see if more fallbacks are still availible.
  9479. */
  9480. get hasMoreFallbacks(): boolean;
  9481. /**
  9482. * Removes the defines that should be removed when falling back.
  9483. * @param currentDefines defines the current define statements for the shader.
  9484. * @param effect defines the current effect we try to compile
  9485. * @returns The resulting defines with defines of the current rank removed.
  9486. */
  9487. reduce(currentDefines: string, effect: Effect): string;
  9488. }
  9489. }
  9490. declare module BABYLON {
  9491. /**
  9492. * Interface used to define Action
  9493. */
  9494. export interface IAction {
  9495. /**
  9496. * Trigger for the action
  9497. */
  9498. trigger: number;
  9499. /** Options of the trigger */
  9500. triggerOptions: any;
  9501. /**
  9502. * Gets the trigger parameters
  9503. * @returns the trigger parameters
  9504. */
  9505. getTriggerParameter(): any;
  9506. /**
  9507. * Internal only - executes current action event
  9508. * @hidden
  9509. */
  9510. _executeCurrent(evt?: ActionEvent): void;
  9511. /**
  9512. * Serialize placeholder for child classes
  9513. * @param parent of child
  9514. * @returns the serialized object
  9515. */
  9516. serialize(parent: any): any;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. _prepare(): void;
  9522. /**
  9523. * Internal only - manager for action
  9524. * @hidden
  9525. */
  9526. _actionManager: Nullable<AbstractActionManager>;
  9527. /**
  9528. * Adds action to chain of actions, may be a DoNothingAction
  9529. * @param action defines the next action to execute
  9530. * @returns The action passed in
  9531. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9532. */
  9533. then(action: IAction): IAction;
  9534. }
  9535. /**
  9536. * The action to be carried out following a trigger
  9537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9538. */
  9539. export class Action implements IAction {
  9540. /** the trigger, with or without parameters, for the action */
  9541. triggerOptions: any;
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /**
  9547. * Internal only - manager for action
  9548. * @hidden
  9549. */
  9550. _actionManager: ActionManager;
  9551. private _nextActiveAction;
  9552. private _child;
  9553. private _condition?;
  9554. private _triggerParameter;
  9555. /**
  9556. * An event triggered prior to action being executed.
  9557. */
  9558. onBeforeExecuteObservable: Observable<Action>;
  9559. /**
  9560. * Creates a new Action
  9561. * @param triggerOptions the trigger, with or without parameters, for the action
  9562. * @param condition an optional determinant of action
  9563. */
  9564. constructor(
  9565. /** the trigger, with or without parameters, for the action */
  9566. triggerOptions: any, condition?: Condition);
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Gets the trigger parameters
  9574. * @returns the trigger parameters
  9575. */
  9576. getTriggerParameter(): any;
  9577. /**
  9578. * Internal only - executes current action event
  9579. * @hidden
  9580. */
  9581. _executeCurrent(evt?: ActionEvent): void;
  9582. /**
  9583. * Execute placeholder for child classes
  9584. * @param evt optional action event
  9585. */
  9586. execute(evt?: ActionEvent): void;
  9587. /**
  9588. * Skips to next active action
  9589. */
  9590. skipToNextActiveAction(): void;
  9591. /**
  9592. * Adds action to chain of actions, may be a DoNothingAction
  9593. * @param action defines the next action to execute
  9594. * @returns The action passed in
  9595. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9596. */
  9597. then(action: Action): Action;
  9598. /**
  9599. * Internal only
  9600. * @hidden
  9601. */
  9602. _getProperty(propertyPath: string): string;
  9603. /**
  9604. * Internal only
  9605. * @hidden
  9606. */
  9607. _getEffectiveTarget(target: any, propertyPath: string): any;
  9608. /**
  9609. * Serialize placeholder for child classes
  9610. * @param parent of child
  9611. * @returns the serialized object
  9612. */
  9613. serialize(parent: any): any;
  9614. /**
  9615. * Internal only called by serialize
  9616. * @hidden
  9617. */
  9618. protected _serialize(serializedAction: any, parent?: any): any;
  9619. /**
  9620. * Internal only
  9621. * @hidden
  9622. */
  9623. static _SerializeValueAsString: (value: any) => string;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. static _GetTargetProperty: (target: Scene | Node) => {
  9629. name: string;
  9630. targetType: string;
  9631. value: string;
  9632. };
  9633. }
  9634. }
  9635. declare module BABYLON {
  9636. /**
  9637. * A Condition applied to an Action
  9638. */
  9639. export class Condition {
  9640. /**
  9641. * Internal only - manager for action
  9642. * @hidden
  9643. */
  9644. _actionManager: ActionManager;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _evaluationId: number;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _currentResult: boolean;
  9655. /**
  9656. * Creates a new Condition
  9657. * @param actionManager the manager of the action the condition is applied to
  9658. */
  9659. constructor(actionManager: ActionManager);
  9660. /**
  9661. * Check if the current condition is valid
  9662. * @returns a boolean
  9663. */
  9664. isValid(): boolean;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. _getProperty(propertyPath: string): string;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. _getEffectiveTarget(target: any, propertyPath: string): any;
  9675. /**
  9676. * Serialize placeholder for child classes
  9677. * @returns the serialized object
  9678. */
  9679. serialize(): any;
  9680. /**
  9681. * Internal only
  9682. * @hidden
  9683. */
  9684. protected _serialize(serializedCondition: any): any;
  9685. }
  9686. /**
  9687. * Defines specific conditional operators as extensions of Condition
  9688. */
  9689. export class ValueCondition extends Condition {
  9690. /** path to specify the property of the target the conditional operator uses */
  9691. propertyPath: string;
  9692. /** the value compared by the conditional operator against the current value of the property */
  9693. value: any;
  9694. /** the conditional operator, default ValueCondition.IsEqual */
  9695. operator: number;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. private static _IsEqual;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. private static _IsDifferent;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. private static _IsGreater;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. private static _IsLesser;
  9716. /**
  9717. * returns the number for IsEqual
  9718. */
  9719. static get IsEqual(): number;
  9720. /**
  9721. * Returns the number for IsDifferent
  9722. */
  9723. static get IsDifferent(): number;
  9724. /**
  9725. * Returns the number for IsGreater
  9726. */
  9727. static get IsGreater(): number;
  9728. /**
  9729. * Returns the number for IsLesser
  9730. */
  9731. static get IsLesser(): number;
  9732. /**
  9733. * Internal only The action manager for the condition
  9734. * @hidden
  9735. */
  9736. _actionManager: ActionManager;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. private _target;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. private _effectiveTarget;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private _property;
  9752. /**
  9753. * Creates a new ValueCondition
  9754. * @param actionManager manager for the action the condition applies to
  9755. * @param target for the action
  9756. * @param propertyPath path to specify the property of the target the conditional operator uses
  9757. * @param value the value compared by the conditional operator against the current value of the property
  9758. * @param operator the conditional operator, default ValueCondition.IsEqual
  9759. */
  9760. constructor(actionManager: ActionManager, target: any,
  9761. /** path to specify the property of the target the conditional operator uses */
  9762. propertyPath: string,
  9763. /** the value compared by the conditional operator against the current value of the property */
  9764. value: any,
  9765. /** the conditional operator, default ValueCondition.IsEqual */
  9766. operator?: number);
  9767. /**
  9768. * Compares the given value with the property value for the specified conditional operator
  9769. * @returns the result of the comparison
  9770. */
  9771. isValid(): boolean;
  9772. /**
  9773. * Serialize the ValueCondition into a JSON compatible object
  9774. * @returns serialization object
  9775. */
  9776. serialize(): any;
  9777. /**
  9778. * Gets the name of the conditional operator for the ValueCondition
  9779. * @param operator the conditional operator
  9780. * @returns the name
  9781. */
  9782. static GetOperatorName(operator: number): string;
  9783. }
  9784. /**
  9785. * Defines a predicate condition as an extension of Condition
  9786. */
  9787. export class PredicateCondition extends Condition {
  9788. /** defines the predicate function used to validate the condition */
  9789. predicate: () => boolean;
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Creates a new PredicateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param predicate defines the predicate function used to validate the condition
  9799. */
  9800. constructor(actionManager: ActionManager,
  9801. /** defines the predicate function used to validate the condition */
  9802. predicate: () => boolean);
  9803. /**
  9804. * @returns the validity of the predicate condition
  9805. */
  9806. isValid(): boolean;
  9807. }
  9808. /**
  9809. * Defines a state condition as an extension of Condition
  9810. */
  9811. export class StateCondition extends Condition {
  9812. /** Value to compare with target state */
  9813. value: string;
  9814. /**
  9815. * Internal only - manager for action
  9816. * @hidden
  9817. */
  9818. _actionManager: ActionManager;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private _target;
  9824. /**
  9825. * Creates a new StateCondition
  9826. * @param actionManager manager for the action the condition applies to
  9827. * @param target of the condition
  9828. * @param value to compare with target state
  9829. */
  9830. constructor(actionManager: ActionManager, target: any,
  9831. /** Value to compare with target state */
  9832. value: string);
  9833. /**
  9834. * Gets a boolean indicating if the current condition is met
  9835. * @returns the validity of the state
  9836. */
  9837. isValid(): boolean;
  9838. /**
  9839. * Serialize the StateCondition into a JSON compatible object
  9840. * @returns serialization object
  9841. */
  9842. serialize(): any;
  9843. }
  9844. }
  9845. declare module BABYLON {
  9846. /**
  9847. * This defines an action responsible to toggle a boolean once triggered.
  9848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9849. */
  9850. export class SwitchBooleanAction extends Action {
  9851. /**
  9852. * The path to the boolean property in the target object
  9853. */
  9854. propertyPath: string;
  9855. private _target;
  9856. private _effectiveTarget;
  9857. private _property;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the boolean
  9862. * @param propertyPath defines the path to the boolean property in the target object
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9866. /** @hidden */
  9867. _prepare(): void;
  9868. /**
  9869. * Execute the action toggle the boolean value.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a the state field of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetStateAction extends Action {
  9885. /**
  9886. * The value to store in the state field.
  9887. */
  9888. value: string;
  9889. private _target;
  9890. /**
  9891. * Instantiate the action
  9892. * @param triggerOptions defines the trigger options
  9893. * @param target defines the object containing the state property
  9894. * @param value defines the value to store in the state field
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9898. /**
  9899. * Execute the action and store the value on the target state property.
  9900. */
  9901. execute(): void;
  9902. /**
  9903. * Serializes the actions and its related information.
  9904. * @param parent defines the object to serialize in
  9905. * @returns the serialized object
  9906. */
  9907. serialize(parent: any): any;
  9908. }
  9909. /**
  9910. * This defines an action responsible to set a property of the target
  9911. * to a desired value once triggered.
  9912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9913. */
  9914. export class SetValueAction extends Action {
  9915. /**
  9916. * The path of the property to set in the target.
  9917. */
  9918. propertyPath: string;
  9919. /**
  9920. * The value to set in the property
  9921. */
  9922. value: any;
  9923. private _target;
  9924. private _effectiveTarget;
  9925. private _property;
  9926. /**
  9927. * Instantiate the action
  9928. * @param triggerOptions defines the trigger options
  9929. * @param target defines the object containing the property
  9930. * @param propertyPath defines the path of the property to set in the target
  9931. * @param value defines the value to set in the property
  9932. * @param condition defines the trigger related conditions
  9933. */
  9934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9935. /** @hidden */
  9936. _prepare(): void;
  9937. /**
  9938. * Execute the action and set the targetted property to the desired value.
  9939. */
  9940. execute(): void;
  9941. /**
  9942. * Serializes the actions and its related information.
  9943. * @param parent defines the object to serialize in
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. }
  9948. /**
  9949. * This defines an action responsible to increment the target value
  9950. * to a desired value once triggered.
  9951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9952. */
  9953. export class IncrementValueAction extends Action {
  9954. /**
  9955. * The path of the property to increment in the target.
  9956. */
  9957. propertyPath: string;
  9958. /**
  9959. * The value we should increment the property by.
  9960. */
  9961. value: any;
  9962. private _target;
  9963. private _effectiveTarget;
  9964. private _property;
  9965. /**
  9966. * Instantiate the action
  9967. * @param triggerOptions defines the trigger options
  9968. * @param target defines the object containing the property
  9969. * @param propertyPath defines the path of the property to increment in the target
  9970. * @param value defines the value value we should increment the property by
  9971. * @param condition defines the trigger related conditions
  9972. */
  9973. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9974. /** @hidden */
  9975. _prepare(): void;
  9976. /**
  9977. * Execute the action and increment the target of the value amount.
  9978. */
  9979. execute(): void;
  9980. /**
  9981. * Serializes the actions and its related information.
  9982. * @param parent defines the object to serialize in
  9983. * @returns the serialized object
  9984. */
  9985. serialize(parent: any): any;
  9986. }
  9987. /**
  9988. * This defines an action responsible to start an animation once triggered.
  9989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9990. */
  9991. export class PlayAnimationAction extends Action {
  9992. /**
  9993. * Where the animation should start (animation frame)
  9994. */
  9995. from: number;
  9996. /**
  9997. * Where the animation should stop (animation frame)
  9998. */
  9999. to: number;
  10000. /**
  10001. * Define if the animation should loop or stop after the first play.
  10002. */
  10003. loop?: boolean;
  10004. private _target;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param target defines the target animation or animation name
  10009. * @param from defines from where the animation should start (animation frame)
  10010. * @param end defines where the animation should stop (animation frame)
  10011. * @param loop defines if the animation should loop or stop after the first play
  10012. * @param condition defines the trigger related conditions
  10013. */
  10014. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10015. /** @hidden */
  10016. _prepare(): void;
  10017. /**
  10018. * Execute the action and play the animation.
  10019. */
  10020. execute(): void;
  10021. /**
  10022. * Serializes the actions and its related information.
  10023. * @param parent defines the object to serialize in
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. }
  10028. /**
  10029. * This defines an action responsible to stop an animation once triggered.
  10030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10031. */
  10032. export class StopAnimationAction extends Action {
  10033. private _target;
  10034. /**
  10035. * Instantiate the action
  10036. * @param triggerOptions defines the trigger options
  10037. * @param target defines the target animation or animation name
  10038. * @param condition defines the trigger related conditions
  10039. */
  10040. constructor(triggerOptions: any, target: any, condition?: Condition);
  10041. /** @hidden */
  10042. _prepare(): void;
  10043. /**
  10044. * Execute the action and stop the animation.
  10045. */
  10046. execute(): void;
  10047. /**
  10048. * Serializes the actions and its related information.
  10049. * @param parent defines the object to serialize in
  10050. * @returns the serialized object
  10051. */
  10052. serialize(parent: any): any;
  10053. }
  10054. /**
  10055. * This defines an action responsible that does nothing once triggered.
  10056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10057. */
  10058. export class DoNothingAction extends Action {
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param condition defines the trigger related conditions
  10063. */
  10064. constructor(triggerOptions?: any, condition?: Condition);
  10065. /**
  10066. * Execute the action and do nothing.
  10067. */
  10068. execute(): void;
  10069. /**
  10070. * Serializes the actions and its related information.
  10071. * @param parent defines the object to serialize in
  10072. * @returns the serialized object
  10073. */
  10074. serialize(parent: any): any;
  10075. }
  10076. /**
  10077. * This defines an action responsible to trigger several actions once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class CombineAction extends Action {
  10081. /**
  10082. * The list of aggregated animations to run.
  10083. */
  10084. children: Action[];
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param children defines the list of aggregated animations to run
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and executes all the aggregated actions.
  10096. */
  10097. execute(evt: ActionEvent): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible to run code (external event) once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class ExecuteCodeAction extends Action {
  10110. /**
  10111. * The callback function to run.
  10112. */
  10113. func: (evt: ActionEvent) => void;
  10114. /**
  10115. * Instantiate the action
  10116. * @param triggerOptions defines the trigger options
  10117. * @param func defines the callback function to run
  10118. * @param condition defines the trigger related conditions
  10119. */
  10120. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10121. /**
  10122. * Execute the action and run the attached code.
  10123. */
  10124. execute(evt: ActionEvent): void;
  10125. }
  10126. /**
  10127. * This defines an action responsible to set the parent property of the target once triggered.
  10128. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10129. */
  10130. export class SetParentAction extends Action {
  10131. private _parent;
  10132. private _target;
  10133. /**
  10134. * Instantiate the action
  10135. * @param triggerOptions defines the trigger options
  10136. * @param target defines the target containing the parent property
  10137. * @param parent defines from where the animation should start (animation frame)
  10138. * @param condition defines the trigger related conditions
  10139. */
  10140. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10141. /** @hidden */
  10142. _prepare(): void;
  10143. /**
  10144. * Execute the action and set the parent property.
  10145. */
  10146. execute(): void;
  10147. /**
  10148. * Serializes the actions and its related information.
  10149. * @param parent defines the object to serialize in
  10150. * @returns the serialized object
  10151. */
  10152. serialize(parent: any): any;
  10153. }
  10154. }
  10155. declare module BABYLON {
  10156. /**
  10157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10160. */
  10161. export class ActionManager extends AbstractActionManager {
  10162. /**
  10163. * Nothing
  10164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly NothingTrigger: number;
  10167. /**
  10168. * On pick
  10169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnPickTrigger: number;
  10172. /**
  10173. * On left pick
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnLeftPickTrigger: number;
  10177. /**
  10178. * On right pick
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnRightPickTrigger: number;
  10182. /**
  10183. * On center pick
  10184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnCenterPickTrigger: number;
  10187. /**
  10188. * On pick down
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPickDownTrigger: number;
  10192. /**
  10193. * On double pick
  10194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnDoublePickTrigger: number;
  10197. /**
  10198. * On pick up
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnPickUpTrigger: number;
  10202. /**
  10203. * On pick out.
  10204. * This trigger will only be raised if you also declared a OnPickDown
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnPickOutTrigger: number;
  10208. /**
  10209. * On long press
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnLongPressTrigger: number;
  10213. /**
  10214. * On pointer over
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnPointerOverTrigger: number;
  10218. /**
  10219. * On pointer out
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnPointerOutTrigger: number;
  10223. /**
  10224. * On every frame
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnEveryFrameTrigger: number;
  10228. /**
  10229. * On intersection enter
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnIntersectionEnterTrigger: number;
  10233. /**
  10234. * On intersection exit
  10235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10236. */
  10237. static readonly OnIntersectionExitTrigger: number;
  10238. /**
  10239. * On key down
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10241. */
  10242. static readonly OnKeyDownTrigger: number;
  10243. /**
  10244. * On key up
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly OnKeyUpTrigger: number;
  10248. private _scene;
  10249. /**
  10250. * Creates a new action manager
  10251. * @param scene defines the hosting scene
  10252. */
  10253. constructor(scene: Scene);
  10254. /**
  10255. * Releases all associated resources
  10256. */
  10257. dispose(): void;
  10258. /**
  10259. * Gets hosting scene
  10260. * @returns the hosting scene
  10261. */
  10262. getScene(): Scene;
  10263. /**
  10264. * Does this action manager handles actions of any of the given triggers
  10265. * @param triggers defines the triggers to be tested
  10266. * @return a boolean indicating whether one (or more) of the triggers is handled
  10267. */
  10268. hasSpecificTriggers(triggers: number[]): boolean;
  10269. /**
  10270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10271. * speed.
  10272. * @param triggerA defines the trigger to be tested
  10273. * @param triggerB defines the trigger to be tested
  10274. * @return a boolean indicating whether one (or more) of the triggers is handled
  10275. */
  10276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10277. /**
  10278. * Does this action manager handles actions of a given trigger
  10279. * @param trigger defines the trigger to be tested
  10280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10281. * @return whether the trigger is handled
  10282. */
  10283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10284. /**
  10285. * Does this action manager has pointer triggers
  10286. */
  10287. get hasPointerTriggers(): boolean;
  10288. /**
  10289. * Does this action manager has pick triggers
  10290. */
  10291. get hasPickTriggers(): boolean;
  10292. /**
  10293. * Registers an action to this action manager
  10294. * @param action defines the action to be registered
  10295. * @return the action amended (prepared) after registration
  10296. */
  10297. registerAction(action: IAction): Nullable<IAction>;
  10298. /**
  10299. * Unregisters an action to this action manager
  10300. * @param action defines the action to be unregistered
  10301. * @return a boolean indicating whether the action has been unregistered
  10302. */
  10303. unregisterAction(action: IAction): Boolean;
  10304. /**
  10305. * Process a specific trigger
  10306. * @param trigger defines the trigger to process
  10307. * @param evt defines the event details to be processed
  10308. */
  10309. processTrigger(trigger: number, evt?: IActionEvent): void;
  10310. /** @hidden */
  10311. _getEffectiveTarget(target: any, propertyPath: string): any;
  10312. /** @hidden */
  10313. _getProperty(propertyPath: string): string;
  10314. /**
  10315. * Serialize this manager to a JSON object
  10316. * @param name defines the property name to store this manager
  10317. * @returns a JSON representation of this manager
  10318. */
  10319. serialize(name: string): any;
  10320. /**
  10321. * Creates a new ActionManager from a JSON data
  10322. * @param parsedActions defines the JSON data to read from
  10323. * @param object defines the hosting mesh
  10324. * @param scene defines the hosting scene
  10325. */
  10326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10327. /**
  10328. * Get a trigger name by index
  10329. * @param trigger defines the trigger index
  10330. * @returns a trigger name
  10331. */
  10332. static GetTriggerName(trigger: number): string;
  10333. }
  10334. }
  10335. declare module BABYLON {
  10336. /**
  10337. * Class used to represent a sprite
  10338. * @see https://doc.babylonjs.com/babylon101/sprites
  10339. */
  10340. export class Sprite implements IAnimatable {
  10341. /** defines the name */
  10342. name: string;
  10343. /** Gets or sets the current world position */
  10344. position: Vector3;
  10345. /** Gets or sets the main color */
  10346. color: Color4;
  10347. /** Gets or sets the width */
  10348. width: number;
  10349. /** Gets or sets the height */
  10350. height: number;
  10351. /** Gets or sets rotation angle */
  10352. angle: number;
  10353. /** Gets or sets the cell index in the sprite sheet */
  10354. cellIndex: number;
  10355. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10356. cellRef: string;
  10357. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10358. invertU: boolean;
  10359. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10360. invertV: boolean;
  10361. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10362. disposeWhenFinishedAnimating: boolean;
  10363. /** Gets the list of attached animations */
  10364. animations: Nullable<Array<Animation>>;
  10365. /** Gets or sets a boolean indicating if the sprite can be picked */
  10366. isPickable: boolean;
  10367. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10368. useAlphaForPicking: boolean;
  10369. /** @hidden */
  10370. _xOffset: number;
  10371. /** @hidden */
  10372. _yOffset: number;
  10373. /** @hidden */
  10374. _xSize: number;
  10375. /** @hidden */
  10376. _ySize: number;
  10377. /**
  10378. * Gets or sets the associated action manager
  10379. */
  10380. actionManager: Nullable<ActionManager>;
  10381. /**
  10382. * An event triggered when the control has been disposed
  10383. */
  10384. onDisposeObservable: Observable<Sprite>;
  10385. private _animationStarted;
  10386. private _loopAnimation;
  10387. private _fromIndex;
  10388. private _toIndex;
  10389. private _delay;
  10390. private _direction;
  10391. private _manager;
  10392. private _time;
  10393. private _onAnimationEnd;
  10394. /**
  10395. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10396. */
  10397. isVisible: boolean;
  10398. /**
  10399. * Gets or sets the sprite size
  10400. */
  10401. get size(): number;
  10402. set size(value: number);
  10403. /**
  10404. * Returns a boolean indicating if the animation is started
  10405. */
  10406. get animationStarted(): boolean;
  10407. /**
  10408. * Gets or sets the unique id of the sprite
  10409. */
  10410. uniqueId: number;
  10411. /**
  10412. * Gets the manager of this sprite
  10413. */
  10414. get manager(): ISpriteManager;
  10415. /**
  10416. * Creates a new Sprite
  10417. * @param name defines the name
  10418. * @param manager defines the manager
  10419. */
  10420. constructor(
  10421. /** defines the name */
  10422. name: string, manager: ISpriteManager);
  10423. /**
  10424. * Returns the string "Sprite"
  10425. * @returns "Sprite"
  10426. */
  10427. getClassName(): string;
  10428. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10429. get fromIndex(): number;
  10430. set fromIndex(value: number);
  10431. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10432. get toIndex(): number;
  10433. set toIndex(value: number);
  10434. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10435. get loopAnimation(): boolean;
  10436. set loopAnimation(value: boolean);
  10437. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10438. get delay(): number;
  10439. set delay(value: number);
  10440. /**
  10441. * Starts an animation
  10442. * @param from defines the initial key
  10443. * @param to defines the end key
  10444. * @param loop defines if the animation must loop
  10445. * @param delay defines the start delay (in ms)
  10446. * @param onAnimationEnd defines a callback to call when animation ends
  10447. */
  10448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10449. /** Stops current animation (if any) */
  10450. stopAnimation(): void;
  10451. /** @hidden */
  10452. _animate(deltaTime: number): void;
  10453. /** Release associated resources */
  10454. dispose(): void;
  10455. /**
  10456. * Serializes the sprite to a JSON object
  10457. * @returns the JSON object
  10458. */
  10459. serialize(): any;
  10460. /**
  10461. * Parses a JSON object to create a new sprite
  10462. * @param parsedSprite The JSON object to parse
  10463. * @param manager defines the hosting manager
  10464. * @returns the new sprite
  10465. */
  10466. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10467. }
  10468. }
  10469. declare module BABYLON {
  10470. /**
  10471. * Information about the result of picking within a scene
  10472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10473. */
  10474. export class PickingInfo {
  10475. /** @hidden */
  10476. _pickingUnavailable: boolean;
  10477. /**
  10478. * If the pick collided with an object
  10479. */
  10480. hit: boolean;
  10481. /**
  10482. * Distance away where the pick collided
  10483. */
  10484. distance: number;
  10485. /**
  10486. * The location of pick collision
  10487. */
  10488. pickedPoint: Nullable<Vector3>;
  10489. /**
  10490. * The mesh corresponding the the pick collision
  10491. */
  10492. pickedMesh: Nullable<AbstractMesh>;
  10493. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10494. bu: number;
  10495. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10496. bv: number;
  10497. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10498. faceId: number;
  10499. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10500. subMeshFaceId: number;
  10501. /** Id of the the submesh that was picked */
  10502. subMeshId: number;
  10503. /** If a sprite was picked, this will be the sprite the pick collided with */
  10504. pickedSprite: Nullable<Sprite>;
  10505. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10506. thinInstanceIndex: number;
  10507. /**
  10508. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10509. */
  10510. originMesh: Nullable<AbstractMesh>;
  10511. /**
  10512. * The ray that was used to perform the picking.
  10513. */
  10514. ray: Nullable<Ray>;
  10515. /**
  10516. * Gets the normal correspodning to the face the pick collided with
  10517. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10518. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10519. * @returns The normal correspodning to the face the pick collided with
  10520. */
  10521. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10522. /**
  10523. * Gets the texture coordinates of where the pick occured
  10524. * @returns the vector containing the coordnates of the texture
  10525. */
  10526. getTextureCoordinates(): Nullable<Vector2>;
  10527. }
  10528. }
  10529. declare module BABYLON {
  10530. /**
  10531. * Class representing a ray with position and direction
  10532. */
  10533. export class Ray {
  10534. /** origin point */
  10535. origin: Vector3;
  10536. /** direction */
  10537. direction: Vector3;
  10538. /** length of the ray */
  10539. length: number;
  10540. private static readonly _TmpVector3;
  10541. private _tmpRay;
  10542. /**
  10543. * Creates a new ray
  10544. * @param origin origin point
  10545. * @param direction direction
  10546. * @param length length of the ray
  10547. */
  10548. constructor(
  10549. /** origin point */
  10550. origin: Vector3,
  10551. /** direction */
  10552. direction: Vector3,
  10553. /** length of the ray */
  10554. length?: number);
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param minimum bound of the box
  10559. * @param maximum bound of the box
  10560. * @param intersectionTreshold extra extend to be added to the box in all direction
  10561. * @returns if the box was hit
  10562. */
  10563. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * Checks if the ray intersects a box
  10566. * This does not account for the ray lenght by design to improve perfs.
  10567. * @param box the bounding box to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10569. * @returns if the box was hit
  10570. */
  10571. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a sphere
  10574. * @param sphere the bounding sphere to check
  10575. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10576. * @returns true if it hits the sphere
  10577. */
  10578. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10579. /**
  10580. * If the ray hits a triange
  10581. * @param vertex0 triangle vertex
  10582. * @param vertex1 triangle vertex
  10583. * @param vertex2 triangle vertex
  10584. * @returns intersection information if hit
  10585. */
  10586. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10587. /**
  10588. * Checks if ray intersects a plane
  10589. * @param plane the plane to check
  10590. * @returns the distance away it was hit
  10591. */
  10592. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10593. /**
  10594. * Calculate the intercept of a ray on a given axis
  10595. * @param axis to check 'x' | 'y' | 'z'
  10596. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10597. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10598. */
  10599. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param mesh the mesh to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @returns picking info of the intersecton
  10605. */
  10606. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10607. /**
  10608. * Checks if ray intersects a mesh
  10609. * @param meshes the meshes to check
  10610. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10611. * @param results array to store result in
  10612. * @returns Array of picking infos
  10613. */
  10614. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10615. private _comparePickingInfo;
  10616. private static smallnum;
  10617. private static rayl;
  10618. /**
  10619. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10620. * @param sega the first point of the segment to test the intersection against
  10621. * @param segb the second point of the segment to test the intersection against
  10622. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10623. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10624. */
  10625. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10626. /**
  10627. * Update the ray from viewport position
  10628. * @param x position
  10629. * @param y y position
  10630. * @param viewportWidth viewport width
  10631. * @param viewportHeight viewport height
  10632. * @param world world matrix
  10633. * @param view view matrix
  10634. * @param projection projection matrix
  10635. * @returns this ray updated
  10636. */
  10637. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10638. /**
  10639. * Creates a ray with origin and direction of 0,0,0
  10640. * @returns the new ray
  10641. */
  10642. static Zero(): Ray;
  10643. /**
  10644. * Creates a new ray from screen space and viewport
  10645. * @param x position
  10646. * @param y y position
  10647. * @param viewportWidth viewport width
  10648. * @param viewportHeight viewport height
  10649. * @param world world matrix
  10650. * @param view view matrix
  10651. * @param projection projection matrix
  10652. * @returns new ray
  10653. */
  10654. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10657. * transformed to the given world matrix.
  10658. * @param origin The origin point
  10659. * @param end The end point
  10660. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10661. * @returns the new ray
  10662. */
  10663. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @returns the resulting new ray
  10669. */
  10670. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10671. /**
  10672. * Transforms a ray by a matrix
  10673. * @param ray ray to transform
  10674. * @param matrix matrix to apply
  10675. * @param result ray to store result in
  10676. */
  10677. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10678. /**
  10679. * Unproject a ray from screen space to object space
  10680. * @param sourceX defines the screen space x coordinate to use
  10681. * @param sourceY defines the screen space y coordinate to use
  10682. * @param viewportWidth defines the current width of the viewport
  10683. * @param viewportHeight defines the current height of the viewport
  10684. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10685. * @param view defines the view matrix to use
  10686. * @param projection defines the projection matrix to use
  10687. */
  10688. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10689. }
  10690. /**
  10691. * Type used to define predicate used to select faces when a mesh intersection is detected
  10692. */
  10693. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10694. interface Scene {
  10695. /** @hidden */
  10696. _tempPickingRay: Nullable<Ray>;
  10697. /** @hidden */
  10698. _cachedRayForTransform: Ray;
  10699. /** @hidden */
  10700. _pickWithRayInverseMatrix: Matrix;
  10701. /** @hidden */
  10702. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10703. /** @hidden */
  10704. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10705. /** @hidden */
  10706. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. /**
  10711. * Groups all the scene component constants in one place to ease maintenance.
  10712. * @hidden
  10713. */
  10714. export class SceneComponentConstants {
  10715. static readonly NAME_EFFECTLAYER: string;
  10716. static readonly NAME_LAYER: string;
  10717. static readonly NAME_LENSFLARESYSTEM: string;
  10718. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10719. static readonly NAME_PARTICLESYSTEM: string;
  10720. static readonly NAME_GAMEPAD: string;
  10721. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10722. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10723. static readonly NAME_PREPASSRENDERER: string;
  10724. static readonly NAME_DEPTHRENDERER: string;
  10725. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10726. static readonly NAME_SPRITE: string;
  10727. static readonly NAME_SUBSURFACE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10742. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10749. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10750. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10754. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10755. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10763. static readonly STEP_POINTERMOVE_SPRITE: number;
  10764. static readonly STEP_POINTERDOWN_SPRITE: number;
  10765. static readonly STEP_POINTERUP_SPRITE: number;
  10766. }
  10767. /**
  10768. * This represents a scene component.
  10769. *
  10770. * This is used to decouple the dependency the scene is having on the different workloads like
  10771. * layers, post processes...
  10772. */
  10773. export interface ISceneComponent {
  10774. /**
  10775. * The name of the component. Each component must have a unique name.
  10776. */
  10777. name: string;
  10778. /**
  10779. * The scene the component belongs to.
  10780. */
  10781. scene: Scene;
  10782. /**
  10783. * Register the component to one instance of a scene.
  10784. */
  10785. register(): void;
  10786. /**
  10787. * Rebuilds the elements related to this component in case of
  10788. * context lost for instance.
  10789. */
  10790. rebuild(): void;
  10791. /**
  10792. * Disposes the component and the associated ressources.
  10793. */
  10794. dispose(): void;
  10795. }
  10796. /**
  10797. * This represents a SERIALIZABLE scene component.
  10798. *
  10799. * This extends Scene Component to add Serialization methods on top.
  10800. */
  10801. export interface ISceneSerializableComponent extends ISceneComponent {
  10802. /**
  10803. * Adds all the elements from the container to the scene
  10804. * @param container the container holding the elements
  10805. */
  10806. addFromContainer(container: AbstractScene): void;
  10807. /**
  10808. * Removes all the elements in the container from the scene
  10809. * @param container contains the elements to remove
  10810. * @param dispose if the removed element should be disposed (default: false)
  10811. */
  10812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10813. /**
  10814. * Serializes the component data to the specified json object
  10815. * @param serializationObject The object to serialize to
  10816. */
  10817. serialize(serializationObject: any): void;
  10818. }
  10819. /**
  10820. * Strong typing of a Mesh related stage step action
  10821. */
  10822. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10823. /**
  10824. * Strong typing of a Evaluate Sub Mesh related stage step action
  10825. */
  10826. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10827. /**
  10828. * Strong typing of a pre active Mesh related stage step action
  10829. */
  10830. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10831. /**
  10832. * Strong typing of a Camera related stage step action
  10833. */
  10834. export type CameraStageAction = (camera: Camera) => void;
  10835. /**
  10836. * Strong typing of a Camera Frame buffer related stage step action
  10837. */
  10838. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10839. /**
  10840. * Strong typing of a Render Target related stage step action
  10841. */
  10842. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10843. /**
  10844. * Strong typing of a RenderingGroup related stage step action
  10845. */
  10846. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10847. /**
  10848. * Strong typing of a Mesh Render related stage step action
  10849. */
  10850. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10851. /**
  10852. * Strong typing of a simple stage step action
  10853. */
  10854. export type SimpleStageAction = () => void;
  10855. /**
  10856. * Strong typing of a render target action.
  10857. */
  10858. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10859. /**
  10860. * Strong typing of a pointer move action.
  10861. */
  10862. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10863. /**
  10864. * Strong typing of a pointer up/down action.
  10865. */
  10866. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10867. /**
  10868. * Representation of a stage in the scene (Basically a list of ordered steps)
  10869. * @hidden
  10870. */
  10871. export class Stage<T extends Function> extends Array<{
  10872. index: number;
  10873. component: ISceneComponent;
  10874. action: T;
  10875. }> {
  10876. /**
  10877. * Hide ctor from the rest of the world.
  10878. * @param items The items to add.
  10879. */
  10880. private constructor();
  10881. /**
  10882. * Creates a new Stage.
  10883. * @returns A new instance of a Stage
  10884. */
  10885. static Create<T extends Function>(): Stage<T>;
  10886. /**
  10887. * Registers a step in an ordered way in the targeted stage.
  10888. * @param index Defines the position to register the step in
  10889. * @param component Defines the component attached to the step
  10890. * @param action Defines the action to launch during the step
  10891. */
  10892. registerStep(index: number, component: ISceneComponent, action: T): void;
  10893. /**
  10894. * Clears all the steps from the stage.
  10895. */
  10896. clear(): void;
  10897. }
  10898. }
  10899. declare module BABYLON {
  10900. interface Scene {
  10901. /** @hidden */
  10902. _pointerOverSprite: Nullable<Sprite>;
  10903. /** @hidden */
  10904. _pickedDownSprite: Nullable<Sprite>;
  10905. /** @hidden */
  10906. _tempSpritePickingRay: Nullable<Ray>;
  10907. /**
  10908. * All of the sprite managers added to this scene
  10909. * @see https://doc.babylonjs.com/babylon101/sprites
  10910. */
  10911. spriteManagers: Array<ISpriteManager>;
  10912. /**
  10913. * An event triggered when sprites rendering is about to start
  10914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10915. */
  10916. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10917. /**
  10918. * An event triggered when sprites rendering is done
  10919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10920. */
  10921. onAfterSpritesRenderingObservable: Observable<Scene>;
  10922. /** @hidden */
  10923. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10924. /** Launch a ray to try to pick a sprite in the scene
  10925. * @param x position on screen
  10926. * @param y position on screen
  10927. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10928. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10930. * @returns a PickingInfo
  10931. */
  10932. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Use the given ray to pick a sprite in the scene
  10934. * @param ray The ray (in world space) to use to pick meshes
  10935. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10936. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10937. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10938. * @returns a PickingInfo
  10939. */
  10940. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10941. /** @hidden */
  10942. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10943. /** Launch a ray to try to pick sprites in the scene
  10944. * @param x position on screen
  10945. * @param y position on screen
  10946. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10947. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10948. * @returns a PickingInfo array
  10949. */
  10950. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10951. /** Use the given ray to pick sprites in the scene
  10952. * @param ray The ray (in world space) to use to pick meshes
  10953. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10954. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /**
  10959. * Force the sprite under the pointer
  10960. * @param sprite defines the sprite to use
  10961. */
  10962. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10963. /**
  10964. * Gets the sprite under the pointer
  10965. * @returns a Sprite or null if no sprite is under the pointer
  10966. */
  10967. getPointerOverSprite(): Nullable<Sprite>;
  10968. }
  10969. /**
  10970. * Defines the sprite scene component responsible to manage sprites
  10971. * in a given scene.
  10972. */
  10973. export class SpriteSceneComponent implements ISceneComponent {
  10974. /**
  10975. * The component name helpfull to identify the component in the list of scene components.
  10976. */
  10977. readonly name: string;
  10978. /**
  10979. * The scene the component belongs to.
  10980. */
  10981. scene: Scene;
  10982. /** @hidden */
  10983. private _spritePredicate;
  10984. /**
  10985. * Creates a new instance of the component for the given scene
  10986. * @param scene Defines the scene to register the component in
  10987. */
  10988. constructor(scene: Scene);
  10989. /**
  10990. * Registers the component in a given scene
  10991. */
  10992. register(): void;
  10993. /**
  10994. * Rebuilds the elements related to this component in case of
  10995. * context lost for instance.
  10996. */
  10997. rebuild(): void;
  10998. /**
  10999. * Disposes the component and the associated ressources.
  11000. */
  11001. dispose(): void;
  11002. private _pickSpriteButKeepRay;
  11003. private _pointerMove;
  11004. private _pointerDown;
  11005. private _pointerUp;
  11006. }
  11007. }
  11008. declare module BABYLON {
  11009. /** @hidden */
  11010. export var fogFragmentDeclaration: {
  11011. name: string;
  11012. shader: string;
  11013. };
  11014. }
  11015. declare module BABYLON {
  11016. /** @hidden */
  11017. export var fogFragment: {
  11018. name: string;
  11019. shader: string;
  11020. };
  11021. }
  11022. declare module BABYLON {
  11023. /** @hidden */
  11024. export var imageProcessingCompatibility: {
  11025. name: string;
  11026. shader: string;
  11027. };
  11028. }
  11029. declare module BABYLON {
  11030. /** @hidden */
  11031. export var spritesPixelShader: {
  11032. name: string;
  11033. shader: string;
  11034. };
  11035. }
  11036. declare module BABYLON {
  11037. /** @hidden */
  11038. export var fogVertexDeclaration: {
  11039. name: string;
  11040. shader: string;
  11041. };
  11042. }
  11043. declare module BABYLON {
  11044. /** @hidden */
  11045. export var spritesVertexShader: {
  11046. name: string;
  11047. shader: string;
  11048. };
  11049. }
  11050. declare module BABYLON {
  11051. /**
  11052. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11053. */
  11054. export interface ISpriteManager extends IDisposable {
  11055. /**
  11056. * Gets manager's name
  11057. */
  11058. name: string;
  11059. /**
  11060. * Restricts the camera to viewing objects with the same layerMask.
  11061. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11062. */
  11063. layerMask: number;
  11064. /**
  11065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11066. */
  11067. isPickable: boolean;
  11068. /**
  11069. * Gets the hosting scene
  11070. */
  11071. scene: Scene;
  11072. /**
  11073. * Specifies the rendering group id for this mesh (0 by default)
  11074. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11075. */
  11076. renderingGroupId: number;
  11077. /**
  11078. * Defines the list of sprites managed by the manager.
  11079. */
  11080. sprites: Array<Sprite>;
  11081. /**
  11082. * Gets or sets the spritesheet texture
  11083. */
  11084. texture: Texture;
  11085. /** Defines the default width of a cell in the spritesheet */
  11086. cellWidth: number;
  11087. /** Defines the default height of a cell in the spritesheet */
  11088. cellHeight: number;
  11089. /**
  11090. * Tests the intersection of a sprite with a specific ray.
  11091. * @param ray The ray we are sending to test the collision
  11092. * @param camera The camera space we are sending rays in
  11093. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11094. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11095. * @returns picking info or null.
  11096. */
  11097. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11098. /**
  11099. * Intersects the sprites with a ray
  11100. * @param ray defines the ray to intersect with
  11101. * @param camera defines the current active camera
  11102. * @param predicate defines a predicate used to select candidate sprites
  11103. * @returns null if no hit or a PickingInfo array
  11104. */
  11105. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11106. /**
  11107. * Renders the list of sprites on screen.
  11108. */
  11109. render(): void;
  11110. }
  11111. /**
  11112. * Class used to manage multiple sprites on the same spritesheet
  11113. * @see https://doc.babylonjs.com/babylon101/sprites
  11114. */
  11115. export class SpriteManager implements ISpriteManager {
  11116. /** defines the manager's name */
  11117. name: string;
  11118. /** Define the Url to load snippets */
  11119. static SnippetUrl: string;
  11120. /** Snippet ID if the manager was created from the snippet server */
  11121. snippetId: string;
  11122. /** Gets the list of sprites */
  11123. sprites: Sprite[];
  11124. /** Gets or sets the rendering group id (0 by default) */
  11125. renderingGroupId: number;
  11126. /** Gets or sets camera layer mask */
  11127. layerMask: number;
  11128. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11129. fogEnabled: boolean;
  11130. /** Gets or sets a boolean indicating if the sprites are pickable */
  11131. isPickable: boolean;
  11132. /** Defines the default width of a cell in the spritesheet */
  11133. cellWidth: number;
  11134. /** Defines the default height of a cell in the spritesheet */
  11135. cellHeight: number;
  11136. /** Associative array from JSON sprite data file */
  11137. private _cellData;
  11138. /** Array of sprite names from JSON sprite data file */
  11139. private _spriteMap;
  11140. /** True when packed cell data from JSON file is ready*/
  11141. private _packedAndReady;
  11142. private _textureContent;
  11143. private _useInstancing;
  11144. /**
  11145. * An event triggered when the manager is disposed.
  11146. */
  11147. onDisposeObservable: Observable<SpriteManager>;
  11148. private _onDisposeObserver;
  11149. /**
  11150. * Callback called when the manager is disposed
  11151. */
  11152. set onDispose(callback: () => void);
  11153. private _capacity;
  11154. private _fromPacked;
  11155. private _spriteTexture;
  11156. private _epsilon;
  11157. private _scene;
  11158. private _vertexData;
  11159. private _buffer;
  11160. private _vertexBuffers;
  11161. private _spriteBuffer;
  11162. private _indexBuffer;
  11163. private _effectBase;
  11164. private _effectFog;
  11165. private _vertexBufferSize;
  11166. /**
  11167. * Gets or sets the unique id of the sprite
  11168. */
  11169. uniqueId: number;
  11170. /**
  11171. * Gets the array of sprites
  11172. */
  11173. get children(): Sprite[];
  11174. /**
  11175. * Gets the hosting scene
  11176. */
  11177. get scene(): Scene;
  11178. /**
  11179. * Gets the capacity of the manager
  11180. */
  11181. get capacity(): number;
  11182. /**
  11183. * Gets or sets the spritesheet texture
  11184. */
  11185. get texture(): Texture;
  11186. set texture(value: Texture);
  11187. private _blendMode;
  11188. /**
  11189. * Blend mode use to render the particle, it can be any of
  11190. * the static Constants.ALPHA_x properties provided in this class.
  11191. * Default value is Constants.ALPHA_COMBINE
  11192. */
  11193. get blendMode(): number;
  11194. set blendMode(blendMode: number);
  11195. /** Disables writing to the depth buffer when rendering the sprites.
  11196. * It can be handy to disable depth writing when using textures without alpha channel
  11197. * and setting some specific blend modes.
  11198. */
  11199. disableDepthWrite: boolean;
  11200. /**
  11201. * Creates a new sprite manager
  11202. * @param name defines the manager's name
  11203. * @param imgUrl defines the sprite sheet url
  11204. * @param capacity defines the maximum allowed number of sprites
  11205. * @param cellSize defines the size of a sprite cell
  11206. * @param scene defines the hosting scene
  11207. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11208. * @param samplingMode defines the smapling mode to use with spritesheet
  11209. * @param fromPacked set to false; do not alter
  11210. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11211. */
  11212. constructor(
  11213. /** defines the manager's name */
  11214. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11215. /**
  11216. * Returns the string "SpriteManager"
  11217. * @returns "SpriteManager"
  11218. */
  11219. getClassName(): string;
  11220. private _makePacked;
  11221. private _appendSpriteVertex;
  11222. private _checkTextureAlpha;
  11223. /**
  11224. * Intersects the sprites with a ray
  11225. * @param ray defines the ray to intersect with
  11226. * @param camera defines the current active camera
  11227. * @param predicate defines a predicate used to select candidate sprites
  11228. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11229. * @returns null if no hit or a PickingInfo
  11230. */
  11231. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11232. /**
  11233. * Intersects the sprites with a ray
  11234. * @param ray defines the ray to intersect with
  11235. * @param camera defines the current active camera
  11236. * @param predicate defines a predicate used to select candidate sprites
  11237. * @returns null if no hit or a PickingInfo array
  11238. */
  11239. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11240. /**
  11241. * Render all child sprites
  11242. */
  11243. render(): void;
  11244. /**
  11245. * Release associated resources
  11246. */
  11247. dispose(): void;
  11248. /**
  11249. * Serializes the sprite manager to a JSON object
  11250. * @param serializeTexture defines if the texture must be serialized as well
  11251. * @returns the JSON object
  11252. */
  11253. serialize(serializeTexture?: boolean): any;
  11254. /**
  11255. * Parses a JSON object to create a new sprite manager.
  11256. * @param parsedManager The JSON object to parse
  11257. * @param scene The scene to create the sprite managerin
  11258. * @param rootUrl The root url to use to load external dependencies like texture
  11259. * @returns the new sprite manager
  11260. */
  11261. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11262. /**
  11263. * Creates a sprite manager from a snippet saved in a remote file
  11264. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11265. * @param url defines the url to load from
  11266. * @param scene defines the hosting scene
  11267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11268. * @returns a promise that will resolve to the new sprite manager
  11269. */
  11270. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11271. /**
  11272. * Creates a sprite manager from a snippet saved by the sprite editor
  11273. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11274. * @param scene defines the hosting scene
  11275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11276. * @returns a promise that will resolve to the new sprite manager
  11277. */
  11278. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11279. }
  11280. }
  11281. declare module BABYLON {
  11282. /** Interface used by value gradients (color, factor, ...) */
  11283. export interface IValueGradient {
  11284. /**
  11285. * Gets or sets the gradient value (between 0 and 1)
  11286. */
  11287. gradient: number;
  11288. }
  11289. /** Class used to store color4 gradient */
  11290. export class ColorGradient implements IValueGradient {
  11291. /**
  11292. * Gets or sets the gradient value (between 0 and 1)
  11293. */
  11294. gradient: number;
  11295. /**
  11296. * Gets or sets first associated color
  11297. */
  11298. color1: Color4;
  11299. /**
  11300. * Gets or sets second associated color
  11301. */
  11302. color2?: Color4 | undefined;
  11303. /**
  11304. * Creates a new color4 gradient
  11305. * @param gradient gets or sets the gradient value (between 0 and 1)
  11306. * @param color1 gets or sets first associated color
  11307. * @param color2 gets or sets first second color
  11308. */
  11309. constructor(
  11310. /**
  11311. * Gets or sets the gradient value (between 0 and 1)
  11312. */
  11313. gradient: number,
  11314. /**
  11315. * Gets or sets first associated color
  11316. */
  11317. color1: Color4,
  11318. /**
  11319. * Gets or sets second associated color
  11320. */
  11321. color2?: Color4 | undefined);
  11322. /**
  11323. * Will get a color picked randomly between color1 and color2.
  11324. * If color2 is undefined then color1 will be used
  11325. * @param result defines the target Color4 to store the result in
  11326. */
  11327. getColorToRef(result: Color4): void;
  11328. }
  11329. /** Class used to store color 3 gradient */
  11330. export class Color3Gradient implements IValueGradient {
  11331. /**
  11332. * Gets or sets the gradient value (between 0 and 1)
  11333. */
  11334. gradient: number;
  11335. /**
  11336. * Gets or sets the associated color
  11337. */
  11338. color: Color3;
  11339. /**
  11340. * Creates a new color3 gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param color gets or sets associated color
  11343. */
  11344. constructor(
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number,
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3);
  11353. }
  11354. /** Class used to store factor gradient */
  11355. export class FactorGradient implements IValueGradient {
  11356. /**
  11357. * Gets or sets the gradient value (between 0 and 1)
  11358. */
  11359. gradient: number;
  11360. /**
  11361. * Gets or sets first associated factor
  11362. */
  11363. factor1: number;
  11364. /**
  11365. * Gets or sets second associated factor
  11366. */
  11367. factor2?: number | undefined;
  11368. /**
  11369. * Creates a new factor gradient
  11370. * @param gradient gets or sets the gradient value (between 0 and 1)
  11371. * @param factor1 gets or sets first associated factor
  11372. * @param factor2 gets or sets second associated factor
  11373. */
  11374. constructor(
  11375. /**
  11376. * Gets or sets the gradient value (between 0 and 1)
  11377. */
  11378. gradient: number,
  11379. /**
  11380. * Gets or sets first associated factor
  11381. */
  11382. factor1: number,
  11383. /**
  11384. * Gets or sets second associated factor
  11385. */
  11386. factor2?: number | undefined);
  11387. /**
  11388. * Will get a number picked randomly between factor1 and factor2.
  11389. * If factor2 is undefined then factor1 will be used
  11390. * @returns the picked number
  11391. */
  11392. getFactor(): number;
  11393. }
  11394. /**
  11395. * Helper used to simplify some generic gradient tasks
  11396. */
  11397. export class GradientHelper {
  11398. /**
  11399. * Gets the current gradient from an array of IValueGradient
  11400. * @param ratio defines the current ratio to get
  11401. * @param gradients defines the array of IValueGradient
  11402. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11403. */
  11404. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11405. }
  11406. }
  11407. declare module BABYLON {
  11408. interface ThinEngine {
  11409. /**
  11410. * Creates a raw texture
  11411. * @param data defines the data to store in the texture
  11412. * @param width defines the width of the texture
  11413. * @param height defines the height of the texture
  11414. * @param format defines the format of the data
  11415. * @param generateMipMaps defines if the engine should generate the mip levels
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11418. * @param compression defines the compression used (null by default)
  11419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11420. * @returns the raw texture inside an InternalTexture
  11421. */
  11422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11423. /**
  11424. * Update a raw texture
  11425. * @param texture defines the texture to update
  11426. * @param data defines the data to store in the texture
  11427. * @param format defines the format of the data
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. */
  11430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11431. /**
  11432. * Update a raw texture
  11433. * @param texture defines the texture to update
  11434. * @param data defines the data to store in the texture
  11435. * @param format defines the format of the data
  11436. * @param invertY defines if data must be stored with Y axis inverted
  11437. * @param compression defines the compression used (null by default)
  11438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11439. */
  11440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11441. /**
  11442. * Creates a new raw cube texture
  11443. * @param data defines the array of data to use to create each face
  11444. * @param size defines the size of the textures
  11445. * @param format defines the format of the data
  11446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11447. * @param generateMipMaps defines if the engine should generate the mip levels
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11450. * @param compression defines the compression used (null by default)
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11454. /**
  11455. * Update a raw cube texture
  11456. * @param texture defines the texture to udpdate
  11457. * @param data defines the data to store
  11458. * @param format defines the data format
  11459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. */
  11462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11463. /**
  11464. * Update a raw cube texture
  11465. * @param texture defines the texture to udpdate
  11466. * @param data defines the data to store
  11467. * @param format defines the data format
  11468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11469. * @param invertY defines if data must be stored with Y axis inverted
  11470. * @param compression defines the compression used (null by default)
  11471. */
  11472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11473. /**
  11474. * Update a raw cube texture
  11475. * @param texture defines the texture to udpdate
  11476. * @param data defines the data to store
  11477. * @param format defines the data format
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. * @param invertY defines if data must be stored with Y axis inverted
  11480. * @param compression defines the compression used (null by default)
  11481. * @param level defines which level of the texture to update
  11482. */
  11483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11484. /**
  11485. * Creates a new raw cube texture from a specified url
  11486. * @param url defines the url where the data is located
  11487. * @param scene defines the current scene
  11488. * @param size defines the size of the textures
  11489. * @param format defines the format of the data
  11490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11491. * @param noMipmap defines if the engine should avoid generating the mip levels
  11492. * @param callback defines a callback used to extract texture data from loaded data
  11493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11494. * @param onLoad defines a callback called when texture is loaded
  11495. * @param onError defines a callback called if there is an error
  11496. * @returns the cube texture as an InternalTexture
  11497. */
  11498. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11499. /**
  11500. * Creates a new raw cube texture from a specified url
  11501. * @param url defines the url where the data is located
  11502. * @param scene defines the current scene
  11503. * @param size defines the size of the textures
  11504. * @param format defines the format of the data
  11505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11506. * @param noMipmap defines if the engine should avoid generating the mip levels
  11507. * @param callback defines a callback used to extract texture data from loaded data
  11508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11509. * @param onLoad defines a callback called when texture is loaded
  11510. * @param onError defines a callback called if there is an error
  11511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11516. /**
  11517. * Creates a new raw 3D texture
  11518. * @param data defines the data used to create the texture
  11519. * @param width defines the width of the texture
  11520. * @param height defines the height of the texture
  11521. * @param depth defines the depth of the texture
  11522. * @param format defines the format of the texture
  11523. * @param generateMipMaps defines if the engine must generate mip levels
  11524. * @param invertY defines if data must be stored with Y axis inverted
  11525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11526. * @param compression defines the compressed used (can be null)
  11527. * @param textureType defines the compressed used (can be null)
  11528. * @returns a new raw 3D texture (stored in an InternalTexture)
  11529. */
  11530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11531. /**
  11532. * Update a raw 3D texture
  11533. * @param texture defines the texture to update
  11534. * @param data defines the data to store
  11535. * @param format defines the data format
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. */
  11538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11539. /**
  11540. * Update a raw 3D texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store
  11543. * @param format defines the data format
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. * @param compression defines the used compression (can be null)
  11546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11547. */
  11548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11549. /**
  11550. * Creates a new raw 2D array texture
  11551. * @param data defines the data used to create the texture
  11552. * @param width defines the width of the texture
  11553. * @param height defines the height of the texture
  11554. * @param depth defines the number of layers of the texture
  11555. * @param format defines the format of the texture
  11556. * @param generateMipMaps defines if the engine must generate mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11559. * @param compression defines the compressed used (can be null)
  11560. * @param textureType defines the compressed used (can be null)
  11561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11562. */
  11563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11564. /**
  11565. * Update a raw 2D array texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store
  11568. * @param format defines the data format
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw 2D array texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store
  11576. * @param format defines the data format
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the used compression (can be null)
  11579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11580. */
  11581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11582. }
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * Raw texture can help creating a texture directly from an array of data.
  11587. * This can be super useful if you either get the data from an uncompressed source or
  11588. * if you wish to create your texture pixel by pixel.
  11589. */
  11590. export class RawTexture extends Texture {
  11591. /**
  11592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11593. */
  11594. format: number;
  11595. /**
  11596. * Instantiates a new RawTexture.
  11597. * Raw texture can help creating a texture directly from an array of data.
  11598. * This can be super useful if you either get the data from an uncompressed source or
  11599. * if you wish to create your texture pixel by pixel.
  11600. * @param data define the array of data to use to create the texture
  11601. * @param width define the width of the texture
  11602. * @param height define the height of the texture
  11603. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11604. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11605. * @param generateMipMaps define whether mip maps should be generated or not
  11606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11608. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11609. */
  11610. constructor(data: ArrayBufferView, width: number, height: number,
  11611. /**
  11612. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11613. */
  11614. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11615. /**
  11616. * Updates the texture underlying data.
  11617. * @param data Define the new data of the texture
  11618. */
  11619. update(data: ArrayBufferView): void;
  11620. /**
  11621. * Creates a luminance texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @returns the luminance texture
  11630. */
  11631. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11632. /**
  11633. * Creates a luminance alpha texture from some data.
  11634. * @param data Define the texture data
  11635. * @param width Define the width of the texture
  11636. * @param height Define the height of the texture
  11637. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11641. * @returns the luminance alpha texture
  11642. */
  11643. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11644. /**
  11645. * Creates an alpha texture from some data.
  11646. * @param data Define the texture data
  11647. * @param width Define the width of the texture
  11648. * @param height Define the height of the texture
  11649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11653. * @returns the alpha texture
  11654. */
  11655. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11656. /**
  11657. * Creates a RGB texture from some data.
  11658. * @param data Define the texture data
  11659. * @param width Define the width of the texture
  11660. * @param height Define the height of the texture
  11661. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11666. * @returns the RGB alpha texture
  11667. */
  11668. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11669. /**
  11670. * Creates a RGBA texture from some data.
  11671. * @param data Define the texture data
  11672. * @param width Define the width of the texture
  11673. * @param height Define the height of the texture
  11674. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11675. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11679. * @returns the RGBA texture
  11680. */
  11681. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11682. /**
  11683. * Creates a R texture from some data.
  11684. * @param data Define the texture data
  11685. * @param width Define the width of the texture
  11686. * @param height Define the height of the texture
  11687. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11691. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11692. * @returns the R texture
  11693. */
  11694. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11695. }
  11696. }
  11697. declare module BABYLON {
  11698. interface ThinEngine {
  11699. /**
  11700. * Update a dynamic index buffer
  11701. * @param indexBuffer defines the target index buffer
  11702. * @param indices defines the data to update
  11703. * @param offset defines the offset in the target index buffer where update should start
  11704. */
  11705. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11706. /**
  11707. * Updates a dynamic vertex buffer.
  11708. * @param vertexBuffer the vertex buffer to update
  11709. * @param data the data used to update the vertex buffer
  11710. * @param byteOffset the byte offset of the data
  11711. * @param byteLength the byte length of the data
  11712. */
  11713. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11714. }
  11715. }
  11716. declare module BABYLON {
  11717. interface AbstractScene {
  11718. /**
  11719. * The list of procedural textures added to the scene
  11720. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11721. */
  11722. proceduralTextures: Array<ProceduralTexture>;
  11723. }
  11724. /**
  11725. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11726. * in a given scene.
  11727. */
  11728. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11729. /**
  11730. * The component name helpfull to identify the component in the list of scene components.
  11731. */
  11732. readonly name: string;
  11733. /**
  11734. * The scene the component belongs to.
  11735. */
  11736. scene: Scene;
  11737. /**
  11738. * Creates a new instance of the component for the given scene
  11739. * @param scene Defines the scene to register the component in
  11740. */
  11741. constructor(scene: Scene);
  11742. /**
  11743. * Registers the component in a given scene
  11744. */
  11745. register(): void;
  11746. /**
  11747. * Rebuilds the elements related to this component in case of
  11748. * context lost for instance.
  11749. */
  11750. rebuild(): void;
  11751. /**
  11752. * Disposes the component and the associated ressources.
  11753. */
  11754. dispose(): void;
  11755. private _beforeClear;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. interface ThinEngine {
  11760. /**
  11761. * Creates a new render target cube texture
  11762. * @param size defines the size of the texture
  11763. * @param options defines the options used to create the texture
  11764. * @returns a new render target cube texture stored in an InternalTexture
  11765. */
  11766. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11767. }
  11768. }
  11769. declare module BABYLON {
  11770. /** @hidden */
  11771. export var proceduralVertexShader: {
  11772. name: string;
  11773. shader: string;
  11774. };
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11779. * This is the base class of any Procedural texture and contains most of the shareable code.
  11780. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11781. */
  11782. export class ProceduralTexture extends Texture {
  11783. /**
  11784. * Define if the texture is enabled or not (disabled texture will not render)
  11785. */
  11786. isEnabled: boolean;
  11787. /**
  11788. * Define if the texture must be cleared before rendering (default is true)
  11789. */
  11790. autoClear: boolean;
  11791. /**
  11792. * Callback called when the texture is generated
  11793. */
  11794. onGenerated: () => void;
  11795. /**
  11796. * Event raised when the texture is generated
  11797. */
  11798. onGeneratedObservable: Observable<ProceduralTexture>;
  11799. /**
  11800. * Event raised before the texture is generated
  11801. */
  11802. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11803. /**
  11804. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11805. */
  11806. nodeMaterialSource: Nullable<NodeMaterial>;
  11807. /** @hidden */
  11808. _generateMipMaps: boolean;
  11809. /** @hidden **/
  11810. _effect: Effect;
  11811. /** @hidden */
  11812. _textures: {
  11813. [key: string]: Texture;
  11814. };
  11815. /** @hidden */
  11816. protected _fallbackTexture: Nullable<Texture>;
  11817. private _size;
  11818. private _currentRefreshId;
  11819. private _frameId;
  11820. private _refreshRate;
  11821. private _vertexBuffers;
  11822. private _indexBuffer;
  11823. private _uniforms;
  11824. private _samplers;
  11825. private _fragment;
  11826. private _floats;
  11827. private _ints;
  11828. private _floatsArrays;
  11829. private _colors3;
  11830. private _colors4;
  11831. private _vectors2;
  11832. private _vectors3;
  11833. private _matrices;
  11834. private _fallbackTextureUsed;
  11835. private _fullEngine;
  11836. private _cachedDefines;
  11837. private _contentUpdateId;
  11838. private _contentData;
  11839. /**
  11840. * Instantiates a new procedural texture.
  11841. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11842. * This is the base class of any Procedural texture and contains most of the shareable code.
  11843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11844. * @param name Define the name of the texture
  11845. * @param size Define the size of the texture to create
  11846. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11847. * @param scene Define the scene the texture belongs to
  11848. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11849. * @param generateMipMaps Define if the texture should creates mip maps or not
  11850. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11851. * @param textureType The FBO internal texture type
  11852. */
  11853. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11854. /**
  11855. * The effect that is created when initializing the post process.
  11856. * @returns The created effect corresponding the the postprocess.
  11857. */
  11858. getEffect(): Effect;
  11859. /**
  11860. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11861. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11862. */
  11863. getContent(): Nullable<ArrayBufferView>;
  11864. private _createIndexBuffer;
  11865. /** @hidden */
  11866. _rebuild(): void;
  11867. /**
  11868. * Resets the texture in order to recreate its associated resources.
  11869. * This can be called in case of context loss
  11870. */
  11871. reset(): void;
  11872. protected _getDefines(): string;
  11873. /**
  11874. * Is the texture ready to be used ? (rendered at least once)
  11875. * @returns true if ready, otherwise, false.
  11876. */
  11877. isReady(): boolean;
  11878. /**
  11879. * Resets the refresh counter of the texture and start bak from scratch.
  11880. * Could be useful to regenerate the texture if it is setup to render only once.
  11881. */
  11882. resetRefreshCounter(): void;
  11883. /**
  11884. * Set the fragment shader to use in order to render the texture.
  11885. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11886. */
  11887. setFragment(fragment: any): void;
  11888. /**
  11889. * Define the refresh rate of the texture or the rendering frequency.
  11890. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11891. */
  11892. get refreshRate(): number;
  11893. set refreshRate(value: number);
  11894. /** @hidden */
  11895. _shouldRender(): boolean;
  11896. /**
  11897. * Get the size the texture is rendering at.
  11898. * @returns the size (on cube texture it is always squared)
  11899. */
  11900. getRenderSize(): RenderTargetTextureSize;
  11901. /**
  11902. * Resize the texture to new value.
  11903. * @param size Define the new size the texture should have
  11904. * @param generateMipMaps Define whether the new texture should create mip maps
  11905. */
  11906. resize(size: number, generateMipMaps: boolean): void;
  11907. private _checkUniform;
  11908. /**
  11909. * Set a texture in the shader program used to render.
  11910. * @param name Define the name of the uniform samplers as defined in the shader
  11911. * @param texture Define the texture to bind to this sampler
  11912. * @return the texture itself allowing "fluent" like uniform updates
  11913. */
  11914. setTexture(name: string, texture: Texture): ProceduralTexture;
  11915. /**
  11916. * Set a float in the shader.
  11917. * @param name Define the name of the uniform as defined in the shader
  11918. * @param value Define the value to give to the uniform
  11919. * @return the texture itself allowing "fluent" like uniform updates
  11920. */
  11921. setFloat(name: string, value: number): ProceduralTexture;
  11922. /**
  11923. * Set a int in the shader.
  11924. * @param name Define the name of the uniform as defined in the shader
  11925. * @param value Define the value to give to the uniform
  11926. * @return the texture itself allowing "fluent" like uniform updates
  11927. */
  11928. setInt(name: string, value: number): ProceduralTexture;
  11929. /**
  11930. * Set an array of floats in the shader.
  11931. * @param name Define the name of the uniform as defined in the shader
  11932. * @param value Define the value to give to the uniform
  11933. * @return the texture itself allowing "fluent" like uniform updates
  11934. */
  11935. setFloats(name: string, value: number[]): ProceduralTexture;
  11936. /**
  11937. * Set a vec3 in the shader from a Color3.
  11938. * @param name Define the name of the uniform as defined in the shader
  11939. * @param value Define the value to give to the uniform
  11940. * @return the texture itself allowing "fluent" like uniform updates
  11941. */
  11942. setColor3(name: string, value: Color3): ProceduralTexture;
  11943. /**
  11944. * Set a vec4 in the shader from a Color4.
  11945. * @param name Define the name of the uniform as defined in the shader
  11946. * @param value Define the value to give to the uniform
  11947. * @return the texture itself allowing "fluent" like uniform updates
  11948. */
  11949. setColor4(name: string, value: Color4): ProceduralTexture;
  11950. /**
  11951. * Set a vec2 in the shader from a Vector2.
  11952. * @param name Define the name of the uniform as defined in the shader
  11953. * @param value Define the value to give to the uniform
  11954. * @return the texture itself allowing "fluent" like uniform updates
  11955. */
  11956. setVector2(name: string, value: Vector2): ProceduralTexture;
  11957. /**
  11958. * Set a vec3 in the shader from a Vector3.
  11959. * @param name Define the name of the uniform as defined in the shader
  11960. * @param value Define the value to give to the uniform
  11961. * @return the texture itself allowing "fluent" like uniform updates
  11962. */
  11963. setVector3(name: string, value: Vector3): ProceduralTexture;
  11964. /**
  11965. * Set a mat4 in the shader from a MAtrix.
  11966. * @param name Define the name of the uniform as defined in the shader
  11967. * @param value Define the value to give to the uniform
  11968. * @return the texture itself allowing "fluent" like uniform updates
  11969. */
  11970. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11971. /**
  11972. * Render the texture to its associated render target.
  11973. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11974. */
  11975. render(useCameraPostProcess?: boolean): void;
  11976. /**
  11977. * Clone the texture.
  11978. * @returns the cloned texture
  11979. */
  11980. clone(): ProceduralTexture;
  11981. /**
  11982. * Dispose the texture and release its asoociated resources.
  11983. */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module BABYLON {
  11988. /**
  11989. * This represents the base class for particle system in Babylon.
  11990. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11991. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11992. * @example https://doc.babylonjs.com/babylon101/particles
  11993. */
  11994. export class BaseParticleSystem {
  11995. /**
  11996. * Source color is added to the destination color without alpha affecting the result
  11997. */
  11998. static BLENDMODE_ONEONE: number;
  11999. /**
  12000. * Blend current color and particle color using particle’s alpha
  12001. */
  12002. static BLENDMODE_STANDARD: number;
  12003. /**
  12004. * Add current color and particle color multiplied by particle’s alpha
  12005. */
  12006. static BLENDMODE_ADD: number;
  12007. /**
  12008. * Multiply current color with particle color
  12009. */
  12010. static BLENDMODE_MULTIPLY: number;
  12011. /**
  12012. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12013. */
  12014. static BLENDMODE_MULTIPLYADD: number;
  12015. /**
  12016. * List of animations used by the particle system.
  12017. */
  12018. animations: Animation[];
  12019. /**
  12020. * Gets or sets the unique id of the particle system
  12021. */
  12022. uniqueId: number;
  12023. /**
  12024. * The id of the Particle system.
  12025. */
  12026. id: string;
  12027. /**
  12028. * The friendly name of the Particle system.
  12029. */
  12030. name: string;
  12031. /**
  12032. * Snippet ID if the particle system was created from the snippet server
  12033. */
  12034. snippetId: string;
  12035. /**
  12036. * The rendering group used by the Particle system to chose when to render.
  12037. */
  12038. renderingGroupId: number;
  12039. /**
  12040. * The emitter represents the Mesh or position we are attaching the particle system to.
  12041. */
  12042. emitter: Nullable<AbstractMesh | Vector3>;
  12043. /**
  12044. * The maximum number of particles to emit per frame
  12045. */
  12046. emitRate: number;
  12047. /**
  12048. * If you want to launch only a few particles at once, that can be done, as well.
  12049. */
  12050. manualEmitCount: number;
  12051. /**
  12052. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12053. */
  12054. updateSpeed: number;
  12055. /**
  12056. * The amount of time the particle system is running (depends of the overall update speed).
  12057. */
  12058. targetStopDuration: number;
  12059. /**
  12060. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12061. */
  12062. disposeOnStop: boolean;
  12063. /**
  12064. * Minimum power of emitting particles.
  12065. */
  12066. minEmitPower: number;
  12067. /**
  12068. * Maximum power of emitting particles.
  12069. */
  12070. maxEmitPower: number;
  12071. /**
  12072. * Minimum life time of emitting particles.
  12073. */
  12074. minLifeTime: number;
  12075. /**
  12076. * Maximum life time of emitting particles.
  12077. */
  12078. maxLifeTime: number;
  12079. /**
  12080. * Minimum Size of emitting particles.
  12081. */
  12082. minSize: number;
  12083. /**
  12084. * Maximum Size of emitting particles.
  12085. */
  12086. maxSize: number;
  12087. /**
  12088. * Minimum scale of emitting particles on X axis.
  12089. */
  12090. minScaleX: number;
  12091. /**
  12092. * Maximum scale of emitting particles on X axis.
  12093. */
  12094. maxScaleX: number;
  12095. /**
  12096. * Minimum scale of emitting particles on Y axis.
  12097. */
  12098. minScaleY: number;
  12099. /**
  12100. * Maximum scale of emitting particles on Y axis.
  12101. */
  12102. maxScaleY: number;
  12103. /**
  12104. * Gets or sets the minimal initial rotation in radians.
  12105. */
  12106. minInitialRotation: number;
  12107. /**
  12108. * Gets or sets the maximal initial rotation in radians.
  12109. */
  12110. maxInitialRotation: number;
  12111. /**
  12112. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12113. */
  12114. minAngularSpeed: number;
  12115. /**
  12116. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12117. */
  12118. maxAngularSpeed: number;
  12119. /**
  12120. * The texture used to render each particle. (this can be a spritesheet)
  12121. */
  12122. particleTexture: Nullable<BaseTexture>;
  12123. /**
  12124. * The layer mask we are rendering the particles through.
  12125. */
  12126. layerMask: number;
  12127. /**
  12128. * This can help using your own shader to render the particle system.
  12129. * The according effect will be created
  12130. */
  12131. customShader: any;
  12132. /**
  12133. * By default particle system starts as soon as they are created. This prevents the
  12134. * automatic start to happen and let you decide when to start emitting particles.
  12135. */
  12136. preventAutoStart: boolean;
  12137. private _noiseTexture;
  12138. /**
  12139. * Gets or sets a texture used to add random noise to particle positions
  12140. */
  12141. get noiseTexture(): Nullable<ProceduralTexture>;
  12142. set noiseTexture(value: Nullable<ProceduralTexture>);
  12143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12144. noiseStrength: Vector3;
  12145. /**
  12146. * Callback triggered when the particle animation is ending.
  12147. */
  12148. onAnimationEnd: Nullable<() => void>;
  12149. /**
  12150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12151. */
  12152. blendMode: number;
  12153. /**
  12154. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12155. * to override the particles.
  12156. */
  12157. forceDepthWrite: boolean;
  12158. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12159. preWarmCycles: number;
  12160. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12161. preWarmStepOffset: number;
  12162. /**
  12163. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12164. */
  12165. spriteCellChangeSpeed: number;
  12166. /**
  12167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12168. */
  12169. startSpriteCellID: number;
  12170. /**
  12171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12172. */
  12173. endSpriteCellID: number;
  12174. /**
  12175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12176. */
  12177. spriteCellWidth: number;
  12178. /**
  12179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12180. */
  12181. spriteCellHeight: number;
  12182. /**
  12183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12184. */
  12185. spriteRandomStartCell: boolean;
  12186. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12187. translationPivot: Vector2;
  12188. /** @hidden */
  12189. protected _isAnimationSheetEnabled: boolean;
  12190. /**
  12191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12192. */
  12193. beginAnimationOnStart: boolean;
  12194. /**
  12195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12196. */
  12197. beginAnimationFrom: number;
  12198. /**
  12199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12200. */
  12201. beginAnimationTo: number;
  12202. /**
  12203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12204. */
  12205. beginAnimationLoop: boolean;
  12206. /**
  12207. * Gets or sets a world offset applied to all particles
  12208. */
  12209. worldOffset: Vector3;
  12210. /**
  12211. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12212. */
  12213. get isAnimationSheetEnabled(): boolean;
  12214. set isAnimationSheetEnabled(value: boolean);
  12215. /**
  12216. * Get hosting scene
  12217. * @returns the scene
  12218. */
  12219. getScene(): Nullable<Scene>;
  12220. /**
  12221. * You can use gravity if you want to give an orientation to your particles.
  12222. */
  12223. gravity: Vector3;
  12224. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12225. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12226. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12227. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12228. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12229. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12230. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12231. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12232. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12233. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12234. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12235. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12236. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12237. /**
  12238. * Defines the delay in milliseconds before starting the system (0 by default)
  12239. */
  12240. startDelay: number;
  12241. /**
  12242. * Gets the current list of drag gradients.
  12243. * You must use addDragGradient and removeDragGradient to udpate this list
  12244. * @returns the list of drag gradients
  12245. */
  12246. getDragGradients(): Nullable<Array<FactorGradient>>;
  12247. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12248. limitVelocityDamping: number;
  12249. /**
  12250. * Gets the current list of limit velocity gradients.
  12251. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12252. * @returns the list of limit velocity gradients
  12253. */
  12254. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12255. /**
  12256. * Gets the current list of color gradients.
  12257. * You must use addColorGradient and removeColorGradient to udpate this list
  12258. * @returns the list of color gradients
  12259. */
  12260. getColorGradients(): Nullable<Array<ColorGradient>>;
  12261. /**
  12262. * Gets the current list of size gradients.
  12263. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12264. * @returns the list of size gradients
  12265. */
  12266. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12267. /**
  12268. * Gets the current list of color remap gradients.
  12269. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12270. * @returns the list of color remap gradients
  12271. */
  12272. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12273. /**
  12274. * Gets the current list of alpha remap gradients.
  12275. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12276. * @returns the list of alpha remap gradients
  12277. */
  12278. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12279. /**
  12280. * Gets the current list of life time gradients.
  12281. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12282. * @returns the list of life time gradients
  12283. */
  12284. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12285. /**
  12286. * Gets the current list of angular speed gradients.
  12287. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12288. * @returns the list of angular speed gradients
  12289. */
  12290. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12291. /**
  12292. * Gets the current list of velocity gradients.
  12293. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12294. * @returns the list of velocity gradients
  12295. */
  12296. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12297. /**
  12298. * Gets the current list of start size gradients.
  12299. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12300. * @returns the list of start size gradients
  12301. */
  12302. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12303. /**
  12304. * Gets the current list of emit rate gradients.
  12305. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12306. * @returns the list of emit rate gradients
  12307. */
  12308. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12309. /**
  12310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12311. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12312. */
  12313. get direction1(): Vector3;
  12314. set direction1(value: Vector3);
  12315. /**
  12316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12318. */
  12319. get direction2(): Vector3;
  12320. set direction2(value: Vector3);
  12321. /**
  12322. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12324. */
  12325. get minEmitBox(): Vector3;
  12326. set minEmitBox(value: Vector3);
  12327. /**
  12328. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12329. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12330. */
  12331. get maxEmitBox(): Vector3;
  12332. set maxEmitBox(value: Vector3);
  12333. /**
  12334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12335. */
  12336. color1: Color4;
  12337. /**
  12338. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12339. */
  12340. color2: Color4;
  12341. /**
  12342. * Color the particle will have at the end of its lifetime
  12343. */
  12344. colorDead: Color4;
  12345. /**
  12346. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12347. */
  12348. textureMask: Color4;
  12349. /**
  12350. * The particle emitter type defines the emitter used by the particle system.
  12351. * It can be for example box, sphere, or cone...
  12352. */
  12353. particleEmitterType: IParticleEmitterType;
  12354. /** @hidden */
  12355. _isSubEmitter: boolean;
  12356. /**
  12357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12359. */
  12360. billboardMode: number;
  12361. protected _isBillboardBased: boolean;
  12362. /**
  12363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12364. */
  12365. get isBillboardBased(): boolean;
  12366. set isBillboardBased(value: boolean);
  12367. /**
  12368. * The scene the particle system belongs to.
  12369. */
  12370. protected _scene: Nullable<Scene>;
  12371. /**
  12372. * The engine the particle system belongs to.
  12373. */
  12374. protected _engine: ThinEngine;
  12375. /**
  12376. * Local cache of defines for image processing.
  12377. */
  12378. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12379. /**
  12380. * Default configuration related to image processing available in the standard Material.
  12381. */
  12382. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12383. /**
  12384. * Gets the image processing configuration used either in this material.
  12385. */
  12386. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12387. /**
  12388. * Sets the Default image processing configuration used either in the this material.
  12389. *
  12390. * If sets to null, the scene one is in use.
  12391. */
  12392. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12393. /**
  12394. * Attaches a new image processing configuration to the Standard Material.
  12395. * @param configuration
  12396. */
  12397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12398. /** @hidden */
  12399. protected _reset(): void;
  12400. /** @hidden */
  12401. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12402. /**
  12403. * Instantiates a particle system.
  12404. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12405. * @param name The name of the particle system
  12406. */
  12407. constructor(name: string);
  12408. /**
  12409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12412. * @returns the emitter
  12413. */
  12414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12415. /**
  12416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12417. * @param radius The radius of the hemisphere to emit from
  12418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12419. * @returns the emitter
  12420. */
  12421. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12422. /**
  12423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12424. * @param radius The radius of the sphere to emit from
  12425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12426. * @returns the emitter
  12427. */
  12428. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12429. /**
  12430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12431. * @param radius The radius of the sphere to emit from
  12432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12434. * @returns the emitter
  12435. */
  12436. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12437. /**
  12438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12439. * @param radius The radius of the emission cylinder
  12440. * @param height The height of the emission cylinder
  12441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12443. * @returns the emitter
  12444. */
  12445. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12446. /**
  12447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12448. * @param radius The radius of the cylinder to emit from
  12449. * @param height The height of the emission cylinder
  12450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12453. * @returns the emitter
  12454. */
  12455. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12456. /**
  12457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12458. * @param radius The radius of the cone to emit from
  12459. * @param angle The base angle of the cone
  12460. * @returns the emitter
  12461. */
  12462. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12463. /**
  12464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12469. * @returns the emitter
  12470. */
  12471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12472. }
  12473. }
  12474. declare module BABYLON {
  12475. /**
  12476. * Type of sub emitter
  12477. */
  12478. export enum SubEmitterType {
  12479. /**
  12480. * Attached to the particle over it's lifetime
  12481. */
  12482. ATTACHED = 0,
  12483. /**
  12484. * Created when the particle dies
  12485. */
  12486. END = 1
  12487. }
  12488. /**
  12489. * Sub emitter class used to emit particles from an existing particle
  12490. */
  12491. export class SubEmitter {
  12492. /**
  12493. * the particle system to be used by the sub emitter
  12494. */
  12495. particleSystem: ParticleSystem;
  12496. /**
  12497. * Type of the submitter (Default: END)
  12498. */
  12499. type: SubEmitterType;
  12500. /**
  12501. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12502. * Note: This only is supported when using an emitter of type Mesh
  12503. */
  12504. inheritDirection: boolean;
  12505. /**
  12506. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12507. */
  12508. inheritedVelocityAmount: number;
  12509. /**
  12510. * Creates a sub emitter
  12511. * @param particleSystem the particle system to be used by the sub emitter
  12512. */
  12513. constructor(
  12514. /**
  12515. * the particle system to be used by the sub emitter
  12516. */
  12517. particleSystem: ParticleSystem);
  12518. /**
  12519. * Clones the sub emitter
  12520. * @returns the cloned sub emitter
  12521. */
  12522. clone(): SubEmitter;
  12523. /**
  12524. * Serialize current object to a JSON object
  12525. * @returns the serialized object
  12526. */
  12527. serialize(): any;
  12528. /** @hidden */
  12529. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12530. /**
  12531. * Creates a new SubEmitter from a serialized JSON version
  12532. * @param serializationObject defines the JSON object to read from
  12533. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12534. * @param rootUrl defines the rootUrl for data loading
  12535. * @returns a new SubEmitter
  12536. */
  12537. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12538. /** Release associated resources */
  12539. dispose(): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /** @hidden */
  12544. export var imageProcessingDeclaration: {
  12545. name: string;
  12546. shader: string;
  12547. };
  12548. }
  12549. declare module BABYLON {
  12550. /** @hidden */
  12551. export var imageProcessingFunctions: {
  12552. name: string;
  12553. shader: string;
  12554. };
  12555. }
  12556. declare module BABYLON {
  12557. /** @hidden */
  12558. export var particlesPixelShader: {
  12559. name: string;
  12560. shader: string;
  12561. };
  12562. }
  12563. declare module BABYLON {
  12564. /** @hidden */
  12565. export var particlesVertexShader: {
  12566. name: string;
  12567. shader: string;
  12568. };
  12569. }
  12570. declare module BABYLON {
  12571. /**
  12572. * Interface used to define entities containing multiple clip planes
  12573. */
  12574. export interface IClipPlanesHolder {
  12575. /**
  12576. * Gets or sets the active clipplane 1
  12577. */
  12578. clipPlane: Nullable<Plane>;
  12579. /**
  12580. * Gets or sets the active clipplane 2
  12581. */
  12582. clipPlane2: Nullable<Plane>;
  12583. /**
  12584. * Gets or sets the active clipplane 3
  12585. */
  12586. clipPlane3: Nullable<Plane>;
  12587. /**
  12588. * Gets or sets the active clipplane 4
  12589. */
  12590. clipPlane4: Nullable<Plane>;
  12591. /**
  12592. * Gets or sets the active clipplane 5
  12593. */
  12594. clipPlane5: Nullable<Plane>;
  12595. /**
  12596. * Gets or sets the active clipplane 6
  12597. */
  12598. clipPlane6: Nullable<Plane>;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12604. *
  12605. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12606. *
  12607. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12608. */
  12609. export class ThinMaterialHelper {
  12610. /**
  12611. * Binds the clip plane information from the holder to the effect.
  12612. * @param effect The effect we are binding the data to
  12613. * @param holder The entity containing the clip plane information
  12614. */
  12615. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12616. }
  12617. }
  12618. declare module BABYLON {
  12619. interface ThinEngine {
  12620. /**
  12621. * Sets alpha constants used by some alpha blending modes
  12622. * @param r defines the red component
  12623. * @param g defines the green component
  12624. * @param b defines the blue component
  12625. * @param a defines the alpha component
  12626. */
  12627. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12628. /**
  12629. * Sets the current alpha mode
  12630. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12632. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12633. */
  12634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12635. /**
  12636. * Gets the current alpha mode
  12637. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12638. * @returns the current alpha mode
  12639. */
  12640. getAlphaMode(): number;
  12641. /**
  12642. * Sets the current alpha equation
  12643. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12644. */
  12645. setAlphaEquation(equation: number): void;
  12646. /**
  12647. * Gets the current alpha equation.
  12648. * @returns the current alpha equation
  12649. */
  12650. getAlphaEquation(): number;
  12651. }
  12652. }
  12653. declare module BABYLON {
  12654. /**
  12655. * This represents a particle system in Babylon.
  12656. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12657. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12658. * @example https://doc.babylonjs.com/babylon101/particles
  12659. */
  12660. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12661. /**
  12662. * Billboard mode will only apply to Y axis
  12663. */
  12664. static readonly BILLBOARDMODE_Y: number;
  12665. /**
  12666. * Billboard mode will apply to all axes
  12667. */
  12668. static readonly BILLBOARDMODE_ALL: number;
  12669. /**
  12670. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12671. */
  12672. static readonly BILLBOARDMODE_STRETCHED: number;
  12673. /**
  12674. * This function can be defined to provide custom update for active particles.
  12675. * This function will be called instead of regular update (age, position, color, etc.).
  12676. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12677. */
  12678. updateFunction: (particles: Particle[]) => void;
  12679. private _emitterWorldMatrix;
  12680. /**
  12681. * This function can be defined to specify initial direction for every new particle.
  12682. * It by default use the emitterType defined function
  12683. */
  12684. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12685. /**
  12686. * This function can be defined to specify initial position for every new particle.
  12687. * It by default use the emitterType defined function
  12688. */
  12689. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12690. /**
  12691. * @hidden
  12692. */
  12693. _inheritedVelocityOffset: Vector3;
  12694. /**
  12695. * An event triggered when the system is disposed
  12696. */
  12697. onDisposeObservable: Observable<IParticleSystem>;
  12698. /**
  12699. * An event triggered when the system is stopped
  12700. */
  12701. onStoppedObservable: Observable<IParticleSystem>;
  12702. private _onDisposeObserver;
  12703. /**
  12704. * Sets a callback that will be triggered when the system is disposed
  12705. */
  12706. set onDispose(callback: () => void);
  12707. private _particles;
  12708. private _epsilon;
  12709. private _capacity;
  12710. private _stockParticles;
  12711. private _newPartsExcess;
  12712. private _vertexData;
  12713. private _vertexBuffer;
  12714. private _vertexBuffers;
  12715. private _spriteBuffer;
  12716. private _indexBuffer;
  12717. private _effect;
  12718. private _customEffect;
  12719. private _cachedDefines;
  12720. private _scaledColorStep;
  12721. private _colorDiff;
  12722. private _scaledDirection;
  12723. private _scaledGravity;
  12724. private _currentRenderId;
  12725. private _alive;
  12726. private _useInstancing;
  12727. private _vertexArrayObject;
  12728. private _started;
  12729. private _stopped;
  12730. private _actualFrame;
  12731. private _scaledUpdateSpeed;
  12732. private _vertexBufferSize;
  12733. /** @hidden */
  12734. _currentEmitRateGradient: Nullable<FactorGradient>;
  12735. /** @hidden */
  12736. _currentEmitRate1: number;
  12737. /** @hidden */
  12738. _currentEmitRate2: number;
  12739. /** @hidden */
  12740. _currentStartSizeGradient: Nullable<FactorGradient>;
  12741. /** @hidden */
  12742. _currentStartSize1: number;
  12743. /** @hidden */
  12744. _currentStartSize2: number;
  12745. private readonly _rawTextureWidth;
  12746. private _rampGradientsTexture;
  12747. private _useRampGradients;
  12748. /** Gets or sets a matrix to use to compute projection */
  12749. defaultProjectionMatrix: Matrix;
  12750. /** Gets or sets a matrix to use to compute view */
  12751. defaultViewMatrix: Matrix;
  12752. /** Gets or sets a boolean indicating that ramp gradients must be used
  12753. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12754. */
  12755. get useRampGradients(): boolean;
  12756. set useRampGradients(value: boolean);
  12757. /**
  12758. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12759. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12760. */
  12761. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12762. private _subEmitters;
  12763. /**
  12764. * @hidden
  12765. * If the particle systems emitter should be disposed when the particle system is disposed
  12766. */
  12767. _disposeEmitterOnDispose: boolean;
  12768. /**
  12769. * The current active Sub-systems, this property is used by the root particle system only.
  12770. */
  12771. activeSubSystems: Array<ParticleSystem>;
  12772. /**
  12773. * Specifies if the particles are updated in emitter local space or world space
  12774. */
  12775. isLocal: boolean;
  12776. private _rootParticleSystem;
  12777. /**
  12778. * Gets the current list of active particles
  12779. */
  12780. get particles(): Particle[];
  12781. /**
  12782. * Gets the number of particles active at the same time.
  12783. * @returns The number of active particles.
  12784. */
  12785. getActiveCount(): number;
  12786. /**
  12787. * Returns the string "ParticleSystem"
  12788. * @returns a string containing the class name
  12789. */
  12790. getClassName(): string;
  12791. /**
  12792. * Gets a boolean indicating that the system is stopping
  12793. * @returns true if the system is currently stopping
  12794. */
  12795. isStopping(): boolean;
  12796. /**
  12797. * Gets the custom effect used to render the particles
  12798. * @param blendMode Blend mode for which the effect should be retrieved
  12799. * @returns The effect
  12800. */
  12801. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12802. /**
  12803. * Sets the custom effect used to render the particles
  12804. * @param effect The effect to set
  12805. * @param blendMode Blend mode for which the effect should be set
  12806. */
  12807. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12808. /** @hidden */
  12809. private _onBeforeDrawParticlesObservable;
  12810. /**
  12811. * Observable that will be called just before the particles are drawn
  12812. */
  12813. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12814. /**
  12815. * Gets the name of the particle vertex shader
  12816. */
  12817. get vertexShaderName(): string;
  12818. /**
  12819. * Instantiates a particle system.
  12820. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12821. * @param name The name of the particle system
  12822. * @param capacity The max number of particles alive at the same time
  12823. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12824. * @param customEffect a custom effect used to change the way particles are rendered by default
  12825. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12826. * @param epsilon Offset used to render the particles
  12827. */
  12828. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12829. private _addFactorGradient;
  12830. private _removeFactorGradient;
  12831. /**
  12832. * Adds a new life time gradient
  12833. * @param gradient defines the gradient to use (between 0 and 1)
  12834. * @param factor defines the life time factor to affect to the specified gradient
  12835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12836. * @returns the current particle system
  12837. */
  12838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12839. /**
  12840. * Remove a specific life time gradient
  12841. * @param gradient defines the gradient to remove
  12842. * @returns the current particle system
  12843. */
  12844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12845. /**
  12846. * Adds a new size gradient
  12847. * @param gradient defines the gradient to use (between 0 and 1)
  12848. * @param factor defines the size factor to affect to the specified gradient
  12849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12850. * @returns the current particle system
  12851. */
  12852. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12853. /**
  12854. * Remove a specific size gradient
  12855. * @param gradient defines the gradient to remove
  12856. * @returns the current particle system
  12857. */
  12858. removeSizeGradient(gradient: number): IParticleSystem;
  12859. /**
  12860. * Adds a new color remap gradient
  12861. * @param gradient defines the gradient to use (between 0 and 1)
  12862. * @param min defines the color remap minimal range
  12863. * @param max defines the color remap maximal range
  12864. * @returns the current particle system
  12865. */
  12866. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12867. /**
  12868. * Remove a specific color remap gradient
  12869. * @param gradient defines the gradient to remove
  12870. * @returns the current particle system
  12871. */
  12872. removeColorRemapGradient(gradient: number): IParticleSystem;
  12873. /**
  12874. * Adds a new alpha remap gradient
  12875. * @param gradient defines the gradient to use (between 0 and 1)
  12876. * @param min defines the alpha remap minimal range
  12877. * @param max defines the alpha remap maximal range
  12878. * @returns the current particle system
  12879. */
  12880. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12881. /**
  12882. * Remove a specific alpha remap gradient
  12883. * @param gradient defines the gradient to remove
  12884. * @returns the current particle system
  12885. */
  12886. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12887. /**
  12888. * Adds a new angular speed gradient
  12889. * @param gradient defines the gradient to use (between 0 and 1)
  12890. * @param factor defines the angular speed to affect to the specified gradient
  12891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12892. * @returns the current particle system
  12893. */
  12894. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12895. /**
  12896. * Remove a specific angular speed gradient
  12897. * @param gradient defines the gradient to remove
  12898. * @returns the current particle system
  12899. */
  12900. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12901. /**
  12902. * Adds a new velocity gradient
  12903. * @param gradient defines the gradient to use (between 0 and 1)
  12904. * @param factor defines the velocity to affect to the specified gradient
  12905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12906. * @returns the current particle system
  12907. */
  12908. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12909. /**
  12910. * Remove a specific velocity gradient
  12911. * @param gradient defines the gradient to remove
  12912. * @returns the current particle system
  12913. */
  12914. removeVelocityGradient(gradient: number): IParticleSystem;
  12915. /**
  12916. * Adds a new limit velocity gradient
  12917. * @param gradient defines the gradient to use (between 0 and 1)
  12918. * @param factor defines the limit velocity value to affect to the specified gradient
  12919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12920. * @returns the current particle system
  12921. */
  12922. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12923. /**
  12924. * Remove a specific limit velocity gradient
  12925. * @param gradient defines the gradient to remove
  12926. * @returns the current particle system
  12927. */
  12928. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12929. /**
  12930. * Adds a new drag gradient
  12931. * @param gradient defines the gradient to use (between 0 and 1)
  12932. * @param factor defines the drag value to affect to the specified gradient
  12933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12934. * @returns the current particle system
  12935. */
  12936. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12937. /**
  12938. * Remove a specific drag gradient
  12939. * @param gradient defines the gradient to remove
  12940. * @returns the current particle system
  12941. */
  12942. removeDragGradient(gradient: number): IParticleSystem;
  12943. /**
  12944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12945. * @param gradient defines the gradient to use (between 0 and 1)
  12946. * @param factor defines the emit rate value to affect to the specified gradient
  12947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12948. * @returns the current particle system
  12949. */
  12950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12951. /**
  12952. * Remove a specific emit rate gradient
  12953. * @param gradient defines the gradient to remove
  12954. * @returns the current particle system
  12955. */
  12956. removeEmitRateGradient(gradient: number): IParticleSystem;
  12957. /**
  12958. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12959. * @param gradient defines the gradient to use (between 0 and 1)
  12960. * @param factor defines the start size value to affect to the specified gradient
  12961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12962. * @returns the current particle system
  12963. */
  12964. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12965. /**
  12966. * Remove a specific start size gradient
  12967. * @param gradient defines the gradient to remove
  12968. * @returns the current particle system
  12969. */
  12970. removeStartSizeGradient(gradient: number): IParticleSystem;
  12971. private _createRampGradientTexture;
  12972. /**
  12973. * Gets the current list of ramp gradients.
  12974. * You must use addRampGradient and removeRampGradient to udpate this list
  12975. * @returns the list of ramp gradients
  12976. */
  12977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12978. /** Force the system to rebuild all gradients that need to be resync */
  12979. forceRefreshGradients(): void;
  12980. private _syncRampGradientTexture;
  12981. /**
  12982. * Adds a new ramp gradient used to remap particle colors
  12983. * @param gradient defines the gradient to use (between 0 and 1)
  12984. * @param color defines the color to affect to the specified gradient
  12985. * @returns the current particle system
  12986. */
  12987. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12988. /**
  12989. * Remove a specific ramp gradient
  12990. * @param gradient defines the gradient to remove
  12991. * @returns the current particle system
  12992. */
  12993. removeRampGradient(gradient: number): ParticleSystem;
  12994. /**
  12995. * Adds a new color gradient
  12996. * @param gradient defines the gradient to use (between 0 and 1)
  12997. * @param color1 defines the color to affect to the specified gradient
  12998. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12999. * @returns this particle system
  13000. */
  13001. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13002. /**
  13003. * Remove a specific color gradient
  13004. * @param gradient defines the gradient to remove
  13005. * @returns this particle system
  13006. */
  13007. removeColorGradient(gradient: number): IParticleSystem;
  13008. private _fetchR;
  13009. protected _reset(): void;
  13010. private _resetEffect;
  13011. private _createVertexBuffers;
  13012. private _createIndexBuffer;
  13013. /**
  13014. * Gets the maximum number of particles active at the same time.
  13015. * @returns The max number of active particles.
  13016. */
  13017. getCapacity(): number;
  13018. /**
  13019. * Gets whether there are still active particles in the system.
  13020. * @returns True if it is alive, otherwise false.
  13021. */
  13022. isAlive(): boolean;
  13023. /**
  13024. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13025. * @returns True if it has been started, otherwise false.
  13026. */
  13027. isStarted(): boolean;
  13028. private _prepareSubEmitterInternalArray;
  13029. /**
  13030. * Starts the particle system and begins to emit
  13031. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13032. */
  13033. start(delay?: number): void;
  13034. /**
  13035. * Stops the particle system.
  13036. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13037. */
  13038. stop(stopSubEmitters?: boolean): void;
  13039. /**
  13040. * Remove all active particles
  13041. */
  13042. reset(): void;
  13043. /**
  13044. * @hidden (for internal use only)
  13045. */
  13046. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13047. /**
  13048. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13049. * Its lifetime will start back at 0.
  13050. */
  13051. recycleParticle: (particle: Particle) => void;
  13052. private _stopSubEmitters;
  13053. private _createParticle;
  13054. private _removeFromRoot;
  13055. private _emitFromParticle;
  13056. private _update;
  13057. /** @hidden */
  13058. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13059. /** @hidden */
  13060. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13061. /**
  13062. * Fill the defines array according to the current settings of the particle system
  13063. * @param defines Array to be updated
  13064. * @param blendMode blend mode to take into account when updating the array
  13065. */
  13066. fillDefines(defines: Array<string>, blendMode: number): void;
  13067. /**
  13068. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13069. * @param uniforms Uniforms array to fill
  13070. * @param attributes Attributes array to fill
  13071. * @param samplers Samplers array to fill
  13072. */
  13073. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13074. /** @hidden */
  13075. private _getEffect;
  13076. /**
  13077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13079. */
  13080. animate(preWarmOnly?: boolean): void;
  13081. private _appendParticleVertices;
  13082. /**
  13083. * Rebuilds the particle system.
  13084. */
  13085. rebuild(): void;
  13086. /**
  13087. * Is this system ready to be used/rendered
  13088. * @return true if the system is ready
  13089. */
  13090. isReady(): boolean;
  13091. private _render;
  13092. /**
  13093. * Renders the particle system in its current state.
  13094. * @returns the current number of particles
  13095. */
  13096. render(): number;
  13097. /**
  13098. * Disposes the particle system and free the associated resources
  13099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13100. */
  13101. dispose(disposeTexture?: boolean): void;
  13102. /**
  13103. * Clones the particle system.
  13104. * @param name The name of the cloned object
  13105. * @param newEmitter The new emitter to use
  13106. * @returns the cloned particle system
  13107. */
  13108. clone(name: string, newEmitter: any): ParticleSystem;
  13109. /**
  13110. * Serializes the particle system to a JSON object
  13111. * @param serializeTexture defines if the texture must be serialized as well
  13112. * @returns the JSON object
  13113. */
  13114. serialize(serializeTexture?: boolean): any;
  13115. /** @hidden */
  13116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13117. /** @hidden */
  13118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13119. /**
  13120. * Parses a JSON object to create a particle system.
  13121. * @param parsedParticleSystem The JSON object to parse
  13122. * @param sceneOrEngine The scene or the engine to create the particle system in
  13123. * @param rootUrl The root url to use to load external dependencies like texture
  13124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13125. * @returns the Parsed particle system
  13126. */
  13127. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. /**
  13132. * A particle represents one of the element emitted by a particle system.
  13133. * This is mainly define by its coordinates, direction, velocity and age.
  13134. */
  13135. export class Particle {
  13136. /**
  13137. * The particle system the particle belongs to.
  13138. */
  13139. particleSystem: ParticleSystem;
  13140. private static _Count;
  13141. /**
  13142. * Unique ID of the particle
  13143. */
  13144. id: number;
  13145. /**
  13146. * The world position of the particle in the scene.
  13147. */
  13148. position: Vector3;
  13149. /**
  13150. * The world direction of the particle in the scene.
  13151. */
  13152. direction: Vector3;
  13153. /**
  13154. * The color of the particle.
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * The color change of the particle per step.
  13159. */
  13160. colorStep: Color4;
  13161. /**
  13162. * Defines how long will the life of the particle be.
  13163. */
  13164. lifeTime: number;
  13165. /**
  13166. * The current age of the particle.
  13167. */
  13168. age: number;
  13169. /**
  13170. * The current size of the particle.
  13171. */
  13172. size: number;
  13173. /**
  13174. * The current scale of the particle.
  13175. */
  13176. scale: Vector2;
  13177. /**
  13178. * The current angle of the particle.
  13179. */
  13180. angle: number;
  13181. /**
  13182. * Defines how fast is the angle changing.
  13183. */
  13184. angularSpeed: number;
  13185. /**
  13186. * Defines the cell index used by the particle to be rendered from a sprite.
  13187. */
  13188. cellIndex: number;
  13189. /**
  13190. * The information required to support color remapping
  13191. */
  13192. remapData: Vector4;
  13193. /** @hidden */
  13194. _randomCellOffset?: number;
  13195. /** @hidden */
  13196. _initialDirection: Nullable<Vector3>;
  13197. /** @hidden */
  13198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13199. /** @hidden */
  13200. _initialStartSpriteCellID: number;
  13201. /** @hidden */
  13202. _initialEndSpriteCellID: number;
  13203. /** @hidden */
  13204. _currentColorGradient: Nullable<ColorGradient>;
  13205. /** @hidden */
  13206. _currentColor1: Color4;
  13207. /** @hidden */
  13208. _currentColor2: Color4;
  13209. /** @hidden */
  13210. _currentSizeGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentSize1: number;
  13213. /** @hidden */
  13214. _currentSize2: number;
  13215. /** @hidden */
  13216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13217. /** @hidden */
  13218. _currentAngularSpeed1: number;
  13219. /** @hidden */
  13220. _currentAngularSpeed2: number;
  13221. /** @hidden */
  13222. _currentVelocityGradient: Nullable<FactorGradient>;
  13223. /** @hidden */
  13224. _currentVelocity1: number;
  13225. /** @hidden */
  13226. _currentVelocity2: number;
  13227. /** @hidden */
  13228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13229. /** @hidden */
  13230. _currentLimitVelocity1: number;
  13231. /** @hidden */
  13232. _currentLimitVelocity2: number;
  13233. /** @hidden */
  13234. _currentDragGradient: Nullable<FactorGradient>;
  13235. /** @hidden */
  13236. _currentDrag1: number;
  13237. /** @hidden */
  13238. _currentDrag2: number;
  13239. /** @hidden */
  13240. _randomNoiseCoordinates1: Vector3;
  13241. /** @hidden */
  13242. _randomNoiseCoordinates2: Vector3;
  13243. /** @hidden */
  13244. _localPosition?: Vector3;
  13245. /**
  13246. * Creates a new instance Particle
  13247. * @param particleSystem the particle system the particle belongs to
  13248. */
  13249. constructor(
  13250. /**
  13251. * The particle system the particle belongs to.
  13252. */
  13253. particleSystem: ParticleSystem);
  13254. private updateCellInfoFromSystem;
  13255. /**
  13256. * Defines how the sprite cell index is updated for the particle
  13257. */
  13258. updateCellIndex(): void;
  13259. /** @hidden */
  13260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13261. /** @hidden */
  13262. _inheritParticleInfoToSubEmitters(): void;
  13263. /** @hidden */
  13264. _reset(): void;
  13265. /**
  13266. * Copy the properties of particle to another one.
  13267. * @param other the particle to copy the information to.
  13268. */
  13269. copyTo(other: Particle): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * Particle emitter represents a volume emitting particles.
  13275. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13276. */
  13277. export interface IParticleEmitterType {
  13278. /**
  13279. * Called by the particle System when the direction is computed for the created particle.
  13280. * @param worldMatrix is the world matrix of the particle system
  13281. * @param directionToUpdate is the direction vector to update with the result
  13282. * @param particle is the particle we are computed the direction for
  13283. * @param isLocal defines if the direction should be set in local space
  13284. */
  13285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13286. /**
  13287. * Called by the particle System when the position is computed for the created particle.
  13288. * @param worldMatrix is the world matrix of the particle system
  13289. * @param positionToUpdate is the position vector to update with the result
  13290. * @param particle is the particle we are computed the position for
  13291. * @param isLocal defines if the position should be set in local space
  13292. */
  13293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13294. /**
  13295. * Clones the current emitter and returns a copy of it
  13296. * @returns the new emitter
  13297. */
  13298. clone(): IParticleEmitterType;
  13299. /**
  13300. * Called by the GPUParticleSystem to setup the update shader
  13301. * @param effect defines the update shader
  13302. */
  13303. applyToShader(effect: Effect): void;
  13304. /**
  13305. * Returns a string to use to update the GPU particles update shader
  13306. * @returns the effect defines string
  13307. */
  13308. getEffectDefines(): string;
  13309. /**
  13310. * Returns a string representing the class name
  13311. * @returns a string containing the class name
  13312. */
  13313. getClassName(): string;
  13314. /**
  13315. * Serializes the particle system to a JSON object.
  13316. * @returns the JSON object
  13317. */
  13318. serialize(): any;
  13319. /**
  13320. * Parse properties from a JSON object
  13321. * @param serializationObject defines the JSON object
  13322. * @param scene defines the hosting scene
  13323. */
  13324. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. /**
  13329. * Particle emitter emitting particles from the inside of a box.
  13330. * It emits the particles randomly between 2 given directions.
  13331. */
  13332. export class BoxParticleEmitter implements IParticleEmitterType {
  13333. /**
  13334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13335. */
  13336. direction1: Vector3;
  13337. /**
  13338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13339. */
  13340. direction2: Vector3;
  13341. /**
  13342. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13343. */
  13344. minEmitBox: Vector3;
  13345. /**
  13346. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13347. */
  13348. maxEmitBox: Vector3;
  13349. /**
  13350. * Creates a new instance BoxParticleEmitter
  13351. */
  13352. constructor();
  13353. /**
  13354. * Called by the particle System when the direction is computed for the created particle.
  13355. * @param worldMatrix is the world matrix of the particle system
  13356. * @param directionToUpdate is the direction vector to update with the result
  13357. * @param particle is the particle we are computed the direction for
  13358. * @param isLocal defines if the direction should be set in local space
  13359. */
  13360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13361. /**
  13362. * Called by the particle System when the position is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param positionToUpdate is the position vector to update with the result
  13365. * @param particle is the particle we are computed the position for
  13366. * @param isLocal defines if the position should be set in local space
  13367. */
  13368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Clones the current emitter and returns a copy of it
  13371. * @returns the new emitter
  13372. */
  13373. clone(): BoxParticleEmitter;
  13374. /**
  13375. * Called by the GPUParticleSystem to setup the update shader
  13376. * @param effect defines the update shader
  13377. */
  13378. applyToShader(effect: Effect): void;
  13379. /**
  13380. * Returns a string to use to update the GPU particles update shader
  13381. * @returns a string containng the defines string
  13382. */
  13383. getEffectDefines(): string;
  13384. /**
  13385. * Returns the string "BoxParticleEmitter"
  13386. * @returns a string containing the class name
  13387. */
  13388. getClassName(): string;
  13389. /**
  13390. * Serializes the particle system to a JSON object.
  13391. * @returns the JSON object
  13392. */
  13393. serialize(): any;
  13394. /**
  13395. * Parse properties from a JSON object
  13396. * @param serializationObject defines the JSON object
  13397. */
  13398. parse(serializationObject: any): void;
  13399. }
  13400. }
  13401. declare module BABYLON {
  13402. /**
  13403. * Particle emitter emitting particles from the inside of a cone.
  13404. * It emits the particles alongside the cone volume from the base to the particle.
  13405. * The emission direction might be randomized.
  13406. */
  13407. export class ConeParticleEmitter implements IParticleEmitterType {
  13408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13409. directionRandomizer: number;
  13410. private _radius;
  13411. private _angle;
  13412. private _height;
  13413. /**
  13414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13415. */
  13416. radiusRange: number;
  13417. /**
  13418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13419. */
  13420. heightRange: number;
  13421. /**
  13422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13423. */
  13424. emitFromSpawnPointOnly: boolean;
  13425. /**
  13426. * Gets or sets the radius of the emission cone
  13427. */
  13428. get radius(): number;
  13429. set radius(value: number);
  13430. /**
  13431. * Gets or sets the angle of the emission cone
  13432. */
  13433. get angle(): number;
  13434. set angle(value: number);
  13435. private _buildHeight;
  13436. /**
  13437. * Creates a new instance ConeParticleEmitter
  13438. * @param radius the radius of the emission cone (1 by default)
  13439. * @param angle the cone base angle (PI by default)
  13440. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13441. */
  13442. constructor(radius?: number, angle?: number,
  13443. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13444. directionRandomizer?: number);
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): ConeParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "ConeParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Particle emitter emitting particles from the inside of a cylinder.
  13496. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13497. */
  13498. export class CylinderParticleEmitter implements IParticleEmitterType {
  13499. /**
  13500. * The radius of the emission cylinder.
  13501. */
  13502. radius: number;
  13503. /**
  13504. * The height of the emission cylinder.
  13505. */
  13506. height: number;
  13507. /**
  13508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * How much to randomize the particle direction [0-1].
  13513. */
  13514. directionRandomizer: number;
  13515. /**
  13516. * Creates a new instance CylinderParticleEmitter
  13517. * @param radius the radius of the emission cylinder (1 by default)
  13518. * @param height the height of the emission cylinder (1 by default)
  13519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13521. */
  13522. constructor(
  13523. /**
  13524. * The radius of the emission cylinder.
  13525. */
  13526. radius?: number,
  13527. /**
  13528. * The height of the emission cylinder.
  13529. */
  13530. height?: number,
  13531. /**
  13532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13533. */
  13534. radiusRange?: number,
  13535. /**
  13536. * How much to randomize the particle direction [0-1].
  13537. */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): CylinderParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "CylinderParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. /**
  13587. * Particle emitter emitting particles from the inside of a cylinder.
  13588. * It emits the particles randomly between two vectors.
  13589. */
  13590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13591. /**
  13592. * The min limit of the emission direction.
  13593. */
  13594. direction1: Vector3;
  13595. /**
  13596. * The max limit of the emission direction.
  13597. */
  13598. direction2: Vector3;
  13599. /**
  13600. * Creates a new instance CylinderDirectedParticleEmitter
  13601. * @param radius the radius of the emission cylinder (1 by default)
  13602. * @param height the height of the emission cylinder (1 by default)
  13603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13604. * @param direction1 the min limit of the emission direction (up vector by default)
  13605. * @param direction2 the max limit of the emission direction (up vector by default)
  13606. */
  13607. constructor(radius?: number, height?: number, radiusRange?: number,
  13608. /**
  13609. * The min limit of the emission direction.
  13610. */
  13611. direction1?: Vector3,
  13612. /**
  13613. * The max limit of the emission direction.
  13614. */
  13615. direction2?: Vector3);
  13616. /**
  13617. * Called by the particle System when the direction is computed for the created particle.
  13618. * @param worldMatrix is the world matrix of the particle system
  13619. * @param directionToUpdate is the direction vector to update with the result
  13620. * @param particle is the particle we are computed the direction for
  13621. */
  13622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13623. /**
  13624. * Clones the current emitter and returns a copy of it
  13625. * @returns the new emitter
  13626. */
  13627. clone(): CylinderDirectedParticleEmitter;
  13628. /**
  13629. * Called by the GPUParticleSystem to setup the update shader
  13630. * @param effect defines the update shader
  13631. */
  13632. applyToShader(effect: Effect): void;
  13633. /**
  13634. * Returns a string to use to update the GPU particles update shader
  13635. * @returns a string containng the defines string
  13636. */
  13637. getEffectDefines(): string;
  13638. /**
  13639. * Returns the string "CylinderDirectedParticleEmitter"
  13640. * @returns a string containing the class name
  13641. */
  13642. getClassName(): string;
  13643. /**
  13644. * Serializes the particle system to a JSON object.
  13645. * @returns the JSON object
  13646. */
  13647. serialize(): any;
  13648. /**
  13649. * Parse properties from a JSON object
  13650. * @param serializationObject defines the JSON object
  13651. */
  13652. parse(serializationObject: any): void;
  13653. }
  13654. }
  13655. declare module BABYLON {
  13656. /**
  13657. * Particle emitter emitting particles from the inside of a hemisphere.
  13658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13659. */
  13660. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13661. /**
  13662. * The radius of the emission hemisphere.
  13663. */
  13664. radius: number;
  13665. /**
  13666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13667. */
  13668. radiusRange: number;
  13669. /**
  13670. * How much to randomize the particle direction [0-1].
  13671. */
  13672. directionRandomizer: number;
  13673. /**
  13674. * Creates a new instance HemisphericParticleEmitter
  13675. * @param radius the radius of the emission hemisphere (1 by default)
  13676. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13678. */
  13679. constructor(
  13680. /**
  13681. * The radius of the emission hemisphere.
  13682. */
  13683. radius?: number,
  13684. /**
  13685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13686. */
  13687. radiusRange?: number,
  13688. /**
  13689. * How much to randomize the particle direction [0-1].
  13690. */
  13691. directionRandomizer?: number);
  13692. /**
  13693. * Called by the particle System when the direction is computed for the created particle.
  13694. * @param worldMatrix is the world matrix of the particle system
  13695. * @param directionToUpdate is the direction vector to update with the result
  13696. * @param particle is the particle we are computed the direction for
  13697. * @param isLocal defines if the direction should be set in local space
  13698. */
  13699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13700. /**
  13701. * Called by the particle System when the position is computed for the created particle.
  13702. * @param worldMatrix is the world matrix of the particle system
  13703. * @param positionToUpdate is the position vector to update with the result
  13704. * @param particle is the particle we are computed the position for
  13705. * @param isLocal defines if the position should be set in local space
  13706. */
  13707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): HemisphericParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "HemisphericParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a point.
  13743. * It emits the particles randomly between 2 given directions.
  13744. */
  13745. export class PointParticleEmitter implements IParticleEmitterType {
  13746. /**
  13747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13748. */
  13749. direction1: Vector3;
  13750. /**
  13751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13752. */
  13753. direction2: Vector3;
  13754. /**
  13755. * Creates a new instance PointParticleEmitter
  13756. */
  13757. constructor();
  13758. /**
  13759. * Called by the particle System when the direction is computed for the created particle.
  13760. * @param worldMatrix is the world matrix of the particle system
  13761. * @param directionToUpdate is the direction vector to update with the result
  13762. * @param particle is the particle we are computed the direction for
  13763. * @param isLocal defines if the direction should be set in local space
  13764. */
  13765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13766. /**
  13767. * Called by the particle System when the position is computed for the created particle.
  13768. * @param worldMatrix is the world matrix of the particle system
  13769. * @param positionToUpdate is the position vector to update with the result
  13770. * @param particle is the particle we are computed the position for
  13771. * @param isLocal defines if the position should be set in local space
  13772. */
  13773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13774. /**
  13775. * Clones the current emitter and returns a copy of it
  13776. * @returns the new emitter
  13777. */
  13778. clone(): PointParticleEmitter;
  13779. /**
  13780. * Called by the GPUParticleSystem to setup the update shader
  13781. * @param effect defines the update shader
  13782. */
  13783. applyToShader(effect: Effect): void;
  13784. /**
  13785. * Returns a string to use to update the GPU particles update shader
  13786. * @returns a string containng the defines string
  13787. */
  13788. getEffectDefines(): string;
  13789. /**
  13790. * Returns the string "PointParticleEmitter"
  13791. * @returns a string containing the class name
  13792. */
  13793. getClassName(): string;
  13794. /**
  13795. * Serializes the particle system to a JSON object.
  13796. * @returns the JSON object
  13797. */
  13798. serialize(): any;
  13799. /**
  13800. * Parse properties from a JSON object
  13801. * @param serializationObject defines the JSON object
  13802. */
  13803. parse(serializationObject: any): void;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a sphere.
  13809. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13810. */
  13811. export class SphereParticleEmitter implements IParticleEmitterType {
  13812. /**
  13813. * The radius of the emission sphere.
  13814. */
  13815. radius: number;
  13816. /**
  13817. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13818. */
  13819. radiusRange: number;
  13820. /**
  13821. * How much to randomize the particle direction [0-1].
  13822. */
  13823. directionRandomizer: number;
  13824. /**
  13825. * Creates a new instance SphereParticleEmitter
  13826. * @param radius the radius of the emission sphere (1 by default)
  13827. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13828. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13829. */
  13830. constructor(
  13831. /**
  13832. * The radius of the emission sphere.
  13833. */
  13834. radius?: number,
  13835. /**
  13836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13837. */
  13838. radiusRange?: number,
  13839. /**
  13840. * How much to randomize the particle direction [0-1].
  13841. */
  13842. directionRandomizer?: number);
  13843. /**
  13844. * Called by the particle System when the direction is computed for the created particle.
  13845. * @param worldMatrix is the world matrix of the particle system
  13846. * @param directionToUpdate is the direction vector to update with the result
  13847. * @param particle is the particle we are computed the direction for
  13848. * @param isLocal defines if the direction should be set in local space
  13849. */
  13850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13851. /**
  13852. * Called by the particle System when the position is computed for the created particle.
  13853. * @param worldMatrix is the world matrix of the particle system
  13854. * @param positionToUpdate is the position vector to update with the result
  13855. * @param particle is the particle we are computed the position for
  13856. * @param isLocal defines if the position should be set in local space
  13857. */
  13858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13859. /**
  13860. * Clones the current emitter and returns a copy of it
  13861. * @returns the new emitter
  13862. */
  13863. clone(): SphereParticleEmitter;
  13864. /**
  13865. * Called by the GPUParticleSystem to setup the update shader
  13866. * @param effect defines the update shader
  13867. */
  13868. applyToShader(effect: Effect): void;
  13869. /**
  13870. * Returns a string to use to update the GPU particles update shader
  13871. * @returns a string containng the defines string
  13872. */
  13873. getEffectDefines(): string;
  13874. /**
  13875. * Returns the string "SphereParticleEmitter"
  13876. * @returns a string containing the class name
  13877. */
  13878. getClassName(): string;
  13879. /**
  13880. * Serializes the particle system to a JSON object.
  13881. * @returns the JSON object
  13882. */
  13883. serialize(): any;
  13884. /**
  13885. * Parse properties from a JSON object
  13886. * @param serializationObject defines the JSON object
  13887. */
  13888. parse(serializationObject: any): void;
  13889. }
  13890. /**
  13891. * Particle emitter emitting particles from the inside of a sphere.
  13892. * It emits the particles randomly between two vectors.
  13893. */
  13894. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13895. /**
  13896. * The min limit of the emission direction.
  13897. */
  13898. direction1: Vector3;
  13899. /**
  13900. * The max limit of the emission direction.
  13901. */
  13902. direction2: Vector3;
  13903. /**
  13904. * Creates a new instance SphereDirectedParticleEmitter
  13905. * @param radius the radius of the emission sphere (1 by default)
  13906. * @param direction1 the min limit of the emission direction (up vector by default)
  13907. * @param direction2 the max limit of the emission direction (up vector by default)
  13908. */
  13909. constructor(radius?: number,
  13910. /**
  13911. * The min limit of the emission direction.
  13912. */
  13913. direction1?: Vector3,
  13914. /**
  13915. * The max limit of the emission direction.
  13916. */
  13917. direction2?: Vector3);
  13918. /**
  13919. * Called by the particle System when the direction is computed for the created particle.
  13920. * @param worldMatrix is the world matrix of the particle system
  13921. * @param directionToUpdate is the direction vector to update with the result
  13922. * @param particle is the particle we are computed the direction for
  13923. */
  13924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13925. /**
  13926. * Clones the current emitter and returns a copy of it
  13927. * @returns the new emitter
  13928. */
  13929. clone(): SphereDirectedParticleEmitter;
  13930. /**
  13931. * Called by the GPUParticleSystem to setup the update shader
  13932. * @param effect defines the update shader
  13933. */
  13934. applyToShader(effect: Effect): void;
  13935. /**
  13936. * Returns a string to use to update the GPU particles update shader
  13937. * @returns a string containng the defines string
  13938. */
  13939. getEffectDefines(): string;
  13940. /**
  13941. * Returns the string "SphereDirectedParticleEmitter"
  13942. * @returns a string containing the class name
  13943. */
  13944. getClassName(): string;
  13945. /**
  13946. * Serializes the particle system to a JSON object.
  13947. * @returns the JSON object
  13948. */
  13949. serialize(): any;
  13950. /**
  13951. * Parse properties from a JSON object
  13952. * @param serializationObject defines the JSON object
  13953. */
  13954. parse(serializationObject: any): void;
  13955. }
  13956. }
  13957. declare module BABYLON {
  13958. /**
  13959. * Particle emitter emitting particles from a custom list of positions.
  13960. */
  13961. export class CustomParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * Gets or sets the position generator that will create the inital position of each particle.
  13964. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13965. */
  13966. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13967. /**
  13968. * Gets or sets the destination generator that will create the final destination of each particle.
  13969. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13970. */
  13971. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13972. /**
  13973. * Creates a new instance CustomParticleEmitter
  13974. */
  13975. constructor();
  13976. /**
  13977. * Called by the particle System when the direction is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param directionToUpdate is the direction vector to update with the result
  13980. * @param particle is the particle we are computed the direction for
  13981. * @param isLocal defines if the direction should be set in local space
  13982. */
  13983. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Called by the particle System when the position is computed for the created particle.
  13986. * @param worldMatrix is the world matrix of the particle system
  13987. * @param positionToUpdate is the position vector to update with the result
  13988. * @param particle is the particle we are computed the position for
  13989. * @param isLocal defines if the position should be set in local space
  13990. */
  13991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13992. /**
  13993. * Clones the current emitter and returns a copy of it
  13994. * @returns the new emitter
  13995. */
  13996. clone(): CustomParticleEmitter;
  13997. /**
  13998. * Called by the GPUParticleSystem to setup the update shader
  13999. * @param effect defines the update shader
  14000. */
  14001. applyToShader(effect: Effect): void;
  14002. /**
  14003. * Returns a string to use to update the GPU particles update shader
  14004. * @returns a string containng the defines string
  14005. */
  14006. getEffectDefines(): string;
  14007. /**
  14008. * Returns the string "PointParticleEmitter"
  14009. * @returns a string containing the class name
  14010. */
  14011. getClassName(): string;
  14012. /**
  14013. * Serializes the particle system to a JSON object.
  14014. * @returns the JSON object
  14015. */
  14016. serialize(): any;
  14017. /**
  14018. * Parse properties from a JSON object
  14019. * @param serializationObject defines the JSON object
  14020. */
  14021. parse(serializationObject: any): void;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. /**
  14026. * Particle emitter emitting particles from the inside of a box.
  14027. * It emits the particles randomly between 2 given directions.
  14028. */
  14029. export class MeshParticleEmitter implements IParticleEmitterType {
  14030. private _indices;
  14031. private _positions;
  14032. private _normals;
  14033. private _storedNormal;
  14034. private _mesh;
  14035. /**
  14036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14037. */
  14038. direction1: Vector3;
  14039. /**
  14040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14041. */
  14042. direction2: Vector3;
  14043. /**
  14044. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14045. */
  14046. useMeshNormalsForDirection: boolean;
  14047. /** Defines the mesh to use as source */
  14048. get mesh(): Nullable<AbstractMesh>;
  14049. set mesh(value: Nullable<AbstractMesh>);
  14050. /**
  14051. * Creates a new instance MeshParticleEmitter
  14052. * @param mesh defines the mesh to use as source
  14053. */
  14054. constructor(mesh?: Nullable<AbstractMesh>);
  14055. /**
  14056. * Called by the particle System when the direction is computed for the created particle.
  14057. * @param worldMatrix is the world matrix of the particle system
  14058. * @param directionToUpdate is the direction vector to update with the result
  14059. * @param particle is the particle we are computed the direction for
  14060. * @param isLocal defines if the direction should be set in local space
  14061. */
  14062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14063. /**
  14064. * Called by the particle System when the position is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param positionToUpdate is the position vector to update with the result
  14067. * @param particle is the particle we are computed the position for
  14068. * @param isLocal defines if the position should be set in local space
  14069. */
  14070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Clones the current emitter and returns a copy of it
  14073. * @returns the new emitter
  14074. */
  14075. clone(): MeshParticleEmitter;
  14076. /**
  14077. * Called by the GPUParticleSystem to setup the update shader
  14078. * @param effect defines the update shader
  14079. */
  14080. applyToShader(effect: Effect): void;
  14081. /**
  14082. * Returns a string to use to update the GPU particles update shader
  14083. * @returns a string containng the defines string
  14084. */
  14085. getEffectDefines(): string;
  14086. /**
  14087. * Returns the string "BoxParticleEmitter"
  14088. * @returns a string containing the class name
  14089. */
  14090. getClassName(): string;
  14091. /**
  14092. * Serializes the particle system to a JSON object.
  14093. * @returns the JSON object
  14094. */
  14095. serialize(): any;
  14096. /**
  14097. * Parse properties from a JSON object
  14098. * @param serializationObject defines the JSON object
  14099. * @param scene defines the hosting scene
  14100. */
  14101. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14102. }
  14103. }
  14104. declare module BABYLON {
  14105. /**
  14106. * Interface representing a particle system in Babylon.js.
  14107. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14108. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14109. */
  14110. export interface IParticleSystem {
  14111. /**
  14112. * List of animations used by the particle system.
  14113. */
  14114. animations: Animation[];
  14115. /**
  14116. * The id of the Particle system.
  14117. */
  14118. id: string;
  14119. /**
  14120. * The name of the Particle system.
  14121. */
  14122. name: string;
  14123. /**
  14124. * The emitter represents the Mesh or position we are attaching the particle system to.
  14125. */
  14126. emitter: Nullable<AbstractMesh | Vector3>;
  14127. /**
  14128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14129. */
  14130. isBillboardBased: boolean;
  14131. /**
  14132. * The rendering group used by the Particle system to chose when to render.
  14133. */
  14134. renderingGroupId: number;
  14135. /**
  14136. * The layer mask we are rendering the particles through.
  14137. */
  14138. layerMask: number;
  14139. /**
  14140. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14141. */
  14142. updateSpeed: number;
  14143. /**
  14144. * The amount of time the particle system is running (depends of the overall update speed).
  14145. */
  14146. targetStopDuration: number;
  14147. /**
  14148. * The texture used to render each particle. (this can be a spritesheet)
  14149. */
  14150. particleTexture: Nullable<BaseTexture>;
  14151. /**
  14152. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14153. */
  14154. blendMode: number;
  14155. /**
  14156. * Minimum life time of emitting particles.
  14157. */
  14158. minLifeTime: number;
  14159. /**
  14160. * Maximum life time of emitting particles.
  14161. */
  14162. maxLifeTime: number;
  14163. /**
  14164. * Minimum Size of emitting particles.
  14165. */
  14166. minSize: number;
  14167. /**
  14168. * Maximum Size of emitting particles.
  14169. */
  14170. maxSize: number;
  14171. /**
  14172. * Minimum scale of emitting particles on X axis.
  14173. */
  14174. minScaleX: number;
  14175. /**
  14176. * Maximum scale of emitting particles on X axis.
  14177. */
  14178. maxScaleX: number;
  14179. /**
  14180. * Minimum scale of emitting particles on Y axis.
  14181. */
  14182. minScaleY: number;
  14183. /**
  14184. * Maximum scale of emitting particles on Y axis.
  14185. */
  14186. maxScaleY: number;
  14187. /**
  14188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14189. */
  14190. color1: Color4;
  14191. /**
  14192. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14193. */
  14194. color2: Color4;
  14195. /**
  14196. * Color the particle will have at the end of its lifetime.
  14197. */
  14198. colorDead: Color4;
  14199. /**
  14200. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14201. */
  14202. emitRate: number;
  14203. /**
  14204. * You can use gravity if you want to give an orientation to your particles.
  14205. */
  14206. gravity: Vector3;
  14207. /**
  14208. * Minimum power of emitting particles.
  14209. */
  14210. minEmitPower: number;
  14211. /**
  14212. * Maximum power of emitting particles.
  14213. */
  14214. maxEmitPower: number;
  14215. /**
  14216. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14217. */
  14218. minAngularSpeed: number;
  14219. /**
  14220. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. maxAngularSpeed: number;
  14223. /**
  14224. * Gets or sets the minimal initial rotation in radians.
  14225. */
  14226. minInitialRotation: number;
  14227. /**
  14228. * Gets or sets the maximal initial rotation in radians.
  14229. */
  14230. maxInitialRotation: number;
  14231. /**
  14232. * The particle emitter type defines the emitter used by the particle system.
  14233. * It can be for example box, sphere, or cone...
  14234. */
  14235. particleEmitterType: Nullable<IParticleEmitterType>;
  14236. /**
  14237. * Defines the delay in milliseconds before starting the system (0 by default)
  14238. */
  14239. startDelay: number;
  14240. /**
  14241. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14242. */
  14243. preWarmCycles: number;
  14244. /**
  14245. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14246. */
  14247. preWarmStepOffset: number;
  14248. /**
  14249. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14250. */
  14251. spriteCellChangeSpeed: number;
  14252. /**
  14253. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14254. */
  14255. startSpriteCellID: number;
  14256. /**
  14257. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14258. */
  14259. endSpriteCellID: number;
  14260. /**
  14261. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14262. */
  14263. spriteCellWidth: number;
  14264. /**
  14265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14266. */
  14267. spriteCellHeight: number;
  14268. /**
  14269. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14270. */
  14271. spriteRandomStartCell: boolean;
  14272. /**
  14273. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14274. */
  14275. isAnimationSheetEnabled: boolean;
  14276. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14277. translationPivot: Vector2;
  14278. /**
  14279. * Gets or sets a texture used to add random noise to particle positions
  14280. */
  14281. noiseTexture: Nullable<BaseTexture>;
  14282. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14283. noiseStrength: Vector3;
  14284. /**
  14285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14287. */
  14288. billboardMode: number;
  14289. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14290. limitVelocityDamping: number;
  14291. /**
  14292. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14293. */
  14294. beginAnimationOnStart: boolean;
  14295. /**
  14296. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14297. */
  14298. beginAnimationFrom: number;
  14299. /**
  14300. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14301. */
  14302. beginAnimationTo: number;
  14303. /**
  14304. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14305. */
  14306. beginAnimationLoop: boolean;
  14307. /**
  14308. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14309. */
  14310. disposeOnStop: boolean;
  14311. /**
  14312. * Specifies if the particles are updated in emitter local space or world space
  14313. */
  14314. isLocal: boolean;
  14315. /** Snippet ID if the particle system was created from the snippet server */
  14316. snippetId: string;
  14317. /** Gets or sets a matrix to use to compute projection */
  14318. defaultProjectionMatrix: Matrix;
  14319. /**
  14320. * Gets the maximum number of particles active at the same time.
  14321. * @returns The max number of active particles.
  14322. */
  14323. getCapacity(): number;
  14324. /**
  14325. * Gets the number of particles active at the same time.
  14326. * @returns The number of active particles.
  14327. */
  14328. getActiveCount(): number;
  14329. /**
  14330. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14331. * @returns True if it has been started, otherwise false.
  14332. */
  14333. isStarted(): boolean;
  14334. /**
  14335. * Animates the particle system for this frame.
  14336. */
  14337. animate(): void;
  14338. /**
  14339. * Renders the particle system in its current state.
  14340. * @returns the current number of particles
  14341. */
  14342. render(): number;
  14343. /**
  14344. * Dispose the particle system and frees its associated resources.
  14345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14346. */
  14347. dispose(disposeTexture?: boolean): void;
  14348. /**
  14349. * An event triggered when the system is disposed
  14350. */
  14351. onDisposeObservable: Observable<IParticleSystem>;
  14352. /**
  14353. * An event triggered when the system is stopped
  14354. */
  14355. onStoppedObservable: Observable<IParticleSystem>;
  14356. /**
  14357. * Clones the particle system.
  14358. * @param name The name of the cloned object
  14359. * @param newEmitter The new emitter to use
  14360. * @returns the cloned particle system
  14361. */
  14362. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14363. /**
  14364. * Serializes the particle system to a JSON object
  14365. * @param serializeTexture defines if the texture must be serialized as well
  14366. * @returns the JSON object
  14367. */
  14368. serialize(serializeTexture: boolean): any;
  14369. /**
  14370. * Rebuild the particle system
  14371. */
  14372. rebuild(): void;
  14373. /** Force the system to rebuild all gradients that need to be resync */
  14374. forceRefreshGradients(): void;
  14375. /**
  14376. * Starts the particle system and begins to emit
  14377. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14378. */
  14379. start(delay?: number): void;
  14380. /**
  14381. * Stops the particle system.
  14382. */
  14383. stop(): void;
  14384. /**
  14385. * Remove all active particles
  14386. */
  14387. reset(): void;
  14388. /**
  14389. * Gets a boolean indicating that the system is stopping
  14390. * @returns true if the system is currently stopping
  14391. */
  14392. isStopping(): boolean;
  14393. /**
  14394. * Is this system ready to be used/rendered
  14395. * @return true if the system is ready
  14396. */
  14397. isReady(): boolean;
  14398. /**
  14399. * Returns the string "ParticleSystem"
  14400. * @returns a string containing the class name
  14401. */
  14402. getClassName(): string;
  14403. /**
  14404. * Gets the custom effect used to render the particles
  14405. * @param blendMode Blend mode for which the effect should be retrieved
  14406. * @returns The effect
  14407. */
  14408. getCustomEffect(blendMode: number): Nullable<Effect>;
  14409. /**
  14410. * Sets the custom effect used to render the particles
  14411. * @param effect The effect to set
  14412. * @param blendMode Blend mode for which the effect should be set
  14413. */
  14414. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14415. /**
  14416. * Fill the defines array according to the current settings of the particle system
  14417. * @param defines Array to be updated
  14418. * @param blendMode blend mode to take into account when updating the array
  14419. */
  14420. fillDefines(defines: Array<string>, blendMode: number): void;
  14421. /**
  14422. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14423. * @param uniforms Uniforms array to fill
  14424. * @param attributes Attributes array to fill
  14425. * @param samplers Samplers array to fill
  14426. */
  14427. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14428. /**
  14429. * Observable that will be called just before the particles are drawn
  14430. */
  14431. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14432. /**
  14433. * Gets the name of the particle vertex shader
  14434. */
  14435. vertexShaderName: string;
  14436. /**
  14437. * Adds a new color gradient
  14438. * @param gradient defines the gradient to use (between 0 and 1)
  14439. * @param color1 defines the color to affect to the specified gradient
  14440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14441. * @returns the current particle system
  14442. */
  14443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14444. /**
  14445. * Remove a specific color gradient
  14446. * @param gradient defines the gradient to remove
  14447. * @returns the current particle system
  14448. */
  14449. removeColorGradient(gradient: number): IParticleSystem;
  14450. /**
  14451. * Adds a new size gradient
  14452. * @param gradient defines the gradient to use (between 0 and 1)
  14453. * @param factor defines the size factor to affect to the specified gradient
  14454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14455. * @returns the current particle system
  14456. */
  14457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14458. /**
  14459. * Remove a specific size gradient
  14460. * @param gradient defines the gradient to remove
  14461. * @returns the current particle system
  14462. */
  14463. removeSizeGradient(gradient: number): IParticleSystem;
  14464. /**
  14465. * Gets the current list of color gradients.
  14466. * You must use addColorGradient and removeColorGradient to udpate this list
  14467. * @returns the list of color gradients
  14468. */
  14469. getColorGradients(): Nullable<Array<ColorGradient>>;
  14470. /**
  14471. * Gets the current list of size gradients.
  14472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14473. * @returns the list of size gradients
  14474. */
  14475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14476. /**
  14477. * Gets the current list of angular speed gradients.
  14478. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14479. * @returns the list of angular speed gradients
  14480. */
  14481. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Adds a new angular speed gradient
  14484. * @param gradient defines the gradient to use (between 0 and 1)
  14485. * @param factor defines the angular speed to affect to the specified gradient
  14486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14487. * @returns the current particle system
  14488. */
  14489. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14490. /**
  14491. * Remove a specific angular speed gradient
  14492. * @param gradient defines the gradient to remove
  14493. * @returns the current particle system
  14494. */
  14495. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14496. /**
  14497. * Gets the current list of velocity gradients.
  14498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14499. * @returns the list of velocity gradients
  14500. */
  14501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14502. /**
  14503. * Adds a new velocity gradient
  14504. * @param gradient defines the gradient to use (between 0 and 1)
  14505. * @param factor defines the velocity to affect to the specified gradient
  14506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14507. * @returns the current particle system
  14508. */
  14509. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14510. /**
  14511. * Remove a specific velocity gradient
  14512. * @param gradient defines the gradient to remove
  14513. * @returns the current particle system
  14514. */
  14515. removeVelocityGradient(gradient: number): IParticleSystem;
  14516. /**
  14517. * Gets the current list of limit velocity gradients.
  14518. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14519. * @returns the list of limit velocity gradients
  14520. */
  14521. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14522. /**
  14523. * Adds a new limit velocity gradient
  14524. * @param gradient defines the gradient to use (between 0 and 1)
  14525. * @param factor defines the limit velocity to affect to the specified gradient
  14526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14527. * @returns the current particle system
  14528. */
  14529. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14530. /**
  14531. * Remove a specific limit velocity gradient
  14532. * @param gradient defines the gradient to remove
  14533. * @returns the current particle system
  14534. */
  14535. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14536. /**
  14537. * Adds a new drag gradient
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the drag to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific drag gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeDragGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Gets the current list of drag gradients.
  14552. * You must use addDragGradient and removeDragGradient to udpate this list
  14553. * @returns the list of drag gradients
  14554. */
  14555. getDragGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the emit rate to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific emit rate gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeEmitRateGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of emit rate gradients.
  14572. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14573. * @returns the list of emit rate gradients
  14574. */
  14575. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14578. * @param gradient defines the gradient to use (between 0 and 1)
  14579. * @param factor defines the start size to affect to the specified gradient
  14580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14581. * @returns the current particle system
  14582. */
  14583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14584. /**
  14585. * Remove a specific start size gradient
  14586. * @param gradient defines the gradient to remove
  14587. * @returns the current particle system
  14588. */
  14589. removeStartSizeGradient(gradient: number): IParticleSystem;
  14590. /**
  14591. * Gets the current list of start size gradients.
  14592. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14593. * @returns the list of start size gradients
  14594. */
  14595. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14596. /**
  14597. * Adds a new life time gradient
  14598. * @param gradient defines the gradient to use (between 0 and 1)
  14599. * @param factor defines the life time factor to affect to the specified gradient
  14600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14601. * @returns the current particle system
  14602. */
  14603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14604. /**
  14605. * Remove a specific life time gradient
  14606. * @param gradient defines the gradient to remove
  14607. * @returns the current particle system
  14608. */
  14609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14610. /**
  14611. * Gets the current list of life time gradients.
  14612. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14613. * @returns the list of life time gradients
  14614. */
  14615. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14616. /**
  14617. * Gets the current list of color gradients.
  14618. * You must use addColorGradient and removeColorGradient to udpate this list
  14619. * @returns the list of color gradients
  14620. */
  14621. getColorGradients(): Nullable<Array<ColorGradient>>;
  14622. /**
  14623. * Adds a new ramp gradient used to remap particle colors
  14624. * @param gradient defines the gradient to use (between 0 and 1)
  14625. * @param color defines the color to affect to the specified gradient
  14626. * @returns the current particle system
  14627. */
  14628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14629. /**
  14630. * Gets the current list of ramp gradients.
  14631. * You must use addRampGradient and removeRampGradient to udpate this list
  14632. * @returns the list of ramp gradients
  14633. */
  14634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14635. /** Gets or sets a boolean indicating that ramp gradients must be used
  14636. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14637. */
  14638. useRampGradients: boolean;
  14639. /**
  14640. * Adds a new color remap gradient
  14641. * @param gradient defines the gradient to use (between 0 and 1)
  14642. * @param min defines the color remap minimal range
  14643. * @param max defines the color remap maximal range
  14644. * @returns the current particle system
  14645. */
  14646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14647. /**
  14648. * Gets the current list of color remap gradients.
  14649. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14650. * @returns the list of color remap gradients
  14651. */
  14652. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14653. /**
  14654. * Adds a new alpha remap gradient
  14655. * @param gradient defines the gradient to use (between 0 and 1)
  14656. * @param min defines the alpha remap minimal range
  14657. * @param max defines the alpha remap maximal range
  14658. * @returns the current particle system
  14659. */
  14660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14661. /**
  14662. * Gets the current list of alpha remap gradients.
  14663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14664. * @returns the list of alpha remap gradients
  14665. */
  14666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14667. /**
  14668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14671. * @returns the emitter
  14672. */
  14673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14674. /**
  14675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14676. * @param radius The radius of the hemisphere to emit from
  14677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14678. * @returns the emitter
  14679. */
  14680. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14681. /**
  14682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14683. * @param radius The radius of the sphere to emit from
  14684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14685. * @returns the emitter
  14686. */
  14687. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14688. /**
  14689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14690. * @param radius The radius of the sphere to emit from
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14693. * @returns the emitter
  14694. */
  14695. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14696. /**
  14697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14698. * @param radius The radius of the emission cylinder
  14699. * @param height The height of the emission cylinder
  14700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14702. * @returns the emitter
  14703. */
  14704. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14705. /**
  14706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14707. * @param radius The radius of the cylinder to emit from
  14708. * @param height The height of the emission cylinder
  14709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14712. * @returns the emitter
  14713. */
  14714. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14715. /**
  14716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14717. * @param radius The radius of the cone to emit from
  14718. * @param angle The base angle of the cone
  14719. * @returns the emitter
  14720. */
  14721. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14722. /**
  14723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14728. * @returns the emitter
  14729. */
  14730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14731. /**
  14732. * Get hosting scene
  14733. * @returns the scene
  14734. */
  14735. getScene(): Nullable<Scene>;
  14736. }
  14737. }
  14738. declare module BABYLON {
  14739. /**
  14740. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14741. * @see https://doc.babylonjs.com/how_to/transformnode
  14742. */
  14743. export class TransformNode extends Node {
  14744. /**
  14745. * Object will not rotate to face the camera
  14746. */
  14747. static BILLBOARDMODE_NONE: number;
  14748. /**
  14749. * Object will rotate to face the camera but only on the x axis
  14750. */
  14751. static BILLBOARDMODE_X: number;
  14752. /**
  14753. * Object will rotate to face the camera but only on the y axis
  14754. */
  14755. static BILLBOARDMODE_Y: number;
  14756. /**
  14757. * Object will rotate to face the camera but only on the z axis
  14758. */
  14759. static BILLBOARDMODE_Z: number;
  14760. /**
  14761. * Object will rotate to face the camera
  14762. */
  14763. static BILLBOARDMODE_ALL: number;
  14764. /**
  14765. * Object will rotate to face the camera's position instead of orientation
  14766. */
  14767. static BILLBOARDMODE_USE_POSITION: number;
  14768. private static _TmpRotation;
  14769. private static _TmpScaling;
  14770. private static _TmpTranslation;
  14771. private _forward;
  14772. private _forwardInverted;
  14773. private _up;
  14774. private _right;
  14775. private _rightInverted;
  14776. private _position;
  14777. private _rotation;
  14778. private _rotationQuaternion;
  14779. protected _scaling: Vector3;
  14780. protected _isDirty: boolean;
  14781. private _transformToBoneReferal;
  14782. private _isAbsoluteSynced;
  14783. private _billboardMode;
  14784. /**
  14785. * Gets or sets the billboard mode. Default is 0.
  14786. *
  14787. * | Value | Type | Description |
  14788. * | --- | --- | --- |
  14789. * | 0 | BILLBOARDMODE_NONE | |
  14790. * | 1 | BILLBOARDMODE_X | |
  14791. * | 2 | BILLBOARDMODE_Y | |
  14792. * | 4 | BILLBOARDMODE_Z | |
  14793. * | 7 | BILLBOARDMODE_ALL | |
  14794. *
  14795. */
  14796. get billboardMode(): number;
  14797. set billboardMode(value: number);
  14798. private _preserveParentRotationForBillboard;
  14799. /**
  14800. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14801. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14802. */
  14803. get preserveParentRotationForBillboard(): boolean;
  14804. set preserveParentRotationForBillboard(value: boolean);
  14805. /**
  14806. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14807. */
  14808. scalingDeterminant: number;
  14809. private _infiniteDistance;
  14810. /**
  14811. * Gets or sets the distance of the object to max, often used by skybox
  14812. */
  14813. get infiniteDistance(): boolean;
  14814. set infiniteDistance(value: boolean);
  14815. /**
  14816. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14817. * By default the system will update normals to compensate
  14818. */
  14819. ignoreNonUniformScaling: boolean;
  14820. /**
  14821. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14822. */
  14823. reIntegrateRotationIntoRotationQuaternion: boolean;
  14824. /** @hidden */
  14825. _poseMatrix: Nullable<Matrix>;
  14826. /** @hidden */
  14827. _localMatrix: Matrix;
  14828. private _usePivotMatrix;
  14829. private _absolutePosition;
  14830. private _absoluteScaling;
  14831. private _absoluteRotationQuaternion;
  14832. private _pivotMatrix;
  14833. private _pivotMatrixInverse;
  14834. /** @hidden */
  14835. _postMultiplyPivotMatrix: boolean;
  14836. protected _isWorldMatrixFrozen: boolean;
  14837. /** @hidden */
  14838. _indexInSceneTransformNodesArray: number;
  14839. /**
  14840. * An event triggered after the world matrix is updated
  14841. */
  14842. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14843. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14844. /**
  14845. * Gets a string identifying the name of the class
  14846. * @returns "TransformNode" string
  14847. */
  14848. getClassName(): string;
  14849. /**
  14850. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14851. */
  14852. get position(): Vector3;
  14853. set position(newPosition: Vector3);
  14854. /**
  14855. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14856. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14857. */
  14858. get rotation(): Vector3;
  14859. set rotation(newRotation: Vector3);
  14860. /**
  14861. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14862. */
  14863. get scaling(): Vector3;
  14864. set scaling(newScaling: Vector3);
  14865. /**
  14866. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14867. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14868. */
  14869. get rotationQuaternion(): Nullable<Quaternion>;
  14870. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14871. /**
  14872. * The forward direction of that transform in world space.
  14873. */
  14874. get forward(): Vector3;
  14875. /**
  14876. * The up direction of that transform in world space.
  14877. */
  14878. get up(): Vector3;
  14879. /**
  14880. * The right direction of that transform in world space.
  14881. */
  14882. get right(): Vector3;
  14883. /**
  14884. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14885. * @param matrix the matrix to copy the pose from
  14886. * @returns this TransformNode.
  14887. */
  14888. updatePoseMatrix(matrix: Matrix): TransformNode;
  14889. /**
  14890. * Returns the mesh Pose matrix.
  14891. * @returns the pose matrix
  14892. */
  14893. getPoseMatrix(): Matrix;
  14894. /** @hidden */
  14895. _isSynchronized(): boolean;
  14896. /** @hidden */
  14897. _initCache(): void;
  14898. /**
  14899. * Flag the transform node as dirty (Forcing it to update everything)
  14900. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14901. * @returns this transform node
  14902. */
  14903. markAsDirty(property: string): TransformNode;
  14904. /**
  14905. * Returns the current mesh absolute position.
  14906. * Returns a Vector3.
  14907. */
  14908. get absolutePosition(): Vector3;
  14909. /**
  14910. * Returns the current mesh absolute scaling.
  14911. * Returns a Vector3.
  14912. */
  14913. get absoluteScaling(): Vector3;
  14914. /**
  14915. * Returns the current mesh absolute rotation.
  14916. * Returns a Quaternion.
  14917. */
  14918. get absoluteRotationQuaternion(): Quaternion;
  14919. /**
  14920. * Sets a new matrix to apply before all other transformation
  14921. * @param matrix defines the transform matrix
  14922. * @returns the current TransformNode
  14923. */
  14924. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14925. /**
  14926. * Sets a new pivot matrix to the current node
  14927. * @param matrix defines the new pivot matrix to use
  14928. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14929. * @returns the current TransformNode
  14930. */
  14931. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14932. /**
  14933. * Returns the mesh pivot matrix.
  14934. * Default : Identity.
  14935. * @returns the matrix
  14936. */
  14937. getPivotMatrix(): Matrix;
  14938. /**
  14939. * Instantiate (when possible) or clone that node with its hierarchy
  14940. * @param newParent defines the new parent to use for the instance (or clone)
  14941. * @param options defines options to configure how copy is done
  14942. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14943. * @returns an instance (or a clone) of the current node with its hiearchy
  14944. */
  14945. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14946. doNotInstantiate: boolean;
  14947. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14948. /**
  14949. * Prevents the World matrix to be computed any longer
  14950. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14951. * @returns the TransformNode.
  14952. */
  14953. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14954. /**
  14955. * Allows back the World matrix computation.
  14956. * @returns the TransformNode.
  14957. */
  14958. unfreezeWorldMatrix(): this;
  14959. /**
  14960. * True if the World matrix has been frozen.
  14961. */
  14962. get isWorldMatrixFrozen(): boolean;
  14963. /**
  14964. * Retuns the mesh absolute position in the World.
  14965. * @returns a Vector3.
  14966. */
  14967. getAbsolutePosition(): Vector3;
  14968. /**
  14969. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14970. * @param absolutePosition the absolute position to set
  14971. * @returns the TransformNode.
  14972. */
  14973. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14974. /**
  14975. * Sets the mesh position in its local space.
  14976. * @param vector3 the position to set in localspace
  14977. * @returns the TransformNode.
  14978. */
  14979. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14980. /**
  14981. * Returns the mesh position in the local space from the current World matrix values.
  14982. * @returns a new Vector3.
  14983. */
  14984. getPositionExpressedInLocalSpace(): Vector3;
  14985. /**
  14986. * Translates the mesh along the passed Vector3 in its local space.
  14987. * @param vector3 the distance to translate in localspace
  14988. * @returns the TransformNode.
  14989. */
  14990. locallyTranslate(vector3: Vector3): TransformNode;
  14991. private static _lookAtVectorCache;
  14992. /**
  14993. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14994. * @param targetPoint the position (must be in same space as current mesh) to look at
  14995. * @param yawCor optional yaw (y-axis) correction in radians
  14996. * @param pitchCor optional pitch (x-axis) correction in radians
  14997. * @param rollCor optional roll (z-axis) correction in radians
  14998. * @param space the choosen space of the target
  14999. * @returns the TransformNode.
  15000. */
  15001. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15002. /**
  15003. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15004. * This Vector3 is expressed in the World space.
  15005. * @param localAxis axis to rotate
  15006. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15007. */
  15008. getDirection(localAxis: Vector3): Vector3;
  15009. /**
  15010. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15011. * localAxis is expressed in the mesh local space.
  15012. * result is computed in the Wordl space from the mesh World matrix.
  15013. * @param localAxis axis to rotate
  15014. * @param result the resulting transformnode
  15015. * @returns this TransformNode.
  15016. */
  15017. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15018. /**
  15019. * Sets this transform node rotation to the given local axis.
  15020. * @param localAxis the axis in local space
  15021. * @param yawCor optional yaw (y-axis) correction in radians
  15022. * @param pitchCor optional pitch (x-axis) correction in radians
  15023. * @param rollCor optional roll (z-axis) correction in radians
  15024. * @returns this TransformNode
  15025. */
  15026. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15027. /**
  15028. * Sets a new pivot point to the current node
  15029. * @param point defines the new pivot point to use
  15030. * @param space defines if the point is in world or local space (local by default)
  15031. * @returns the current TransformNode
  15032. */
  15033. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15034. /**
  15035. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15036. * @returns the pivot point
  15037. */
  15038. getPivotPoint(): Vector3;
  15039. /**
  15040. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15041. * @param result the vector3 to store the result
  15042. * @returns this TransformNode.
  15043. */
  15044. getPivotPointToRef(result: Vector3): TransformNode;
  15045. /**
  15046. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15047. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15048. */
  15049. getAbsolutePivotPoint(): Vector3;
  15050. /**
  15051. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15052. * @param result vector3 to store the result
  15053. * @returns this TransformNode.
  15054. */
  15055. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15056. /**
  15057. * Defines the passed node as the parent of the current node.
  15058. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15059. * @see https://doc.babylonjs.com/how_to/parenting
  15060. * @param node the node ot set as the parent
  15061. * @returns this TransformNode.
  15062. */
  15063. setParent(node: Nullable<Node>): TransformNode;
  15064. private _nonUniformScaling;
  15065. /**
  15066. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15067. */
  15068. get nonUniformScaling(): boolean;
  15069. /** @hidden */
  15070. _updateNonUniformScalingState(value: boolean): boolean;
  15071. /**
  15072. * Attach the current TransformNode to another TransformNode associated with a bone
  15073. * @param bone Bone affecting the TransformNode
  15074. * @param affectedTransformNode TransformNode associated with the bone
  15075. * @returns this object
  15076. */
  15077. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15078. /**
  15079. * Detach the transform node if its associated with a bone
  15080. * @returns this object
  15081. */
  15082. detachFromBone(): TransformNode;
  15083. private static _rotationAxisCache;
  15084. /**
  15085. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15086. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15087. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15088. * The passed axis is also normalized.
  15089. * @param axis the axis to rotate around
  15090. * @param amount the amount to rotate in radians
  15091. * @param space Space to rotate in (Default: local)
  15092. * @returns the TransformNode.
  15093. */
  15094. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15095. /**
  15096. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15097. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15098. * The passed axis is also normalized. .
  15099. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15100. * @param point the point to rotate around
  15101. * @param axis the axis to rotate around
  15102. * @param amount the amount to rotate in radians
  15103. * @returns the TransformNode
  15104. */
  15105. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15106. /**
  15107. * Translates the mesh along the axis vector for the passed distance in the given space.
  15108. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15109. * @param axis the axis to translate in
  15110. * @param distance the distance to translate
  15111. * @param space Space to rotate in (Default: local)
  15112. * @returns the TransformNode.
  15113. */
  15114. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15115. /**
  15116. * Adds a rotation step to the mesh current rotation.
  15117. * x, y, z are Euler angles expressed in radians.
  15118. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15119. * This means this rotation is made in the mesh local space only.
  15120. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15121. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15122. * ```javascript
  15123. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15124. * ```
  15125. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15126. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15127. * @param x Rotation to add
  15128. * @param y Rotation to add
  15129. * @param z Rotation to add
  15130. * @returns the TransformNode.
  15131. */
  15132. addRotation(x: number, y: number, z: number): TransformNode;
  15133. /**
  15134. * @hidden
  15135. */
  15136. protected _getEffectiveParent(): Nullable<Node>;
  15137. /**
  15138. * Computes the world matrix of the node
  15139. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15140. * @returns the world matrix
  15141. */
  15142. computeWorldMatrix(force?: boolean): Matrix;
  15143. /**
  15144. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15145. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15146. */
  15147. resetLocalMatrix(independentOfChildren?: boolean): void;
  15148. protected _afterComputeWorldMatrix(): void;
  15149. /**
  15150. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15151. * @param func callback function to add
  15152. *
  15153. * @returns the TransformNode.
  15154. */
  15155. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15156. /**
  15157. * Removes a registered callback function.
  15158. * @param func callback function to remove
  15159. * @returns the TransformNode.
  15160. */
  15161. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15162. /**
  15163. * Gets the position of the current mesh in camera space
  15164. * @param camera defines the camera to use
  15165. * @returns a position
  15166. */
  15167. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15168. /**
  15169. * Returns the distance from the mesh to the active camera
  15170. * @param camera defines the camera to use
  15171. * @returns the distance
  15172. */
  15173. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15174. /**
  15175. * Clone the current transform node
  15176. * @param name Name of the new clone
  15177. * @param newParent New parent for the clone
  15178. * @param doNotCloneChildren Do not clone children hierarchy
  15179. * @returns the new transform node
  15180. */
  15181. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15182. /**
  15183. * Serializes the objects information.
  15184. * @param currentSerializationObject defines the object to serialize in
  15185. * @returns the serialized object
  15186. */
  15187. serialize(currentSerializationObject?: any): any;
  15188. /**
  15189. * Returns a new TransformNode object parsed from the source provided.
  15190. * @param parsedTransformNode is the source.
  15191. * @param scene the scne the object belongs to
  15192. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15193. * @returns a new TransformNode object parsed from the source provided.
  15194. */
  15195. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15196. /**
  15197. * Get all child-transformNodes of this node
  15198. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15199. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15200. * @returns an array of TransformNode
  15201. */
  15202. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15203. /**
  15204. * Releases resources associated with this transform node.
  15205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15207. */
  15208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15209. /**
  15210. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15211. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15212. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15213. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15214. * @returns the current mesh
  15215. */
  15216. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15217. private _syncAbsoluteScalingAndRotation;
  15218. }
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * Class used to override all child animations of a given target
  15223. */
  15224. export class AnimationPropertiesOverride {
  15225. /**
  15226. * Gets or sets a value indicating if animation blending must be used
  15227. */
  15228. enableBlending: boolean;
  15229. /**
  15230. * Gets or sets the blending speed to use when enableBlending is true
  15231. */
  15232. blendingSpeed: number;
  15233. /**
  15234. * Gets or sets the default loop mode to use
  15235. */
  15236. loopMode: number;
  15237. }
  15238. }
  15239. declare module BABYLON {
  15240. /**
  15241. * Class used to store bone information
  15242. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15243. */
  15244. export class Bone extends Node {
  15245. /**
  15246. * defines the bone name
  15247. */
  15248. name: string;
  15249. private static _tmpVecs;
  15250. private static _tmpQuat;
  15251. private static _tmpMats;
  15252. /**
  15253. * Gets the list of child bones
  15254. */
  15255. children: Bone[];
  15256. /** Gets the animations associated with this bone */
  15257. animations: Animation[];
  15258. /**
  15259. * Gets or sets bone length
  15260. */
  15261. length: number;
  15262. /**
  15263. * @hidden Internal only
  15264. * Set this value to map this bone to a different index in the transform matrices
  15265. * Set this value to -1 to exclude the bone from the transform matrices
  15266. */
  15267. _index: Nullable<number>;
  15268. private _skeleton;
  15269. private _localMatrix;
  15270. private _restPose;
  15271. private _bindPose;
  15272. private _baseMatrix;
  15273. private _absoluteTransform;
  15274. private _invertedAbsoluteTransform;
  15275. private _parent;
  15276. private _scalingDeterminant;
  15277. private _worldTransform;
  15278. private _localScaling;
  15279. private _localRotation;
  15280. private _localPosition;
  15281. private _needToDecompose;
  15282. private _needToCompose;
  15283. /** @hidden */
  15284. _linkedTransformNode: Nullable<TransformNode>;
  15285. /** @hidden */
  15286. _waitingTransformNodeId: Nullable<string>;
  15287. /** @hidden */
  15288. get _matrix(): Matrix;
  15289. /** @hidden */
  15290. set _matrix(value: Matrix);
  15291. /**
  15292. * Create a new bone
  15293. * @param name defines the bone name
  15294. * @param skeleton defines the parent skeleton
  15295. * @param parentBone defines the parent (can be null if the bone is the root)
  15296. * @param localMatrix defines the local matrix
  15297. * @param restPose defines the rest pose matrix
  15298. * @param baseMatrix defines the base matrix
  15299. * @param index defines index of the bone in the hiearchy
  15300. */
  15301. constructor(
  15302. /**
  15303. * defines the bone name
  15304. */
  15305. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15306. /**
  15307. * Gets the current object class name.
  15308. * @return the class name
  15309. */
  15310. getClassName(): string;
  15311. /**
  15312. * Gets the parent skeleton
  15313. * @returns a skeleton
  15314. */
  15315. getSkeleton(): Skeleton;
  15316. /**
  15317. * Gets parent bone
  15318. * @returns a bone or null if the bone is the root of the bone hierarchy
  15319. */
  15320. getParent(): Nullable<Bone>;
  15321. /**
  15322. * Returns an array containing the root bones
  15323. * @returns an array containing the root bones
  15324. */
  15325. getChildren(): Array<Bone>;
  15326. /**
  15327. * Gets the node index in matrix array generated for rendering
  15328. * @returns the node index
  15329. */
  15330. getIndex(): number;
  15331. /**
  15332. * Sets the parent bone
  15333. * @param parent defines the parent (can be null if the bone is the root)
  15334. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15335. */
  15336. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15337. /**
  15338. * Gets the local matrix
  15339. * @returns a matrix
  15340. */
  15341. getLocalMatrix(): Matrix;
  15342. /**
  15343. * Gets the base matrix (initial matrix which remains unchanged)
  15344. * @returns a matrix
  15345. */
  15346. getBaseMatrix(): Matrix;
  15347. /**
  15348. * Gets the rest pose matrix
  15349. * @returns a matrix
  15350. */
  15351. getRestPose(): Matrix;
  15352. /**
  15353. * Sets the rest pose matrix
  15354. * @param matrix the local-space rest pose to set for this bone
  15355. */
  15356. setRestPose(matrix: Matrix): void;
  15357. /**
  15358. * Gets the bind pose matrix
  15359. * @returns the bind pose matrix
  15360. */
  15361. getBindPose(): Matrix;
  15362. /**
  15363. * Sets the bind pose matrix
  15364. * @param matrix the local-space bind pose to set for this bone
  15365. */
  15366. setBindPose(matrix: Matrix): void;
  15367. /**
  15368. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15369. */
  15370. getWorldMatrix(): Matrix;
  15371. /**
  15372. * Sets the local matrix to rest pose matrix
  15373. */
  15374. returnToRest(): void;
  15375. /**
  15376. * Gets the inverse of the absolute transform matrix.
  15377. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15378. * @returns a matrix
  15379. */
  15380. getInvertedAbsoluteTransform(): Matrix;
  15381. /**
  15382. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15383. * @returns a matrix
  15384. */
  15385. getAbsoluteTransform(): Matrix;
  15386. /**
  15387. * Links with the given transform node.
  15388. * The local matrix of this bone is copied from the transform node every frame.
  15389. * @param transformNode defines the transform node to link to
  15390. */
  15391. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15392. /**
  15393. * Gets the node used to drive the bone's transformation
  15394. * @returns a transform node or null
  15395. */
  15396. getTransformNode(): Nullable<TransformNode>;
  15397. /** Gets or sets current position (in local space) */
  15398. get position(): Vector3;
  15399. set position(newPosition: Vector3);
  15400. /** Gets or sets current rotation (in local space) */
  15401. get rotation(): Vector3;
  15402. set rotation(newRotation: Vector3);
  15403. /** Gets or sets current rotation quaternion (in local space) */
  15404. get rotationQuaternion(): Quaternion;
  15405. set rotationQuaternion(newRotation: Quaternion);
  15406. /** Gets or sets current scaling (in local space) */
  15407. get scaling(): Vector3;
  15408. set scaling(newScaling: Vector3);
  15409. /**
  15410. * Gets the animation properties override
  15411. */
  15412. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15413. private _decompose;
  15414. private _compose;
  15415. /**
  15416. * Update the base and local matrices
  15417. * @param matrix defines the new base or local matrix
  15418. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15419. * @param updateLocalMatrix defines if the local matrix should be updated
  15420. */
  15421. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15422. /** @hidden */
  15423. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15424. /**
  15425. * Flag the bone as dirty (Forcing it to update everything)
  15426. */
  15427. markAsDirty(): void;
  15428. /** @hidden */
  15429. _markAsDirtyAndCompose(): void;
  15430. private _markAsDirtyAndDecompose;
  15431. /**
  15432. * Translate the bone in local or world space
  15433. * @param vec The amount to translate the bone
  15434. * @param space The space that the translation is in
  15435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15436. */
  15437. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15438. /**
  15439. * Set the postion of the bone in local or world space
  15440. * @param position The position to set the bone
  15441. * @param space The space that the position is in
  15442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15443. */
  15444. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15445. /**
  15446. * Set the absolute position of the bone (world space)
  15447. * @param position The position to set the bone
  15448. * @param mesh The mesh that this bone is attached to
  15449. */
  15450. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15451. /**
  15452. * Scale the bone on the x, y and z axes (in local space)
  15453. * @param x The amount to scale the bone on the x axis
  15454. * @param y The amount to scale the bone on the y axis
  15455. * @param z The amount to scale the bone on the z axis
  15456. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15457. */
  15458. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15459. /**
  15460. * Set the bone scaling in local space
  15461. * @param scale defines the scaling vector
  15462. */
  15463. setScale(scale: Vector3): void;
  15464. /**
  15465. * Gets the current scaling in local space
  15466. * @returns the current scaling vector
  15467. */
  15468. getScale(): Vector3;
  15469. /**
  15470. * Gets the current scaling in local space and stores it in a target vector
  15471. * @param result defines the target vector
  15472. */
  15473. getScaleToRef(result: Vector3): void;
  15474. /**
  15475. * Set the yaw, pitch, and roll of the bone in local or world space
  15476. * @param yaw The rotation of the bone on the y axis
  15477. * @param pitch The rotation of the bone on the x axis
  15478. * @param roll The rotation of the bone on the z axis
  15479. * @param space The space that the axes of rotation are in
  15480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15481. */
  15482. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15483. /**
  15484. * Add a rotation to the bone on an axis in local or world space
  15485. * @param axis The axis to rotate the bone on
  15486. * @param amount The amount to rotate the bone
  15487. * @param space The space that the axis is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15491. /**
  15492. * Set the rotation of the bone to a particular axis angle in local or world space
  15493. * @param axis The axis to rotate the bone on
  15494. * @param angle The angle that the bone should be rotated to
  15495. * @param space The space that the axis is in
  15496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15497. */
  15498. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15499. /**
  15500. * Set the euler rotation of the bone in local or world space
  15501. * @param rotation The euler rotation that the bone should be set to
  15502. * @param space The space that the rotation is in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Set the quaternion rotation of the bone in local or world space
  15508. * @param quat The quaternion rotation that the bone should be set to
  15509. * @param space The space that the rotation is in
  15510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15511. */
  15512. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15513. /**
  15514. * Set the rotation matrix of the bone in local or world space
  15515. * @param rotMat The rotation matrix that the bone should be set to
  15516. * @param space The space that the rotation is in
  15517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15518. */
  15519. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15520. private _rotateWithMatrix;
  15521. private _getNegativeRotationToRef;
  15522. /**
  15523. * Get the position of the bone in local or world space
  15524. * @param space The space that the returned position is in
  15525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15526. * @returns The position of the bone
  15527. */
  15528. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15529. /**
  15530. * Copy the position of the bone to a vector3 in local or world space
  15531. * @param space The space that the returned position is in
  15532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15533. * @param result The vector3 to copy the position to
  15534. */
  15535. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15536. /**
  15537. * Get the absolute position of the bone (world space)
  15538. * @param mesh The mesh that this bone is attached to
  15539. * @returns The absolute position of the bone
  15540. */
  15541. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15542. /**
  15543. * Copy the absolute position of the bone (world space) to the result param
  15544. * @param mesh The mesh that this bone is attached to
  15545. * @param result The vector3 to copy the absolute position to
  15546. */
  15547. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15548. /**
  15549. * Compute the absolute transforms of this bone and its children
  15550. */
  15551. computeAbsoluteTransforms(): void;
  15552. /**
  15553. * Get the world direction from an axis that is in the local space of the bone
  15554. * @param localAxis The local direction that is used to compute the world direction
  15555. * @param mesh The mesh that this bone is attached to
  15556. * @returns The world direction
  15557. */
  15558. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15559. /**
  15560. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15561. * @param localAxis The local direction that is used to compute the world direction
  15562. * @param mesh The mesh that this bone is attached to
  15563. * @param result The vector3 that the world direction will be copied to
  15564. */
  15565. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15566. /**
  15567. * Get the euler rotation of the bone in local or world space
  15568. * @param space The space that the rotation should be in
  15569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15570. * @returns The euler rotation
  15571. */
  15572. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15573. /**
  15574. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15575. * @param space The space that the rotation should be in
  15576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15577. * @param result The vector3 that the rotation should be copied to
  15578. */
  15579. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15580. /**
  15581. * Get the quaternion rotation of the bone in either local or world space
  15582. * @param space The space that the rotation should be in
  15583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15584. * @returns The quaternion rotation
  15585. */
  15586. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15587. /**
  15588. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15589. * @param space The space that the rotation should be in
  15590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15591. * @param result The quaternion that the rotation should be copied to
  15592. */
  15593. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15594. /**
  15595. * Get the rotation matrix of the bone in local or world space
  15596. * @param space The space that the rotation should be in
  15597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15598. * @returns The rotation matrix
  15599. */
  15600. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15601. /**
  15602. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15603. * @param space The space that the rotation should be in
  15604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15605. * @param result The quaternion that the rotation should be copied to
  15606. */
  15607. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15608. /**
  15609. * Get the world position of a point that is in the local space of the bone
  15610. * @param position The local position
  15611. * @param mesh The mesh that this bone is attached to
  15612. * @returns The world position
  15613. */
  15614. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15615. /**
  15616. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15617. * @param position The local position
  15618. * @param mesh The mesh that this bone is attached to
  15619. * @param result The vector3 that the world position should be copied to
  15620. */
  15621. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15622. /**
  15623. * Get the local position of a point that is in world space
  15624. * @param position The world position
  15625. * @param mesh The mesh that this bone is attached to
  15626. * @returns The local position
  15627. */
  15628. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15629. /**
  15630. * Get the local position of a point that is in world space and copy it to the result param
  15631. * @param position The world position
  15632. * @param mesh The mesh that this bone is attached to
  15633. * @param result The vector3 that the local position should be copied to
  15634. */
  15635. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15636. /**
  15637. * Set the current local matrix as the restPose for this bone.
  15638. */
  15639. setCurrentPoseAsRest(): void;
  15640. }
  15641. }
  15642. declare module BABYLON {
  15643. /**
  15644. * Defines a runtime animation
  15645. */
  15646. export class RuntimeAnimation {
  15647. private _events;
  15648. /**
  15649. * The current frame of the runtime animation
  15650. */
  15651. private _currentFrame;
  15652. /**
  15653. * The animation used by the runtime animation
  15654. */
  15655. private _animation;
  15656. /**
  15657. * The target of the runtime animation
  15658. */
  15659. private _target;
  15660. /**
  15661. * The initiating animatable
  15662. */
  15663. private _host;
  15664. /**
  15665. * The original value of the runtime animation
  15666. */
  15667. private _originalValue;
  15668. /**
  15669. * The original blend value of the runtime animation
  15670. */
  15671. private _originalBlendValue;
  15672. /**
  15673. * The offsets cache of the runtime animation
  15674. */
  15675. private _offsetsCache;
  15676. /**
  15677. * The high limits cache of the runtime animation
  15678. */
  15679. private _highLimitsCache;
  15680. /**
  15681. * Specifies if the runtime animation has been stopped
  15682. */
  15683. private _stopped;
  15684. /**
  15685. * The blending factor of the runtime animation
  15686. */
  15687. private _blendingFactor;
  15688. /**
  15689. * The BabylonJS scene
  15690. */
  15691. private _scene;
  15692. /**
  15693. * The current value of the runtime animation
  15694. */
  15695. private _currentValue;
  15696. /** @hidden */
  15697. _animationState: _IAnimationState;
  15698. /**
  15699. * The active target of the runtime animation
  15700. */
  15701. private _activeTargets;
  15702. private _currentActiveTarget;
  15703. private _directTarget;
  15704. /**
  15705. * The target path of the runtime animation
  15706. */
  15707. private _targetPath;
  15708. /**
  15709. * The weight of the runtime animation
  15710. */
  15711. private _weight;
  15712. /**
  15713. * The ratio offset of the runtime animation
  15714. */
  15715. private _ratioOffset;
  15716. /**
  15717. * The previous delay of the runtime animation
  15718. */
  15719. private _previousDelay;
  15720. /**
  15721. * The previous ratio of the runtime animation
  15722. */
  15723. private _previousRatio;
  15724. private _enableBlending;
  15725. private _keys;
  15726. private _minFrame;
  15727. private _maxFrame;
  15728. private _minValue;
  15729. private _maxValue;
  15730. private _targetIsArray;
  15731. /**
  15732. * Gets the current frame of the runtime animation
  15733. */
  15734. get currentFrame(): number;
  15735. /**
  15736. * Gets the weight of the runtime animation
  15737. */
  15738. get weight(): number;
  15739. /**
  15740. * Gets the current value of the runtime animation
  15741. */
  15742. get currentValue(): any;
  15743. /**
  15744. * Gets the target path of the runtime animation
  15745. */
  15746. get targetPath(): string;
  15747. /**
  15748. * Gets the actual target of the runtime animation
  15749. */
  15750. get target(): any;
  15751. /**
  15752. * Gets the additive state of the runtime animation
  15753. */
  15754. get isAdditive(): boolean;
  15755. /** @hidden */
  15756. _onLoop: () => void;
  15757. /**
  15758. * Create a new RuntimeAnimation object
  15759. * @param target defines the target of the animation
  15760. * @param animation defines the source animation object
  15761. * @param scene defines the hosting scene
  15762. * @param host defines the initiating Animatable
  15763. */
  15764. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15765. private _preparePath;
  15766. /**
  15767. * Gets the animation from the runtime animation
  15768. */
  15769. get animation(): Animation;
  15770. /**
  15771. * Resets the runtime animation to the beginning
  15772. * @param restoreOriginal defines whether to restore the target property to the original value
  15773. */
  15774. reset(restoreOriginal?: boolean): void;
  15775. /**
  15776. * Specifies if the runtime animation is stopped
  15777. * @returns Boolean specifying if the runtime animation is stopped
  15778. */
  15779. isStopped(): boolean;
  15780. /**
  15781. * Disposes of the runtime animation
  15782. */
  15783. dispose(): void;
  15784. /**
  15785. * Apply the interpolated value to the target
  15786. * @param currentValue defines the value computed by the animation
  15787. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15788. */
  15789. setValue(currentValue: any, weight: number): void;
  15790. private _getOriginalValues;
  15791. private _setValue;
  15792. /**
  15793. * Gets the loop pmode of the runtime animation
  15794. * @returns Loop Mode
  15795. */
  15796. private _getCorrectLoopMode;
  15797. /**
  15798. * Move the current animation to a given frame
  15799. * @param frame defines the frame to move to
  15800. */
  15801. goToFrame(frame: number): void;
  15802. /**
  15803. * @hidden Internal use only
  15804. */
  15805. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15806. /**
  15807. * Execute the current animation
  15808. * @param delay defines the delay to add to the current frame
  15809. * @param from defines the lower bound of the animation range
  15810. * @param to defines the upper bound of the animation range
  15811. * @param loop defines if the current animation must loop
  15812. * @param speedRatio defines the current speed ratio
  15813. * @param weight defines the weight of the animation (default is -1 so no weight)
  15814. * @param onLoop optional callback called when animation loops
  15815. * @returns a boolean indicating if the animation is running
  15816. */
  15817. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15818. }
  15819. }
  15820. declare module BABYLON {
  15821. /**
  15822. * Class used to store an actual running animation
  15823. */
  15824. export class Animatable {
  15825. /** defines the target object */
  15826. target: any;
  15827. /** defines the starting frame number (default is 0) */
  15828. fromFrame: number;
  15829. /** defines the ending frame number (default is 100) */
  15830. toFrame: number;
  15831. /** defines if the animation must loop (default is false) */
  15832. loopAnimation: boolean;
  15833. /** defines a callback to call when animation ends if it is not looping */
  15834. onAnimationEnd?: (() => void) | null | undefined;
  15835. /** defines a callback to call when animation loops */
  15836. onAnimationLoop?: (() => void) | null | undefined;
  15837. /** defines whether the animation should be evaluated additively */
  15838. isAdditive: boolean;
  15839. private _localDelayOffset;
  15840. private _pausedDelay;
  15841. private _runtimeAnimations;
  15842. private _paused;
  15843. private _scene;
  15844. private _speedRatio;
  15845. private _weight;
  15846. private _syncRoot;
  15847. /**
  15848. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15849. * This will only apply for non looping animation (default is true)
  15850. */
  15851. disposeOnEnd: boolean;
  15852. /**
  15853. * Gets a boolean indicating if the animation has started
  15854. */
  15855. animationStarted: boolean;
  15856. /**
  15857. * Observer raised when the animation ends
  15858. */
  15859. onAnimationEndObservable: Observable<Animatable>;
  15860. /**
  15861. * Observer raised when the animation loops
  15862. */
  15863. onAnimationLoopObservable: Observable<Animatable>;
  15864. /**
  15865. * Gets the root Animatable used to synchronize and normalize animations
  15866. */
  15867. get syncRoot(): Nullable<Animatable>;
  15868. /**
  15869. * Gets the current frame of the first RuntimeAnimation
  15870. * Used to synchronize Animatables
  15871. */
  15872. get masterFrame(): number;
  15873. /**
  15874. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15875. */
  15876. get weight(): number;
  15877. set weight(value: number);
  15878. /**
  15879. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15880. */
  15881. get speedRatio(): number;
  15882. set speedRatio(value: number);
  15883. /**
  15884. * Creates a new Animatable
  15885. * @param scene defines the hosting scene
  15886. * @param target defines the target object
  15887. * @param fromFrame defines the starting frame number (default is 0)
  15888. * @param toFrame defines the ending frame number (default is 100)
  15889. * @param loopAnimation defines if the animation must loop (default is false)
  15890. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15891. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15892. * @param animations defines a group of animation to add to the new Animatable
  15893. * @param onAnimationLoop defines a callback to call when animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively
  15895. */
  15896. constructor(scene: Scene,
  15897. /** defines the target object */
  15898. target: any,
  15899. /** defines the starting frame number (default is 0) */
  15900. fromFrame?: number,
  15901. /** defines the ending frame number (default is 100) */
  15902. toFrame?: number,
  15903. /** defines if the animation must loop (default is false) */
  15904. loopAnimation?: boolean, speedRatio?: number,
  15905. /** defines a callback to call when animation ends if it is not looping */
  15906. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15907. /** defines a callback to call when animation loops */
  15908. onAnimationLoop?: (() => void) | null | undefined,
  15909. /** defines whether the animation should be evaluated additively */
  15910. isAdditive?: boolean);
  15911. /**
  15912. * Synchronize and normalize current Animatable with a source Animatable
  15913. * This is useful when using animation weights and when animations are not of the same length
  15914. * @param root defines the root Animatable to synchronize with
  15915. * @returns the current Animatable
  15916. */
  15917. syncWith(root: Animatable): Animatable;
  15918. /**
  15919. * Gets the list of runtime animations
  15920. * @returns an array of RuntimeAnimation
  15921. */
  15922. getAnimations(): RuntimeAnimation[];
  15923. /**
  15924. * Adds more animations to the current animatable
  15925. * @param target defines the target of the animations
  15926. * @param animations defines the new animations to add
  15927. */
  15928. appendAnimations(target: any, animations: Animation[]): void;
  15929. /**
  15930. * Gets the source animation for a specific property
  15931. * @param property defines the propertyu to look for
  15932. * @returns null or the source animation for the given property
  15933. */
  15934. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15935. /**
  15936. * Gets the runtime animation for a specific property
  15937. * @param property defines the propertyu to look for
  15938. * @returns null or the runtime animation for the given property
  15939. */
  15940. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15941. /**
  15942. * Resets the animatable to its original state
  15943. */
  15944. reset(): void;
  15945. /**
  15946. * Allows the animatable to blend with current running animations
  15947. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15948. * @param blendingSpeed defines the blending speed to use
  15949. */
  15950. enableBlending(blendingSpeed: number): void;
  15951. /**
  15952. * Disable animation blending
  15953. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15954. */
  15955. disableBlending(): void;
  15956. /**
  15957. * Jump directly to a given frame
  15958. * @param frame defines the frame to jump to
  15959. */
  15960. goToFrame(frame: number): void;
  15961. /**
  15962. * Pause the animation
  15963. */
  15964. pause(): void;
  15965. /**
  15966. * Restart the animation
  15967. */
  15968. restart(): void;
  15969. private _raiseOnAnimationEnd;
  15970. /**
  15971. * Stop and delete the current animation
  15972. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15973. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15974. */
  15975. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15976. /**
  15977. * Wait asynchronously for the animation to end
  15978. * @returns a promise which will be fullfilled when the animation ends
  15979. */
  15980. waitAsync(): Promise<Animatable>;
  15981. /** @hidden */
  15982. _animate(delay: number): boolean;
  15983. }
  15984. interface Scene {
  15985. /** @hidden */
  15986. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15987. /** @hidden */
  15988. _processLateAnimationBindingsForMatrices(holder: {
  15989. totalWeight: number;
  15990. totalAdditiveWeight: number;
  15991. animations: RuntimeAnimation[];
  15992. additiveAnimations: RuntimeAnimation[];
  15993. originalValue: Matrix;
  15994. }): any;
  15995. /** @hidden */
  15996. _processLateAnimationBindingsForQuaternions(holder: {
  15997. totalWeight: number;
  15998. totalAdditiveWeight: number;
  15999. animations: RuntimeAnimation[];
  16000. additiveAnimations: RuntimeAnimation[];
  16001. originalValue: Quaternion;
  16002. }, refQuaternion: Quaternion): Quaternion;
  16003. /** @hidden */
  16004. _processLateAnimationBindings(): void;
  16005. /**
  16006. * Will start the animation sequence of a given target
  16007. * @param target defines the target
  16008. * @param from defines from which frame should animation start
  16009. * @param to defines until which frame should animation run.
  16010. * @param weight defines the weight to apply to the animation (1.0 by default)
  16011. * @param loop defines if the animation loops
  16012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16013. * @param onAnimationEnd defines the function to be executed when the animation ends
  16014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16015. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16016. * @param onAnimationLoop defines the callback to call when an animation loops
  16017. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16018. * @returns the animatable object created for this animation
  16019. */
  16020. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16021. /**
  16022. * Will start the animation sequence of a given target
  16023. * @param target defines the target
  16024. * @param from defines from which frame should animation start
  16025. * @param to defines until which frame should animation run.
  16026. * @param loop defines if the animation loops
  16027. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16028. * @param onAnimationEnd defines the function to be executed when the animation ends
  16029. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16030. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16031. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16032. * @param onAnimationLoop defines the callback to call when an animation loops
  16033. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16034. * @returns the animatable object created for this animation
  16035. */
  16036. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16037. /**
  16038. * Will start the animation sequence of a given target and its hierarchy
  16039. * @param target defines the target
  16040. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16041. * @param from defines from which frame should animation start
  16042. * @param to defines until which frame should animation run.
  16043. * @param loop defines if the animation loops
  16044. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16045. * @param onAnimationEnd defines the function to be executed when the animation ends
  16046. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16047. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16048. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16049. * @param onAnimationLoop defines the callback to call when an animation loops
  16050. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16051. * @returns the list of created animatables
  16052. */
  16053. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16054. /**
  16055. * Begin a new animation on a given node
  16056. * @param target defines the target where the animation will take place
  16057. * @param animations defines the list of animations to start
  16058. * @param from defines the initial value
  16059. * @param to defines the final value
  16060. * @param loop defines if you want animation to loop (off by default)
  16061. * @param speedRatio defines the speed ratio to apply to all animations
  16062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16063. * @param onAnimationLoop defines the callback to call when an animation loops
  16064. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16065. * @returns the list of created animatables
  16066. */
  16067. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16068. /**
  16069. * Begin a new animation on a given node and its hierarchy
  16070. * @param target defines the root node where the animation will take place
  16071. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16072. * @param animations defines the list of animations to start
  16073. * @param from defines the initial value
  16074. * @param to defines the final value
  16075. * @param loop defines if you want animation to loop (off by default)
  16076. * @param speedRatio defines the speed ratio to apply to all animations
  16077. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16078. * @param onAnimationLoop defines the callback to call when an animation loops
  16079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16080. * @returns the list of animatables created for all nodes
  16081. */
  16082. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16083. /**
  16084. * Gets the animatable associated with a specific target
  16085. * @param target defines the target of the animatable
  16086. * @returns the required animatable if found
  16087. */
  16088. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16089. /**
  16090. * Gets all animatables associated with a given target
  16091. * @param target defines the target to look animatables for
  16092. * @returns an array of Animatables
  16093. */
  16094. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16095. /**
  16096. * Stops and removes all animations that have been applied to the scene
  16097. */
  16098. stopAllAnimations(): void;
  16099. /**
  16100. * Gets the current delta time used by animation engine
  16101. */
  16102. deltaTime: number;
  16103. }
  16104. interface Bone {
  16105. /**
  16106. * Copy an animation range from another bone
  16107. * @param source defines the source bone
  16108. * @param rangeName defines the range name to copy
  16109. * @param frameOffset defines the frame offset
  16110. * @param rescaleAsRequired defines if rescaling must be applied if required
  16111. * @param skelDimensionsRatio defines the scaling ratio
  16112. * @returns true if operation was successful
  16113. */
  16114. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Class used to handle skinning animations
  16120. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16121. */
  16122. export class Skeleton implements IAnimatable {
  16123. /** defines the skeleton name */
  16124. name: string;
  16125. /** defines the skeleton Id */
  16126. id: string;
  16127. /**
  16128. * Defines the list of child bones
  16129. */
  16130. bones: Bone[];
  16131. /**
  16132. * Defines an estimate of the dimension of the skeleton at rest
  16133. */
  16134. dimensionsAtRest: Vector3;
  16135. /**
  16136. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16137. */
  16138. needInitialSkinMatrix: boolean;
  16139. /**
  16140. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16141. */
  16142. overrideMesh: Nullable<AbstractMesh>;
  16143. /**
  16144. * Gets the list of animations attached to this skeleton
  16145. */
  16146. animations: Array<Animation>;
  16147. private _scene;
  16148. private _isDirty;
  16149. private _transformMatrices;
  16150. private _transformMatrixTexture;
  16151. private _meshesWithPoseMatrix;
  16152. private _animatables;
  16153. private _identity;
  16154. private _synchronizedWithMesh;
  16155. private _ranges;
  16156. private _lastAbsoluteTransformsUpdateId;
  16157. private _canUseTextureForBones;
  16158. private _uniqueId;
  16159. /** @hidden */
  16160. _numBonesWithLinkedTransformNode: number;
  16161. /** @hidden */
  16162. _hasWaitingData: Nullable<boolean>;
  16163. /** @hidden */
  16164. _waitingOverrideMeshId: Nullable<string>;
  16165. /**
  16166. * Specifies if the skeleton should be serialized
  16167. */
  16168. doNotSerialize: boolean;
  16169. private _useTextureToStoreBoneMatrices;
  16170. /**
  16171. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16172. * Please note that this option is not available if the hardware does not support it
  16173. */
  16174. get useTextureToStoreBoneMatrices(): boolean;
  16175. set useTextureToStoreBoneMatrices(value: boolean);
  16176. private _animationPropertiesOverride;
  16177. /**
  16178. * Gets or sets the animation properties override
  16179. */
  16180. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16181. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16182. /**
  16183. * List of inspectable custom properties (used by the Inspector)
  16184. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16185. */
  16186. inspectableCustomProperties: IInspectable[];
  16187. /**
  16188. * An observable triggered before computing the skeleton's matrices
  16189. */
  16190. onBeforeComputeObservable: Observable<Skeleton>;
  16191. /**
  16192. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16193. */
  16194. get isUsingTextureForMatrices(): boolean;
  16195. /**
  16196. * Gets the unique ID of this skeleton
  16197. */
  16198. get uniqueId(): number;
  16199. /**
  16200. * Creates a new skeleton
  16201. * @param name defines the skeleton name
  16202. * @param id defines the skeleton Id
  16203. * @param scene defines the hosting scene
  16204. */
  16205. constructor(
  16206. /** defines the skeleton name */
  16207. name: string,
  16208. /** defines the skeleton Id */
  16209. id: string, scene: Scene);
  16210. /**
  16211. * Gets the current object class name.
  16212. * @return the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Returns an array containing the root bones
  16217. * @returns an array containing the root bones
  16218. */
  16219. getChildren(): Array<Bone>;
  16220. /**
  16221. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16222. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16223. * @returns a Float32Array containing matrices data
  16224. */
  16225. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16226. /**
  16227. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16228. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16229. * @returns a raw texture containing the data
  16230. */
  16231. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16232. /**
  16233. * Gets the current hosting scene
  16234. * @returns a scene object
  16235. */
  16236. getScene(): Scene;
  16237. /**
  16238. * Gets a string representing the current skeleton data
  16239. * @param fullDetails defines a boolean indicating if we want a verbose version
  16240. * @returns a string representing the current skeleton data
  16241. */
  16242. toString(fullDetails?: boolean): string;
  16243. /**
  16244. * Get bone's index searching by name
  16245. * @param name defines bone's name to search for
  16246. * @return the indice of the bone. Returns -1 if not found
  16247. */
  16248. getBoneIndexByName(name: string): number;
  16249. /**
  16250. * Creater a new animation range
  16251. * @param name defines the name of the range
  16252. * @param from defines the start key
  16253. * @param to defines the end key
  16254. */
  16255. createAnimationRange(name: string, from: number, to: number): void;
  16256. /**
  16257. * Delete a specific animation range
  16258. * @param name defines the name of the range
  16259. * @param deleteFrames defines if frames must be removed as well
  16260. */
  16261. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16262. /**
  16263. * Gets a specific animation range
  16264. * @param name defines the name of the range to look for
  16265. * @returns the requested animation range or null if not found
  16266. */
  16267. getAnimationRange(name: string): Nullable<AnimationRange>;
  16268. /**
  16269. * Gets the list of all animation ranges defined on this skeleton
  16270. * @returns an array
  16271. */
  16272. getAnimationRanges(): Nullable<AnimationRange>[];
  16273. /**
  16274. * Copy animation range from a source skeleton.
  16275. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16276. * @param source defines the source skeleton
  16277. * @param name defines the name of the range to copy
  16278. * @param rescaleAsRequired defines if rescaling must be applied if required
  16279. * @returns true if operation was successful
  16280. */
  16281. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16282. /**
  16283. * Forces the skeleton to go to rest pose
  16284. */
  16285. returnToRest(): void;
  16286. private _getHighestAnimationFrame;
  16287. /**
  16288. * Begin a specific animation range
  16289. * @param name defines the name of the range to start
  16290. * @param loop defines if looping must be turned on (false by default)
  16291. * @param speedRatio defines the speed ratio to apply (1 by default)
  16292. * @param onAnimationEnd defines a callback which will be called when animation will end
  16293. * @returns a new animatable
  16294. */
  16295. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16296. /**
  16297. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16298. * @param skeleton defines the Skeleton containing the animation range to convert
  16299. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16300. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16301. * @returns the original skeleton
  16302. */
  16303. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16304. /** @hidden */
  16305. _markAsDirty(): void;
  16306. /** @hidden */
  16307. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16308. /** @hidden */
  16309. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16310. private _computeTransformMatrices;
  16311. /**
  16312. * Build all resources required to render a skeleton
  16313. */
  16314. prepare(): void;
  16315. /**
  16316. * Gets the list of animatables currently running for this skeleton
  16317. * @returns an array of animatables
  16318. */
  16319. getAnimatables(): IAnimatable[];
  16320. /**
  16321. * Clone the current skeleton
  16322. * @param name defines the name of the new skeleton
  16323. * @param id defines the id of the new skeleton
  16324. * @returns the new skeleton
  16325. */
  16326. clone(name: string, id?: string): Skeleton;
  16327. /**
  16328. * Enable animation blending for this skeleton
  16329. * @param blendingSpeed defines the blending speed to apply
  16330. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16331. */
  16332. enableBlending(blendingSpeed?: number): void;
  16333. /**
  16334. * Releases all resources associated with the current skeleton
  16335. */
  16336. dispose(): void;
  16337. /**
  16338. * Serialize the skeleton in a JSON object
  16339. * @returns a JSON object
  16340. */
  16341. serialize(): any;
  16342. /**
  16343. * Creates a new skeleton from serialized data
  16344. * @param parsedSkeleton defines the serialized data
  16345. * @param scene defines the hosting scene
  16346. * @returns a new skeleton
  16347. */
  16348. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16349. /**
  16350. * Compute all node absolute transforms
  16351. * @param forceUpdate defines if computation must be done even if cache is up to date
  16352. */
  16353. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16354. /**
  16355. * Gets the root pose matrix
  16356. * @returns a matrix
  16357. */
  16358. getPoseMatrix(): Nullable<Matrix>;
  16359. /**
  16360. * Sorts bones per internal index
  16361. */
  16362. sortBones(): void;
  16363. private _sortBones;
  16364. /**
  16365. * Set the current local matrix as the restPose for all bones in the skeleton.
  16366. */
  16367. setCurrentPoseAsRest(): void;
  16368. }
  16369. }
  16370. declare module BABYLON {
  16371. /**
  16372. * Creates an instance based on a source mesh.
  16373. */
  16374. export class InstancedMesh extends AbstractMesh {
  16375. private _sourceMesh;
  16376. private _currentLOD;
  16377. /** @hidden */
  16378. _indexInSourceMeshInstanceArray: number;
  16379. constructor(name: string, source: Mesh);
  16380. /**
  16381. * Returns the string "InstancedMesh".
  16382. */
  16383. getClassName(): string;
  16384. /** Gets the list of lights affecting that mesh */
  16385. get lightSources(): Light[];
  16386. _resyncLightSources(): void;
  16387. _resyncLightSource(light: Light): void;
  16388. _removeLightSource(light: Light, dispose: boolean): void;
  16389. /**
  16390. * If the source mesh receives shadows
  16391. */
  16392. get receiveShadows(): boolean;
  16393. /**
  16394. * The material of the source mesh
  16395. */
  16396. get material(): Nullable<Material>;
  16397. /**
  16398. * Visibility of the source mesh
  16399. */
  16400. get visibility(): number;
  16401. /**
  16402. * Skeleton of the source mesh
  16403. */
  16404. get skeleton(): Nullable<Skeleton>;
  16405. /**
  16406. * Rendering ground id of the source mesh
  16407. */
  16408. get renderingGroupId(): number;
  16409. set renderingGroupId(value: number);
  16410. /**
  16411. * Returns the total number of vertices (integer).
  16412. */
  16413. getTotalVertices(): number;
  16414. /**
  16415. * Returns a positive integer : the total number of indices in this mesh geometry.
  16416. * @returns the numner of indices or zero if the mesh has no geometry.
  16417. */
  16418. getTotalIndices(): number;
  16419. /**
  16420. * The source mesh of the instance
  16421. */
  16422. get sourceMesh(): Mesh;
  16423. /**
  16424. * Creates a new InstancedMesh object from the mesh model.
  16425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16426. * @param name defines the name of the new instance
  16427. * @returns a new InstancedMesh
  16428. */
  16429. createInstance(name: string): InstancedMesh;
  16430. /**
  16431. * Is this node ready to be used/rendered
  16432. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16433. * @return {boolean} is it ready
  16434. */
  16435. isReady(completeCheck?: boolean): boolean;
  16436. /**
  16437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16438. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16439. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16440. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16441. */
  16442. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16443. /**
  16444. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16445. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16446. * The `data` are either a numeric array either a Float32Array.
  16447. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16448. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16449. * Note that a new underlying VertexBuffer object is created each call.
  16450. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16451. *
  16452. * Possible `kind` values :
  16453. * - VertexBuffer.PositionKind
  16454. * - VertexBuffer.UVKind
  16455. * - VertexBuffer.UV2Kind
  16456. * - VertexBuffer.UV3Kind
  16457. * - VertexBuffer.UV4Kind
  16458. * - VertexBuffer.UV5Kind
  16459. * - VertexBuffer.UV6Kind
  16460. * - VertexBuffer.ColorKind
  16461. * - VertexBuffer.MatricesIndicesKind
  16462. * - VertexBuffer.MatricesIndicesExtraKind
  16463. * - VertexBuffer.MatricesWeightsKind
  16464. * - VertexBuffer.MatricesWeightsExtraKind
  16465. *
  16466. * Returns the Mesh.
  16467. */
  16468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16469. /**
  16470. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16471. * If the mesh has no geometry, it is simply returned as it is.
  16472. * The `data` are either a numeric array either a Float32Array.
  16473. * No new underlying VertexBuffer object is created.
  16474. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16475. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16476. *
  16477. * Possible `kind` values :
  16478. * - VertexBuffer.PositionKind
  16479. * - VertexBuffer.UVKind
  16480. * - VertexBuffer.UV2Kind
  16481. * - VertexBuffer.UV3Kind
  16482. * - VertexBuffer.UV4Kind
  16483. * - VertexBuffer.UV5Kind
  16484. * - VertexBuffer.UV6Kind
  16485. * - VertexBuffer.ColorKind
  16486. * - VertexBuffer.MatricesIndicesKind
  16487. * - VertexBuffer.MatricesIndicesExtraKind
  16488. * - VertexBuffer.MatricesWeightsKind
  16489. * - VertexBuffer.MatricesWeightsExtraKind
  16490. *
  16491. * Returns the Mesh.
  16492. */
  16493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16494. /**
  16495. * Sets the mesh indices.
  16496. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16497. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16498. * This method creates a new index buffer each call.
  16499. * Returns the Mesh.
  16500. */
  16501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16502. /**
  16503. * Boolean : True if the mesh owns the requested kind of data.
  16504. */
  16505. isVerticesDataPresent(kind: string): boolean;
  16506. /**
  16507. * Returns an array of indices (IndicesArray).
  16508. */
  16509. getIndices(): Nullable<IndicesArray>;
  16510. get _positions(): Nullable<Vector3[]>;
  16511. /**
  16512. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16513. * This means the mesh underlying bounding box and sphere are recomputed.
  16514. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16515. * @returns the current mesh
  16516. */
  16517. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16518. /** @hidden */
  16519. _preActivate(): InstancedMesh;
  16520. /** @hidden */
  16521. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16522. /** @hidden */
  16523. _postActivate(): void;
  16524. getWorldMatrix(): Matrix;
  16525. get isAnInstance(): boolean;
  16526. /**
  16527. * Returns the current associated LOD AbstractMesh.
  16528. */
  16529. getLOD(camera: Camera): AbstractMesh;
  16530. /** @hidden */
  16531. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16532. /** @hidden */
  16533. _syncSubMeshes(): InstancedMesh;
  16534. /** @hidden */
  16535. _generatePointsArray(): boolean;
  16536. /** @hidden */
  16537. _updateBoundingInfo(): AbstractMesh;
  16538. /**
  16539. * Creates a new InstancedMesh from the current mesh.
  16540. * - name (string) : the cloned mesh name
  16541. * - newParent (optional Node) : the optional Node to parent the clone to.
  16542. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16543. *
  16544. * Returns the clone.
  16545. */
  16546. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16547. /**
  16548. * Disposes the InstancedMesh.
  16549. * Returns nothing.
  16550. */
  16551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16552. }
  16553. interface Mesh {
  16554. /**
  16555. * Register a custom buffer that will be instanced
  16556. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16557. * @param kind defines the buffer kind
  16558. * @param stride defines the stride in floats
  16559. */
  16560. registerInstancedBuffer(kind: string, stride: number): void;
  16561. /**
  16562. * true to use the edge renderer for all instances of this mesh
  16563. */
  16564. edgesShareWithInstances: boolean;
  16565. /** @hidden */
  16566. _userInstancedBuffersStorage: {
  16567. data: {
  16568. [key: string]: Float32Array;
  16569. };
  16570. sizes: {
  16571. [key: string]: number;
  16572. };
  16573. vertexBuffers: {
  16574. [key: string]: Nullable<VertexBuffer>;
  16575. };
  16576. strides: {
  16577. [key: string]: number;
  16578. };
  16579. };
  16580. }
  16581. interface AbstractMesh {
  16582. /**
  16583. * Object used to store instanced buffers defined by user
  16584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16585. */
  16586. instancedBuffers: {
  16587. [key: string]: any;
  16588. };
  16589. }
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * Defines the options associated with the creation of a shader material.
  16594. */
  16595. export interface IShaderMaterialOptions {
  16596. /**
  16597. * Does the material work in alpha blend mode
  16598. */
  16599. needAlphaBlending: boolean;
  16600. /**
  16601. * Does the material work in alpha test mode
  16602. */
  16603. needAlphaTesting: boolean;
  16604. /**
  16605. * The list of attribute names used in the shader
  16606. */
  16607. attributes: string[];
  16608. /**
  16609. * The list of unifrom names used in the shader
  16610. */
  16611. uniforms: string[];
  16612. /**
  16613. * The list of UBO names used in the shader
  16614. */
  16615. uniformBuffers: string[];
  16616. /**
  16617. * The list of sampler names used in the shader
  16618. */
  16619. samplers: string[];
  16620. /**
  16621. * The list of defines used in the shader
  16622. */
  16623. defines: string[];
  16624. }
  16625. /**
  16626. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16627. *
  16628. * This returned material effects how the mesh will look based on the code in the shaders.
  16629. *
  16630. * @see https://doc.babylonjs.com/how_to/shader_material
  16631. */
  16632. export class ShaderMaterial extends Material {
  16633. private _shaderPath;
  16634. private _options;
  16635. private _textures;
  16636. private _textureArrays;
  16637. private _floats;
  16638. private _ints;
  16639. private _floatsArrays;
  16640. private _colors3;
  16641. private _colors3Arrays;
  16642. private _colors4;
  16643. private _colors4Arrays;
  16644. private _vectors2;
  16645. private _vectors3;
  16646. private _vectors4;
  16647. private _matrices;
  16648. private _matrixArrays;
  16649. private _matrices3x3;
  16650. private _matrices2x2;
  16651. private _vectors2Arrays;
  16652. private _vectors3Arrays;
  16653. private _vectors4Arrays;
  16654. private _cachedWorldViewMatrix;
  16655. private _cachedWorldViewProjectionMatrix;
  16656. private _renderId;
  16657. private _multiview;
  16658. private _cachedDefines;
  16659. /** Define the Url to load snippets */
  16660. static SnippetUrl: string;
  16661. /** Snippet ID if the material was created from the snippet server */
  16662. snippetId: string;
  16663. /**
  16664. * Instantiate a new shader material.
  16665. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16666. * This returned material effects how the mesh will look based on the code in the shaders.
  16667. * @see https://doc.babylonjs.com/how_to/shader_material
  16668. * @param name Define the name of the material in the scene
  16669. * @param scene Define the scene the material belongs to
  16670. * @param shaderPath Defines the route to the shader code in one of three ways:
  16671. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16672. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16673. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16674. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16675. * @param options Define the options used to create the shader
  16676. */
  16677. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16678. /**
  16679. * Gets the shader path used to define the shader code
  16680. * It can be modified to trigger a new compilation
  16681. */
  16682. get shaderPath(): any;
  16683. /**
  16684. * Sets the shader path used to define the shader code
  16685. * It can be modified to trigger a new compilation
  16686. */
  16687. set shaderPath(shaderPath: any);
  16688. /**
  16689. * Gets the options used to compile the shader.
  16690. * They can be modified to trigger a new compilation
  16691. */
  16692. get options(): IShaderMaterialOptions;
  16693. /**
  16694. * Gets the current class name of the material e.g. "ShaderMaterial"
  16695. * Mainly use in serialization.
  16696. * @returns the class name
  16697. */
  16698. getClassName(): string;
  16699. /**
  16700. * Specifies if the material will require alpha blending
  16701. * @returns a boolean specifying if alpha blending is needed
  16702. */
  16703. needAlphaBlending(): boolean;
  16704. /**
  16705. * Specifies if this material should be rendered in alpha test mode
  16706. * @returns a boolean specifying if an alpha test is needed.
  16707. */
  16708. needAlphaTesting(): boolean;
  16709. private _checkUniform;
  16710. /**
  16711. * Set a texture in the shader.
  16712. * @param name Define the name of the uniform samplers as defined in the shader
  16713. * @param texture Define the texture to bind to this sampler
  16714. * @return the material itself allowing "fluent" like uniform updates
  16715. */
  16716. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16717. /**
  16718. * Set a texture array in the shader.
  16719. * @param name Define the name of the uniform sampler array as defined in the shader
  16720. * @param textures Define the list of textures to bind to this sampler
  16721. * @return the material itself allowing "fluent" like uniform updates
  16722. */
  16723. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16724. /**
  16725. * Set a float in the shader.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the material itself allowing "fluent" like uniform updates
  16729. */
  16730. setFloat(name: string, value: number): ShaderMaterial;
  16731. /**
  16732. * Set a int in the shader.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the material itself allowing "fluent" like uniform updates
  16736. */
  16737. setInt(name: string, value: number): ShaderMaterial;
  16738. /**
  16739. * Set an array of floats in the shader.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the material itself allowing "fluent" like uniform updates
  16743. */
  16744. setFloats(name: string, value: number[]): ShaderMaterial;
  16745. /**
  16746. * Set a vec3 in the shader from a Color3.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setColor3(name: string, value: Color3): ShaderMaterial;
  16752. /**
  16753. * Set a vec3 array in the shader from a Color3 array.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the material itself allowing "fluent" like uniform updates
  16757. */
  16758. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16759. /**
  16760. * Set a vec4 in the shader from a Color4.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setColor4(name: string, value: Color4): ShaderMaterial;
  16766. /**
  16767. * Set a vec4 array in the shader from a Color4 array.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16773. /**
  16774. * Set a vec2 in the shader from a Vector2.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setVector2(name: string, value: Vector2): ShaderMaterial;
  16780. /**
  16781. * Set a vec3 in the shader from a Vector3.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setVector3(name: string, value: Vector3): ShaderMaterial;
  16787. /**
  16788. * Set a vec4 in the shader from a Vector4.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setVector4(name: string, value: Vector4): ShaderMaterial;
  16794. /**
  16795. * Set a mat4 in the shader from a Matrix.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16801. /**
  16802. * Set a float32Array in the shader from a matrix array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16808. /**
  16809. * Set a mat3 in the shader from a Float32Array.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16815. /**
  16816. * Set a mat2 in the shader from a Float32Array.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16822. /**
  16823. * Set a vec2 array in the shader from a number array.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setArray2(name: string, value: number[]): ShaderMaterial;
  16829. /**
  16830. * Set a vec3 array in the shader from a number array.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setArray3(name: string, value: number[]): ShaderMaterial;
  16836. /**
  16837. * Set a vec4 array in the shader from a number array.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setArray4(name: string, value: number[]): ShaderMaterial;
  16843. private _checkCache;
  16844. /**
  16845. * Specifies that the submesh is ready to be used
  16846. * @param mesh defines the mesh to check
  16847. * @param subMesh defines which submesh to check
  16848. * @param useInstances specifies that instances should be used
  16849. * @returns a boolean indicating that the submesh is ready or not
  16850. */
  16851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16852. /**
  16853. * Checks if the material is ready to render the requested mesh
  16854. * @param mesh Define the mesh to render
  16855. * @param useInstances Define whether or not the material is used with instances
  16856. * @returns true if ready, otherwise false
  16857. */
  16858. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16859. /**
  16860. * Binds the world matrix to the material
  16861. * @param world defines the world transformation matrix
  16862. * @param effectOverride - If provided, use this effect instead of internal effect
  16863. */
  16864. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16865. /**
  16866. * Binds the submesh to this material by preparing the effect and shader to draw
  16867. * @param world defines the world transformation matrix
  16868. * @param mesh defines the mesh containing the submesh
  16869. * @param subMesh defines the submesh to bind the material to
  16870. */
  16871. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16872. /**
  16873. * Binds the material to the mesh
  16874. * @param world defines the world transformation matrix
  16875. * @param mesh defines the mesh to bind the material to
  16876. * @param effectOverride - If provided, use this effect instead of internal effect
  16877. */
  16878. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16879. protected _afterBind(mesh?: Mesh): void;
  16880. /**
  16881. * Gets the active textures from the material
  16882. * @returns an array of textures
  16883. */
  16884. getActiveTextures(): BaseTexture[];
  16885. /**
  16886. * Specifies if the material uses a texture
  16887. * @param texture defines the texture to check against the material
  16888. * @returns a boolean specifying if the material uses the texture
  16889. */
  16890. hasTexture(texture: BaseTexture): boolean;
  16891. /**
  16892. * Makes a duplicate of the material, and gives it a new name
  16893. * @param name defines the new name for the duplicated material
  16894. * @returns the cloned material
  16895. */
  16896. clone(name: string): ShaderMaterial;
  16897. /**
  16898. * Disposes the material
  16899. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16900. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16901. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16902. */
  16903. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16904. /**
  16905. * Serializes this material in a JSON representation
  16906. * @returns the serialized material object
  16907. */
  16908. serialize(): any;
  16909. /**
  16910. * Creates a shader material from parsed shader material data
  16911. * @param source defines the JSON represnetation of the material
  16912. * @param scene defines the hosting scene
  16913. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16914. * @returns a new material
  16915. */
  16916. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16917. /**
  16918. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16919. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16920. * @param url defines the url to load from
  16921. * @param scene defines the hosting scene
  16922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16923. * @returns a promise that will resolve to the new ShaderMaterial
  16924. */
  16925. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16926. /**
  16927. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16928. * @param snippetId defines the snippet to load
  16929. * @param scene defines the hosting scene
  16930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16931. * @returns a promise that will resolve to the new ShaderMaterial
  16932. */
  16933. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /** @hidden */
  16938. export var colorPixelShader: {
  16939. name: string;
  16940. shader: string;
  16941. };
  16942. }
  16943. declare module BABYLON {
  16944. /** @hidden */
  16945. export var colorVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module BABYLON {
  16951. /**
  16952. * Line mesh
  16953. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16954. */
  16955. export class LinesMesh extends Mesh {
  16956. /**
  16957. * If vertex color should be applied to the mesh
  16958. */
  16959. readonly useVertexColor?: boolean | undefined;
  16960. /**
  16961. * If vertex alpha should be applied to the mesh
  16962. */
  16963. readonly useVertexAlpha?: boolean | undefined;
  16964. /**
  16965. * Color of the line (Default: White)
  16966. */
  16967. color: Color3;
  16968. /**
  16969. * Alpha of the line (Default: 1)
  16970. */
  16971. alpha: number;
  16972. /**
  16973. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16974. * This margin is expressed in world space coordinates, so its value may vary.
  16975. * Default value is 0.1
  16976. */
  16977. intersectionThreshold: number;
  16978. private _colorShader;
  16979. private color4;
  16980. /**
  16981. * Creates a new LinesMesh
  16982. * @param name defines the name
  16983. * @param scene defines the hosting scene
  16984. * @param parent defines the parent mesh if any
  16985. * @param source defines the optional source LinesMesh used to clone data from
  16986. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16987. * When false, achieved by calling a clone(), also passing False.
  16988. * This will make creation of children, recursive.
  16989. * @param useVertexColor defines if this LinesMesh supports vertex color
  16990. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16991. */
  16992. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16993. /**
  16994. * If vertex color should be applied to the mesh
  16995. */
  16996. useVertexColor?: boolean | undefined,
  16997. /**
  16998. * If vertex alpha should be applied to the mesh
  16999. */
  17000. useVertexAlpha?: boolean | undefined);
  17001. private _addClipPlaneDefine;
  17002. private _removeClipPlaneDefine;
  17003. isReady(): boolean;
  17004. /**
  17005. * Returns the string "LineMesh"
  17006. */
  17007. getClassName(): string;
  17008. /**
  17009. * @hidden
  17010. */
  17011. get material(): Material;
  17012. /**
  17013. * @hidden
  17014. */
  17015. set material(value: Material);
  17016. /**
  17017. * @hidden
  17018. */
  17019. get checkCollisions(): boolean;
  17020. /** @hidden */
  17021. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17022. /** @hidden */
  17023. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17024. /**
  17025. * Disposes of the line mesh
  17026. * @param doNotRecurse If children should be disposed
  17027. */
  17028. dispose(doNotRecurse?: boolean): void;
  17029. /**
  17030. * Returns a new LineMesh object cloned from the current one.
  17031. */
  17032. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17033. /**
  17034. * Creates a new InstancedLinesMesh object from the mesh model.
  17035. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17036. * @param name defines the name of the new instance
  17037. * @returns a new InstancedLinesMesh
  17038. */
  17039. createInstance(name: string): InstancedLinesMesh;
  17040. }
  17041. /**
  17042. * Creates an instance based on a source LinesMesh
  17043. */
  17044. export class InstancedLinesMesh extends InstancedMesh {
  17045. /**
  17046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17047. * This margin is expressed in world space coordinates, so its value may vary.
  17048. * Initilized with the intersectionThreshold value of the source LinesMesh
  17049. */
  17050. intersectionThreshold: number;
  17051. constructor(name: string, source: LinesMesh);
  17052. /**
  17053. * Returns the string "InstancedLinesMesh".
  17054. */
  17055. getClassName(): string;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /** @hidden */
  17060. export var linePixelShader: {
  17061. name: string;
  17062. shader: string;
  17063. };
  17064. }
  17065. declare module BABYLON {
  17066. /** @hidden */
  17067. export var lineVertexShader: {
  17068. name: string;
  17069. shader: string;
  17070. };
  17071. }
  17072. declare module BABYLON {
  17073. interface Scene {
  17074. /** @hidden */
  17075. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17076. }
  17077. interface AbstractMesh {
  17078. /**
  17079. * Gets the edgesRenderer associated with the mesh
  17080. */
  17081. edgesRenderer: Nullable<EdgesRenderer>;
  17082. }
  17083. interface LinesMesh {
  17084. /**
  17085. * Enables the edge rendering mode on the mesh.
  17086. * This mode makes the mesh edges visible
  17087. * @param epsilon defines the maximal distance between two angles to detect a face
  17088. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17089. * @returns the currentAbstractMesh
  17090. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17091. */
  17092. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17093. }
  17094. interface InstancedLinesMesh {
  17095. /**
  17096. * Enables the edge rendering mode on the mesh.
  17097. * This mode makes the mesh edges visible
  17098. * @param epsilon defines the maximal distance between two angles to detect a face
  17099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17100. * @returns the current InstancedLinesMesh
  17101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17102. */
  17103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17104. }
  17105. /**
  17106. * Defines the minimum contract an Edges renderer should follow.
  17107. */
  17108. export interface IEdgesRenderer extends IDisposable {
  17109. /**
  17110. * Gets or sets a boolean indicating if the edgesRenderer is active
  17111. */
  17112. isEnabled: boolean;
  17113. /**
  17114. * Renders the edges of the attached mesh,
  17115. */
  17116. render(): void;
  17117. /**
  17118. * Checks wether or not the edges renderer is ready to render.
  17119. * @return true if ready, otherwise false.
  17120. */
  17121. isReady(): boolean;
  17122. /**
  17123. * List of instances to render in case the source mesh has instances
  17124. */
  17125. customInstances: SmartArray<Matrix>;
  17126. }
  17127. /**
  17128. * Defines the additional options of the edges renderer
  17129. */
  17130. export interface IEdgesRendererOptions {
  17131. /**
  17132. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17133. * If not defined, the default value is true
  17134. */
  17135. useAlternateEdgeFinder?: boolean;
  17136. /**
  17137. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17138. * If not defined, the default value is true.
  17139. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17140. * This option is used only if useAlternateEdgeFinder = true
  17141. */
  17142. useFastVertexMerger?: boolean;
  17143. /**
  17144. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17145. * The default value is 1e-6
  17146. * This option is used only if useAlternateEdgeFinder = true
  17147. */
  17148. epsilonVertexMerge?: number;
  17149. /**
  17150. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17151. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17152. * This option is used only if useAlternateEdgeFinder = true
  17153. */
  17154. applyTessellation?: boolean;
  17155. /**
  17156. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17157. * The default value is 1e-6
  17158. * This option is used only if useAlternateEdgeFinder = true
  17159. */
  17160. epsilonVertexAligned?: number;
  17161. }
  17162. /**
  17163. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17164. */
  17165. export class EdgesRenderer implements IEdgesRenderer {
  17166. /**
  17167. * Define the size of the edges with an orthographic camera
  17168. */
  17169. edgesWidthScalerForOrthographic: number;
  17170. /**
  17171. * Define the size of the edges with a perspective camera
  17172. */
  17173. edgesWidthScalerForPerspective: number;
  17174. protected _source: AbstractMesh;
  17175. protected _linesPositions: number[];
  17176. protected _linesNormals: number[];
  17177. protected _linesIndices: number[];
  17178. protected _epsilon: number;
  17179. protected _indicesCount: number;
  17180. protected _lineShader: ShaderMaterial;
  17181. protected _ib: DataBuffer;
  17182. protected _buffers: {
  17183. [key: string]: Nullable<VertexBuffer>;
  17184. };
  17185. protected _buffersForInstances: {
  17186. [key: string]: Nullable<VertexBuffer>;
  17187. };
  17188. protected _checkVerticesInsteadOfIndices: boolean;
  17189. protected _options: Nullable<IEdgesRendererOptions>;
  17190. private _meshRebuildObserver;
  17191. private _meshDisposeObserver;
  17192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17193. isEnabled: boolean;
  17194. /**
  17195. * List of instances to render in case the source mesh has instances
  17196. */
  17197. customInstances: SmartArray<Matrix>;
  17198. private static GetShader;
  17199. /**
  17200. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17201. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17202. * @param source Mesh used to create edges
  17203. * @param epsilon sum of angles in adjacency to check for edge
  17204. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17205. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17206. * @param options The options to apply when generating the edges
  17207. */
  17208. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17209. protected _prepareRessources(): void;
  17210. /** @hidden */
  17211. _rebuild(): void;
  17212. /**
  17213. * Releases the required resources for the edges renderer
  17214. */
  17215. dispose(): void;
  17216. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17217. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17218. /**
  17219. * Checks if the pair of p0 and p1 is en edge
  17220. * @param faceIndex
  17221. * @param edge
  17222. * @param faceNormals
  17223. * @param p0
  17224. * @param p1
  17225. * @private
  17226. */
  17227. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17228. /**
  17229. * push line into the position, normal and index buffer
  17230. * @protected
  17231. */
  17232. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17233. /**
  17234. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17235. */
  17236. private _tessellateTriangle;
  17237. private _generateEdgesLinesAlternate;
  17238. /**
  17239. * Generates lines edges from adjacencjes
  17240. * @private
  17241. */
  17242. _generateEdgesLines(): void;
  17243. /**
  17244. * Checks wether or not the edges renderer is ready to render.
  17245. * @return true if ready, otherwise false.
  17246. */
  17247. isReady(): boolean;
  17248. /**
  17249. * Renders the edges of the attached mesh,
  17250. */
  17251. render(): void;
  17252. }
  17253. /**
  17254. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17255. */
  17256. export class LineEdgesRenderer extends EdgesRenderer {
  17257. /**
  17258. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17259. * @param source LineMesh used to generate edges
  17260. * @param epsilon not important (specified angle for edge detection)
  17261. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17262. */
  17263. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17264. /**
  17265. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17266. */
  17267. _generateEdgesLines(): void;
  17268. }
  17269. }
  17270. declare module BABYLON {
  17271. /**
  17272. * This represents the object necessary to create a rendering group.
  17273. * This is exclusively used and created by the rendering manager.
  17274. * To modify the behavior, you use the available helpers in your scene or meshes.
  17275. * @hidden
  17276. */
  17277. export class RenderingGroup {
  17278. index: number;
  17279. private static _zeroVector;
  17280. private _scene;
  17281. private _opaqueSubMeshes;
  17282. private _transparentSubMeshes;
  17283. private _alphaTestSubMeshes;
  17284. private _depthOnlySubMeshes;
  17285. private _particleSystems;
  17286. private _spriteManagers;
  17287. private _opaqueSortCompareFn;
  17288. private _alphaTestSortCompareFn;
  17289. private _transparentSortCompareFn;
  17290. private _renderOpaque;
  17291. private _renderAlphaTest;
  17292. private _renderTransparent;
  17293. /** @hidden */
  17294. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17295. onBeforeTransparentRendering: () => void;
  17296. /**
  17297. * Set the opaque sort comparison function.
  17298. * If null the sub meshes will be render in the order they were created
  17299. */
  17300. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17301. /**
  17302. * Set the alpha test sort comparison function.
  17303. * If null the sub meshes will be render in the order they were created
  17304. */
  17305. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17306. /**
  17307. * Set the transparent sort comparison function.
  17308. * If null the sub meshes will be render in the order they were created
  17309. */
  17310. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17311. /**
  17312. * Creates a new rendering group.
  17313. * @param index The rendering group index
  17314. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17315. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17316. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17317. */
  17318. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17319. /**
  17320. * Render all the sub meshes contained in the group.
  17321. * @param customRenderFunction Used to override the default render behaviour of the group.
  17322. * @returns true if rendered some submeshes.
  17323. */
  17324. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17325. /**
  17326. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17327. * @param subMeshes The submeshes to render
  17328. */
  17329. private renderOpaqueSorted;
  17330. /**
  17331. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17332. * @param subMeshes The submeshes to render
  17333. */
  17334. private renderAlphaTestSorted;
  17335. /**
  17336. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17337. * @param subMeshes The submeshes to render
  17338. */
  17339. private renderTransparentSorted;
  17340. /**
  17341. * Renders the submeshes in a specified order.
  17342. * @param subMeshes The submeshes to sort before render
  17343. * @param sortCompareFn The comparison function use to sort
  17344. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17345. * @param transparent Specifies to activate blending if true
  17346. */
  17347. private static renderSorted;
  17348. /**
  17349. * Renders the submeshes in the order they were dispatched (no sort applied).
  17350. * @param subMeshes The submeshes to render
  17351. */
  17352. private static renderUnsorted;
  17353. /**
  17354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17355. * are rendered back to front if in the same alpha index.
  17356. *
  17357. * @param a The first submesh
  17358. * @param b The second submesh
  17359. * @returns The result of the comparison
  17360. */
  17361. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17362. /**
  17363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17364. * are rendered back to front.
  17365. *
  17366. * @param a The first submesh
  17367. * @param b The second submesh
  17368. * @returns The result of the comparison
  17369. */
  17370. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17371. /**
  17372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17373. * are rendered front to back (prevent overdraw).
  17374. *
  17375. * @param a The first submesh
  17376. * @param b The second submesh
  17377. * @returns The result of the comparison
  17378. */
  17379. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17380. /**
  17381. * Resets the different lists of submeshes to prepare a new frame.
  17382. */
  17383. prepare(): void;
  17384. dispose(): void;
  17385. /**
  17386. * Inserts the submesh in its correct queue depending on its material.
  17387. * @param subMesh The submesh to dispatch
  17388. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17389. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17390. */
  17391. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17392. dispatchSprites(spriteManager: ISpriteManager): void;
  17393. dispatchParticles(particleSystem: IParticleSystem): void;
  17394. private _renderParticles;
  17395. private _renderSprites;
  17396. }
  17397. }
  17398. declare module BABYLON {
  17399. /**
  17400. * Interface describing the different options available in the rendering manager
  17401. * regarding Auto Clear between groups.
  17402. */
  17403. export interface IRenderingManagerAutoClearSetup {
  17404. /**
  17405. * Defines whether or not autoclear is enable.
  17406. */
  17407. autoClear: boolean;
  17408. /**
  17409. * Defines whether or not to autoclear the depth buffer.
  17410. */
  17411. depth: boolean;
  17412. /**
  17413. * Defines whether or not to autoclear the stencil buffer.
  17414. */
  17415. stencil: boolean;
  17416. }
  17417. /**
  17418. * This class is used by the onRenderingGroupObservable
  17419. */
  17420. export class RenderingGroupInfo {
  17421. /**
  17422. * The Scene that being rendered
  17423. */
  17424. scene: Scene;
  17425. /**
  17426. * The camera currently used for the rendering pass
  17427. */
  17428. camera: Nullable<Camera>;
  17429. /**
  17430. * The ID of the renderingGroup being processed
  17431. */
  17432. renderingGroupId: number;
  17433. }
  17434. /**
  17435. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17436. * It is enable to manage the different groups as well as the different necessary sort functions.
  17437. * This should not be used directly aside of the few static configurations
  17438. */
  17439. export class RenderingManager {
  17440. /**
  17441. * The max id used for rendering groups (not included)
  17442. */
  17443. static MAX_RENDERINGGROUPS: number;
  17444. /**
  17445. * The min id used for rendering groups (included)
  17446. */
  17447. static MIN_RENDERINGGROUPS: number;
  17448. /**
  17449. * Used to globally prevent autoclearing scenes.
  17450. */
  17451. static AUTOCLEAR: boolean;
  17452. /**
  17453. * @hidden
  17454. */
  17455. _useSceneAutoClearSetup: boolean;
  17456. private _scene;
  17457. private _renderingGroups;
  17458. private _depthStencilBufferAlreadyCleaned;
  17459. private _autoClearDepthStencil;
  17460. private _customOpaqueSortCompareFn;
  17461. private _customAlphaTestSortCompareFn;
  17462. private _customTransparentSortCompareFn;
  17463. private _renderingGroupInfo;
  17464. /**
  17465. * Instantiates a new rendering group for a particular scene
  17466. * @param scene Defines the scene the groups belongs to
  17467. */
  17468. constructor(scene: Scene);
  17469. private _clearDepthStencilBuffer;
  17470. /**
  17471. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17472. * @hidden
  17473. */
  17474. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17475. /**
  17476. * Resets the different information of the group to prepare a new frame
  17477. * @hidden
  17478. */
  17479. reset(): void;
  17480. /**
  17481. * Dispose and release the group and its associated resources.
  17482. * @hidden
  17483. */
  17484. dispose(): void;
  17485. /**
  17486. * Clear the info related to rendering groups preventing retention points during dispose.
  17487. */
  17488. freeRenderingGroups(): void;
  17489. private _prepareRenderingGroup;
  17490. /**
  17491. * Add a sprite manager to the rendering manager in order to render it this frame.
  17492. * @param spriteManager Define the sprite manager to render
  17493. */
  17494. dispatchSprites(spriteManager: ISpriteManager): void;
  17495. /**
  17496. * Add a particle system to the rendering manager in order to render it this frame.
  17497. * @param particleSystem Define the particle system to render
  17498. */
  17499. dispatchParticles(particleSystem: IParticleSystem): void;
  17500. /**
  17501. * Add a submesh to the manager in order to render it this frame
  17502. * @param subMesh The submesh to dispatch
  17503. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17504. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17505. */
  17506. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17507. /**
  17508. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17509. * This allowed control for front to back rendering or reversly depending of the special needs.
  17510. *
  17511. * @param renderingGroupId The rendering group id corresponding to its index
  17512. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17513. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17514. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17515. */
  17516. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17517. /**
  17518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17519. *
  17520. * @param renderingGroupId The rendering group id corresponding to its index
  17521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17522. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17523. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17524. */
  17525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17526. /**
  17527. * Gets the current auto clear configuration for one rendering group of the rendering
  17528. * manager.
  17529. * @param index the rendering group index to get the information for
  17530. * @returns The auto clear setup for the requested rendering group
  17531. */
  17532. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17533. }
  17534. }
  17535. declare module BABYLON {
  17536. /**
  17537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17538. */
  17539. export interface ICustomShaderOptions {
  17540. /**
  17541. * Gets or sets the custom shader name to use
  17542. */
  17543. shaderName: string;
  17544. /**
  17545. * The list of attribute names used in the shader
  17546. */
  17547. attributes?: string[];
  17548. /**
  17549. * The list of unifrom names used in the shader
  17550. */
  17551. uniforms?: string[];
  17552. /**
  17553. * The list of sampler names used in the shader
  17554. */
  17555. samplers?: string[];
  17556. /**
  17557. * The list of defines used in the shader
  17558. */
  17559. defines?: string[];
  17560. }
  17561. /**
  17562. * Interface to implement to create a shadow generator compatible with BJS.
  17563. */
  17564. export interface IShadowGenerator {
  17565. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17566. id: string;
  17567. /**
  17568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17569. * @returns The render target texture if present otherwise, null
  17570. */
  17571. getShadowMap(): Nullable<RenderTargetTexture>;
  17572. /**
  17573. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17574. * @param subMesh The submesh we want to render in the shadow map
  17575. * @param useInstances Defines wether will draw in the map using instances
  17576. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17577. * @returns true if ready otherwise, false
  17578. */
  17579. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17580. /**
  17581. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17582. * @param defines Defines of the material we want to update
  17583. * @param lightIndex Index of the light in the enabled light list of the material
  17584. */
  17585. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17586. /**
  17587. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17588. * defined in the generator but impacting the effect).
  17589. * It implies the unifroms available on the materials are the standard BJS ones.
  17590. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17591. * @param effect The effect we are binfing the information for
  17592. */
  17593. bindShadowLight(lightIndex: string, effect: Effect): void;
  17594. /**
  17595. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17596. * (eq to shadow prjection matrix * light transform matrix)
  17597. * @returns The transform matrix used to create the shadow map
  17598. */
  17599. getTransformMatrix(): Matrix;
  17600. /**
  17601. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17602. * Cube and 2D textures for instance.
  17603. */
  17604. recreateShadowMap(): void;
  17605. /**
  17606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17607. * @param onCompiled Callback triggered at the and of the effects compilation
  17608. * @param options Sets of optional options forcing the compilation with different modes
  17609. */
  17610. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17611. useInstances: boolean;
  17612. }>): void;
  17613. /**
  17614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17615. * @param options Sets of optional options forcing the compilation with different modes
  17616. * @returns A promise that resolves when the compilation completes
  17617. */
  17618. forceCompilationAsync(options?: Partial<{
  17619. useInstances: boolean;
  17620. }>): Promise<void>;
  17621. /**
  17622. * Serializes the shadow generator setup to a json object.
  17623. * @returns The serialized JSON object
  17624. */
  17625. serialize(): any;
  17626. /**
  17627. * Disposes the Shadow map and related Textures and effects.
  17628. */
  17629. dispose(): void;
  17630. }
  17631. /**
  17632. * Default implementation IShadowGenerator.
  17633. * This is the main object responsible of generating shadows in the framework.
  17634. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17635. */
  17636. export class ShadowGenerator implements IShadowGenerator {
  17637. /**
  17638. * Name of the shadow generator class
  17639. */
  17640. static CLASSNAME: string;
  17641. /**
  17642. * Shadow generator mode None: no filtering applied.
  17643. */
  17644. static readonly FILTER_NONE: number;
  17645. /**
  17646. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17648. */
  17649. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17650. /**
  17651. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17652. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17653. */
  17654. static readonly FILTER_POISSONSAMPLING: number;
  17655. /**
  17656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17657. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17658. */
  17659. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17660. /**
  17661. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17662. * edge artifacts on steep falloff.
  17663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17664. */
  17665. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17666. /**
  17667. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17668. * edge artifacts on steep falloff.
  17669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17670. */
  17671. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17672. /**
  17673. * Shadow generator mode PCF: Percentage Closer Filtering
  17674. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17675. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17676. */
  17677. static readonly FILTER_PCF: number;
  17678. /**
  17679. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17680. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17681. * Contact Hardening
  17682. */
  17683. static readonly FILTER_PCSS: number;
  17684. /**
  17685. * Reserved for PCF and PCSS
  17686. * Highest Quality.
  17687. *
  17688. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17689. *
  17690. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17691. */
  17692. static readonly QUALITY_HIGH: number;
  17693. /**
  17694. * Reserved for PCF and PCSS
  17695. * Good tradeoff for quality/perf cross devices
  17696. *
  17697. * Execute PCF on a 3*3 kernel.
  17698. *
  17699. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17700. */
  17701. static readonly QUALITY_MEDIUM: number;
  17702. /**
  17703. * Reserved for PCF and PCSS
  17704. * The lowest quality but the fastest.
  17705. *
  17706. * Execute PCF on a 1*1 kernel.
  17707. *
  17708. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17709. */
  17710. static readonly QUALITY_LOW: number;
  17711. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17712. id: string;
  17713. /** Gets or sets the custom shader name to use */
  17714. customShaderOptions: ICustomShaderOptions;
  17715. /**
  17716. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17717. */
  17718. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17719. /**
  17720. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17721. */
  17722. onAfterShadowMapRenderObservable: Observable<Effect>;
  17723. /**
  17724. * Observable triggered before a mesh is rendered in the shadow map.
  17725. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17726. */
  17727. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17728. /**
  17729. * Observable triggered after a mesh is rendered in the shadow map.
  17730. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17731. */
  17732. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17733. protected _bias: number;
  17734. /**
  17735. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17736. */
  17737. get bias(): number;
  17738. /**
  17739. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17740. */
  17741. set bias(bias: number);
  17742. protected _normalBias: number;
  17743. /**
  17744. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17745. */
  17746. get normalBias(): number;
  17747. /**
  17748. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17749. */
  17750. set normalBias(normalBias: number);
  17751. protected _blurBoxOffset: number;
  17752. /**
  17753. * Gets the blur box offset: offset applied during the blur pass.
  17754. * Only useful if useKernelBlur = false
  17755. */
  17756. get blurBoxOffset(): number;
  17757. /**
  17758. * Sets the blur box offset: offset applied during the blur pass.
  17759. * Only useful if useKernelBlur = false
  17760. */
  17761. set blurBoxOffset(value: number);
  17762. protected _blurScale: number;
  17763. /**
  17764. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17765. * 2 means half of the size.
  17766. */
  17767. get blurScale(): number;
  17768. /**
  17769. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17770. * 2 means half of the size.
  17771. */
  17772. set blurScale(value: number);
  17773. protected _blurKernel: number;
  17774. /**
  17775. * Gets the blur kernel: kernel size of the blur pass.
  17776. * Only useful if useKernelBlur = true
  17777. */
  17778. get blurKernel(): number;
  17779. /**
  17780. * Sets the blur kernel: kernel size of the blur pass.
  17781. * Only useful if useKernelBlur = true
  17782. */
  17783. set blurKernel(value: number);
  17784. protected _useKernelBlur: boolean;
  17785. /**
  17786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17788. */
  17789. get useKernelBlur(): boolean;
  17790. /**
  17791. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17792. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17793. */
  17794. set useKernelBlur(value: boolean);
  17795. protected _depthScale: number;
  17796. /**
  17797. * Gets the depth scale used in ESM mode.
  17798. */
  17799. get depthScale(): number;
  17800. /**
  17801. * Sets the depth scale used in ESM mode.
  17802. * This can override the scale stored on the light.
  17803. */
  17804. set depthScale(value: number);
  17805. protected _validateFilter(filter: number): number;
  17806. protected _filter: number;
  17807. /**
  17808. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17810. */
  17811. get filter(): number;
  17812. /**
  17813. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17815. */
  17816. set filter(value: number);
  17817. /**
  17818. * Gets if the current filter is set to Poisson Sampling.
  17819. */
  17820. get usePoissonSampling(): boolean;
  17821. /**
  17822. * Sets the current filter to Poisson Sampling.
  17823. */
  17824. set usePoissonSampling(value: boolean);
  17825. /**
  17826. * Gets if the current filter is set to ESM.
  17827. */
  17828. get useExponentialShadowMap(): boolean;
  17829. /**
  17830. * Sets the current filter is to ESM.
  17831. */
  17832. set useExponentialShadowMap(value: boolean);
  17833. /**
  17834. * Gets if the current filter is set to filtered ESM.
  17835. */
  17836. get useBlurExponentialShadowMap(): boolean;
  17837. /**
  17838. * Gets if the current filter is set to filtered ESM.
  17839. */
  17840. set useBlurExponentialShadowMap(value: boolean);
  17841. /**
  17842. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17843. * exponential to prevent steep falloff artifacts).
  17844. */
  17845. get useCloseExponentialShadowMap(): boolean;
  17846. /**
  17847. * Sets the current filter to "close ESM" (using the inverse of the
  17848. * exponential to prevent steep falloff artifacts).
  17849. */
  17850. set useCloseExponentialShadowMap(value: boolean);
  17851. /**
  17852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17853. * exponential to prevent steep falloff artifacts).
  17854. */
  17855. get useBlurCloseExponentialShadowMap(): boolean;
  17856. /**
  17857. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17858. * exponential to prevent steep falloff artifacts).
  17859. */
  17860. set useBlurCloseExponentialShadowMap(value: boolean);
  17861. /**
  17862. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17863. */
  17864. get usePercentageCloserFiltering(): boolean;
  17865. /**
  17866. * Sets the current filter to "PCF" (percentage closer filtering).
  17867. */
  17868. set usePercentageCloserFiltering(value: boolean);
  17869. protected _filteringQuality: number;
  17870. /**
  17871. * Gets the PCF or PCSS Quality.
  17872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17873. */
  17874. get filteringQuality(): number;
  17875. /**
  17876. * Sets the PCF or PCSS Quality.
  17877. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17878. */
  17879. set filteringQuality(filteringQuality: number);
  17880. /**
  17881. * Gets if the current filter is set to "PCSS" (contact hardening).
  17882. */
  17883. get useContactHardeningShadow(): boolean;
  17884. /**
  17885. * Sets the current filter to "PCSS" (contact hardening).
  17886. */
  17887. set useContactHardeningShadow(value: boolean);
  17888. protected _contactHardeningLightSizeUVRatio: number;
  17889. /**
  17890. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17891. * Using a ratio helps keeping shape stability independently of the map size.
  17892. *
  17893. * It does not account for the light projection as it was having too much
  17894. * instability during the light setup or during light position changes.
  17895. *
  17896. * Only valid if useContactHardeningShadow is true.
  17897. */
  17898. get contactHardeningLightSizeUVRatio(): number;
  17899. /**
  17900. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17901. * Using a ratio helps keeping shape stability independently of the map size.
  17902. *
  17903. * It does not account for the light projection as it was having too much
  17904. * instability during the light setup or during light position changes.
  17905. *
  17906. * Only valid if useContactHardeningShadow is true.
  17907. */
  17908. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17909. protected _darkness: number;
  17910. /** Gets or sets the actual darkness of a shadow */
  17911. get darkness(): number;
  17912. set darkness(value: number);
  17913. /**
  17914. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17915. * 0 means strongest and 1 would means no shadow.
  17916. * @returns the darkness.
  17917. */
  17918. getDarkness(): number;
  17919. /**
  17920. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17921. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17922. * @returns the shadow generator allowing fluent coding.
  17923. */
  17924. setDarkness(darkness: number): ShadowGenerator;
  17925. protected _transparencyShadow: boolean;
  17926. /** Gets or sets the ability to have transparent shadow */
  17927. get transparencyShadow(): boolean;
  17928. set transparencyShadow(value: boolean);
  17929. /**
  17930. * Sets the ability to have transparent shadow (boolean).
  17931. * @param transparent True if transparent else False
  17932. * @returns the shadow generator allowing fluent coding
  17933. */
  17934. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17935. /**
  17936. * Enables or disables shadows with varying strength based on the transparency
  17937. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17938. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17939. * mesh.visibility * alphaTexture.a
  17940. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17941. */
  17942. enableSoftTransparentShadow: boolean;
  17943. protected _shadowMap: Nullable<RenderTargetTexture>;
  17944. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17945. /**
  17946. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17947. * @returns The render target texture if present otherwise, null
  17948. */
  17949. getShadowMap(): Nullable<RenderTargetTexture>;
  17950. /**
  17951. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17952. * @returns The render target texture if the shadow map is present otherwise, null
  17953. */
  17954. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17955. /**
  17956. * Gets the class name of that object
  17957. * @returns "ShadowGenerator"
  17958. */
  17959. getClassName(): string;
  17960. /**
  17961. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17962. * @param mesh Mesh to add
  17963. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17964. * @returns the Shadow Generator itself
  17965. */
  17966. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17967. /**
  17968. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17969. * @param mesh Mesh to remove
  17970. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17971. * @returns the Shadow Generator itself
  17972. */
  17973. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17974. /**
  17975. * Controls the extent to which the shadows fade out at the edge of the frustum
  17976. */
  17977. frustumEdgeFalloff: number;
  17978. protected _light: IShadowLight;
  17979. /**
  17980. * Returns the associated light object.
  17981. * @returns the light generating the shadow
  17982. */
  17983. getLight(): IShadowLight;
  17984. /**
  17985. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17986. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17987. * It might on the other hand introduce peter panning.
  17988. */
  17989. forceBackFacesOnly: boolean;
  17990. protected _scene: Scene;
  17991. protected _lightDirection: Vector3;
  17992. protected _effect: Effect;
  17993. protected _viewMatrix: Matrix;
  17994. protected _projectionMatrix: Matrix;
  17995. protected _transformMatrix: Matrix;
  17996. protected _cachedPosition: Vector3;
  17997. protected _cachedDirection: Vector3;
  17998. protected _cachedDefines: string;
  17999. protected _currentRenderID: number;
  18000. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18001. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18002. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18003. protected _blurPostProcesses: PostProcess[];
  18004. protected _mapSize: number;
  18005. protected _currentFaceIndex: number;
  18006. protected _currentFaceIndexCache: number;
  18007. protected _textureType: number;
  18008. protected _defaultTextureMatrix: Matrix;
  18009. protected _storedUniqueId: Nullable<number>;
  18010. /** @hidden */
  18011. static _SceneComponentInitialization: (scene: Scene) => void;
  18012. /**
  18013. * Gets or sets the size of the texture what stores the shadows
  18014. */
  18015. get mapSize(): number;
  18016. set mapSize(size: number);
  18017. /**
  18018. * Creates a ShadowGenerator object.
  18019. * A ShadowGenerator is the required tool to use the shadows.
  18020. * Each light casting shadows needs to use its own ShadowGenerator.
  18021. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18022. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18023. * @param light The light object generating the shadows.
  18024. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18025. */
  18026. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18027. protected _initializeGenerator(): void;
  18028. protected _createTargetRenderTexture(): void;
  18029. protected _initializeShadowMap(): void;
  18030. protected _initializeBlurRTTAndPostProcesses(): void;
  18031. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18032. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18033. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18034. protected _applyFilterValues(): void;
  18035. /**
  18036. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18037. * @param onCompiled Callback triggered at the and of the effects compilation
  18038. * @param options Sets of optional options forcing the compilation with different modes
  18039. */
  18040. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18041. useInstances: boolean;
  18042. }>): void;
  18043. /**
  18044. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18045. * @param options Sets of optional options forcing the compilation with different modes
  18046. * @returns A promise that resolves when the compilation completes
  18047. */
  18048. forceCompilationAsync(options?: Partial<{
  18049. useInstances: boolean;
  18050. }>): Promise<void>;
  18051. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18052. private _prepareShadowDefines;
  18053. /**
  18054. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18055. * @param subMesh The submesh we want to render in the shadow map
  18056. * @param useInstances Defines wether will draw in the map using instances
  18057. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18058. * @returns true if ready otherwise, false
  18059. */
  18060. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18061. /**
  18062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18063. * @param defines Defines of the material we want to update
  18064. * @param lightIndex Index of the light in the enabled light list of the material
  18065. */
  18066. prepareDefines(defines: any, lightIndex: number): void;
  18067. /**
  18068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18069. * defined in the generator but impacting the effect).
  18070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18071. * @param effect The effect we are binfing the information for
  18072. */
  18073. bindShadowLight(lightIndex: string, effect: Effect): void;
  18074. /**
  18075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18076. * (eq to shadow prjection matrix * light transform matrix)
  18077. * @returns The transform matrix used to create the shadow map
  18078. */
  18079. getTransformMatrix(): Matrix;
  18080. /**
  18081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18082. * Cube and 2D textures for instance.
  18083. */
  18084. recreateShadowMap(): void;
  18085. protected _disposeBlurPostProcesses(): void;
  18086. protected _disposeRTTandPostProcesses(): void;
  18087. /**
  18088. * Disposes the ShadowGenerator.
  18089. * Returns nothing.
  18090. */
  18091. dispose(): void;
  18092. /**
  18093. * Serializes the shadow generator setup to a json object.
  18094. * @returns The serialized JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18099. * @param parsedShadowGenerator The JSON object to parse
  18100. * @param scene The scene to create the shadow map for
  18101. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18102. * @returns The parsed shadow generator
  18103. */
  18104. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18105. }
  18106. }
  18107. declare module BABYLON {
  18108. /**
  18109. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18110. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18111. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18112. */
  18113. export abstract class Light extends Node {
  18114. /**
  18115. * Falloff Default: light is falling off following the material specification:
  18116. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18117. */
  18118. static readonly FALLOFF_DEFAULT: number;
  18119. /**
  18120. * Falloff Physical: light is falling off following the inverse squared distance law.
  18121. */
  18122. static readonly FALLOFF_PHYSICAL: number;
  18123. /**
  18124. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18125. * to enhance interoperability with other engines.
  18126. */
  18127. static readonly FALLOFF_GLTF: number;
  18128. /**
  18129. * Falloff Standard: light is falling off like in the standard material
  18130. * to enhance interoperability with other materials.
  18131. */
  18132. static readonly FALLOFF_STANDARD: number;
  18133. /**
  18134. * If every light affecting the material is in this lightmapMode,
  18135. * material.lightmapTexture adds or multiplies
  18136. * (depends on material.useLightmapAsShadowmap)
  18137. * after every other light calculations.
  18138. */
  18139. static readonly LIGHTMAP_DEFAULT: number;
  18140. /**
  18141. * material.lightmapTexture as only diffuse lighting from this light
  18142. * adds only specular lighting from this light
  18143. * adds dynamic shadows
  18144. */
  18145. static readonly LIGHTMAP_SPECULAR: number;
  18146. /**
  18147. * material.lightmapTexture as only lighting
  18148. * no light calculation from this light
  18149. * only adds dynamic shadows from this light
  18150. */
  18151. static readonly LIGHTMAP_SHADOWSONLY: number;
  18152. /**
  18153. * Each light type uses the default quantity according to its type:
  18154. * point/spot lights use luminous intensity
  18155. * directional lights use illuminance
  18156. */
  18157. static readonly INTENSITYMODE_AUTOMATIC: number;
  18158. /**
  18159. * lumen (lm)
  18160. */
  18161. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18162. /**
  18163. * candela (lm/sr)
  18164. */
  18165. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18166. /**
  18167. * lux (lm/m^2)
  18168. */
  18169. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18170. /**
  18171. * nit (cd/m^2)
  18172. */
  18173. static readonly INTENSITYMODE_LUMINANCE: number;
  18174. /**
  18175. * Light type const id of the point light.
  18176. */
  18177. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18178. /**
  18179. * Light type const id of the directional light.
  18180. */
  18181. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18182. /**
  18183. * Light type const id of the spot light.
  18184. */
  18185. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18186. /**
  18187. * Light type const id of the hemispheric light.
  18188. */
  18189. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18190. /**
  18191. * Diffuse gives the basic color to an object.
  18192. */
  18193. diffuse: Color3;
  18194. /**
  18195. * Specular produces a highlight color on an object.
  18196. * Note: This is note affecting PBR materials.
  18197. */
  18198. specular: Color3;
  18199. /**
  18200. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18201. * falling off base on range or angle.
  18202. * This can be set to any values in Light.FALLOFF_x.
  18203. *
  18204. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18205. * other types of materials.
  18206. */
  18207. falloffType: number;
  18208. /**
  18209. * Strength of the light.
  18210. * Note: By default it is define in the framework own unit.
  18211. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18212. */
  18213. intensity: number;
  18214. private _range;
  18215. protected _inverseSquaredRange: number;
  18216. /**
  18217. * Defines how far from the source the light is impacting in scene units.
  18218. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18219. */
  18220. get range(): number;
  18221. /**
  18222. * Defines how far from the source the light is impacting in scene units.
  18223. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18224. */
  18225. set range(value: number);
  18226. /**
  18227. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18228. * of light.
  18229. */
  18230. private _photometricScale;
  18231. private _intensityMode;
  18232. /**
  18233. * Gets the photometric scale used to interpret the intensity.
  18234. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18235. */
  18236. get intensityMode(): number;
  18237. /**
  18238. * Sets the photometric scale used to interpret the intensity.
  18239. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18240. */
  18241. set intensityMode(value: number);
  18242. private _radius;
  18243. /**
  18244. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18245. */
  18246. get radius(): number;
  18247. /**
  18248. * sets the light radius used by PBR Materials to simulate soft area lights.
  18249. */
  18250. set radius(value: number);
  18251. private _renderPriority;
  18252. /**
  18253. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18254. * exceeding the number allowed of the materials.
  18255. */
  18256. renderPriority: number;
  18257. private _shadowEnabled;
  18258. /**
  18259. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18260. * the current shadow generator.
  18261. */
  18262. get shadowEnabled(): boolean;
  18263. /**
  18264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18265. * the current shadow generator.
  18266. */
  18267. set shadowEnabled(value: boolean);
  18268. private _includedOnlyMeshes;
  18269. /**
  18270. * Gets the only meshes impacted by this light.
  18271. */
  18272. get includedOnlyMeshes(): AbstractMesh[];
  18273. /**
  18274. * Sets the only meshes impacted by this light.
  18275. */
  18276. set includedOnlyMeshes(value: AbstractMesh[]);
  18277. private _excludedMeshes;
  18278. /**
  18279. * Gets the meshes not impacted by this light.
  18280. */
  18281. get excludedMeshes(): AbstractMesh[];
  18282. /**
  18283. * Sets the meshes not impacted by this light.
  18284. */
  18285. set excludedMeshes(value: AbstractMesh[]);
  18286. private _excludeWithLayerMask;
  18287. /**
  18288. * Gets the layer id use to find what meshes are not impacted by the light.
  18289. * Inactive if 0
  18290. */
  18291. get excludeWithLayerMask(): number;
  18292. /**
  18293. * Sets the layer id use to find what meshes are not impacted by the light.
  18294. * Inactive if 0
  18295. */
  18296. set excludeWithLayerMask(value: number);
  18297. private _includeOnlyWithLayerMask;
  18298. /**
  18299. * Gets the layer id use to find what meshes are impacted by the light.
  18300. * Inactive if 0
  18301. */
  18302. get includeOnlyWithLayerMask(): number;
  18303. /**
  18304. * Sets the layer id use to find what meshes are impacted by the light.
  18305. * Inactive if 0
  18306. */
  18307. set includeOnlyWithLayerMask(value: number);
  18308. private _lightmapMode;
  18309. /**
  18310. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18311. */
  18312. get lightmapMode(): number;
  18313. /**
  18314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18315. */
  18316. set lightmapMode(value: number);
  18317. /**
  18318. * Shadow generator associted to the light.
  18319. * @hidden Internal use only.
  18320. */
  18321. _shadowGenerator: Nullable<IShadowGenerator>;
  18322. /**
  18323. * @hidden Internal use only.
  18324. */
  18325. _excludedMeshesIds: string[];
  18326. /**
  18327. * @hidden Internal use only.
  18328. */
  18329. _includedOnlyMeshesIds: string[];
  18330. /**
  18331. * The current light unifom buffer.
  18332. * @hidden Internal use only.
  18333. */
  18334. _uniformBuffer: UniformBuffer;
  18335. /** @hidden */
  18336. _renderId: number;
  18337. /**
  18338. * Creates a Light object in the scene.
  18339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18340. * @param name The firendly name of the light
  18341. * @param scene The scene the light belongs too
  18342. */
  18343. constructor(name: string, scene: Scene);
  18344. protected abstract _buildUniformLayout(): void;
  18345. /**
  18346. * Sets the passed Effect "effect" with the Light information.
  18347. * @param effect The effect to update
  18348. * @param lightIndex The index of the light in the effect to update
  18349. * @returns The light
  18350. */
  18351. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18352. /**
  18353. * Sets the passed Effect "effect" with the Light textures.
  18354. * @param effect The effect to update
  18355. * @param lightIndex The index of the light in the effect to update
  18356. * @returns The light
  18357. */
  18358. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18359. /**
  18360. * Binds the lights information from the scene to the effect for the given mesh.
  18361. * @param lightIndex Light index
  18362. * @param scene The scene where the light belongs to
  18363. * @param effect The effect we are binding the data to
  18364. * @param useSpecular Defines if specular is supported
  18365. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18366. */
  18367. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18368. /**
  18369. * Sets the passed Effect "effect" with the Light information.
  18370. * @param effect The effect to update
  18371. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18372. * @returns The light
  18373. */
  18374. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18375. /**
  18376. * Returns the string "Light".
  18377. * @returns the class name
  18378. */
  18379. getClassName(): string;
  18380. /** @hidden */
  18381. readonly _isLight: boolean;
  18382. /**
  18383. * Converts the light information to a readable string for debug purpose.
  18384. * @param fullDetails Supports for multiple levels of logging within scene loading
  18385. * @returns the human readable light info
  18386. */
  18387. toString(fullDetails?: boolean): string;
  18388. /** @hidden */
  18389. protected _syncParentEnabledState(): void;
  18390. /**
  18391. * Set the enabled state of this node.
  18392. * @param value - the new enabled state
  18393. */
  18394. setEnabled(value: boolean): void;
  18395. /**
  18396. * Returns the Light associated shadow generator if any.
  18397. * @return the associated shadow generator.
  18398. */
  18399. getShadowGenerator(): Nullable<IShadowGenerator>;
  18400. /**
  18401. * Returns a Vector3, the absolute light position in the World.
  18402. * @returns the world space position of the light
  18403. */
  18404. getAbsolutePosition(): Vector3;
  18405. /**
  18406. * Specifies if the light will affect the passed mesh.
  18407. * @param mesh The mesh to test against the light
  18408. * @return true the mesh is affected otherwise, false.
  18409. */
  18410. canAffectMesh(mesh: AbstractMesh): boolean;
  18411. /**
  18412. * Sort function to order lights for rendering.
  18413. * @param a First Light object to compare to second.
  18414. * @param b Second Light object to compare first.
  18415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18416. */
  18417. static CompareLightsPriority(a: Light, b: Light): number;
  18418. /**
  18419. * Releases resources associated with this node.
  18420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18422. */
  18423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18424. /**
  18425. * Returns the light type ID (integer).
  18426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18427. */
  18428. getTypeID(): number;
  18429. /**
  18430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18431. * @returns the scaled intensity in intensity mode unit
  18432. */
  18433. getScaledIntensity(): number;
  18434. /**
  18435. * Returns a new Light object, named "name", from the current one.
  18436. * @param name The name of the cloned light
  18437. * @param newParent The parent of this light, if it has one
  18438. * @returns the new created light
  18439. */
  18440. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18441. /**
  18442. * Serializes the current light into a Serialization object.
  18443. * @returns the serialized object.
  18444. */
  18445. serialize(): any;
  18446. /**
  18447. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18448. * This new light is named "name" and added to the passed scene.
  18449. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18450. * @param name The friendly name of the light
  18451. * @param scene The scene the new light will belong to
  18452. * @returns the constructor function
  18453. */
  18454. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18455. /**
  18456. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18457. * @param parsedLight The JSON representation of the light
  18458. * @param scene The scene to create the parsed light in
  18459. * @returns the created light after parsing
  18460. */
  18461. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18462. private _hookArrayForExcluded;
  18463. private _hookArrayForIncludedOnly;
  18464. private _resyncMeshes;
  18465. /**
  18466. * Forces the meshes to update their light related information in their rendering used effects
  18467. * @hidden Internal Use Only
  18468. */
  18469. _markMeshesAsLightDirty(): void;
  18470. /**
  18471. * Recomputes the cached photometric scale if needed.
  18472. */
  18473. private _computePhotometricScale;
  18474. /**
  18475. * Returns the Photometric Scale according to the light type and intensity mode.
  18476. */
  18477. private _getPhotometricScale;
  18478. /**
  18479. * Reorder the light in the scene according to their defined priority.
  18480. * @hidden Internal Use Only
  18481. */
  18482. _reorderLightsInScene(): void;
  18483. /**
  18484. * Prepares the list of defines specific to the light type.
  18485. * @param defines the list of defines
  18486. * @param lightIndex defines the index of the light for the effect
  18487. */
  18488. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18489. }
  18490. }
  18491. declare module BABYLON {
  18492. /**
  18493. * Configuration needed for prepass-capable materials
  18494. */
  18495. export class PrePassConfiguration {
  18496. /**
  18497. * Previous world matrices of meshes carrying this material
  18498. * Used for computing velocity
  18499. */
  18500. previousWorldMatrices: {
  18501. [index: number]: Matrix;
  18502. };
  18503. /**
  18504. * Previous view project matrix
  18505. * Used for computing velocity
  18506. */
  18507. previousViewProjection: Matrix;
  18508. /**
  18509. * Previous bones of meshes carrying this material
  18510. * Used for computing velocity
  18511. */
  18512. previousBones: {
  18513. [index: number]: Float32Array;
  18514. };
  18515. /**
  18516. * Add the required uniforms to the current list.
  18517. * @param uniforms defines the current uniform list.
  18518. */
  18519. static AddUniforms(uniforms: string[]): void;
  18520. /**
  18521. * Add the required samplers to the current list.
  18522. * @param samplers defines the current sampler list.
  18523. */
  18524. static AddSamplers(samplers: string[]): void;
  18525. /**
  18526. * Binds the material data.
  18527. * @param effect defines the effect to update
  18528. * @param scene defines the scene the material belongs to.
  18529. * @param mesh The mesh
  18530. * @param world World matrix of this mesh
  18531. * @param isFrozen Is the material frozen
  18532. */
  18533. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18534. }
  18535. }
  18536. declare module BABYLON {
  18537. /**
  18538. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18539. * This is the base of the follow, arc rotate cameras and Free camera
  18540. * @see https://doc.babylonjs.com/features/cameras
  18541. */
  18542. export class TargetCamera extends Camera {
  18543. private static _RigCamTransformMatrix;
  18544. private static _TargetTransformMatrix;
  18545. private static _TargetFocalPoint;
  18546. private _tmpUpVector;
  18547. private _tmpTargetVector;
  18548. /**
  18549. * Define the current direction the camera is moving to
  18550. */
  18551. cameraDirection: Vector3;
  18552. /**
  18553. * Define the current rotation the camera is rotating to
  18554. */
  18555. cameraRotation: Vector2;
  18556. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18557. ignoreParentScaling: boolean;
  18558. /**
  18559. * When set, the up vector of the camera will be updated by the rotation of the camera
  18560. */
  18561. updateUpVectorFromRotation: boolean;
  18562. private _tmpQuaternion;
  18563. /**
  18564. * Define the current rotation of the camera
  18565. */
  18566. rotation: Vector3;
  18567. /**
  18568. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18569. */
  18570. rotationQuaternion: Quaternion;
  18571. /**
  18572. * Define the current speed of the camera
  18573. */
  18574. speed: number;
  18575. /**
  18576. * Add constraint to the camera to prevent it to move freely in all directions and
  18577. * around all axis.
  18578. */
  18579. noRotationConstraint: boolean;
  18580. /**
  18581. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18582. * panning
  18583. */
  18584. invertRotation: boolean;
  18585. /**
  18586. * Speed multiplier for inverse camera panning
  18587. */
  18588. inverseRotationSpeed: number;
  18589. /**
  18590. * Define the current target of the camera as an object or a position.
  18591. */
  18592. lockedTarget: any;
  18593. /** @hidden */
  18594. _currentTarget: Vector3;
  18595. /** @hidden */
  18596. _initialFocalDistance: number;
  18597. /** @hidden */
  18598. _viewMatrix: Matrix;
  18599. /** @hidden */
  18600. _camMatrix: Matrix;
  18601. /** @hidden */
  18602. _cameraTransformMatrix: Matrix;
  18603. /** @hidden */
  18604. _cameraRotationMatrix: Matrix;
  18605. /** @hidden */
  18606. _referencePoint: Vector3;
  18607. /** @hidden */
  18608. _transformedReferencePoint: Vector3;
  18609. /** @hidden */
  18610. _reset: () => void;
  18611. private _defaultUp;
  18612. /**
  18613. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18614. * This is the base of the follow, arc rotate cameras and Free camera
  18615. * @see https://doc.babylonjs.com/features/cameras
  18616. * @param name Defines the name of the camera in the scene
  18617. * @param position Defines the start position of the camera in the scene
  18618. * @param scene Defines the scene the camera belongs to
  18619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18620. */
  18621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18622. /**
  18623. * Gets the position in front of the camera at a given distance.
  18624. * @param distance The distance from the camera we want the position to be
  18625. * @returns the position
  18626. */
  18627. getFrontPosition(distance: number): Vector3;
  18628. /** @hidden */
  18629. _getLockedTargetPosition(): Nullable<Vector3>;
  18630. private _storedPosition;
  18631. private _storedRotation;
  18632. private _storedRotationQuaternion;
  18633. /**
  18634. * Store current camera state of the camera (fov, position, rotation, etc..)
  18635. * @returns the camera
  18636. */
  18637. storeState(): Camera;
  18638. /**
  18639. * Restored camera state. You must call storeState() first
  18640. * @returns whether it was successful or not
  18641. * @hidden
  18642. */
  18643. _restoreStateValues(): boolean;
  18644. /** @hidden */
  18645. _initCache(): void;
  18646. /** @hidden */
  18647. _updateCache(ignoreParentClass?: boolean): void;
  18648. /** @hidden */
  18649. _isSynchronizedViewMatrix(): boolean;
  18650. /** @hidden */
  18651. _computeLocalCameraSpeed(): number;
  18652. /**
  18653. * Defines the target the camera should look at.
  18654. * @param target Defines the new target as a Vector or a mesh
  18655. */
  18656. setTarget(target: Vector3): void;
  18657. /**
  18658. * Defines the target point of the camera.
  18659. * The camera looks towards it form the radius distance.
  18660. */
  18661. get target(): Vector3;
  18662. set target(value: Vector3);
  18663. /**
  18664. * Return the current target position of the camera. This value is expressed in local space.
  18665. * @returns the target position
  18666. */
  18667. getTarget(): Vector3;
  18668. /** @hidden */
  18669. _decideIfNeedsToMove(): boolean;
  18670. /** @hidden */
  18671. _updatePosition(): void;
  18672. /** @hidden */
  18673. _checkInputs(): void;
  18674. protected _updateCameraRotationMatrix(): void;
  18675. /**
  18676. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18677. * @returns the current camera
  18678. */
  18679. private _rotateUpVectorWithCameraRotationMatrix;
  18680. private _cachedRotationZ;
  18681. private _cachedQuaternionRotationZ;
  18682. /** @hidden */
  18683. _getViewMatrix(): Matrix;
  18684. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18685. /**
  18686. * @hidden
  18687. */
  18688. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18689. /**
  18690. * @hidden
  18691. */
  18692. _updateRigCameras(): void;
  18693. private _getRigCamPositionAndTarget;
  18694. /**
  18695. * Gets the current object class name.
  18696. * @return the class name
  18697. */
  18698. getClassName(): string;
  18699. }
  18700. }
  18701. declare module BABYLON {
  18702. /**
  18703. * Gather the list of keyboard event types as constants.
  18704. */
  18705. export class KeyboardEventTypes {
  18706. /**
  18707. * The keydown event is fired when a key becomes active (pressed).
  18708. */
  18709. static readonly KEYDOWN: number;
  18710. /**
  18711. * The keyup event is fired when a key has been released.
  18712. */
  18713. static readonly KEYUP: number;
  18714. }
  18715. /**
  18716. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18717. */
  18718. export class KeyboardInfo {
  18719. /**
  18720. * Defines the type of event (KeyboardEventTypes)
  18721. */
  18722. type: number;
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: KeyboardEvent;
  18727. /**
  18728. * Instantiates a new keyboard info.
  18729. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18730. * @param type Defines the type of event (KeyboardEventTypes)
  18731. * @param event Defines the related dom event
  18732. */
  18733. constructor(
  18734. /**
  18735. * Defines the type of event (KeyboardEventTypes)
  18736. */
  18737. type: number,
  18738. /**
  18739. * Defines the related dom event
  18740. */
  18741. event: KeyboardEvent);
  18742. }
  18743. /**
  18744. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18745. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18746. */
  18747. export class KeyboardInfoPre extends KeyboardInfo {
  18748. /**
  18749. * Defines the type of event (KeyboardEventTypes)
  18750. */
  18751. type: number;
  18752. /**
  18753. * Defines the related dom event
  18754. */
  18755. event: KeyboardEvent;
  18756. /**
  18757. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18758. */
  18759. skipOnPointerObservable: boolean;
  18760. /**
  18761. * Instantiates a new keyboard pre info.
  18762. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18763. * @param type Defines the type of event (KeyboardEventTypes)
  18764. * @param event Defines the related dom event
  18765. */
  18766. constructor(
  18767. /**
  18768. * Defines the type of event (KeyboardEventTypes)
  18769. */
  18770. type: number,
  18771. /**
  18772. * Defines the related dom event
  18773. */
  18774. event: KeyboardEvent);
  18775. }
  18776. }
  18777. declare module BABYLON {
  18778. /**
  18779. * Manage the keyboard inputs to control the movement of a free camera.
  18780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18781. */
  18782. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18783. /**
  18784. * Defines the camera the input is attached to.
  18785. */
  18786. camera: FreeCamera;
  18787. /**
  18788. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18789. */
  18790. keysUp: number[];
  18791. /**
  18792. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18793. */
  18794. keysUpward: number[];
  18795. /**
  18796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18797. */
  18798. keysDown: number[];
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18801. */
  18802. keysDownward: number[];
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18805. */
  18806. keysLeft: number[];
  18807. /**
  18808. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18809. */
  18810. keysRight: number[];
  18811. private _keys;
  18812. private _onCanvasBlurObserver;
  18813. private _onKeyboardObserver;
  18814. private _engine;
  18815. private _scene;
  18816. /**
  18817. * Attach the input controls to a specific dom element to get the input from.
  18818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18819. */
  18820. attachControl(noPreventDefault?: boolean): void;
  18821. /**
  18822. * Detach the current controls from the specified dom element.
  18823. */
  18824. detachControl(): void;
  18825. /**
  18826. * Update the current camera state depending on the inputs that have been used this frame.
  18827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18828. */
  18829. checkInputs(): void;
  18830. /**
  18831. * Gets the class name of the current intput.
  18832. * @returns the class name
  18833. */
  18834. getClassName(): string;
  18835. /** @hidden */
  18836. _onLostFocus(): void;
  18837. /**
  18838. * Get the friendly name associated with the input class.
  18839. * @returns the input friendly name
  18840. */
  18841. getSimpleName(): string;
  18842. }
  18843. }
  18844. declare module BABYLON {
  18845. /**
  18846. * Gather the list of pointer event types as constants.
  18847. */
  18848. export class PointerEventTypes {
  18849. /**
  18850. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18851. */
  18852. static readonly POINTERDOWN: number;
  18853. /**
  18854. * The pointerup event is fired when a pointer is no longer active.
  18855. */
  18856. static readonly POINTERUP: number;
  18857. /**
  18858. * The pointermove event is fired when a pointer changes coordinates.
  18859. */
  18860. static readonly POINTERMOVE: number;
  18861. /**
  18862. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18863. */
  18864. static readonly POINTERWHEEL: number;
  18865. /**
  18866. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18867. */
  18868. static readonly POINTERPICK: number;
  18869. /**
  18870. * The pointertap event is fired when a the object has been touched and released without drag.
  18871. */
  18872. static readonly POINTERTAP: number;
  18873. /**
  18874. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18875. */
  18876. static readonly POINTERDOUBLETAP: number;
  18877. }
  18878. /**
  18879. * Base class of pointer info types.
  18880. */
  18881. export class PointerInfoBase {
  18882. /**
  18883. * Defines the type of event (PointerEventTypes)
  18884. */
  18885. type: number;
  18886. /**
  18887. * Defines the related dom event
  18888. */
  18889. event: PointerEvent | MouseWheelEvent;
  18890. /**
  18891. * Instantiates the base class of pointers info.
  18892. * @param type Defines the type of event (PointerEventTypes)
  18893. * @param event Defines the related dom event
  18894. */
  18895. constructor(
  18896. /**
  18897. * Defines the type of event (PointerEventTypes)
  18898. */
  18899. type: number,
  18900. /**
  18901. * Defines the related dom event
  18902. */
  18903. event: PointerEvent | MouseWheelEvent);
  18904. }
  18905. /**
  18906. * This class is used to store pointer related info for the onPrePointerObservable event.
  18907. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18908. */
  18909. export class PointerInfoPre extends PointerInfoBase {
  18910. /**
  18911. * Ray from a pointer if availible (eg. 6dof controller)
  18912. */
  18913. ray: Nullable<Ray>;
  18914. /**
  18915. * Defines the local position of the pointer on the canvas.
  18916. */
  18917. localPosition: Vector2;
  18918. /**
  18919. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18920. */
  18921. skipOnPointerObservable: boolean;
  18922. /**
  18923. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18924. * @param type Defines the type of event (PointerEventTypes)
  18925. * @param event Defines the related dom event
  18926. * @param localX Defines the local x coordinates of the pointer when the event occured
  18927. * @param localY Defines the local y coordinates of the pointer when the event occured
  18928. */
  18929. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18930. }
  18931. /**
  18932. * This type contains all the data related to a pointer event in Babylon.js.
  18933. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18934. */
  18935. export class PointerInfo extends PointerInfoBase {
  18936. /**
  18937. * Defines the picking info associated to the info (if any)\
  18938. */
  18939. pickInfo: Nullable<PickingInfo>;
  18940. /**
  18941. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18942. * @param type Defines the type of event (PointerEventTypes)
  18943. * @param event Defines the related dom event
  18944. * @param pickInfo Defines the picking info associated to the info (if any)\
  18945. */
  18946. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18947. /**
  18948. * Defines the picking info associated to the info (if any)\
  18949. */
  18950. pickInfo: Nullable<PickingInfo>);
  18951. }
  18952. /**
  18953. * Data relating to a touch event on the screen.
  18954. */
  18955. export interface PointerTouch {
  18956. /**
  18957. * X coordinate of touch.
  18958. */
  18959. x: number;
  18960. /**
  18961. * Y coordinate of touch.
  18962. */
  18963. y: number;
  18964. /**
  18965. * Id of touch. Unique for each finger.
  18966. */
  18967. pointerId: number;
  18968. /**
  18969. * Event type passed from DOM.
  18970. */
  18971. type: any;
  18972. }
  18973. }
  18974. declare module BABYLON {
  18975. /**
  18976. * Manage the mouse inputs to control the movement of a free camera.
  18977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18978. */
  18979. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18980. /**
  18981. * Define if touch is enabled in the mouse input
  18982. */
  18983. touchEnabled: boolean;
  18984. /**
  18985. * Defines the camera the input is attached to.
  18986. */
  18987. camera: FreeCamera;
  18988. /**
  18989. * Defines the buttons associated with the input to handle camera move.
  18990. */
  18991. buttons: number[];
  18992. /**
  18993. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18994. */
  18995. angularSensibility: number;
  18996. private _pointerInput;
  18997. private _onMouseMove;
  18998. private _observer;
  18999. private previousPosition;
  19000. /**
  19001. * Observable for when a pointer move event occurs containing the move offset
  19002. */
  19003. onPointerMovedObservable: Observable<{
  19004. offsetX: number;
  19005. offsetY: number;
  19006. }>;
  19007. /**
  19008. * @hidden
  19009. * If the camera should be rotated automatically based on pointer movement
  19010. */
  19011. _allowCameraRotation: boolean;
  19012. /**
  19013. * Manage the mouse inputs to control the movement of a free camera.
  19014. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19015. * @param touchEnabled Defines if touch is enabled or not
  19016. */
  19017. constructor(
  19018. /**
  19019. * Define if touch is enabled in the mouse input
  19020. */
  19021. touchEnabled?: boolean);
  19022. /**
  19023. * Attach the input controls to a specific dom element to get the input from.
  19024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19025. */
  19026. attachControl(noPreventDefault?: boolean): void;
  19027. /**
  19028. * Called on JS contextmenu event.
  19029. * Override this method to provide functionality.
  19030. */
  19031. protected onContextMenu(evt: PointerEvent): void;
  19032. /**
  19033. * Detach the current controls from the specified dom element.
  19034. */
  19035. detachControl(): void;
  19036. /**
  19037. * Gets the class name of the current intput.
  19038. * @returns the class name
  19039. */
  19040. getClassName(): string;
  19041. /**
  19042. * Get the friendly name associated with the input class.
  19043. * @returns the input friendly name
  19044. */
  19045. getSimpleName(): string;
  19046. }
  19047. }
  19048. declare module BABYLON {
  19049. /**
  19050. * Base class for mouse wheel input..
  19051. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19052. * for example usage.
  19053. */
  19054. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19055. /**
  19056. * Defines the camera the input is attached to.
  19057. */
  19058. abstract camera: Camera;
  19059. /**
  19060. * How fast is the camera moves in relation to X axis mouseWheel events.
  19061. * Use negative value to reverse direction.
  19062. */
  19063. wheelPrecisionX: number;
  19064. /**
  19065. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19066. * Use negative value to reverse direction.
  19067. */
  19068. wheelPrecisionY: number;
  19069. /**
  19070. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19071. * Use negative value to reverse direction.
  19072. */
  19073. wheelPrecisionZ: number;
  19074. /**
  19075. * Observable for when a mouse wheel move event occurs.
  19076. */
  19077. onChangedObservable: Observable<{
  19078. wheelDeltaX: number;
  19079. wheelDeltaY: number;
  19080. wheelDeltaZ: number;
  19081. }>;
  19082. private _wheel;
  19083. private _observer;
  19084. /**
  19085. * Attach the input controls to a specific dom element to get the input from.
  19086. * @param noPreventDefault Defines whether event caught by the controls
  19087. * should call preventdefault().
  19088. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19089. */
  19090. attachControl(noPreventDefault?: boolean): void;
  19091. /**
  19092. * Detach the current controls from the specified dom element.
  19093. */
  19094. detachControl(): void;
  19095. /**
  19096. * Called for each rendered frame.
  19097. */
  19098. checkInputs(): void;
  19099. /**
  19100. * Gets the class name of the current intput.
  19101. * @returns the class name
  19102. */
  19103. getClassName(): string;
  19104. /**
  19105. * Get the friendly name associated with the input class.
  19106. * @returns the input friendly name
  19107. */
  19108. getSimpleName(): string;
  19109. /**
  19110. * Incremental value of multiple mouse wheel movements of the X axis.
  19111. * Should be zero-ed when read.
  19112. */
  19113. protected _wheelDeltaX: number;
  19114. /**
  19115. * Incremental value of multiple mouse wheel movements of the Y axis.
  19116. * Should be zero-ed when read.
  19117. */
  19118. protected _wheelDeltaY: number;
  19119. /**
  19120. * Incremental value of multiple mouse wheel movements of the Z axis.
  19121. * Should be zero-ed when read.
  19122. */
  19123. protected _wheelDeltaZ: number;
  19124. /**
  19125. * Firefox uses a different scheme to report scroll distances to other
  19126. * browsers. Rather than use complicated methods to calculate the exact
  19127. * multiple we need to apply, let's just cheat and use a constant.
  19128. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19129. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19130. */
  19131. private readonly _ffMultiplier;
  19132. /**
  19133. * Different event attributes for wheel data fall into a few set ranges.
  19134. * Some relevant but dated date here:
  19135. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19136. */
  19137. private readonly _normalize;
  19138. }
  19139. }
  19140. declare module BABYLON {
  19141. /**
  19142. * Manage the mouse wheel inputs to control a free camera.
  19143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19144. */
  19145. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19146. /**
  19147. * Defines the camera the input is attached to.
  19148. */
  19149. camera: FreeCamera;
  19150. /**
  19151. * Gets the class name of the current input.
  19152. * @returns the class name
  19153. */
  19154. getClassName(): string;
  19155. /**
  19156. * Set which movement axis (relative to camera's orientation) the mouse
  19157. * wheel's X axis controls.
  19158. * @param axis The axis to be moved. Set null to clear.
  19159. */
  19160. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19161. /**
  19162. * Get the configured movement axis (relative to camera's orientation) the
  19163. * mouse wheel's X axis controls.
  19164. * @returns The configured axis or null if none.
  19165. */
  19166. get wheelXMoveRelative(): Nullable<Coordinate>;
  19167. /**
  19168. * Set which movement axis (relative to camera's orientation) the mouse
  19169. * wheel's Y axis controls.
  19170. * @param axis The axis to be moved. Set null to clear.
  19171. */
  19172. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19173. /**
  19174. * Get the configured movement axis (relative to camera's orientation) the
  19175. * mouse wheel's Y axis controls.
  19176. * @returns The configured axis or null if none.
  19177. */
  19178. get wheelYMoveRelative(): Nullable<Coordinate>;
  19179. /**
  19180. * Set which movement axis (relative to camera's orientation) the mouse
  19181. * wheel's Z axis controls.
  19182. * @param axis The axis to be moved. Set null to clear.
  19183. */
  19184. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19185. /**
  19186. * Get the configured movement axis (relative to camera's orientation) the
  19187. * mouse wheel's Z axis controls.
  19188. * @returns The configured axis or null if none.
  19189. */
  19190. get wheelZMoveRelative(): Nullable<Coordinate>;
  19191. /**
  19192. * Set which rotation axis (relative to camera's orientation) the mouse
  19193. * wheel's X axis controls.
  19194. * @param axis The axis to be moved. Set null to clear.
  19195. */
  19196. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19197. /**
  19198. * Get the configured rotation axis (relative to camera's orientation) the
  19199. * mouse wheel's X axis controls.
  19200. * @returns The configured axis or null if none.
  19201. */
  19202. get wheelXRotateRelative(): Nullable<Coordinate>;
  19203. /**
  19204. * Set which rotation axis (relative to camera's orientation) the mouse
  19205. * wheel's Y axis controls.
  19206. * @param axis The axis to be moved. Set null to clear.
  19207. */
  19208. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19209. /**
  19210. * Get the configured rotation axis (relative to camera's orientation) the
  19211. * mouse wheel's Y axis controls.
  19212. * @returns The configured axis or null if none.
  19213. */
  19214. get wheelYRotateRelative(): Nullable<Coordinate>;
  19215. /**
  19216. * Set which rotation axis (relative to camera's orientation) the mouse
  19217. * wheel's Z axis controls.
  19218. * @param axis The axis to be moved. Set null to clear.
  19219. */
  19220. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19221. /**
  19222. * Get the configured rotation axis (relative to camera's orientation) the
  19223. * mouse wheel's Z axis controls.
  19224. * @returns The configured axis or null if none.
  19225. */
  19226. get wheelZRotateRelative(): Nullable<Coordinate>;
  19227. /**
  19228. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19229. * controls.
  19230. * @param axis The axis to be moved. Set null to clear.
  19231. */
  19232. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19233. /**
  19234. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19235. * X axis controls.
  19236. * @returns The configured axis or null if none.
  19237. */
  19238. get wheelXMoveScene(): Nullable<Coordinate>;
  19239. /**
  19240. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19241. * controls.
  19242. * @param axis The axis to be moved. Set null to clear.
  19243. */
  19244. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19245. /**
  19246. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19247. * Y axis controls.
  19248. * @returns The configured axis or null if none.
  19249. */
  19250. get wheelYMoveScene(): Nullable<Coordinate>;
  19251. /**
  19252. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19253. * controls.
  19254. * @param axis The axis to be moved. Set null to clear.
  19255. */
  19256. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19257. /**
  19258. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19259. * Z axis controls.
  19260. * @returns The configured axis or null if none.
  19261. */
  19262. get wheelZMoveScene(): Nullable<Coordinate>;
  19263. /**
  19264. * Called for each rendered frame.
  19265. */
  19266. checkInputs(): void;
  19267. private _moveRelative;
  19268. private _rotateRelative;
  19269. private _moveScene;
  19270. /**
  19271. * These are set to the desired default behaviour.
  19272. */
  19273. private _wheelXAction;
  19274. private _wheelXActionCoordinate;
  19275. private _wheelYAction;
  19276. private _wheelYActionCoordinate;
  19277. private _wheelZAction;
  19278. private _wheelZActionCoordinate;
  19279. /**
  19280. * Update the camera according to any configured properties for the 3
  19281. * mouse-wheel axis.
  19282. */
  19283. private _updateCamera;
  19284. }
  19285. }
  19286. declare module BABYLON {
  19287. /**
  19288. * Manage the touch inputs to control the movement of a free camera.
  19289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19290. */
  19291. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19292. /**
  19293. * Define if mouse events can be treated as touch events
  19294. */
  19295. allowMouse: boolean;
  19296. /**
  19297. * Defines the camera the input is attached to.
  19298. */
  19299. camera: FreeCamera;
  19300. /**
  19301. * Defines the touch sensibility for rotation.
  19302. * The higher the faster.
  19303. */
  19304. touchAngularSensibility: number;
  19305. /**
  19306. * Defines the touch sensibility for move.
  19307. * The higher the faster.
  19308. */
  19309. touchMoveSensibility: number;
  19310. private _offsetX;
  19311. private _offsetY;
  19312. private _pointerPressed;
  19313. private _pointerInput?;
  19314. private _observer;
  19315. private _onLostFocus;
  19316. /**
  19317. * Manage the touch inputs to control the movement of a free camera.
  19318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19319. * @param allowMouse Defines if mouse events can be treated as touch events
  19320. */
  19321. constructor(
  19322. /**
  19323. * Define if mouse events can be treated as touch events
  19324. */
  19325. allowMouse?: boolean);
  19326. /**
  19327. * Attach the input controls to a specific dom element to get the input from.
  19328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19329. */
  19330. attachControl(noPreventDefault?: boolean): void;
  19331. /**
  19332. * Detach the current controls from the specified dom element.
  19333. * @param element Defines the element to stop listening the inputs from
  19334. */
  19335. detachControl(): void;
  19336. /**
  19337. * Update the current camera state depending on the inputs that have been used this frame.
  19338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19339. */
  19340. checkInputs(): void;
  19341. /**
  19342. * Gets the class name of the current intput.
  19343. * @returns the class name
  19344. */
  19345. getClassName(): string;
  19346. /**
  19347. * Get the friendly name associated with the input class.
  19348. * @returns the input friendly name
  19349. */
  19350. getSimpleName(): string;
  19351. }
  19352. }
  19353. declare module BABYLON {
  19354. /**
  19355. * Default Inputs manager for the FreeCamera.
  19356. * It groups all the default supported inputs for ease of use.
  19357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19358. */
  19359. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19360. /**
  19361. * @hidden
  19362. */
  19363. _mouseInput: Nullable<FreeCameraMouseInput>;
  19364. /**
  19365. * @hidden
  19366. */
  19367. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19368. /**
  19369. * Instantiates a new FreeCameraInputsManager.
  19370. * @param camera Defines the camera the inputs belong to
  19371. */
  19372. constructor(camera: FreeCamera);
  19373. /**
  19374. * Add keyboard input support to the input manager.
  19375. * @returns the current input manager
  19376. */
  19377. addKeyboard(): FreeCameraInputsManager;
  19378. /**
  19379. * Add mouse input support to the input manager.
  19380. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19381. * @returns the current input manager
  19382. */
  19383. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19384. /**
  19385. * Removes the mouse input support from the manager
  19386. * @returns the current input manager
  19387. */
  19388. removeMouse(): FreeCameraInputsManager;
  19389. /**
  19390. * Add mouse wheel input support to the input manager.
  19391. * @returns the current input manager
  19392. */
  19393. addMouseWheel(): FreeCameraInputsManager;
  19394. /**
  19395. * Removes the mouse wheel input support from the manager
  19396. * @returns the current input manager
  19397. */
  19398. removeMouseWheel(): FreeCameraInputsManager;
  19399. /**
  19400. * Add touch input support to the input manager.
  19401. * @returns the current input manager
  19402. */
  19403. addTouch(): FreeCameraInputsManager;
  19404. /**
  19405. * Remove all attached input methods from a camera
  19406. */
  19407. clear(): void;
  19408. }
  19409. }
  19410. declare module BABYLON {
  19411. /**
  19412. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19413. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19414. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19415. */
  19416. export class FreeCamera extends TargetCamera {
  19417. /**
  19418. * Define the collision ellipsoid of the camera.
  19419. * This is helpful to simulate a camera body like the player body around the camera
  19420. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19421. */
  19422. ellipsoid: Vector3;
  19423. /**
  19424. * Define an offset for the position of the ellipsoid around the camera.
  19425. * This can be helpful to determine the center of the body near the gravity center of the body
  19426. * instead of its head.
  19427. */
  19428. ellipsoidOffset: Vector3;
  19429. /**
  19430. * Enable or disable collisions of the camera with the rest of the scene objects.
  19431. */
  19432. checkCollisions: boolean;
  19433. /**
  19434. * Enable or disable gravity on the camera.
  19435. */
  19436. applyGravity: boolean;
  19437. /**
  19438. * Define the input manager associated to the camera.
  19439. */
  19440. inputs: FreeCameraInputsManager;
  19441. /**
  19442. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19443. * Higher values reduce sensitivity.
  19444. */
  19445. get angularSensibility(): number;
  19446. /**
  19447. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19448. * Higher values reduce sensitivity.
  19449. */
  19450. set angularSensibility(value: number);
  19451. /**
  19452. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19453. */
  19454. get keysUp(): number[];
  19455. set keysUp(value: number[]);
  19456. /**
  19457. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19458. */
  19459. get keysUpward(): number[];
  19460. set keysUpward(value: number[]);
  19461. /**
  19462. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19463. */
  19464. get keysDown(): number[];
  19465. set keysDown(value: number[]);
  19466. /**
  19467. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19468. */
  19469. get keysDownward(): number[];
  19470. set keysDownward(value: number[]);
  19471. /**
  19472. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19473. */
  19474. get keysLeft(): number[];
  19475. set keysLeft(value: number[]);
  19476. /**
  19477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19478. */
  19479. get keysRight(): number[];
  19480. set keysRight(value: number[]);
  19481. /**
  19482. * Event raised when the camera collide with a mesh in the scene.
  19483. */
  19484. onCollide: (collidedMesh: AbstractMesh) => void;
  19485. private _collider;
  19486. private _needMoveForGravity;
  19487. private _oldPosition;
  19488. private _diffPosition;
  19489. private _newPosition;
  19490. /** @hidden */
  19491. _localDirection: Vector3;
  19492. /** @hidden */
  19493. _transformedDirection: Vector3;
  19494. /**
  19495. * Instantiates a Free Camera.
  19496. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19497. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19498. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19499. * @param name Define the name of the camera in the scene
  19500. * @param position Define the start position of the camera in the scene
  19501. * @param scene Define the scene the camera belongs to
  19502. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19503. */
  19504. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19505. /**
  19506. * Attached controls to the current camera.
  19507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19508. */
  19509. attachControl(noPreventDefault?: boolean): void;
  19510. /**
  19511. * Detach the current controls from the camera.
  19512. * The camera will stop reacting to inputs.
  19513. */
  19514. detachControl(): void;
  19515. private _collisionMask;
  19516. /**
  19517. * Define a collision mask to limit the list of object the camera can collide with
  19518. */
  19519. get collisionMask(): number;
  19520. set collisionMask(mask: number);
  19521. /** @hidden */
  19522. _collideWithWorld(displacement: Vector3): void;
  19523. private _onCollisionPositionChange;
  19524. /** @hidden */
  19525. _checkInputs(): void;
  19526. /** @hidden */
  19527. _decideIfNeedsToMove(): boolean;
  19528. /** @hidden */
  19529. _updatePosition(): void;
  19530. /**
  19531. * Destroy the camera and release the current resources hold by it.
  19532. */
  19533. dispose(): void;
  19534. /**
  19535. * Gets the current object class name.
  19536. * @return the class name
  19537. */
  19538. getClassName(): string;
  19539. }
  19540. }
  19541. declare module BABYLON {
  19542. /**
  19543. * Represents a gamepad control stick position
  19544. */
  19545. export class StickValues {
  19546. /**
  19547. * The x component of the control stick
  19548. */
  19549. x: number;
  19550. /**
  19551. * The y component of the control stick
  19552. */
  19553. y: number;
  19554. /**
  19555. * Initializes the gamepad x and y control stick values
  19556. * @param x The x component of the gamepad control stick value
  19557. * @param y The y component of the gamepad control stick value
  19558. */
  19559. constructor(
  19560. /**
  19561. * The x component of the control stick
  19562. */
  19563. x: number,
  19564. /**
  19565. * The y component of the control stick
  19566. */
  19567. y: number);
  19568. }
  19569. /**
  19570. * An interface which manages callbacks for gamepad button changes
  19571. */
  19572. export interface GamepadButtonChanges {
  19573. /**
  19574. * Called when a gamepad has been changed
  19575. */
  19576. changed: boolean;
  19577. /**
  19578. * Called when a gamepad press event has been triggered
  19579. */
  19580. pressChanged: boolean;
  19581. /**
  19582. * Called when a touch event has been triggered
  19583. */
  19584. touchChanged: boolean;
  19585. /**
  19586. * Called when a value has changed
  19587. */
  19588. valueChanged: boolean;
  19589. }
  19590. /**
  19591. * Represents a gamepad
  19592. */
  19593. export class Gamepad {
  19594. /**
  19595. * The id of the gamepad
  19596. */
  19597. id: string;
  19598. /**
  19599. * The index of the gamepad
  19600. */
  19601. index: number;
  19602. /**
  19603. * The browser gamepad
  19604. */
  19605. browserGamepad: any;
  19606. /**
  19607. * Specifies what type of gamepad this represents
  19608. */
  19609. type: number;
  19610. private _leftStick;
  19611. private _rightStick;
  19612. /** @hidden */
  19613. _isConnected: boolean;
  19614. private _leftStickAxisX;
  19615. private _leftStickAxisY;
  19616. private _rightStickAxisX;
  19617. private _rightStickAxisY;
  19618. /**
  19619. * Triggered when the left control stick has been changed
  19620. */
  19621. private _onleftstickchanged;
  19622. /**
  19623. * Triggered when the right control stick has been changed
  19624. */
  19625. private _onrightstickchanged;
  19626. /**
  19627. * Represents a gamepad controller
  19628. */
  19629. static GAMEPAD: number;
  19630. /**
  19631. * Represents a generic controller
  19632. */
  19633. static GENERIC: number;
  19634. /**
  19635. * Represents an XBox controller
  19636. */
  19637. static XBOX: number;
  19638. /**
  19639. * Represents a pose-enabled controller
  19640. */
  19641. static POSE_ENABLED: number;
  19642. /**
  19643. * Represents an Dual Shock controller
  19644. */
  19645. static DUALSHOCK: number;
  19646. /**
  19647. * Specifies whether the left control stick should be Y-inverted
  19648. */
  19649. protected _invertLeftStickY: boolean;
  19650. /**
  19651. * Specifies if the gamepad has been connected
  19652. */
  19653. get isConnected(): boolean;
  19654. /**
  19655. * Initializes the gamepad
  19656. * @param id The id of the gamepad
  19657. * @param index The index of the gamepad
  19658. * @param browserGamepad The browser gamepad
  19659. * @param leftStickX The x component of the left joystick
  19660. * @param leftStickY The y component of the left joystick
  19661. * @param rightStickX The x component of the right joystick
  19662. * @param rightStickY The y component of the right joystick
  19663. */
  19664. constructor(
  19665. /**
  19666. * The id of the gamepad
  19667. */
  19668. id: string,
  19669. /**
  19670. * The index of the gamepad
  19671. */
  19672. index: number,
  19673. /**
  19674. * The browser gamepad
  19675. */
  19676. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19677. /**
  19678. * Callback triggered when the left joystick has changed
  19679. * @param callback
  19680. */
  19681. onleftstickchanged(callback: (values: StickValues) => void): void;
  19682. /**
  19683. * Callback triggered when the right joystick has changed
  19684. * @param callback
  19685. */
  19686. onrightstickchanged(callback: (values: StickValues) => void): void;
  19687. /**
  19688. * Gets the left joystick
  19689. */
  19690. get leftStick(): StickValues;
  19691. /**
  19692. * Sets the left joystick values
  19693. */
  19694. set leftStick(newValues: StickValues);
  19695. /**
  19696. * Gets the right joystick
  19697. */
  19698. get rightStick(): StickValues;
  19699. /**
  19700. * Sets the right joystick value
  19701. */
  19702. set rightStick(newValues: StickValues);
  19703. /**
  19704. * Updates the gamepad joystick positions
  19705. */
  19706. update(): void;
  19707. /**
  19708. * Disposes the gamepad
  19709. */
  19710. dispose(): void;
  19711. }
  19712. /**
  19713. * Represents a generic gamepad
  19714. */
  19715. export class GenericPad extends Gamepad {
  19716. private _buttons;
  19717. private _onbuttondown;
  19718. private _onbuttonup;
  19719. /**
  19720. * Observable triggered when a button has been pressed
  19721. */
  19722. onButtonDownObservable: Observable<number>;
  19723. /**
  19724. * Observable triggered when a button has been released
  19725. */
  19726. onButtonUpObservable: Observable<number>;
  19727. /**
  19728. * Callback triggered when a button has been pressed
  19729. * @param callback Called when a button has been pressed
  19730. */
  19731. onbuttondown(callback: (buttonPressed: number) => void): void;
  19732. /**
  19733. * Callback triggered when a button has been released
  19734. * @param callback Called when a button has been released
  19735. */
  19736. onbuttonup(callback: (buttonReleased: number) => void): void;
  19737. /**
  19738. * Initializes the generic gamepad
  19739. * @param id The id of the generic gamepad
  19740. * @param index The index of the generic gamepad
  19741. * @param browserGamepad The browser gamepad
  19742. */
  19743. constructor(id: string, index: number, browserGamepad: any);
  19744. private _setButtonValue;
  19745. /**
  19746. * Updates the generic gamepad
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Disposes the generic gamepad
  19751. */
  19752. dispose(): void;
  19753. }
  19754. }
  19755. declare module BABYLON {
  19756. /**
  19757. * Defines the types of pose enabled controllers that are supported
  19758. */
  19759. export enum PoseEnabledControllerType {
  19760. /**
  19761. * HTC Vive
  19762. */
  19763. VIVE = 0,
  19764. /**
  19765. * Oculus Rift
  19766. */
  19767. OCULUS = 1,
  19768. /**
  19769. * Windows mixed reality
  19770. */
  19771. WINDOWS = 2,
  19772. /**
  19773. * Samsung gear VR
  19774. */
  19775. GEAR_VR = 3,
  19776. /**
  19777. * Google Daydream
  19778. */
  19779. DAYDREAM = 4,
  19780. /**
  19781. * Generic
  19782. */
  19783. GENERIC = 5
  19784. }
  19785. /**
  19786. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19787. */
  19788. export interface MutableGamepadButton {
  19789. /**
  19790. * Value of the button/trigger
  19791. */
  19792. value: number;
  19793. /**
  19794. * If the button/trigger is currently touched
  19795. */
  19796. touched: boolean;
  19797. /**
  19798. * If the button/trigger is currently pressed
  19799. */
  19800. pressed: boolean;
  19801. }
  19802. /**
  19803. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19804. * @hidden
  19805. */
  19806. export interface ExtendedGamepadButton extends GamepadButton {
  19807. /**
  19808. * If the button/trigger is currently pressed
  19809. */
  19810. readonly pressed: boolean;
  19811. /**
  19812. * If the button/trigger is currently touched
  19813. */
  19814. readonly touched: boolean;
  19815. /**
  19816. * Value of the button/trigger
  19817. */
  19818. readonly value: number;
  19819. }
  19820. /** @hidden */
  19821. export interface _GamePadFactory {
  19822. /**
  19823. * Returns whether or not the current gamepad can be created for this type of controller.
  19824. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19825. * @returns true if it can be created, otherwise false
  19826. */
  19827. canCreate(gamepadInfo: any): boolean;
  19828. /**
  19829. * Creates a new instance of the Gamepad.
  19830. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19831. * @returns the new gamepad instance
  19832. */
  19833. create(gamepadInfo: any): Gamepad;
  19834. }
  19835. /**
  19836. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19837. */
  19838. export class PoseEnabledControllerHelper {
  19839. /** @hidden */
  19840. static _ControllerFactories: _GamePadFactory[];
  19841. /** @hidden */
  19842. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19843. /**
  19844. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19845. * @param vrGamepad the gamepad to initialized
  19846. * @returns a vr controller of the type the gamepad identified as
  19847. */
  19848. static InitiateController(vrGamepad: any): Gamepad;
  19849. }
  19850. /**
  19851. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19852. */
  19853. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19854. /**
  19855. * If the controller is used in a webXR session
  19856. */
  19857. isXR: boolean;
  19858. private _deviceRoomPosition;
  19859. private _deviceRoomRotationQuaternion;
  19860. /**
  19861. * The device position in babylon space
  19862. */
  19863. devicePosition: Vector3;
  19864. /**
  19865. * The device rotation in babylon space
  19866. */
  19867. deviceRotationQuaternion: Quaternion;
  19868. /**
  19869. * The scale factor of the device in babylon space
  19870. */
  19871. deviceScaleFactor: number;
  19872. /**
  19873. * (Likely devicePosition should be used instead) The device position in its room space
  19874. */
  19875. position: Vector3;
  19876. /**
  19877. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19878. */
  19879. rotationQuaternion: Quaternion;
  19880. /**
  19881. * The type of controller (Eg. Windows mixed reality)
  19882. */
  19883. controllerType: PoseEnabledControllerType;
  19884. protected _calculatedPosition: Vector3;
  19885. private _calculatedRotation;
  19886. /**
  19887. * The raw pose from the device
  19888. */
  19889. rawPose: DevicePose;
  19890. private _trackPosition;
  19891. private _maxRotationDistFromHeadset;
  19892. private _draggedRoomRotation;
  19893. /**
  19894. * @hidden
  19895. */
  19896. _disableTrackPosition(fixedPosition: Vector3): void;
  19897. /**
  19898. * Internal, the mesh attached to the controller
  19899. * @hidden
  19900. */
  19901. _mesh: Nullable<AbstractMesh>;
  19902. private _poseControlledCamera;
  19903. private _leftHandSystemQuaternion;
  19904. /**
  19905. * Internal, matrix used to convert room space to babylon space
  19906. * @hidden
  19907. */
  19908. _deviceToWorld: Matrix;
  19909. /**
  19910. * Node to be used when casting a ray from the controller
  19911. * @hidden
  19912. */
  19913. _pointingPoseNode: Nullable<TransformNode>;
  19914. /**
  19915. * Name of the child mesh that can be used to cast a ray from the controller
  19916. */
  19917. static readonly POINTING_POSE: string;
  19918. /**
  19919. * Creates a new PoseEnabledController from a gamepad
  19920. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19921. */
  19922. constructor(browserGamepad: any);
  19923. private _workingMatrix;
  19924. /**
  19925. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19926. */
  19927. update(): void;
  19928. /**
  19929. * Updates only the pose device and mesh without doing any button event checking
  19930. */
  19931. protected _updatePoseAndMesh(): void;
  19932. /**
  19933. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19934. * @param poseData raw pose fromthe device
  19935. */
  19936. updateFromDevice(poseData: DevicePose): void;
  19937. /**
  19938. * @hidden
  19939. */
  19940. _meshAttachedObservable: Observable<AbstractMesh>;
  19941. /**
  19942. * Attaches a mesh to the controller
  19943. * @param mesh the mesh to be attached
  19944. */
  19945. attachToMesh(mesh: AbstractMesh): void;
  19946. /**
  19947. * Attaches the controllers mesh to a camera
  19948. * @param camera the camera the mesh should be attached to
  19949. */
  19950. attachToPoseControlledCamera(camera: TargetCamera): void;
  19951. /**
  19952. * Disposes of the controller
  19953. */
  19954. dispose(): void;
  19955. /**
  19956. * The mesh that is attached to the controller
  19957. */
  19958. get mesh(): Nullable<AbstractMesh>;
  19959. /**
  19960. * Gets the ray of the controller in the direction the controller is pointing
  19961. * @param length the length the resulting ray should be
  19962. * @returns a ray in the direction the controller is pointing
  19963. */
  19964. getForwardRay(length?: number): Ray;
  19965. }
  19966. }
  19967. declare module BABYLON {
  19968. /**
  19969. * Defines the WebVRController object that represents controllers tracked in 3D space
  19970. */
  19971. export abstract class WebVRController extends PoseEnabledController {
  19972. /**
  19973. * Internal, the default controller model for the controller
  19974. */
  19975. protected _defaultModel: Nullable<AbstractMesh>;
  19976. /**
  19977. * Fired when the trigger state has changed
  19978. */
  19979. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19980. /**
  19981. * Fired when the main button state has changed
  19982. */
  19983. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19984. /**
  19985. * Fired when the secondary button state has changed
  19986. */
  19987. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19988. /**
  19989. * Fired when the pad state has changed
  19990. */
  19991. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19992. /**
  19993. * Fired when controllers stick values have changed
  19994. */
  19995. onPadValuesChangedObservable: Observable<StickValues>;
  19996. /**
  19997. * Array of button availible on the controller
  19998. */
  19999. protected _buttons: Array<MutableGamepadButton>;
  20000. private _onButtonStateChange;
  20001. /**
  20002. * Fired when a controller button's state has changed
  20003. * @param callback the callback containing the button that was modified
  20004. */
  20005. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20006. /**
  20007. * X and Y axis corresponding to the controllers joystick
  20008. */
  20009. pad: StickValues;
  20010. /**
  20011. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20012. */
  20013. hand: string;
  20014. /**
  20015. * The default controller model for the controller
  20016. */
  20017. get defaultModel(): Nullable<AbstractMesh>;
  20018. /**
  20019. * Creates a new WebVRController from a gamepad
  20020. * @param vrGamepad the gamepad that the WebVRController should be created from
  20021. */
  20022. constructor(vrGamepad: any);
  20023. /**
  20024. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20025. */
  20026. update(): void;
  20027. /**
  20028. * Function to be called when a button is modified
  20029. */
  20030. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20031. /**
  20032. * Loads a mesh and attaches it to the controller
  20033. * @param scene the scene the mesh should be added to
  20034. * @param meshLoaded callback for when the mesh has been loaded
  20035. */
  20036. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20037. private _setButtonValue;
  20038. private _changes;
  20039. private _checkChanges;
  20040. /**
  20041. * Disposes of th webVRCOntroller
  20042. */
  20043. dispose(): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * The HemisphericLight simulates the ambient environment light,
  20049. * so the passed direction is the light reflection direction, not the incoming direction.
  20050. */
  20051. export class HemisphericLight extends Light {
  20052. /**
  20053. * The groundColor is the light in the opposite direction to the one specified during creation.
  20054. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  20055. */
  20056. groundColor: Color3;
  20057. /**
  20058. * The light reflection direction, not the incoming direction.
  20059. */
  20060. direction: Vector3;
  20061. /**
  20062. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20063. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20064. * The HemisphericLight can't cast shadows.
  20065. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20066. * @param name The friendly name of the light
  20067. * @param direction The direction of the light reflection
  20068. * @param scene The scene the light belongs to
  20069. */
  20070. constructor(name: string, direction: Vector3, scene: Scene);
  20071. protected _buildUniformLayout(): void;
  20072. /**
  20073. * Returns the string "HemisphericLight".
  20074. * @return The class name
  20075. */
  20076. getClassName(): string;
  20077. /**
  20078. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20079. * Returns the updated direction.
  20080. * @param target The target the direction should point to
  20081. * @return The computed direction
  20082. */
  20083. setDirectionToTarget(target: Vector3): Vector3;
  20084. /**
  20085. * Returns the shadow generator associated to the light.
  20086. * @returns Always null for hemispheric lights because it does not support shadows.
  20087. */
  20088. getShadowGenerator(): Nullable<IShadowGenerator>;
  20089. /**
  20090. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20091. * @param effect The effect to update
  20092. * @param lightIndex The index of the light in the effect to update
  20093. * @returns The hemispheric light
  20094. */
  20095. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20096. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20097. /**
  20098. * Computes the world matrix of the node
  20099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20100. * @param useWasUpdatedFlag defines a reserved property
  20101. * @returns the world matrix
  20102. */
  20103. computeWorldMatrix(): Matrix;
  20104. /**
  20105. * Returns the integer 3.
  20106. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20107. */
  20108. getTypeID(): number;
  20109. /**
  20110. * Prepares the list of defines specific to the light type.
  20111. * @param defines the list of defines
  20112. * @param lightIndex defines the index of the light for the effect
  20113. */
  20114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20115. }
  20116. }
  20117. declare module BABYLON {
  20118. /** @hidden */
  20119. export var vrMultiviewToSingleviewPixelShader: {
  20120. name: string;
  20121. shader: string;
  20122. };
  20123. }
  20124. declare module BABYLON {
  20125. /**
  20126. * Renders to multiple views with a single draw call
  20127. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20128. */
  20129. export class MultiviewRenderTarget extends RenderTargetTexture {
  20130. /**
  20131. * Creates a multiview render target
  20132. * @param scene scene used with the render target
  20133. * @param size the size of the render target (used for each view)
  20134. */
  20135. constructor(scene: Scene, size?: number | {
  20136. width: number;
  20137. height: number;
  20138. } | {
  20139. ratio: number;
  20140. });
  20141. /**
  20142. * @hidden
  20143. * @param faceIndex the face index, if its a cube texture
  20144. */
  20145. _bindFrameBuffer(faceIndex?: number): void;
  20146. /**
  20147. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20148. * @returns the view count
  20149. */
  20150. getViewCount(): number;
  20151. }
  20152. }
  20153. declare module BABYLON {
  20154. interface Engine {
  20155. /**
  20156. * Creates a new multiview render target
  20157. * @param width defines the width of the texture
  20158. * @param height defines the height of the texture
  20159. * @returns the created multiview texture
  20160. */
  20161. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20162. /**
  20163. * Binds a multiview framebuffer to be drawn to
  20164. * @param multiviewTexture texture to bind
  20165. */
  20166. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20167. }
  20168. interface Camera {
  20169. /**
  20170. * @hidden
  20171. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20172. */
  20173. _useMultiviewToSingleView: boolean;
  20174. /**
  20175. * @hidden
  20176. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20177. */
  20178. _multiviewTexture: Nullable<RenderTargetTexture>;
  20179. /**
  20180. * @hidden
  20181. * ensures the multiview texture of the camera exists and has the specified width/height
  20182. * @param width height to set on the multiview texture
  20183. * @param height width to set on the multiview texture
  20184. */
  20185. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20186. }
  20187. interface Scene {
  20188. /** @hidden */
  20189. _transformMatrixR: Matrix;
  20190. /** @hidden */
  20191. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20192. /** @hidden */
  20193. _createMultiviewUbo(): void;
  20194. /** @hidden */
  20195. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20196. /** @hidden */
  20197. _renderMultiviewToSingleView(camera: Camera): void;
  20198. }
  20199. }
  20200. declare module BABYLON {
  20201. /**
  20202. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20203. * This will not be used for webXR as it supports displaying texture arrays directly
  20204. */
  20205. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20206. /**
  20207. * Gets a string identifying the name of the class
  20208. * @returns "VRMultiviewToSingleviewPostProcess" string
  20209. */
  20210. getClassName(): string;
  20211. /**
  20212. * Initializes a VRMultiviewToSingleview
  20213. * @param name name of the post process
  20214. * @param camera camera to be applied to
  20215. * @param scaleFactor scaling factor to the size of the output texture
  20216. */
  20217. constructor(name: string, camera: Camera, scaleFactor: number);
  20218. }
  20219. }
  20220. declare module BABYLON {
  20221. /**
  20222. * Interface used to define additional presentation attributes
  20223. */
  20224. export interface IVRPresentationAttributes {
  20225. /**
  20226. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20227. */
  20228. highRefreshRate: boolean;
  20229. /**
  20230. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20231. */
  20232. foveationLevel: number;
  20233. }
  20234. interface Engine {
  20235. /** @hidden */
  20236. _vrDisplay: any;
  20237. /** @hidden */
  20238. _vrSupported: boolean;
  20239. /** @hidden */
  20240. _oldSize: Size;
  20241. /** @hidden */
  20242. _oldHardwareScaleFactor: number;
  20243. /** @hidden */
  20244. _vrExclusivePointerMode: boolean;
  20245. /** @hidden */
  20246. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20247. /** @hidden */
  20248. _onVRDisplayPointerRestricted: () => void;
  20249. /** @hidden */
  20250. _onVRDisplayPointerUnrestricted: () => void;
  20251. /** @hidden */
  20252. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20253. /** @hidden */
  20254. _onVrDisplayDisconnect: Nullable<() => void>;
  20255. /** @hidden */
  20256. _onVrDisplayPresentChange: Nullable<() => void>;
  20257. /**
  20258. * Observable signaled when VR display mode changes
  20259. */
  20260. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20261. /**
  20262. * Observable signaled when VR request present is complete
  20263. */
  20264. onVRRequestPresentComplete: Observable<boolean>;
  20265. /**
  20266. * Observable signaled when VR request present starts
  20267. */
  20268. onVRRequestPresentStart: Observable<Engine>;
  20269. /**
  20270. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20271. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20272. */
  20273. isInVRExclusivePointerMode: boolean;
  20274. /**
  20275. * Gets a boolean indicating if a webVR device was detected
  20276. * @returns true if a webVR device was detected
  20277. */
  20278. isVRDevicePresent(): boolean;
  20279. /**
  20280. * Gets the current webVR device
  20281. * @returns the current webVR device (or null)
  20282. */
  20283. getVRDevice(): any;
  20284. /**
  20285. * Initializes a webVR display and starts listening to display change events
  20286. * The onVRDisplayChangedObservable will be notified upon these changes
  20287. * @returns A promise containing a VRDisplay and if vr is supported
  20288. */
  20289. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20290. /** @hidden */
  20291. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20292. /**
  20293. * Gets or sets the presentation attributes used to configure VR rendering
  20294. */
  20295. vrPresentationAttributes?: IVRPresentationAttributes;
  20296. /**
  20297. * Call this function to switch to webVR mode
  20298. * Will do nothing if webVR is not supported or if there is no webVR device
  20299. * @param options the webvr options provided to the camera. mainly used for multiview
  20300. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20301. */
  20302. enableVR(options: WebVROptions): void;
  20303. /** @hidden */
  20304. _onVRFullScreenTriggered(): void;
  20305. }
  20306. }
  20307. declare module BABYLON {
  20308. /**
  20309. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20310. * IMPORTANT!! The data is right-hand data.
  20311. * @export
  20312. * @interface DevicePose
  20313. */
  20314. export interface DevicePose {
  20315. /**
  20316. * The position of the device, values in array are [x,y,z].
  20317. */
  20318. readonly position: Nullable<Float32Array>;
  20319. /**
  20320. * The linearVelocity of the device, values in array are [x,y,z].
  20321. */
  20322. readonly linearVelocity: Nullable<Float32Array>;
  20323. /**
  20324. * The linearAcceleration of the device, values in array are [x,y,z].
  20325. */
  20326. readonly linearAcceleration: Nullable<Float32Array>;
  20327. /**
  20328. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20329. */
  20330. readonly orientation: Nullable<Float32Array>;
  20331. /**
  20332. * The angularVelocity of the device, values in array are [x,y,z].
  20333. */
  20334. readonly angularVelocity: Nullable<Float32Array>;
  20335. /**
  20336. * The angularAcceleration of the device, values in array are [x,y,z].
  20337. */
  20338. readonly angularAcceleration: Nullable<Float32Array>;
  20339. }
  20340. /**
  20341. * Interface representing a pose controlled object in Babylon.
  20342. * A pose controlled object has both regular pose values as well as pose values
  20343. * from an external device such as a VR head mounted display
  20344. */
  20345. export interface PoseControlled {
  20346. /**
  20347. * The position of the object in babylon space.
  20348. */
  20349. position: Vector3;
  20350. /**
  20351. * The rotation quaternion of the object in babylon space.
  20352. */
  20353. rotationQuaternion: Quaternion;
  20354. /**
  20355. * The position of the device in babylon space.
  20356. */
  20357. devicePosition?: Vector3;
  20358. /**
  20359. * The rotation quaternion of the device in babylon space.
  20360. */
  20361. deviceRotationQuaternion: Quaternion;
  20362. /**
  20363. * The raw pose coming from the device.
  20364. */
  20365. rawPose: Nullable<DevicePose>;
  20366. /**
  20367. * The scale of the device to be used when translating from device space to babylon space.
  20368. */
  20369. deviceScaleFactor: number;
  20370. /**
  20371. * Updates the poseControlled values based on the input device pose.
  20372. * @param poseData the pose data to update the object with
  20373. */
  20374. updateFromDevice(poseData: DevicePose): void;
  20375. }
  20376. /**
  20377. * Set of options to customize the webVRCamera
  20378. */
  20379. export interface WebVROptions {
  20380. /**
  20381. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20382. */
  20383. trackPosition?: boolean;
  20384. /**
  20385. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20386. */
  20387. positionScale?: number;
  20388. /**
  20389. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20390. */
  20391. displayName?: string;
  20392. /**
  20393. * Should the native controller meshes be initialized. (default: true)
  20394. */
  20395. controllerMeshes?: boolean;
  20396. /**
  20397. * Creating a default HemiLight only on controllers. (default: true)
  20398. */
  20399. defaultLightingOnControllers?: boolean;
  20400. /**
  20401. * If you don't want to use the default VR button of the helper. (default: false)
  20402. */
  20403. useCustomVRButton?: boolean;
  20404. /**
  20405. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20406. */
  20407. customVRButton?: HTMLButtonElement;
  20408. /**
  20409. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20410. */
  20411. rayLength?: number;
  20412. /**
  20413. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20414. */
  20415. defaultHeight?: number;
  20416. /**
  20417. * If multiview should be used if availible (default: false)
  20418. */
  20419. useMultiview?: boolean;
  20420. }
  20421. /**
  20422. * This represents a WebVR camera.
  20423. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20424. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20425. */
  20426. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20427. private webVROptions;
  20428. /**
  20429. * @hidden
  20430. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20431. */
  20432. _vrDevice: any;
  20433. /**
  20434. * The rawPose of the vrDevice.
  20435. */
  20436. rawPose: Nullable<DevicePose>;
  20437. private _onVREnabled;
  20438. private _specsVersion;
  20439. private _attached;
  20440. private _frameData;
  20441. protected _descendants: Array<Node>;
  20442. private _deviceRoomPosition;
  20443. /** @hidden */
  20444. _deviceRoomRotationQuaternion: Quaternion;
  20445. private _standingMatrix;
  20446. /**
  20447. * Represents device position in babylon space.
  20448. */
  20449. devicePosition: Vector3;
  20450. /**
  20451. * Represents device rotation in babylon space.
  20452. */
  20453. deviceRotationQuaternion: Quaternion;
  20454. /**
  20455. * The scale of the device to be used when translating from device space to babylon space.
  20456. */
  20457. deviceScaleFactor: number;
  20458. private _deviceToWorld;
  20459. private _worldToDevice;
  20460. /**
  20461. * References to the webVR controllers for the vrDevice.
  20462. */
  20463. controllers: Array<WebVRController>;
  20464. /**
  20465. * Emits an event when a controller is attached.
  20466. */
  20467. onControllersAttachedObservable: Observable<WebVRController[]>;
  20468. /**
  20469. * Emits an event when a controller's mesh has been loaded;
  20470. */
  20471. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20472. /**
  20473. * Emits an event when the HMD's pose has been updated.
  20474. */
  20475. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20476. private _poseSet;
  20477. /**
  20478. * If the rig cameras be used as parent instead of this camera.
  20479. */
  20480. rigParenting: boolean;
  20481. private _lightOnControllers;
  20482. private _defaultHeight?;
  20483. /**
  20484. * Instantiates a WebVRFreeCamera.
  20485. * @param name The name of the WebVRFreeCamera
  20486. * @param position The starting anchor position for the camera
  20487. * @param scene The scene the camera belongs to
  20488. * @param webVROptions a set of customizable options for the webVRCamera
  20489. */
  20490. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20491. /**
  20492. * Gets the device distance from the ground in meters.
  20493. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20494. */
  20495. deviceDistanceToRoomGround(): number;
  20496. /**
  20497. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20498. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20499. */
  20500. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20501. /**
  20502. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20503. * @returns A promise with a boolean set to if the standing matrix is supported.
  20504. */
  20505. useStandingMatrixAsync(): Promise<boolean>;
  20506. /**
  20507. * Disposes the camera
  20508. */
  20509. dispose(): void;
  20510. /**
  20511. * Gets a vrController by name.
  20512. * @param name The name of the controller to retreive
  20513. * @returns the controller matching the name specified or null if not found
  20514. */
  20515. getControllerByName(name: string): Nullable<WebVRController>;
  20516. private _leftController;
  20517. /**
  20518. * The controller corresponding to the users left hand.
  20519. */
  20520. get leftController(): Nullable<WebVRController>;
  20521. private _rightController;
  20522. /**
  20523. * The controller corresponding to the users right hand.
  20524. */
  20525. get rightController(): Nullable<WebVRController>;
  20526. /**
  20527. * Casts a ray forward from the vrCamera's gaze.
  20528. * @param length Length of the ray (default: 100)
  20529. * @returns the ray corresponding to the gaze
  20530. */
  20531. getForwardRay(length?: number): Ray;
  20532. /**
  20533. * @hidden
  20534. * Updates the camera based on device's frame data
  20535. */
  20536. _checkInputs(): void;
  20537. /**
  20538. * Updates the poseControlled values based on the input device pose.
  20539. * @param poseData Pose coming from the device
  20540. */
  20541. updateFromDevice(poseData: DevicePose): void;
  20542. private _detachIfAttached;
  20543. /**
  20544. * WebVR's attach control will start broadcasting frames to the device.
  20545. * Note that in certain browsers (chrome for example) this function must be called
  20546. * within a user-interaction callback. Example:
  20547. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20548. *
  20549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20550. */
  20551. attachControl(noPreventDefault?: boolean): void;
  20552. /**
  20553. * Detaches the camera from the html element and disables VR
  20554. */
  20555. detachControl(): void;
  20556. /**
  20557. * @returns the name of this class
  20558. */
  20559. getClassName(): string;
  20560. /**
  20561. * Calls resetPose on the vrDisplay
  20562. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20563. */
  20564. resetToCurrentRotation(): void;
  20565. /**
  20566. * @hidden
  20567. * Updates the rig cameras (left and right eye)
  20568. */
  20569. _updateRigCameras(): void;
  20570. private _workingVector;
  20571. private _oneVector;
  20572. private _workingMatrix;
  20573. private updateCacheCalled;
  20574. private _correctPositionIfNotTrackPosition;
  20575. /**
  20576. * @hidden
  20577. * Updates the cached values of the camera
  20578. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20579. */
  20580. _updateCache(ignoreParentClass?: boolean): void;
  20581. /**
  20582. * @hidden
  20583. * Get current device position in babylon world
  20584. */
  20585. _computeDevicePosition(): void;
  20586. /**
  20587. * Updates the current device position and rotation in the babylon world
  20588. */
  20589. update(): void;
  20590. /**
  20591. * @hidden
  20592. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20593. * @returns an identity matrix
  20594. */
  20595. _getViewMatrix(): Matrix;
  20596. private _tmpMatrix;
  20597. /**
  20598. * This function is called by the two RIG cameras.
  20599. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20600. * @hidden
  20601. */
  20602. _getWebVRViewMatrix(): Matrix;
  20603. /** @hidden */
  20604. _getWebVRProjectionMatrix(): Matrix;
  20605. private _onGamepadConnectedObserver;
  20606. private _onGamepadDisconnectedObserver;
  20607. private _updateCacheWhenTrackingDisabledObserver;
  20608. /**
  20609. * Initializes the controllers and their meshes
  20610. */
  20611. initControllers(): void;
  20612. }
  20613. }
  20614. declare module BABYLON {
  20615. /**
  20616. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20617. *
  20618. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20619. *
  20620. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20621. */
  20622. export class MaterialHelper {
  20623. /**
  20624. * Bind the current view position to an effect.
  20625. * @param effect The effect to be bound
  20626. * @param scene The scene the eyes position is used from
  20627. * @param variableName name of the shader variable that will hold the eye position
  20628. */
  20629. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20630. /**
  20631. * Helps preparing the defines values about the UVs in used in the effect.
  20632. * UVs are shared as much as we can accross channels in the shaders.
  20633. * @param texture The texture we are preparing the UVs for
  20634. * @param defines The defines to update
  20635. * @param key The channel key "diffuse", "specular"... used in the shader
  20636. */
  20637. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20638. /**
  20639. * Binds a texture matrix value to its corrsponding uniform
  20640. * @param texture The texture to bind the matrix for
  20641. * @param uniformBuffer The uniform buffer receivin the data
  20642. * @param key The channel key "diffuse", "specular"... used in the shader
  20643. */
  20644. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20645. /**
  20646. * Gets the current status of the fog (should it be enabled?)
  20647. * @param mesh defines the mesh to evaluate for fog support
  20648. * @param scene defines the hosting scene
  20649. * @returns true if fog must be enabled
  20650. */
  20651. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20652. /**
  20653. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20654. * @param mesh defines the current mesh
  20655. * @param scene defines the current scene
  20656. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20657. * @param pointsCloud defines if point cloud rendering has to be turned on
  20658. * @param fogEnabled defines if fog has to be turned on
  20659. * @param alphaTest defines if alpha testing has to be turned on
  20660. * @param defines defines the current list of defines
  20661. */
  20662. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20663. /**
  20664. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20665. * @param scene defines the current scene
  20666. * @param engine defines the current engine
  20667. * @param defines specifies the list of active defines
  20668. * @param useInstances defines if instances have to be turned on
  20669. * @param useClipPlane defines if clip plane have to be turned on
  20670. * @param useInstances defines if instances have to be turned on
  20671. * @param useThinInstances defines if thin instances have to be turned on
  20672. */
  20673. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20674. /**
  20675. * Prepares the defines for bones
  20676. * @param mesh The mesh containing the geometry data we will draw
  20677. * @param defines The defines to update
  20678. */
  20679. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20680. /**
  20681. * Prepares the defines for morph targets
  20682. * @param mesh The mesh containing the geometry data we will draw
  20683. * @param defines The defines to update
  20684. */
  20685. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20686. /**
  20687. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20688. * @param mesh The mesh containing the geometry data we will draw
  20689. * @param defines The defines to update
  20690. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20691. * @param useBones Precise whether bones should be used or not (override mesh info)
  20692. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20693. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20694. * @returns false if defines are considered not dirty and have not been checked
  20695. */
  20696. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20697. /**
  20698. * Prepares the defines related to multiview
  20699. * @param scene The scene we are intending to draw
  20700. * @param defines The defines to update
  20701. */
  20702. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20703. /**
  20704. * Prepares the defines related to the prepass
  20705. * @param scene The scene we are intending to draw
  20706. * @param defines The defines to update
  20707. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20708. */
  20709. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20710. /**
  20711. * Prepares the defines related to the light information passed in parameter
  20712. * @param scene The scene we are intending to draw
  20713. * @param mesh The mesh the effect is compiling for
  20714. * @param light The light the effect is compiling for
  20715. * @param lightIndex The index of the light
  20716. * @param defines The defines to update
  20717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20718. * @param state Defines the current state regarding what is needed (normals, etc...)
  20719. */
  20720. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20721. needNormals: boolean;
  20722. needRebuild: boolean;
  20723. shadowEnabled: boolean;
  20724. specularEnabled: boolean;
  20725. lightmapMode: boolean;
  20726. }): void;
  20727. /**
  20728. * Prepares the defines related to the light information passed in parameter
  20729. * @param scene The scene we are intending to draw
  20730. * @param mesh The mesh the effect is compiling for
  20731. * @param defines The defines to update
  20732. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20733. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20734. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20735. * @returns true if normals will be required for the rest of the effect
  20736. */
  20737. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20738. /**
  20739. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20740. * @param lightIndex defines the light index
  20741. * @param uniformsList The uniform list
  20742. * @param samplersList The sampler list
  20743. * @param projectedLightTexture defines if projected texture must be used
  20744. * @param uniformBuffersList defines an optional list of uniform buffers
  20745. */
  20746. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20747. /**
  20748. * Prepares the uniforms and samplers list to be used in the effect
  20749. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20750. * @param samplersList The sampler list
  20751. * @param defines The defines helping in the list generation
  20752. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20753. */
  20754. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20755. /**
  20756. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20757. * @param defines The defines to update while falling back
  20758. * @param fallbacks The authorized effect fallbacks
  20759. * @param maxSimultaneousLights The maximum number of lights allowed
  20760. * @param rank the current rank of the Effect
  20761. * @returns The newly affected rank
  20762. */
  20763. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20764. private static _TmpMorphInfluencers;
  20765. /**
  20766. * Prepares the list of attributes required for morph targets according to the effect defines.
  20767. * @param attribs The current list of supported attribs
  20768. * @param mesh The mesh to prepare the morph targets attributes for
  20769. * @param influencers The number of influencers
  20770. */
  20771. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20772. /**
  20773. * Prepares the list of attributes required for morph targets according to the effect defines.
  20774. * @param attribs The current list of supported attribs
  20775. * @param mesh The mesh to prepare the morph targets attributes for
  20776. * @param defines The current Defines of the effect
  20777. */
  20778. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20779. /**
  20780. * Prepares the list of attributes required for bones according to the effect defines.
  20781. * @param attribs The current list of supported attribs
  20782. * @param mesh The mesh to prepare the bones attributes for
  20783. * @param defines The current Defines of the effect
  20784. * @param fallbacks The current efffect fallback strategy
  20785. */
  20786. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20787. /**
  20788. * Check and prepare the list of attributes required for instances according to the effect defines.
  20789. * @param attribs The current list of supported attribs
  20790. * @param defines The current MaterialDefines of the effect
  20791. */
  20792. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20793. /**
  20794. * Add the list of attributes required for instances to the attribs array.
  20795. * @param attribs The current list of supported attribs
  20796. */
  20797. static PushAttributesForInstances(attribs: string[]): void;
  20798. /**
  20799. * Binds the light information to the effect.
  20800. * @param light The light containing the generator
  20801. * @param effect The effect we are binding the data to
  20802. * @param lightIndex The light index in the effect used to render
  20803. */
  20804. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20805. /**
  20806. * Binds the lights information from the scene to the effect for the given mesh.
  20807. * @param light Light to bind
  20808. * @param lightIndex Light index
  20809. * @param scene The scene where the light belongs to
  20810. * @param effect The effect we are binding the data to
  20811. * @param useSpecular Defines if specular is supported
  20812. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20813. */
  20814. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20815. /**
  20816. * Binds the lights information from the scene to the effect for the given mesh.
  20817. * @param scene The scene the lights belongs to
  20818. * @param mesh The mesh we are binding the information to render
  20819. * @param effect The effect we are binding the data to
  20820. * @param defines The generated defines for the effect
  20821. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20823. */
  20824. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20825. private static _tempFogColor;
  20826. /**
  20827. * Binds the fog information from the scene to the effect for the given mesh.
  20828. * @param scene The scene the lights belongs to
  20829. * @param mesh The mesh we are binding the information to render
  20830. * @param effect The effect we are binding the data to
  20831. * @param linearSpace Defines if the fog effect is applied in linear space
  20832. */
  20833. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20834. /**
  20835. * Binds the bones information from the mesh to the effect.
  20836. * @param mesh The mesh we are binding the information to render
  20837. * @param effect The effect we are binding the data to
  20838. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20839. */
  20840. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20841. private static _CopyBonesTransformationMatrices;
  20842. /**
  20843. * Binds the morph targets information from the mesh to the effect.
  20844. * @param abstractMesh The mesh we are binding the information to render
  20845. * @param effect The effect we are binding the data to
  20846. */
  20847. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20848. /**
  20849. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20850. * @param defines The generated defines used in the effect
  20851. * @param effect The effect we are binding the data to
  20852. * @param scene The scene we are willing to render with logarithmic scale for
  20853. */
  20854. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20855. /**
  20856. * Binds the clip plane information from the scene to the effect.
  20857. * @param scene The scene the clip plane information are extracted from
  20858. * @param effect The effect we are binding the data to
  20859. */
  20860. static BindClipPlane(effect: Effect, scene: Scene): void;
  20861. }
  20862. }
  20863. declare module BABYLON {
  20864. /**
  20865. * Block used to expose an input value
  20866. */
  20867. export class InputBlock extends NodeMaterialBlock {
  20868. private _mode;
  20869. private _associatedVariableName;
  20870. private _storedValue;
  20871. private _valueCallback;
  20872. private _type;
  20873. private _animationType;
  20874. /** Gets or set a value used to limit the range of float values */
  20875. min: number;
  20876. /** Gets or set a value used to limit the range of float values */
  20877. max: number;
  20878. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20879. isBoolean: boolean;
  20880. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20881. matrixMode: number;
  20882. /** @hidden */
  20883. _systemValue: Nullable<NodeMaterialSystemValues>;
  20884. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20885. isConstant: boolean;
  20886. /** Gets or sets the group to use to display this block in the Inspector */
  20887. groupInInspector: string;
  20888. /** Gets an observable raised when the value is changed */
  20889. onValueChangedObservable: Observable<InputBlock>;
  20890. /**
  20891. * Gets or sets the connection point type (default is float)
  20892. */
  20893. get type(): NodeMaterialBlockConnectionPointTypes;
  20894. /**
  20895. * Creates a new InputBlock
  20896. * @param name defines the block name
  20897. * @param target defines the target of that block (Vertex by default)
  20898. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20899. */
  20900. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20901. /**
  20902. * Validates if a name is a reserve word.
  20903. * @param newName the new name to be given to the node.
  20904. * @returns false if the name is a reserve word, else true.
  20905. */
  20906. validateBlockName(newName: string): boolean;
  20907. /**
  20908. * Gets the output component
  20909. */
  20910. get output(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Set the source of this connection point to a vertex attribute
  20913. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20914. * @returns the current connection point
  20915. */
  20916. setAsAttribute(attributeName?: string): InputBlock;
  20917. /**
  20918. * Set the source of this connection point to a system value
  20919. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20920. * @returns the current connection point
  20921. */
  20922. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20923. /**
  20924. * Gets or sets the value of that point.
  20925. * Please note that this value will be ignored if valueCallback is defined
  20926. */
  20927. get value(): any;
  20928. set value(value: any);
  20929. /**
  20930. * Gets or sets a callback used to get the value of that point.
  20931. * Please note that setting this value will force the connection point to ignore the value property
  20932. */
  20933. get valueCallback(): () => any;
  20934. set valueCallback(value: () => any);
  20935. /**
  20936. * Gets or sets the associated variable name in the shader
  20937. */
  20938. get associatedVariableName(): string;
  20939. set associatedVariableName(value: string);
  20940. /** Gets or sets the type of animation applied to the input */
  20941. get animationType(): AnimatedInputBlockTypes;
  20942. set animationType(value: AnimatedInputBlockTypes);
  20943. /**
  20944. * Gets a boolean indicating that this connection point not defined yet
  20945. */
  20946. get isUndefined(): boolean;
  20947. /**
  20948. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20949. * In this case the connection point name must be the name of the uniform to use.
  20950. * Can only be set on inputs
  20951. */
  20952. get isUniform(): boolean;
  20953. set isUniform(value: boolean);
  20954. /**
  20955. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20956. * In this case the connection point name must be the name of the attribute to use
  20957. * Can only be set on inputs
  20958. */
  20959. get isAttribute(): boolean;
  20960. set isAttribute(value: boolean);
  20961. /**
  20962. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20963. * Can only be set on exit points
  20964. */
  20965. get isVarying(): boolean;
  20966. set isVarying(value: boolean);
  20967. /**
  20968. * Gets a boolean indicating that the current connection point is a system value
  20969. */
  20970. get isSystemValue(): boolean;
  20971. /**
  20972. * Gets or sets the current well known value or null if not defined as a system value
  20973. */
  20974. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20975. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20976. /**
  20977. * Gets the current class name
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Animate the input if animationType !== None
  20983. * @param scene defines the rendering scene
  20984. */
  20985. animate(scene: Scene): void;
  20986. private _emitDefine;
  20987. initialize(state: NodeMaterialBuildState): void;
  20988. /**
  20989. * Set the input block to its default value (based on its type)
  20990. */
  20991. setDefaultValue(): void;
  20992. private _emitConstant;
  20993. /** @hidden */
  20994. get _noContextSwitch(): boolean;
  20995. private _emit;
  20996. /** @hidden */
  20997. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20998. /** @hidden */
  20999. _transmit(effect: Effect, scene: Scene): void;
  21000. protected _buildBlock(state: NodeMaterialBuildState): void;
  21001. protected _dumpPropertiesCode(): string;
  21002. dispose(): void;
  21003. serialize(): any;
  21004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21005. }
  21006. }
  21007. declare module BABYLON {
  21008. /**
  21009. * Enum used to define the compatibility state between two connection points
  21010. */
  21011. export enum NodeMaterialConnectionPointCompatibilityStates {
  21012. /** Points are compatibles */
  21013. Compatible = 0,
  21014. /** Points are incompatible because of their types */
  21015. TypeIncompatible = 1,
  21016. /** Points are incompatible because of their targets (vertex vs fragment) */
  21017. TargetIncompatible = 2
  21018. }
  21019. /**
  21020. * Defines the direction of a connection point
  21021. */
  21022. export enum NodeMaterialConnectionPointDirection {
  21023. /** Input */
  21024. Input = 0,
  21025. /** Output */
  21026. Output = 1
  21027. }
  21028. /**
  21029. * Defines a connection point for a block
  21030. */
  21031. export class NodeMaterialConnectionPoint {
  21032. /** @hidden */
  21033. _ownerBlock: NodeMaterialBlock;
  21034. /** @hidden */
  21035. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21036. private _endpoints;
  21037. private _associatedVariableName;
  21038. private _direction;
  21039. /** @hidden */
  21040. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21041. /** @hidden */
  21042. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21043. private _type;
  21044. /** @hidden */
  21045. _enforceAssociatedVariableName: boolean;
  21046. /** Gets the direction of the point */
  21047. get direction(): NodeMaterialConnectionPointDirection;
  21048. /** Indicates that this connection point needs dual validation before being connected to another point */
  21049. needDualDirectionValidation: boolean;
  21050. /**
  21051. * Gets or sets the additional types supported by this connection point
  21052. */
  21053. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21054. /**
  21055. * Gets or sets the additional types excluded by this connection point
  21056. */
  21057. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21058. /**
  21059. * Observable triggered when this point is connected
  21060. */
  21061. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21062. /**
  21063. * Gets or sets the associated variable name in the shader
  21064. */
  21065. get associatedVariableName(): string;
  21066. set associatedVariableName(value: string);
  21067. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21068. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21069. /**
  21070. * Gets or sets the connection point type (default is float)
  21071. */
  21072. get type(): NodeMaterialBlockConnectionPointTypes;
  21073. set type(value: NodeMaterialBlockConnectionPointTypes);
  21074. /**
  21075. * Gets or sets the connection point name
  21076. */
  21077. name: string;
  21078. /**
  21079. * Gets or sets the connection point name
  21080. */
  21081. displayName: string;
  21082. /**
  21083. * Gets or sets a boolean indicating that this connection point can be omitted
  21084. */
  21085. isOptional: boolean;
  21086. /**
  21087. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21088. */
  21089. isExposedOnFrame: boolean;
  21090. /**
  21091. * Gets or sets number indicating the position that the port is exposed to on a frame
  21092. */
  21093. exposedPortPosition: number;
  21094. /**
  21095. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21096. */
  21097. define: string;
  21098. /** @hidden */
  21099. _prioritizeVertex: boolean;
  21100. private _target;
  21101. /** Gets or sets the target of that connection point */
  21102. get target(): NodeMaterialBlockTargets;
  21103. set target(value: NodeMaterialBlockTargets);
  21104. /**
  21105. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21106. */
  21107. get isConnected(): boolean;
  21108. /**
  21109. * Gets a boolean indicating that the current point is connected to an input block
  21110. */
  21111. get isConnectedToInputBlock(): boolean;
  21112. /**
  21113. * Gets a the connected input block (if any)
  21114. */
  21115. get connectInputBlock(): Nullable<InputBlock>;
  21116. /** Get the other side of the connection (if any) */
  21117. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21118. /** Get the block that owns this connection point */
  21119. get ownerBlock(): NodeMaterialBlock;
  21120. /** Get the block connected on the other side of this connection (if any) */
  21121. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21122. /** Get the block connected on the endpoints of this connection (if any) */
  21123. get connectedBlocks(): Array<NodeMaterialBlock>;
  21124. /** Gets the list of connected endpoints */
  21125. get endpoints(): NodeMaterialConnectionPoint[];
  21126. /** Gets a boolean indicating if that output point is connected to at least one input */
  21127. get hasEndpoints(): boolean;
  21128. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21129. get isConnectedInVertexShader(): boolean;
  21130. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21131. get isConnectedInFragmentShader(): boolean;
  21132. /**
  21133. * Creates a block suitable to be used as an input for this input point.
  21134. * If null is returned, a block based on the point type will be created.
  21135. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21136. */
  21137. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21138. /**
  21139. * Creates a new connection point
  21140. * @param name defines the connection point name
  21141. * @param ownerBlock defines the block hosting this connection point
  21142. * @param direction defines the direction of the connection point
  21143. */
  21144. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21145. /**
  21146. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21147. * @returns the class name
  21148. */
  21149. getClassName(): string;
  21150. /**
  21151. * Gets a boolean indicating if the current point can be connected to another point
  21152. * @param connectionPoint defines the other connection point
  21153. * @returns a boolean
  21154. */
  21155. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21156. /**
  21157. * Gets a number indicating if the current point can be connected to another point
  21158. * @param connectionPoint defines the other connection point
  21159. * @returns a number defining the compatibility state
  21160. */
  21161. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21162. /**
  21163. * Connect this point to another connection point
  21164. * @param connectionPoint defines the other connection point
  21165. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21166. * @returns the current connection point
  21167. */
  21168. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21169. /**
  21170. * Disconnect this point from one of his endpoint
  21171. * @param endpoint defines the other connection point
  21172. * @returns the current connection point
  21173. */
  21174. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21175. /**
  21176. * Serializes this point in a JSON representation
  21177. * @param isInput defines if the connection point is an input (default is true)
  21178. * @returns the serialized point object
  21179. */
  21180. serialize(isInput?: boolean): any;
  21181. /**
  21182. * Release resources
  21183. */
  21184. dispose(): void;
  21185. }
  21186. }
  21187. declare module BABYLON {
  21188. /**
  21189. * Enum used to define the material modes
  21190. */
  21191. export enum NodeMaterialModes {
  21192. /** Regular material */
  21193. Material = 0,
  21194. /** For post process */
  21195. PostProcess = 1,
  21196. /** For particle system */
  21197. Particle = 2,
  21198. /** For procedural texture */
  21199. ProceduralTexture = 3
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * Block used to read a texture from a sampler
  21205. */
  21206. export class TextureBlock extends NodeMaterialBlock {
  21207. private _defineName;
  21208. private _linearDefineName;
  21209. private _gammaDefineName;
  21210. private _tempTextureRead;
  21211. private _samplerName;
  21212. private _transformedUVName;
  21213. private _textureTransformName;
  21214. private _textureInfoName;
  21215. private _mainUVName;
  21216. private _mainUVDefineName;
  21217. private _fragmentOnly;
  21218. /**
  21219. * Gets or sets the texture associated with the node
  21220. */
  21221. texture: Nullable<Texture>;
  21222. /**
  21223. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21224. */
  21225. convertToGammaSpace: boolean;
  21226. /**
  21227. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21228. */
  21229. convertToLinearSpace: boolean;
  21230. /**
  21231. * Create a new TextureBlock
  21232. * @param name defines the block name
  21233. */
  21234. constructor(name: string, fragmentOnly?: boolean);
  21235. /**
  21236. * Gets the current class name
  21237. * @returns the class name
  21238. */
  21239. getClassName(): string;
  21240. /**
  21241. * Gets the uv input component
  21242. */
  21243. get uv(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the rgba output component
  21246. */
  21247. get rgba(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the rgb output component
  21250. */
  21251. get rgb(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the r output component
  21254. */
  21255. get r(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the g output component
  21258. */
  21259. get g(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the b output component
  21262. */
  21263. get b(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Gets the a output component
  21266. */
  21267. get a(): NodeMaterialConnectionPoint;
  21268. get target(): NodeMaterialBlockTargets;
  21269. autoConfigure(material: NodeMaterial): void;
  21270. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21272. isReady(): boolean;
  21273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21274. private get _isMixed();
  21275. private _injectVertexCode;
  21276. private _writeTextureRead;
  21277. private _writeOutput;
  21278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21279. protected _dumpPropertiesCode(): string;
  21280. serialize(): any;
  21281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21282. }
  21283. }
  21284. declare module BABYLON {
  21285. /** @hidden */
  21286. export var reflectionFunction: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module BABYLON {
  21292. /**
  21293. * Base block used to read a reflection texture from a sampler
  21294. */
  21295. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21296. /** @hidden */
  21297. _define3DName: string;
  21298. /** @hidden */
  21299. _defineCubicName: string;
  21300. /** @hidden */
  21301. _defineExplicitName: string;
  21302. /** @hidden */
  21303. _defineProjectionName: string;
  21304. /** @hidden */
  21305. _defineLocalCubicName: string;
  21306. /** @hidden */
  21307. _defineSphericalName: string;
  21308. /** @hidden */
  21309. _definePlanarName: string;
  21310. /** @hidden */
  21311. _defineEquirectangularName: string;
  21312. /** @hidden */
  21313. _defineMirroredEquirectangularFixedName: string;
  21314. /** @hidden */
  21315. _defineEquirectangularFixedName: string;
  21316. /** @hidden */
  21317. _defineSkyboxName: string;
  21318. /** @hidden */
  21319. _defineOppositeZ: string;
  21320. /** @hidden */
  21321. _cubeSamplerName: string;
  21322. /** @hidden */
  21323. _2DSamplerName: string;
  21324. protected _positionUVWName: string;
  21325. protected _directionWName: string;
  21326. protected _reflectionVectorName: string;
  21327. /** @hidden */
  21328. _reflectionCoordsName: string;
  21329. /** @hidden */
  21330. _reflectionMatrixName: string;
  21331. protected _reflectionColorName: string;
  21332. /**
  21333. * Gets or sets the texture associated with the node
  21334. */
  21335. texture: Nullable<BaseTexture>;
  21336. /**
  21337. * Create a new ReflectionTextureBaseBlock
  21338. * @param name defines the block name
  21339. */
  21340. constructor(name: string);
  21341. /**
  21342. * Gets the current class name
  21343. * @returns the class name
  21344. */
  21345. getClassName(): string;
  21346. /**
  21347. * Gets the world position input component
  21348. */
  21349. abstract get position(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the world position input component
  21352. */
  21353. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the world normal input component
  21356. */
  21357. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the world input component
  21360. */
  21361. abstract get world(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Gets the camera (or eye) position component
  21364. */
  21365. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21366. /**
  21367. * Gets the view input component
  21368. */
  21369. abstract get view(): NodeMaterialConnectionPoint;
  21370. protected _getTexture(): Nullable<BaseTexture>;
  21371. autoConfigure(material: NodeMaterial): void;
  21372. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21373. isReady(): boolean;
  21374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21375. /**
  21376. * Gets the code to inject in the vertex shader
  21377. * @param state current state of the node material building
  21378. * @returns the shader code
  21379. */
  21380. handleVertexSide(state: NodeMaterialBuildState): string;
  21381. /**
  21382. * Handles the inits for the fragment code path
  21383. * @param state node material build state
  21384. */
  21385. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21386. /**
  21387. * Generates the reflection coords code for the fragment code path
  21388. * @param worldNormalVarName name of the world normal variable
  21389. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21390. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21391. * @returns the shader code
  21392. */
  21393. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21394. /**
  21395. * Generates the reflection color code for the fragment code path
  21396. * @param lodVarName name of the lod variable
  21397. * @param swizzleLookupTexture swizzle to use for the final color variable
  21398. * @returns the shader code
  21399. */
  21400. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21401. /**
  21402. * Generates the code corresponding to the connected output points
  21403. * @param state node material build state
  21404. * @param varName name of the variable to output
  21405. * @returns the shader code
  21406. */
  21407. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21408. protected _buildBlock(state: NodeMaterialBuildState): this;
  21409. protected _dumpPropertiesCode(): string;
  21410. serialize(): any;
  21411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21412. }
  21413. }
  21414. declare module BABYLON {
  21415. /**
  21416. * Defines a connection point to be used for points with a custom object type
  21417. */
  21418. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21419. private _blockType;
  21420. private _blockName;
  21421. private _nameForCheking?;
  21422. /**
  21423. * Creates a new connection point
  21424. * @param name defines the connection point name
  21425. * @param ownerBlock defines the block hosting this connection point
  21426. * @param direction defines the direction of the connection point
  21427. */
  21428. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21429. /**
  21430. * Gets a number indicating if the current point can be connected to another point
  21431. * @param connectionPoint defines the other connection point
  21432. * @returns a number defining the compatibility state
  21433. */
  21434. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21435. /**
  21436. * Creates a block suitable to be used as an input for this input point.
  21437. * If null is returned, a block based on the point type will be created.
  21438. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21439. */
  21440. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21441. }
  21442. }
  21443. declare module BABYLON {
  21444. /**
  21445. * Enum defining the type of properties that can be edited in the property pages in the NME
  21446. */
  21447. export enum PropertyTypeForEdition {
  21448. /** property is a boolean */
  21449. Boolean = 0,
  21450. /** property is a float */
  21451. Float = 1,
  21452. /** property is a Vector2 */
  21453. Vector2 = 2,
  21454. /** property is a list of values */
  21455. List = 3
  21456. }
  21457. /**
  21458. * Interface that defines an option in a variable of type list
  21459. */
  21460. export interface IEditablePropertyListOption {
  21461. /** label of the option */
  21462. "label": string;
  21463. /** value of the option */
  21464. "value": number;
  21465. }
  21466. /**
  21467. * Interface that defines the options available for an editable property
  21468. */
  21469. export interface IEditablePropertyOption {
  21470. /** min value */
  21471. "min"?: number;
  21472. /** max value */
  21473. "max"?: number;
  21474. /** notifiers: indicates which actions to take when the property is changed */
  21475. "notifiers"?: {
  21476. /** the material should be rebuilt */
  21477. "rebuild"?: boolean;
  21478. /** the preview should be updated */
  21479. "update"?: boolean;
  21480. };
  21481. /** list of the options for a variable of type list */
  21482. "options"?: IEditablePropertyListOption[];
  21483. }
  21484. /**
  21485. * Interface that describes an editable property
  21486. */
  21487. export interface IPropertyDescriptionForEdition {
  21488. /** name of the property */
  21489. "propertyName": string;
  21490. /** display name of the property */
  21491. "displayName": string;
  21492. /** type of the property */
  21493. "type": PropertyTypeForEdition;
  21494. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21495. "groupName": string;
  21496. /** options for the property */
  21497. "options": IEditablePropertyOption;
  21498. }
  21499. /**
  21500. * Decorator that flags a property in a node material block as being editable
  21501. */
  21502. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21503. }
  21504. declare module BABYLON {
  21505. /**
  21506. * Block used to implement the refraction part of the sub surface module of the PBR material
  21507. */
  21508. export class RefractionBlock extends NodeMaterialBlock {
  21509. /** @hidden */
  21510. _define3DName: string;
  21511. /** @hidden */
  21512. _refractionMatrixName: string;
  21513. /** @hidden */
  21514. _defineLODRefractionAlpha: string;
  21515. /** @hidden */
  21516. _defineLinearSpecularRefraction: string;
  21517. /** @hidden */
  21518. _defineOppositeZ: string;
  21519. /** @hidden */
  21520. _cubeSamplerName: string;
  21521. /** @hidden */
  21522. _2DSamplerName: string;
  21523. /** @hidden */
  21524. _vRefractionMicrosurfaceInfosName: string;
  21525. /** @hidden */
  21526. _vRefractionInfosName: string;
  21527. private _scene;
  21528. /**
  21529. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21530. * Materials half opaque for instance using refraction could benefit from this control.
  21531. */
  21532. linkRefractionWithTransparency: boolean;
  21533. /**
  21534. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21535. */
  21536. invertRefractionY: boolean;
  21537. /**
  21538. * Gets or sets the texture associated with the node
  21539. */
  21540. texture: Nullable<BaseTexture>;
  21541. /**
  21542. * Create a new RefractionBlock
  21543. * @param name defines the block name
  21544. */
  21545. constructor(name: string);
  21546. /**
  21547. * Gets the current class name
  21548. * @returns the class name
  21549. */
  21550. getClassName(): string;
  21551. /**
  21552. * Gets the intensity input component
  21553. */
  21554. get intensity(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the index of refraction input component
  21557. */
  21558. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Gets the tint at distance input component
  21561. */
  21562. get tintAtDistance(): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Gets the view input component
  21565. */
  21566. get view(): NodeMaterialConnectionPoint;
  21567. /**
  21568. * Gets the refraction object output component
  21569. */
  21570. get refraction(): NodeMaterialConnectionPoint;
  21571. /**
  21572. * Returns true if the block has a texture
  21573. */
  21574. get hasTexture(): boolean;
  21575. protected _getTexture(): Nullable<BaseTexture>;
  21576. autoConfigure(material: NodeMaterial): void;
  21577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21578. isReady(): boolean;
  21579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21580. /**
  21581. * Gets the main code of the block (fragment side)
  21582. * @param state current state of the node material building
  21583. * @returns the shader code
  21584. */
  21585. getCode(state: NodeMaterialBuildState): string;
  21586. protected _buildBlock(state: NodeMaterialBuildState): this;
  21587. protected _dumpPropertiesCode(): string;
  21588. serialize(): any;
  21589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21590. }
  21591. }
  21592. declare module BABYLON {
  21593. /**
  21594. * Base block used as input for post process
  21595. */
  21596. export class CurrentScreenBlock extends NodeMaterialBlock {
  21597. private _samplerName;
  21598. private _linearDefineName;
  21599. private _gammaDefineName;
  21600. private _mainUVName;
  21601. private _tempTextureRead;
  21602. /**
  21603. * Gets or sets the texture associated with the node
  21604. */
  21605. texture: Nullable<BaseTexture>;
  21606. /**
  21607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21608. */
  21609. convertToGammaSpace: boolean;
  21610. /**
  21611. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21612. */
  21613. convertToLinearSpace: boolean;
  21614. /**
  21615. * Create a new CurrentScreenBlock
  21616. * @param name defines the block name
  21617. */
  21618. constructor(name: string);
  21619. /**
  21620. * Gets the current class name
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Gets the uv input component
  21626. */
  21627. get uv(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the rgba output component
  21630. */
  21631. get rgba(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the rgb output component
  21634. */
  21635. get rgb(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the r output component
  21638. */
  21639. get r(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the g output component
  21642. */
  21643. get g(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the b output component
  21646. */
  21647. get b(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the a output component
  21650. */
  21651. get a(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Initialize the block and prepare the context for build
  21654. * @param state defines the state that will be used for the build
  21655. */
  21656. initialize(state: NodeMaterialBuildState): void;
  21657. get target(): NodeMaterialBlockTargets;
  21658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21659. isReady(): boolean;
  21660. private _injectVertexCode;
  21661. private _writeTextureRead;
  21662. private _writeOutput;
  21663. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module BABYLON {
  21669. /**
  21670. * Base block used for the particle texture
  21671. */
  21672. export class ParticleTextureBlock extends NodeMaterialBlock {
  21673. private _samplerName;
  21674. private _linearDefineName;
  21675. private _gammaDefineName;
  21676. private _tempTextureRead;
  21677. /**
  21678. * Gets or sets the texture associated with the node
  21679. */
  21680. texture: Nullable<BaseTexture>;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21683. */
  21684. convertToGammaSpace: boolean;
  21685. /**
  21686. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21687. */
  21688. convertToLinearSpace: boolean;
  21689. /**
  21690. * Create a new ParticleTextureBlock
  21691. * @param name defines the block name
  21692. */
  21693. constructor(name: string);
  21694. /**
  21695. * Gets the current class name
  21696. * @returns the class name
  21697. */
  21698. getClassName(): string;
  21699. /**
  21700. * Gets the uv input component
  21701. */
  21702. get uv(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgba output component
  21705. */
  21706. get rgba(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the rgb output component
  21709. */
  21710. get rgb(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the r output component
  21713. */
  21714. get r(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the g output component
  21717. */
  21718. get g(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the b output component
  21721. */
  21722. get b(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the a output component
  21725. */
  21726. get a(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Initialize the block and prepare the context for build
  21729. * @param state defines the state that will be used for the build
  21730. */
  21731. initialize(state: NodeMaterialBuildState): void;
  21732. autoConfigure(material: NodeMaterial): void;
  21733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21734. isReady(): boolean;
  21735. private _writeOutput;
  21736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21737. serialize(): any;
  21738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21739. }
  21740. }
  21741. declare module BABYLON {
  21742. /**
  21743. * Class used to store shared data between 2 NodeMaterialBuildState
  21744. */
  21745. export class NodeMaterialBuildStateSharedData {
  21746. /**
  21747. * Gets the list of emitted varyings
  21748. */
  21749. temps: string[];
  21750. /**
  21751. * Gets the list of emitted varyings
  21752. */
  21753. varyings: string[];
  21754. /**
  21755. * Gets the varying declaration string
  21756. */
  21757. varyingDeclaration: string;
  21758. /**
  21759. * Input blocks
  21760. */
  21761. inputBlocks: InputBlock[];
  21762. /**
  21763. * Input blocks
  21764. */
  21765. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21766. /**
  21767. * Bindable blocks (Blocks that need to set data to the effect)
  21768. */
  21769. bindableBlocks: NodeMaterialBlock[];
  21770. /**
  21771. * List of blocks that can provide a compilation fallback
  21772. */
  21773. blocksWithFallbacks: NodeMaterialBlock[];
  21774. /**
  21775. * List of blocks that can provide a define update
  21776. */
  21777. blocksWithDefines: NodeMaterialBlock[];
  21778. /**
  21779. * List of blocks that can provide a repeatable content
  21780. */
  21781. repeatableContentBlocks: NodeMaterialBlock[];
  21782. /**
  21783. * List of blocks that can provide a dynamic list of uniforms
  21784. */
  21785. dynamicUniformBlocks: NodeMaterialBlock[];
  21786. /**
  21787. * List of blocks that can block the isReady function for the material
  21788. */
  21789. blockingBlocks: NodeMaterialBlock[];
  21790. /**
  21791. * Gets the list of animated inputs
  21792. */
  21793. animatedInputs: InputBlock[];
  21794. /**
  21795. * Build Id used to avoid multiple recompilations
  21796. */
  21797. buildId: number;
  21798. /** List of emitted variables */
  21799. variableNames: {
  21800. [key: string]: number;
  21801. };
  21802. /** List of emitted defines */
  21803. defineNames: {
  21804. [key: string]: number;
  21805. };
  21806. /** Should emit comments? */
  21807. emitComments: boolean;
  21808. /** Emit build activity */
  21809. verbose: boolean;
  21810. /** Gets or sets the hosting scene */
  21811. scene: Scene;
  21812. /**
  21813. * Gets the compilation hints emitted at compilation time
  21814. */
  21815. hints: {
  21816. needWorldViewMatrix: boolean;
  21817. needWorldViewProjectionMatrix: boolean;
  21818. needAlphaBlending: boolean;
  21819. needAlphaTesting: boolean;
  21820. };
  21821. /**
  21822. * List of compilation checks
  21823. */
  21824. checks: {
  21825. emitVertex: boolean;
  21826. emitFragment: boolean;
  21827. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21828. };
  21829. /**
  21830. * Is vertex program allowed to be empty?
  21831. */
  21832. allowEmptyVertexProgram: boolean;
  21833. /** Creates a new shared data */
  21834. constructor();
  21835. /**
  21836. * Emits console errors and exceptions if there is a failing check
  21837. */
  21838. emitErrors(): void;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Class used to store node based material build state
  21844. */
  21845. export class NodeMaterialBuildState {
  21846. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21847. supportUniformBuffers: boolean;
  21848. /**
  21849. * Gets the list of emitted attributes
  21850. */
  21851. attributes: string[];
  21852. /**
  21853. * Gets the list of emitted uniforms
  21854. */
  21855. uniforms: string[];
  21856. /**
  21857. * Gets the list of emitted constants
  21858. */
  21859. constants: string[];
  21860. /**
  21861. * Gets the list of emitted samplers
  21862. */
  21863. samplers: string[];
  21864. /**
  21865. * Gets the list of emitted functions
  21866. */
  21867. functions: {
  21868. [key: string]: string;
  21869. };
  21870. /**
  21871. * Gets the list of emitted extensions
  21872. */
  21873. extensions: {
  21874. [key: string]: string;
  21875. };
  21876. /**
  21877. * Gets the target of the compilation state
  21878. */
  21879. target: NodeMaterialBlockTargets;
  21880. /**
  21881. * Gets the list of emitted counters
  21882. */
  21883. counters: {
  21884. [key: string]: number;
  21885. };
  21886. /**
  21887. * Shared data between multiple NodeMaterialBuildState instances
  21888. */
  21889. sharedData: NodeMaterialBuildStateSharedData;
  21890. /** @hidden */
  21891. _vertexState: NodeMaterialBuildState;
  21892. /** @hidden */
  21893. _attributeDeclaration: string;
  21894. /** @hidden */
  21895. _uniformDeclaration: string;
  21896. /** @hidden */
  21897. _constantDeclaration: string;
  21898. /** @hidden */
  21899. _samplerDeclaration: string;
  21900. /** @hidden */
  21901. _varyingTransfer: string;
  21902. /** @hidden */
  21903. _injectAtEnd: string;
  21904. private _repeatableContentAnchorIndex;
  21905. /** @hidden */
  21906. _builtCompilationString: string;
  21907. /**
  21908. * Gets the emitted compilation strings
  21909. */
  21910. compilationString: string;
  21911. /**
  21912. * Finalize the compilation strings
  21913. * @param state defines the current compilation state
  21914. */
  21915. finalize(state: NodeMaterialBuildState): void;
  21916. /** @hidden */
  21917. get _repeatableContentAnchor(): string;
  21918. /** @hidden */
  21919. _getFreeVariableName(prefix: string): string;
  21920. /** @hidden */
  21921. _getFreeDefineName(prefix: string): string;
  21922. /** @hidden */
  21923. _excludeVariableName(name: string): void;
  21924. /** @hidden */
  21925. _emit2DSampler(name: string): void;
  21926. /** @hidden */
  21927. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21928. /** @hidden */
  21929. _emitExtension(name: string, extension: string, define?: string): void;
  21930. /** @hidden */
  21931. _emitFunction(name: string, code: string, comments: string): void;
  21932. /** @hidden */
  21933. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21934. replaceStrings?: {
  21935. search: RegExp;
  21936. replace: string;
  21937. }[];
  21938. repeatKey?: string;
  21939. }): string;
  21940. /** @hidden */
  21941. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21942. repeatKey?: string;
  21943. removeAttributes?: boolean;
  21944. removeUniforms?: boolean;
  21945. removeVaryings?: boolean;
  21946. removeIfDef?: boolean;
  21947. replaceStrings?: {
  21948. search: RegExp;
  21949. replace: string;
  21950. }[];
  21951. }, storeKey?: string): void;
  21952. /** @hidden */
  21953. _registerTempVariable(name: string): boolean;
  21954. /** @hidden */
  21955. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21956. /** @hidden */
  21957. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21958. /** @hidden */
  21959. _emitFloat(value: number): string;
  21960. }
  21961. }
  21962. declare module BABYLON {
  21963. /**
  21964. * Helper class used to generate session unique ID
  21965. */
  21966. export class UniqueIdGenerator {
  21967. private static _UniqueIdCounter;
  21968. /**
  21969. * Gets an unique (relatively to the current scene) Id
  21970. */
  21971. static get UniqueId(): number;
  21972. }
  21973. }
  21974. declare module BABYLON {
  21975. /**
  21976. * Defines a block that can be used inside a node based material
  21977. */
  21978. export class NodeMaterialBlock {
  21979. private _buildId;
  21980. private _buildTarget;
  21981. private _target;
  21982. private _isFinalMerger;
  21983. private _isInput;
  21984. private _name;
  21985. protected _isUnique: boolean;
  21986. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21987. inputsAreExclusive: boolean;
  21988. /** @hidden */
  21989. _codeVariableName: string;
  21990. /** @hidden */
  21991. _inputs: NodeMaterialConnectionPoint[];
  21992. /** @hidden */
  21993. _outputs: NodeMaterialConnectionPoint[];
  21994. /** @hidden */
  21995. _preparationId: number;
  21996. /**
  21997. * Gets the name of the block
  21998. */
  21999. get name(): string;
  22000. /**
  22001. * Sets the name of the block. Will check if the name is valid.
  22002. */
  22003. set name(newName: string);
  22004. /**
  22005. * Gets or sets the unique id of the node
  22006. */
  22007. uniqueId: number;
  22008. /**
  22009. * Gets or sets the comments associated with this block
  22010. */
  22011. comments: string;
  22012. /**
  22013. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22014. */
  22015. get isUnique(): boolean;
  22016. /**
  22017. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22018. */
  22019. get isFinalMerger(): boolean;
  22020. /**
  22021. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22022. */
  22023. get isInput(): boolean;
  22024. /**
  22025. * Gets or sets the build Id
  22026. */
  22027. get buildId(): number;
  22028. set buildId(value: number);
  22029. /**
  22030. * Gets or sets the target of the block
  22031. */
  22032. get target(): NodeMaterialBlockTargets;
  22033. set target(value: NodeMaterialBlockTargets);
  22034. /**
  22035. * Gets the list of input points
  22036. */
  22037. get inputs(): NodeMaterialConnectionPoint[];
  22038. /** Gets the list of output points */
  22039. get outputs(): NodeMaterialConnectionPoint[];
  22040. /**
  22041. * Find an input by its name
  22042. * @param name defines the name of the input to look for
  22043. * @returns the input or null if not found
  22044. */
  22045. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22046. /**
  22047. * Find an output by its name
  22048. * @param name defines the name of the outputto look for
  22049. * @returns the output or null if not found
  22050. */
  22051. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22052. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22053. visibleInInspector: boolean;
  22054. /**
  22055. * Creates a new NodeMaterialBlock
  22056. * @param name defines the block name
  22057. * @param target defines the target of that block (Vertex by default)
  22058. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22059. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22060. */
  22061. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22062. /**
  22063. * Initialize the block and prepare the context for build
  22064. * @param state defines the state that will be used for the build
  22065. */
  22066. initialize(state: NodeMaterialBuildState): void;
  22067. /**
  22068. * Bind data to effect. Will only be called for blocks with isBindable === true
  22069. * @param effect defines the effect to bind data to
  22070. * @param nodeMaterial defines the hosting NodeMaterial
  22071. * @param mesh defines the mesh that will be rendered
  22072. * @param subMesh defines the submesh that will be rendered
  22073. */
  22074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22075. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22076. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22077. protected _writeFloat(value: number): string;
  22078. /**
  22079. * Gets the current class name e.g. "NodeMaterialBlock"
  22080. * @returns the class name
  22081. */
  22082. getClassName(): string;
  22083. /**
  22084. * Register a new input. Must be called inside a block constructor
  22085. * @param name defines the connection point name
  22086. * @param type defines the connection point type
  22087. * @param isOptional defines a boolean indicating that this input can be omitted
  22088. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22089. * @param point an already created connection point. If not provided, create a new one
  22090. * @returns the current block
  22091. */
  22092. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22093. /**
  22094. * Register a new output. Must be called inside a block constructor
  22095. * @param name defines the connection point name
  22096. * @param type defines the connection point type
  22097. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22098. * @param point an already created connection point. If not provided, create a new one
  22099. * @returns the current block
  22100. */
  22101. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22102. /**
  22103. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22104. * @param forOutput defines an optional connection point to check compatibility with
  22105. * @returns the first available input or null
  22106. */
  22107. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22108. /**
  22109. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22110. * @param forBlock defines an optional block to check compatibility with
  22111. * @returns the first available input or null
  22112. */
  22113. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22114. /**
  22115. * Gets the sibling of the given output
  22116. * @param current defines the current output
  22117. * @returns the next output in the list or null
  22118. */
  22119. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22120. /**
  22121. * Connect current block with another block
  22122. * @param other defines the block to connect with
  22123. * @param options define the various options to help pick the right connections
  22124. * @returns the current block
  22125. */
  22126. connectTo(other: NodeMaterialBlock, options?: {
  22127. input?: string;
  22128. output?: string;
  22129. outputSwizzle?: string;
  22130. }): this | undefined;
  22131. protected _buildBlock(state: NodeMaterialBuildState): void;
  22132. /**
  22133. * Add uniforms, samplers and uniform buffers at compilation time
  22134. * @param state defines the state to update
  22135. * @param nodeMaterial defines the node material requesting the update
  22136. * @param defines defines the material defines to update
  22137. * @param uniformBuffers defines the list of uniform buffer names
  22138. */
  22139. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22140. /**
  22141. * Add potential fallbacks if shader compilation fails
  22142. * @param mesh defines the mesh to be rendered
  22143. * @param fallbacks defines the current prioritized list of fallbacks
  22144. */
  22145. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22146. /**
  22147. * Initialize defines for shader compilation
  22148. * @param mesh defines the mesh to be rendered
  22149. * @param nodeMaterial defines the node material requesting the update
  22150. * @param defines defines the material defines to update
  22151. * @param useInstances specifies that instances should be used
  22152. */
  22153. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22154. /**
  22155. * Update defines for shader compilation
  22156. * @param mesh defines the mesh to be rendered
  22157. * @param nodeMaterial defines the node material requesting the update
  22158. * @param defines defines the material defines to update
  22159. * @param useInstances specifies that instances should be used
  22160. * @param subMesh defines which submesh to render
  22161. */
  22162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22163. /**
  22164. * Lets the block try to connect some inputs automatically
  22165. * @param material defines the hosting NodeMaterial
  22166. */
  22167. autoConfigure(material: NodeMaterial): void;
  22168. /**
  22169. * Function called when a block is declared as repeatable content generator
  22170. * @param vertexShaderState defines the current compilation state for the vertex shader
  22171. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22172. * @param mesh defines the mesh to be rendered
  22173. * @param defines defines the material defines to update
  22174. */
  22175. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22176. /**
  22177. * Checks if the block is ready
  22178. * @param mesh defines the mesh to be rendered
  22179. * @param nodeMaterial defines the node material requesting the update
  22180. * @param defines defines the material defines to update
  22181. * @param useInstances specifies that instances should be used
  22182. * @returns true if the block is ready
  22183. */
  22184. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22185. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22186. private _processBuild;
  22187. /**
  22188. * Validates the new name for the block node.
  22189. * @param newName the new name to be given to the node.
  22190. * @returns false if the name is a reserve word, else true.
  22191. */
  22192. validateBlockName(newName: string): boolean;
  22193. /**
  22194. * Compile the current node and generate the shader code
  22195. * @param state defines the current compilation state (uniforms, samplers, current string)
  22196. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22197. * @returns true if already built
  22198. */
  22199. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22200. protected _inputRename(name: string): string;
  22201. protected _outputRename(name: string): string;
  22202. protected _dumpPropertiesCode(): string;
  22203. /** @hidden */
  22204. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22205. /** @hidden */
  22206. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22207. /**
  22208. * Clone the current block to a new identical block
  22209. * @param scene defines the hosting scene
  22210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22211. * @returns a copy of the current block
  22212. */
  22213. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22214. /**
  22215. * Serializes this block in a JSON representation
  22216. * @returns the serialized block object
  22217. */
  22218. serialize(): any;
  22219. /** @hidden */
  22220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22221. private _deserializePortDisplayNamesAndExposedOnFrame;
  22222. /**
  22223. * Release resources
  22224. */
  22225. dispose(): void;
  22226. }
  22227. }
  22228. declare module BABYLON {
  22229. /**
  22230. * Base class of materials working in push mode in babylon JS
  22231. * @hidden
  22232. */
  22233. export class PushMaterial extends Material {
  22234. protected _activeEffect: Effect;
  22235. protected _normalMatrix: Matrix;
  22236. constructor(name: string, scene: Scene);
  22237. getEffect(): Effect;
  22238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22239. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22240. /**
  22241. * Binds the given world matrix to the active effect
  22242. *
  22243. * @param world the matrix to bind
  22244. */
  22245. bindOnlyWorldMatrix(world: Matrix): void;
  22246. /**
  22247. * Binds the given normal matrix to the active effect
  22248. *
  22249. * @param normalMatrix the matrix to bind
  22250. */
  22251. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22252. bind(world: Matrix, mesh?: Mesh): void;
  22253. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22254. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22255. }
  22256. }
  22257. declare module BABYLON {
  22258. /**
  22259. * Root class for all node material optimizers
  22260. */
  22261. export class NodeMaterialOptimizer {
  22262. /**
  22263. * Function used to optimize a NodeMaterial graph
  22264. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22265. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22266. */
  22267. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22268. }
  22269. }
  22270. declare module BABYLON {
  22271. /**
  22272. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22273. */
  22274. export class TransformBlock extends NodeMaterialBlock {
  22275. /**
  22276. * Defines the value to use to complement W value to transform it to a Vector4
  22277. */
  22278. complementW: number;
  22279. /**
  22280. * Defines the value to use to complement z value to transform it to a Vector4
  22281. */
  22282. complementZ: number;
  22283. /**
  22284. * Creates a new TransformBlock
  22285. * @param name defines the block name
  22286. */
  22287. constructor(name: string);
  22288. /**
  22289. * Gets the current class name
  22290. * @returns the class name
  22291. */
  22292. getClassName(): string;
  22293. /**
  22294. * Gets the vector input
  22295. */
  22296. get vector(): NodeMaterialConnectionPoint;
  22297. /**
  22298. * Gets the output component
  22299. */
  22300. get output(): NodeMaterialConnectionPoint;
  22301. /**
  22302. * Gets the xyz output component
  22303. */
  22304. get xyz(): NodeMaterialConnectionPoint;
  22305. /**
  22306. * Gets the matrix transform input
  22307. */
  22308. get transform(): NodeMaterialConnectionPoint;
  22309. protected _buildBlock(state: NodeMaterialBuildState): this;
  22310. /**
  22311. * Update defines for shader compilation
  22312. * @param mesh defines the mesh to be rendered
  22313. * @param nodeMaterial defines the node material requesting the update
  22314. * @param defines defines the material defines to update
  22315. * @param useInstances specifies that instances should be used
  22316. * @param subMesh defines which submesh to render
  22317. */
  22318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22319. serialize(): any;
  22320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22321. protected _dumpPropertiesCode(): string;
  22322. }
  22323. }
  22324. declare module BABYLON {
  22325. /**
  22326. * Block used to output the vertex position
  22327. */
  22328. export class VertexOutputBlock extends NodeMaterialBlock {
  22329. /**
  22330. * Creates a new VertexOutputBlock
  22331. * @param name defines the block name
  22332. */
  22333. constructor(name: string);
  22334. /**
  22335. * Gets the current class name
  22336. * @returns the class name
  22337. */
  22338. getClassName(): string;
  22339. /**
  22340. * Gets the vector input component
  22341. */
  22342. get vector(): NodeMaterialConnectionPoint;
  22343. protected _buildBlock(state: NodeMaterialBuildState): this;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Block used to output the final color
  22349. */
  22350. export class FragmentOutputBlock extends NodeMaterialBlock {
  22351. /**
  22352. * Create a new FragmentOutputBlock
  22353. * @param name defines the block name
  22354. */
  22355. constructor(name: string);
  22356. /**
  22357. * Gets the current class name
  22358. * @returns the class name
  22359. */
  22360. getClassName(): string;
  22361. /**
  22362. * Gets the rgba input component
  22363. */
  22364. get rgba(): NodeMaterialConnectionPoint;
  22365. /**
  22366. * Gets the rgb input component
  22367. */
  22368. get rgb(): NodeMaterialConnectionPoint;
  22369. /**
  22370. * Gets the a input component
  22371. */
  22372. get a(): NodeMaterialConnectionPoint;
  22373. protected _buildBlock(state: NodeMaterialBuildState): this;
  22374. }
  22375. }
  22376. declare module BABYLON {
  22377. /**
  22378. * Block used for the particle ramp gradient section
  22379. */
  22380. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22381. /**
  22382. * Create a new ParticleRampGradientBlock
  22383. * @param name defines the block name
  22384. */
  22385. constructor(name: string);
  22386. /**
  22387. * Gets the current class name
  22388. * @returns the class name
  22389. */
  22390. getClassName(): string;
  22391. /**
  22392. * Gets the color input component
  22393. */
  22394. get color(): NodeMaterialConnectionPoint;
  22395. /**
  22396. * Gets the rampColor output component
  22397. */
  22398. get rampColor(): NodeMaterialConnectionPoint;
  22399. /**
  22400. * Initialize the block and prepare the context for build
  22401. * @param state defines the state that will be used for the build
  22402. */
  22403. initialize(state: NodeMaterialBuildState): void;
  22404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22405. }
  22406. }
  22407. declare module BABYLON {
  22408. /**
  22409. * Block used for the particle blend multiply section
  22410. */
  22411. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22412. /**
  22413. * Create a new ParticleBlendMultiplyBlock
  22414. * @param name defines the block name
  22415. */
  22416. constructor(name: string);
  22417. /**
  22418. * Gets the current class name
  22419. * @returns the class name
  22420. */
  22421. getClassName(): string;
  22422. /**
  22423. * Gets the color input component
  22424. */
  22425. get color(): NodeMaterialConnectionPoint;
  22426. /**
  22427. * Gets the alphaTexture input component
  22428. */
  22429. get alphaTexture(): NodeMaterialConnectionPoint;
  22430. /**
  22431. * Gets the alphaColor input component
  22432. */
  22433. get alphaColor(): NodeMaterialConnectionPoint;
  22434. /**
  22435. * Gets the blendColor output component
  22436. */
  22437. get blendColor(): NodeMaterialConnectionPoint;
  22438. /**
  22439. * Initialize the block and prepare the context for build
  22440. * @param state defines the state that will be used for the build
  22441. */
  22442. initialize(state: NodeMaterialBuildState): void;
  22443. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22444. }
  22445. }
  22446. declare module BABYLON {
  22447. /**
  22448. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22449. */
  22450. export class VectorMergerBlock extends NodeMaterialBlock {
  22451. /**
  22452. * Create a new VectorMergerBlock
  22453. * @param name defines the block name
  22454. */
  22455. constructor(name: string);
  22456. /**
  22457. * Gets the current class name
  22458. * @returns the class name
  22459. */
  22460. getClassName(): string;
  22461. /**
  22462. * Gets the xyz component (input)
  22463. */
  22464. get xyzIn(): NodeMaterialConnectionPoint;
  22465. /**
  22466. * Gets the xy component (input)
  22467. */
  22468. get xyIn(): NodeMaterialConnectionPoint;
  22469. /**
  22470. * Gets the x component (input)
  22471. */
  22472. get x(): NodeMaterialConnectionPoint;
  22473. /**
  22474. * Gets the y component (input)
  22475. */
  22476. get y(): NodeMaterialConnectionPoint;
  22477. /**
  22478. * Gets the z component (input)
  22479. */
  22480. get z(): NodeMaterialConnectionPoint;
  22481. /**
  22482. * Gets the w component (input)
  22483. */
  22484. get w(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xyzw component (output)
  22487. */
  22488. get xyzw(): NodeMaterialConnectionPoint;
  22489. /**
  22490. * Gets the xyz component (output)
  22491. */
  22492. get xyzOut(): NodeMaterialConnectionPoint;
  22493. /**
  22494. * Gets the xy component (output)
  22495. */
  22496. get xyOut(): NodeMaterialConnectionPoint;
  22497. /**
  22498. * Gets the xy component (output)
  22499. * @deprecated Please use xyOut instead.
  22500. */
  22501. get xy(): NodeMaterialConnectionPoint;
  22502. /**
  22503. * Gets the xyz component (output)
  22504. * @deprecated Please use xyzOut instead.
  22505. */
  22506. get xyz(): NodeMaterialConnectionPoint;
  22507. protected _buildBlock(state: NodeMaterialBuildState): this;
  22508. }
  22509. }
  22510. declare module BABYLON {
  22511. /**
  22512. * Block used to remap a float from a range to a new one
  22513. */
  22514. export class RemapBlock extends NodeMaterialBlock {
  22515. /**
  22516. * Gets or sets the source range
  22517. */
  22518. sourceRange: Vector2;
  22519. /**
  22520. * Gets or sets the target range
  22521. */
  22522. targetRange: Vector2;
  22523. /**
  22524. * Creates a new RemapBlock
  22525. * @param name defines the block name
  22526. */
  22527. constructor(name: string);
  22528. /**
  22529. * Gets the current class name
  22530. * @returns the class name
  22531. */
  22532. getClassName(): string;
  22533. /**
  22534. * Gets the input component
  22535. */
  22536. get input(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the source min input component
  22539. */
  22540. get sourceMin(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the source max input component
  22543. */
  22544. get sourceMax(): NodeMaterialConnectionPoint;
  22545. /**
  22546. * Gets the target min input component
  22547. */
  22548. get targetMin(): NodeMaterialConnectionPoint;
  22549. /**
  22550. * Gets the target max input component
  22551. */
  22552. get targetMax(): NodeMaterialConnectionPoint;
  22553. /**
  22554. * Gets the output component
  22555. */
  22556. get output(): NodeMaterialConnectionPoint;
  22557. protected _buildBlock(state: NodeMaterialBuildState): this;
  22558. protected _dumpPropertiesCode(): string;
  22559. serialize(): any;
  22560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22561. }
  22562. }
  22563. declare module BABYLON {
  22564. /**
  22565. * Block used to multiply 2 values
  22566. */
  22567. export class MultiplyBlock extends NodeMaterialBlock {
  22568. /**
  22569. * Creates a new MultiplyBlock
  22570. * @param name defines the block name
  22571. */
  22572. constructor(name: string);
  22573. /**
  22574. * Gets the current class name
  22575. * @returns the class name
  22576. */
  22577. getClassName(): string;
  22578. /**
  22579. * Gets the left operand input component
  22580. */
  22581. get left(): NodeMaterialConnectionPoint;
  22582. /**
  22583. * Gets the right operand input component
  22584. */
  22585. get right(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the output component
  22588. */
  22589. get output(): NodeMaterialConnectionPoint;
  22590. protected _buildBlock(state: NodeMaterialBuildState): this;
  22591. }
  22592. }
  22593. declare module BABYLON {
  22594. /**
  22595. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22596. */
  22597. export class ColorSplitterBlock extends NodeMaterialBlock {
  22598. /**
  22599. * Create a new ColorSplitterBlock
  22600. * @param name defines the block name
  22601. */
  22602. constructor(name: string);
  22603. /**
  22604. * Gets the current class name
  22605. * @returns the class name
  22606. */
  22607. getClassName(): string;
  22608. /**
  22609. * Gets the rgba component (input)
  22610. */
  22611. get rgba(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the rgb component (input)
  22614. */
  22615. get rgbIn(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the rgb component (output)
  22618. */
  22619. get rgbOut(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the r component (output)
  22622. */
  22623. get r(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the g component (output)
  22626. */
  22627. get g(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the b component (output)
  22630. */
  22631. get b(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the a component (output)
  22634. */
  22635. get a(): NodeMaterialConnectionPoint;
  22636. protected _inputRename(name: string): string;
  22637. protected _outputRename(name: string): string;
  22638. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22639. }
  22640. }
  22641. declare module BABYLON {
  22642. /**
  22643. * Operations supported by the Trigonometry block
  22644. */
  22645. export enum TrigonometryBlockOperations {
  22646. /** Cos */
  22647. Cos = 0,
  22648. /** Sin */
  22649. Sin = 1,
  22650. /** Abs */
  22651. Abs = 2,
  22652. /** Exp */
  22653. Exp = 3,
  22654. /** Exp2 */
  22655. Exp2 = 4,
  22656. /** Round */
  22657. Round = 5,
  22658. /** Floor */
  22659. Floor = 6,
  22660. /** Ceiling */
  22661. Ceiling = 7,
  22662. /** Square root */
  22663. Sqrt = 8,
  22664. /** Log */
  22665. Log = 9,
  22666. /** Tangent */
  22667. Tan = 10,
  22668. /** Arc tangent */
  22669. ArcTan = 11,
  22670. /** Arc cosinus */
  22671. ArcCos = 12,
  22672. /** Arc sinus */
  22673. ArcSin = 13,
  22674. /** Fraction */
  22675. Fract = 14,
  22676. /** Sign */
  22677. Sign = 15,
  22678. /** To radians (from degrees) */
  22679. Radians = 16,
  22680. /** To degrees (from radians) */
  22681. Degrees = 17
  22682. }
  22683. /**
  22684. * Block used to apply trigonometry operation to floats
  22685. */
  22686. export class TrigonometryBlock extends NodeMaterialBlock {
  22687. /**
  22688. * Gets or sets the operation applied by the block
  22689. */
  22690. operation: TrigonometryBlockOperations;
  22691. /**
  22692. * Creates a new TrigonometryBlock
  22693. * @param name defines the block name
  22694. */
  22695. constructor(name: string);
  22696. /**
  22697. * Gets the current class name
  22698. * @returns the class name
  22699. */
  22700. getClassName(): string;
  22701. /**
  22702. * Gets the input component
  22703. */
  22704. get input(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Gets the output component
  22707. */
  22708. get output(): NodeMaterialConnectionPoint;
  22709. protected _buildBlock(state: NodeMaterialBuildState): this;
  22710. serialize(): any;
  22711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22712. protected _dumpPropertiesCode(): string;
  22713. }
  22714. }
  22715. declare module BABYLON {
  22716. /**
  22717. * Interface used to configure the node material editor
  22718. */
  22719. export interface INodeMaterialEditorOptions {
  22720. /** Define the URl to load node editor script */
  22721. editorURL?: string;
  22722. }
  22723. /** @hidden */
  22724. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22725. NORMAL: boolean;
  22726. TANGENT: boolean;
  22727. UV1: boolean;
  22728. /** BONES */
  22729. NUM_BONE_INFLUENCERS: number;
  22730. BonesPerMesh: number;
  22731. BONETEXTURE: boolean;
  22732. /** MORPH TARGETS */
  22733. MORPHTARGETS: boolean;
  22734. MORPHTARGETS_NORMAL: boolean;
  22735. MORPHTARGETS_TANGENT: boolean;
  22736. MORPHTARGETS_UV: boolean;
  22737. NUM_MORPH_INFLUENCERS: number;
  22738. /** IMAGE PROCESSING */
  22739. IMAGEPROCESSING: boolean;
  22740. VIGNETTE: boolean;
  22741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22742. VIGNETTEBLENDMODEOPAQUE: boolean;
  22743. TONEMAPPING: boolean;
  22744. TONEMAPPING_ACES: boolean;
  22745. CONTRAST: boolean;
  22746. EXPOSURE: boolean;
  22747. COLORCURVES: boolean;
  22748. COLORGRADING: boolean;
  22749. COLORGRADING3D: boolean;
  22750. SAMPLER3DGREENDEPTH: boolean;
  22751. SAMPLER3DBGRMAP: boolean;
  22752. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22753. /** MISC. */
  22754. BUMPDIRECTUV: number;
  22755. constructor();
  22756. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22757. }
  22758. /**
  22759. * Class used to configure NodeMaterial
  22760. */
  22761. export interface INodeMaterialOptions {
  22762. /**
  22763. * Defines if blocks should emit comments
  22764. */
  22765. emitComments: boolean;
  22766. }
  22767. /**
  22768. * Class used to create a node based material built by assembling shader blocks
  22769. */
  22770. export class NodeMaterial extends PushMaterial {
  22771. private static _BuildIdGenerator;
  22772. private _options;
  22773. private _vertexCompilationState;
  22774. private _fragmentCompilationState;
  22775. private _sharedData;
  22776. private _buildId;
  22777. private _buildWasSuccessful;
  22778. private _cachedWorldViewMatrix;
  22779. private _cachedWorldViewProjectionMatrix;
  22780. private _optimizers;
  22781. private _animationFrame;
  22782. /** Define the Url to load node editor script */
  22783. static EditorURL: string;
  22784. /** Define the Url to load snippets */
  22785. static SnippetUrl: string;
  22786. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22787. static IgnoreTexturesAtLoadTime: boolean;
  22788. private BJSNODEMATERIALEDITOR;
  22789. /** Get the inspector from bundle or global */
  22790. private _getGlobalNodeMaterialEditor;
  22791. /**
  22792. * Snippet ID if the material was created from the snippet server
  22793. */
  22794. snippetId: string;
  22795. /**
  22796. * Gets or sets data used by visual editor
  22797. * @see https://nme.babylonjs.com
  22798. */
  22799. editorData: any;
  22800. /**
  22801. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  22802. */
  22803. ignoreAlpha: boolean;
  22804. /**
  22805. * Defines the maximum number of lights that can be used in the material
  22806. */
  22807. maxSimultaneousLights: number;
  22808. /**
  22809. * Observable raised when the material is built
  22810. */
  22811. onBuildObservable: Observable<NodeMaterial>;
  22812. /**
  22813. * Gets or sets the root nodes of the material vertex shader
  22814. */
  22815. _vertexOutputNodes: NodeMaterialBlock[];
  22816. /**
  22817. * Gets or sets the root nodes of the material fragment (pixel) shader
  22818. */
  22819. _fragmentOutputNodes: NodeMaterialBlock[];
  22820. /** Gets or sets options to control the node material overall behavior */
  22821. get options(): INodeMaterialOptions;
  22822. set options(options: INodeMaterialOptions);
  22823. /**
  22824. * Default configuration related to image processing available in the standard Material.
  22825. */
  22826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22827. /**
  22828. * Gets the image processing configuration used either in this material.
  22829. */
  22830. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22831. /**
  22832. * Sets the Default image processing configuration used either in the this material.
  22833. *
  22834. * If sets to null, the scene one is in use.
  22835. */
  22836. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22837. /**
  22838. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22839. */
  22840. attachedBlocks: NodeMaterialBlock[];
  22841. /**
  22842. * Specifies the mode of the node material
  22843. * @hidden
  22844. */
  22845. _mode: NodeMaterialModes;
  22846. /**
  22847. * Gets the mode property
  22848. */
  22849. get mode(): NodeMaterialModes;
  22850. /**
  22851. * A free comment about the material
  22852. */
  22853. comment: string;
  22854. /**
  22855. * Create a new node based material
  22856. * @param name defines the material name
  22857. * @param scene defines the hosting scene
  22858. * @param options defines creation option
  22859. */
  22860. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22861. /**
  22862. * Gets the current class name of the material e.g. "NodeMaterial"
  22863. * @returns the class name
  22864. */
  22865. getClassName(): string;
  22866. /**
  22867. * Keep track of the image processing observer to allow dispose and replace.
  22868. */
  22869. private _imageProcessingObserver;
  22870. /**
  22871. * Attaches a new image processing configuration to the Standard Material.
  22872. * @param configuration
  22873. */
  22874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22875. /**
  22876. * Get a block by its name
  22877. * @param name defines the name of the block to retrieve
  22878. * @returns the required block or null if not found
  22879. */
  22880. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22881. /**
  22882. * Get a block by its name
  22883. * @param predicate defines the predicate used to find the good candidate
  22884. * @returns the required block or null if not found
  22885. */
  22886. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22887. /**
  22888. * Get an input block by its name
  22889. * @param predicate defines the predicate used to find the good candidate
  22890. * @returns the required input block or null if not found
  22891. */
  22892. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22893. /**
  22894. * Gets the list of input blocks attached to this material
  22895. * @returns an array of InputBlocks
  22896. */
  22897. getInputBlocks(): InputBlock[];
  22898. /**
  22899. * Adds a new optimizer to the list of optimizers
  22900. * @param optimizer defines the optimizers to add
  22901. * @returns the current material
  22902. */
  22903. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22904. /**
  22905. * Remove an optimizer from the list of optimizers
  22906. * @param optimizer defines the optimizers to remove
  22907. * @returns the current material
  22908. */
  22909. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22910. /**
  22911. * Add a new block to the list of output nodes
  22912. * @param node defines the node to add
  22913. * @returns the current material
  22914. */
  22915. addOutputNode(node: NodeMaterialBlock): this;
  22916. /**
  22917. * Remove a block from the list of root nodes
  22918. * @param node defines the node to remove
  22919. * @returns the current material
  22920. */
  22921. removeOutputNode(node: NodeMaterialBlock): this;
  22922. private _addVertexOutputNode;
  22923. private _removeVertexOutputNode;
  22924. private _addFragmentOutputNode;
  22925. private _removeFragmentOutputNode;
  22926. /**
  22927. * Specifies if the material will require alpha blending
  22928. * @returns a boolean specifying if alpha blending is needed
  22929. */
  22930. needAlphaBlending(): boolean;
  22931. /**
  22932. * Specifies if this material should be rendered in alpha test mode
  22933. * @returns a boolean specifying if an alpha test is needed.
  22934. */
  22935. needAlphaTesting(): boolean;
  22936. private _initializeBlock;
  22937. private _resetDualBlocks;
  22938. /**
  22939. * Remove a block from the current node material
  22940. * @param block defines the block to remove
  22941. */
  22942. removeBlock(block: NodeMaterialBlock): void;
  22943. /**
  22944. * Build the material and generates the inner effect
  22945. * @param verbose defines if the build should log activity
  22946. */
  22947. build(verbose?: boolean): void;
  22948. /**
  22949. * Runs an otpimization phase to try to improve the shader code
  22950. */
  22951. optimize(): void;
  22952. private _prepareDefinesForAttributes;
  22953. /**
  22954. * Create a post process from the material
  22955. * @param camera The camera to apply the render pass to.
  22956. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22958. * @param engine The engine which the post process will be applied. (default: current engine)
  22959. * @param reusable If the post process can be reused on the same frame. (default: false)
  22960. * @param textureType Type of textures used when performing the post process. (default: 0)
  22961. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22962. * @returns the post process created
  22963. */
  22964. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22965. /**
  22966. * Create the post process effect from the material
  22967. * @param postProcess The post process to create the effect for
  22968. */
  22969. createEffectForPostProcess(postProcess: PostProcess): void;
  22970. private _createEffectForPostProcess;
  22971. /**
  22972. * Create a new procedural texture based on this node material
  22973. * @param size defines the size of the texture
  22974. * @param scene defines the hosting scene
  22975. * @returns the new procedural texture attached to this node material
  22976. */
  22977. createProceduralTexture(size: number | {
  22978. width: number;
  22979. height: number;
  22980. layers?: number;
  22981. }, scene: Scene): Nullable<ProceduralTexture>;
  22982. private _createEffectForParticles;
  22983. private _checkInternals;
  22984. /**
  22985. * Create the effect to be used as the custom effect for a particle system
  22986. * @param particleSystem Particle system to create the effect for
  22987. * @param onCompiled defines a function to call when the effect creation is successful
  22988. * @param onError defines a function to call when the effect creation has failed
  22989. */
  22990. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22991. private _processDefines;
  22992. /**
  22993. * Get if the submesh is ready to be used and all its information available.
  22994. * Child classes can use it to update shaders
  22995. * @param mesh defines the mesh to check
  22996. * @param subMesh defines which submesh to check
  22997. * @param useInstances specifies that instances should be used
  22998. * @returns a boolean indicating that the submesh is ready or not
  22999. */
  23000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23001. /**
  23002. * Get a string representing the shaders built by the current node graph
  23003. */
  23004. get compiledShaders(): string;
  23005. /**
  23006. * Binds the world matrix to the material
  23007. * @param world defines the world transformation matrix
  23008. */
  23009. bindOnlyWorldMatrix(world: Matrix): void;
  23010. /**
  23011. * Binds the submesh to this material by preparing the effect and shader to draw
  23012. * @param world defines the world transformation matrix
  23013. * @param mesh defines the mesh containing the submesh
  23014. * @param subMesh defines the submesh to bind the material to
  23015. */
  23016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23017. /**
  23018. * Gets the active textures from the material
  23019. * @returns an array of textures
  23020. */
  23021. getActiveTextures(): BaseTexture[];
  23022. /**
  23023. * Gets the list of texture blocks
  23024. * @returns an array of texture blocks
  23025. */
  23026. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23027. /**
  23028. * Specifies if the material uses a texture
  23029. * @param texture defines the texture to check against the material
  23030. * @returns a boolean specifying if the material uses the texture
  23031. */
  23032. hasTexture(texture: BaseTexture): boolean;
  23033. /**
  23034. * Disposes the material
  23035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23037. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23038. */
  23039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23040. /** Creates the node editor window. */
  23041. private _createNodeEditor;
  23042. /**
  23043. * Launch the node material editor
  23044. * @param config Define the configuration of the editor
  23045. * @return a promise fulfilled when the node editor is visible
  23046. */
  23047. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23048. /**
  23049. * Clear the current material
  23050. */
  23051. clear(): void;
  23052. /**
  23053. * Clear the current material and set it to a default state
  23054. */
  23055. setToDefault(): void;
  23056. /**
  23057. * Clear the current material and set it to a default state for post process
  23058. */
  23059. setToDefaultPostProcess(): void;
  23060. /**
  23061. * Clear the current material and set it to a default state for procedural texture
  23062. */
  23063. setToDefaultProceduralTexture(): void;
  23064. /**
  23065. * Clear the current material and set it to a default state for particle
  23066. */
  23067. setToDefaultParticle(): void;
  23068. /**
  23069. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23070. * @param url defines the url to load from
  23071. * @returns a promise that will fullfil when the material is fully loaded
  23072. */
  23073. loadAsync(url: string): Promise<void>;
  23074. private _gatherBlocks;
  23075. /**
  23076. * Generate a string containing the code declaration required to create an equivalent of this material
  23077. * @returns a string
  23078. */
  23079. generateCode(): string;
  23080. /**
  23081. * Serializes this material in a JSON representation
  23082. * @returns the serialized material object
  23083. */
  23084. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23085. private _restoreConnections;
  23086. /**
  23087. * Clear the current graph and load a new one from a serialization object
  23088. * @param source defines the JSON representation of the material
  23089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23090. * @param merge defines whether or not the source must be merged or replace the current content
  23091. */
  23092. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23093. /**
  23094. * Makes a duplicate of the current material.
  23095. * @param name - name to use for the new material.
  23096. */
  23097. clone(name: string): NodeMaterial;
  23098. /**
  23099. * Creates a node material from parsed material data
  23100. * @param source defines the JSON representation of the material
  23101. * @param scene defines the hosting scene
  23102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23103. * @returns a new node material
  23104. */
  23105. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23106. /**
  23107. * Creates a node material from a snippet saved in a remote file
  23108. * @param name defines the name of the material to create
  23109. * @param url defines the url to load from
  23110. * @param scene defines the hosting scene
  23111. * @returns a promise that will resolve to the new node material
  23112. */
  23113. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23114. /**
  23115. * Creates a node material from a snippet saved by the node material editor
  23116. * @param snippetId defines the snippet to load
  23117. * @param scene defines the hosting scene
  23118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23119. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23120. * @returns a promise that will resolve to the new node material
  23121. */
  23122. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23123. /**
  23124. * Creates a new node material set to default basic configuration
  23125. * @param name defines the name of the material
  23126. * @param scene defines the hosting scene
  23127. * @returns a new NodeMaterial
  23128. */
  23129. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23130. }
  23131. }
  23132. declare module BABYLON {
  23133. interface ThinEngine {
  23134. /**
  23135. * Unbind a list of render target textures from the webGL context
  23136. * This is used only when drawBuffer extension or webGL2 are active
  23137. * @param textures defines the render target textures to unbind
  23138. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23139. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23140. */
  23141. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23142. /**
  23143. * Create a multi render target texture
  23144. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23145. * @param size defines the size of the texture
  23146. * @param options defines the creation options
  23147. * @returns the cube texture as an InternalTexture
  23148. */
  23149. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23150. /**
  23151. * Update the sample count for a given multiple render target texture
  23152. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23153. * @param textures defines the textures to update
  23154. * @param samples defines the sample count to set
  23155. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23156. */
  23157. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23158. /**
  23159. * Select a subsets of attachments to draw to.
  23160. * @param attachments gl attachments
  23161. */
  23162. bindAttachments(attachments: number[]): void;
  23163. /**
  23164. * Creates a layout object to draw/clear on specific textures in a MRT
  23165. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23166. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23167. */
  23168. buildTextureLayout(textureStatus: boolean[]): number[];
  23169. /**
  23170. * Restores the webgl state to only draw on the main color attachment
  23171. */
  23172. restoreSingleAttachment(): void;
  23173. }
  23174. }
  23175. declare module BABYLON {
  23176. /**
  23177. * Creation options of the multi render target texture.
  23178. */
  23179. export interface IMultiRenderTargetOptions {
  23180. /**
  23181. * Define if the texture needs to create mip maps after render.
  23182. */
  23183. generateMipMaps?: boolean;
  23184. /**
  23185. * Define the types of all the draw buffers we want to create
  23186. */
  23187. types?: number[];
  23188. /**
  23189. * Define the sampling modes of all the draw buffers we want to create
  23190. */
  23191. samplingModes?: number[];
  23192. /**
  23193. * Define if a depth buffer is required
  23194. */
  23195. generateDepthBuffer?: boolean;
  23196. /**
  23197. * Define if a stencil buffer is required
  23198. */
  23199. generateStencilBuffer?: boolean;
  23200. /**
  23201. * Define if a depth texture is required instead of a depth buffer
  23202. */
  23203. generateDepthTexture?: boolean;
  23204. /**
  23205. * Define the number of desired draw buffers
  23206. */
  23207. textureCount?: number;
  23208. /**
  23209. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23210. */
  23211. doNotChangeAspectRatio?: boolean;
  23212. /**
  23213. * Define the default type of the buffers we are creating
  23214. */
  23215. defaultType?: number;
  23216. }
  23217. /**
  23218. * A multi render target, like a render target provides the ability to render to a texture.
  23219. * Unlike the render target, it can render to several draw buffers in one draw.
  23220. * This is specially interesting in deferred rendering or for any effects requiring more than
  23221. * just one color from a single pass.
  23222. */
  23223. export class MultiRenderTarget extends RenderTargetTexture {
  23224. private _internalTextures;
  23225. private _textures;
  23226. private _multiRenderTargetOptions;
  23227. private _count;
  23228. /**
  23229. * Get if draw buffers are currently supported by the used hardware and browser.
  23230. */
  23231. get isSupported(): boolean;
  23232. /**
  23233. * Get the list of textures generated by the multi render target.
  23234. */
  23235. get textures(): Texture[];
  23236. /**
  23237. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23238. */
  23239. get count(): number;
  23240. /**
  23241. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23242. */
  23243. get depthTexture(): Texture;
  23244. /**
  23245. * Set the wrapping mode on U of all the textures we are rendering to.
  23246. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23247. */
  23248. set wrapU(wrap: number);
  23249. /**
  23250. * Set the wrapping mode on V of all the textures we are rendering to.
  23251. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23252. */
  23253. set wrapV(wrap: number);
  23254. /**
  23255. * Instantiate a new multi render target texture.
  23256. * A multi render target, like a render target provides the ability to render to a texture.
  23257. * Unlike the render target, it can render to several draw buffers in one draw.
  23258. * This is specially interesting in deferred rendering or for any effects requiring more than
  23259. * just one color from a single pass.
  23260. * @param name Define the name of the texture
  23261. * @param size Define the size of the buffers to render to
  23262. * @param count Define the number of target we are rendering into
  23263. * @param scene Define the scene the texture belongs to
  23264. * @param options Define the options used to create the multi render target
  23265. */
  23266. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23267. private _initTypes;
  23268. /** @hidden */
  23269. _rebuild(forceFullRebuild?: boolean): void;
  23270. private _createInternalTextures;
  23271. private _createTextures;
  23272. /**
  23273. * Replaces a texture within the MRT.
  23274. * @param texture The new texture to insert in the MRT
  23275. * @param index The index of the texture to replace
  23276. */
  23277. replaceTexture(texture: Texture, index: number): void;
  23278. /**
  23279. * Define the number of samples used if MSAA is enabled.
  23280. */
  23281. get samples(): number;
  23282. set samples(value: number);
  23283. /**
  23284. * Resize all the textures in the multi render target.
  23285. * Be careful as it will recreate all the data in the new texture.
  23286. * @param size Define the new size
  23287. */
  23288. resize(size: any): void;
  23289. /**
  23290. * Changes the number of render targets in this MRT
  23291. * Be careful as it will recreate all the data in the new texture.
  23292. * @param count new texture count
  23293. * @param options Specifies texture types and sampling modes for new textures
  23294. */
  23295. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23296. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23297. /**
  23298. * Dispose the render targets and their associated resources
  23299. */
  23300. dispose(): void;
  23301. /**
  23302. * Release all the underlying texture used as draw buffers.
  23303. */
  23304. releaseInternalTextures(): void;
  23305. }
  23306. }
  23307. declare module BABYLON {
  23308. /** @hidden */
  23309. export var imageProcessingPixelShader: {
  23310. name: string;
  23311. shader: string;
  23312. };
  23313. }
  23314. declare module BABYLON {
  23315. /**
  23316. * ImageProcessingPostProcess
  23317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23318. */
  23319. export class ImageProcessingPostProcess extends PostProcess {
  23320. /**
  23321. * Default configuration related to image processing available in the PBR Material.
  23322. */
  23323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23324. /**
  23325. * Gets the image processing configuration used either in this material.
  23326. */
  23327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23328. /**
  23329. * Sets the Default image processing configuration used either in the this material.
  23330. *
  23331. * If sets to null, the scene one is in use.
  23332. */
  23333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23334. /**
  23335. * Keep track of the image processing observer to allow dispose and replace.
  23336. */
  23337. private _imageProcessingObserver;
  23338. /**
  23339. * Attaches a new image processing configuration to the PBR Material.
  23340. * @param configuration
  23341. */
  23342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23343. /**
  23344. * If the post process is supported.
  23345. */
  23346. get isSupported(): boolean;
  23347. /**
  23348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23349. */
  23350. get colorCurves(): Nullable<ColorCurves>;
  23351. /**
  23352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23353. */
  23354. set colorCurves(value: Nullable<ColorCurves>);
  23355. /**
  23356. * Gets wether the color curves effect is enabled.
  23357. */
  23358. get colorCurvesEnabled(): boolean;
  23359. /**
  23360. * Sets wether the color curves effect is enabled.
  23361. */
  23362. set colorCurvesEnabled(value: boolean);
  23363. /**
  23364. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23365. */
  23366. get colorGradingTexture(): Nullable<BaseTexture>;
  23367. /**
  23368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23369. */
  23370. set colorGradingTexture(value: Nullable<BaseTexture>);
  23371. /**
  23372. * Gets wether the color grading effect is enabled.
  23373. */
  23374. get colorGradingEnabled(): boolean;
  23375. /**
  23376. * Gets wether the color grading effect is enabled.
  23377. */
  23378. set colorGradingEnabled(value: boolean);
  23379. /**
  23380. * Gets exposure used in the effect.
  23381. */
  23382. get exposure(): number;
  23383. /**
  23384. * Sets exposure used in the effect.
  23385. */
  23386. set exposure(value: number);
  23387. /**
  23388. * Gets wether tonemapping is enabled or not.
  23389. */
  23390. get toneMappingEnabled(): boolean;
  23391. /**
  23392. * Sets wether tonemapping is enabled or not
  23393. */
  23394. set toneMappingEnabled(value: boolean);
  23395. /**
  23396. * Gets the type of tone mapping effect.
  23397. */
  23398. get toneMappingType(): number;
  23399. /**
  23400. * Sets the type of tone mapping effect.
  23401. */
  23402. set toneMappingType(value: number);
  23403. /**
  23404. * Gets contrast used in the effect.
  23405. */
  23406. get contrast(): number;
  23407. /**
  23408. * Sets contrast used in the effect.
  23409. */
  23410. set contrast(value: number);
  23411. /**
  23412. * Gets Vignette stretch size.
  23413. */
  23414. get vignetteStretch(): number;
  23415. /**
  23416. * Sets Vignette stretch size.
  23417. */
  23418. set vignetteStretch(value: number);
  23419. /**
  23420. * Gets Vignette centre X Offset.
  23421. */
  23422. get vignetteCentreX(): number;
  23423. /**
  23424. * Sets Vignette centre X Offset.
  23425. */
  23426. set vignetteCentreX(value: number);
  23427. /**
  23428. * Gets Vignette centre Y Offset.
  23429. */
  23430. get vignetteCentreY(): number;
  23431. /**
  23432. * Sets Vignette centre Y Offset.
  23433. */
  23434. set vignetteCentreY(value: number);
  23435. /**
  23436. * Gets Vignette weight or intensity of the vignette effect.
  23437. */
  23438. get vignetteWeight(): number;
  23439. /**
  23440. * Sets Vignette weight or intensity of the vignette effect.
  23441. */
  23442. set vignetteWeight(value: number);
  23443. /**
  23444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23445. * if vignetteEnabled is set to true.
  23446. */
  23447. get vignetteColor(): Color4;
  23448. /**
  23449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23450. * if vignetteEnabled is set to true.
  23451. */
  23452. set vignetteColor(value: Color4);
  23453. /**
  23454. * Gets Camera field of view used by the Vignette effect.
  23455. */
  23456. get vignetteCameraFov(): number;
  23457. /**
  23458. * Sets Camera field of view used by the Vignette effect.
  23459. */
  23460. set vignetteCameraFov(value: number);
  23461. /**
  23462. * Gets the vignette blend mode allowing different kind of effect.
  23463. */
  23464. get vignetteBlendMode(): number;
  23465. /**
  23466. * Sets the vignette blend mode allowing different kind of effect.
  23467. */
  23468. set vignetteBlendMode(value: number);
  23469. /**
  23470. * Gets wether the vignette effect is enabled.
  23471. */
  23472. get vignetteEnabled(): boolean;
  23473. /**
  23474. * Sets wether the vignette effect is enabled.
  23475. */
  23476. set vignetteEnabled(value: boolean);
  23477. private _fromLinearSpace;
  23478. /**
  23479. * Gets wether the input of the processing is in Gamma or Linear Space.
  23480. */
  23481. get fromLinearSpace(): boolean;
  23482. /**
  23483. * Sets wether the input of the processing is in Gamma or Linear Space.
  23484. */
  23485. set fromLinearSpace(value: boolean);
  23486. /**
  23487. * Defines cache preventing GC.
  23488. */
  23489. private _defines;
  23490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23491. /**
  23492. * "ImageProcessingPostProcess"
  23493. * @returns "ImageProcessingPostProcess"
  23494. */
  23495. getClassName(): string;
  23496. /**
  23497. * @hidden
  23498. */
  23499. _updateParameters(): void;
  23500. dispose(camera?: Camera): void;
  23501. }
  23502. }
  23503. declare module BABYLON {
  23504. /**
  23505. * Interface for defining prepass effects in the prepass post-process pipeline
  23506. */
  23507. export interface PrePassEffectConfiguration {
  23508. /**
  23509. * Name of the effect
  23510. */
  23511. name: string;
  23512. /**
  23513. * Post process to attach for this effect
  23514. */
  23515. postProcess?: PostProcess;
  23516. /**
  23517. * Textures required in the MRT
  23518. */
  23519. texturesRequired: number[];
  23520. /**
  23521. * Is the effect enabled
  23522. */
  23523. enabled: boolean;
  23524. /**
  23525. * Disposes the effect configuration
  23526. */
  23527. dispose?: () => void;
  23528. /**
  23529. * Creates the associated post process
  23530. */
  23531. createPostProcess?: () => PostProcess;
  23532. }
  23533. }
  23534. declare module BABYLON {
  23535. /**
  23536. * Options to be used when creating a FresnelParameters.
  23537. */
  23538. export type IFresnelParametersCreationOptions = {
  23539. /**
  23540. * Define the color used on edges (grazing angle)
  23541. */
  23542. leftColor?: Color3;
  23543. /**
  23544. * Define the color used on center
  23545. */
  23546. rightColor?: Color3;
  23547. /**
  23548. * Define bias applied to computed fresnel term
  23549. */
  23550. bias?: number;
  23551. /**
  23552. * Defined the power exponent applied to fresnel term
  23553. */
  23554. power?: number;
  23555. /**
  23556. * Define if the fresnel effect is enable or not.
  23557. */
  23558. isEnabled?: boolean;
  23559. };
  23560. /**
  23561. * Serialized format for FresnelParameters.
  23562. */
  23563. export type IFresnelParametersSerialized = {
  23564. /**
  23565. * Define the color used on edges (grazing angle) [as an array]
  23566. */
  23567. leftColor: number[];
  23568. /**
  23569. * Define the color used on center [as an array]
  23570. */
  23571. rightColor: number[];
  23572. /**
  23573. * Define bias applied to computed fresnel term
  23574. */
  23575. bias: number;
  23576. /**
  23577. * Defined the power exponent applied to fresnel term
  23578. */
  23579. power?: number;
  23580. /**
  23581. * Define if the fresnel effect is enable or not.
  23582. */
  23583. isEnabled: boolean;
  23584. };
  23585. /**
  23586. * This represents all the required information to add a fresnel effect on a material:
  23587. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23588. */
  23589. export class FresnelParameters {
  23590. private _isEnabled;
  23591. /**
  23592. * Define if the fresnel effect is enable or not.
  23593. */
  23594. get isEnabled(): boolean;
  23595. set isEnabled(value: boolean);
  23596. /**
  23597. * Define the color used on edges (grazing angle)
  23598. */
  23599. leftColor: Color3;
  23600. /**
  23601. * Define the color used on center
  23602. */
  23603. rightColor: Color3;
  23604. /**
  23605. * Define bias applied to computed fresnel term
  23606. */
  23607. bias: number;
  23608. /**
  23609. * Defined the power exponent applied to fresnel term
  23610. */
  23611. power: number;
  23612. /**
  23613. * Creates a new FresnelParameters object.
  23614. *
  23615. * @param options provide your own settings to optionally to override defaults
  23616. */
  23617. constructor(options?: IFresnelParametersCreationOptions);
  23618. /**
  23619. * Clones the current fresnel and its valuues
  23620. * @returns a clone fresnel configuration
  23621. */
  23622. clone(): FresnelParameters;
  23623. /**
  23624. * Determines equality between FresnelParameters objects
  23625. * @param otherFresnelParameters defines the second operand
  23626. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23627. */
  23628. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23629. /**
  23630. * Serializes the current fresnel parameters to a JSON representation.
  23631. * @return the JSON serialization
  23632. */
  23633. serialize(): IFresnelParametersSerialized;
  23634. /**
  23635. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23636. * @param parsedFresnelParameters Define the JSON representation
  23637. * @returns the parsed parameters
  23638. */
  23639. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23640. }
  23641. }
  23642. declare module BABYLON {
  23643. /**
  23644. * This groups all the flags used to control the materials channel.
  23645. */
  23646. export class MaterialFlags {
  23647. private static _DiffuseTextureEnabled;
  23648. /**
  23649. * Are diffuse textures enabled in the application.
  23650. */
  23651. static get DiffuseTextureEnabled(): boolean;
  23652. static set DiffuseTextureEnabled(value: boolean);
  23653. private static _DetailTextureEnabled;
  23654. /**
  23655. * Are detail textures enabled in the application.
  23656. */
  23657. static get DetailTextureEnabled(): boolean;
  23658. static set DetailTextureEnabled(value: boolean);
  23659. private static _AmbientTextureEnabled;
  23660. /**
  23661. * Are ambient textures enabled in the application.
  23662. */
  23663. static get AmbientTextureEnabled(): boolean;
  23664. static set AmbientTextureEnabled(value: boolean);
  23665. private static _OpacityTextureEnabled;
  23666. /**
  23667. * Are opacity textures enabled in the application.
  23668. */
  23669. static get OpacityTextureEnabled(): boolean;
  23670. static set OpacityTextureEnabled(value: boolean);
  23671. private static _ReflectionTextureEnabled;
  23672. /**
  23673. * Are reflection textures enabled in the application.
  23674. */
  23675. static get ReflectionTextureEnabled(): boolean;
  23676. static set ReflectionTextureEnabled(value: boolean);
  23677. private static _EmissiveTextureEnabled;
  23678. /**
  23679. * Are emissive textures enabled in the application.
  23680. */
  23681. static get EmissiveTextureEnabled(): boolean;
  23682. static set EmissiveTextureEnabled(value: boolean);
  23683. private static _SpecularTextureEnabled;
  23684. /**
  23685. * Are specular textures enabled in the application.
  23686. */
  23687. static get SpecularTextureEnabled(): boolean;
  23688. static set SpecularTextureEnabled(value: boolean);
  23689. private static _BumpTextureEnabled;
  23690. /**
  23691. * Are bump textures enabled in the application.
  23692. */
  23693. static get BumpTextureEnabled(): boolean;
  23694. static set BumpTextureEnabled(value: boolean);
  23695. private static _LightmapTextureEnabled;
  23696. /**
  23697. * Are lightmap textures enabled in the application.
  23698. */
  23699. static get LightmapTextureEnabled(): boolean;
  23700. static set LightmapTextureEnabled(value: boolean);
  23701. private static _RefractionTextureEnabled;
  23702. /**
  23703. * Are refraction textures enabled in the application.
  23704. */
  23705. static get RefractionTextureEnabled(): boolean;
  23706. static set RefractionTextureEnabled(value: boolean);
  23707. private static _ColorGradingTextureEnabled;
  23708. /**
  23709. * Are color grading textures enabled in the application.
  23710. */
  23711. static get ColorGradingTextureEnabled(): boolean;
  23712. static set ColorGradingTextureEnabled(value: boolean);
  23713. private static _FresnelEnabled;
  23714. /**
  23715. * Are fresnels enabled in the application.
  23716. */
  23717. static get FresnelEnabled(): boolean;
  23718. static set FresnelEnabled(value: boolean);
  23719. private static _ClearCoatTextureEnabled;
  23720. /**
  23721. * Are clear coat textures enabled in the application.
  23722. */
  23723. static get ClearCoatTextureEnabled(): boolean;
  23724. static set ClearCoatTextureEnabled(value: boolean);
  23725. private static _ClearCoatBumpTextureEnabled;
  23726. /**
  23727. * Are clear coat bump textures enabled in the application.
  23728. */
  23729. static get ClearCoatBumpTextureEnabled(): boolean;
  23730. static set ClearCoatBumpTextureEnabled(value: boolean);
  23731. private static _ClearCoatTintTextureEnabled;
  23732. /**
  23733. * Are clear coat tint textures enabled in the application.
  23734. */
  23735. static get ClearCoatTintTextureEnabled(): boolean;
  23736. static set ClearCoatTintTextureEnabled(value: boolean);
  23737. private static _SheenTextureEnabled;
  23738. /**
  23739. * Are sheen textures enabled in the application.
  23740. */
  23741. static get SheenTextureEnabled(): boolean;
  23742. static set SheenTextureEnabled(value: boolean);
  23743. private static _AnisotropicTextureEnabled;
  23744. /**
  23745. * Are anisotropic textures enabled in the application.
  23746. */
  23747. static get AnisotropicTextureEnabled(): boolean;
  23748. static set AnisotropicTextureEnabled(value: boolean);
  23749. private static _ThicknessTextureEnabled;
  23750. /**
  23751. * Are thickness textures enabled in the application.
  23752. */
  23753. static get ThicknessTextureEnabled(): boolean;
  23754. static set ThicknessTextureEnabled(value: boolean);
  23755. }
  23756. }
  23757. declare module BABYLON {
  23758. /** @hidden */
  23759. export var defaultFragmentDeclaration: {
  23760. name: string;
  23761. shader: string;
  23762. };
  23763. }
  23764. declare module BABYLON {
  23765. /** @hidden */
  23766. export var defaultUboDeclaration: {
  23767. name: string;
  23768. shader: string;
  23769. };
  23770. }
  23771. declare module BABYLON {
  23772. /** @hidden */
  23773. export var prePassDeclaration: {
  23774. name: string;
  23775. shader: string;
  23776. };
  23777. }
  23778. declare module BABYLON {
  23779. /** @hidden */
  23780. export var lightFragmentDeclaration: {
  23781. name: string;
  23782. shader: string;
  23783. };
  23784. }
  23785. declare module BABYLON {
  23786. /** @hidden */
  23787. export var lightUboDeclaration: {
  23788. name: string;
  23789. shader: string;
  23790. };
  23791. }
  23792. declare module BABYLON {
  23793. /** @hidden */
  23794. export var lightsFragmentFunctions: {
  23795. name: string;
  23796. shader: string;
  23797. };
  23798. }
  23799. declare module BABYLON {
  23800. /** @hidden */
  23801. export var shadowsFragmentFunctions: {
  23802. name: string;
  23803. shader: string;
  23804. };
  23805. }
  23806. declare module BABYLON {
  23807. /** @hidden */
  23808. export var fresnelFunction: {
  23809. name: string;
  23810. shader: string;
  23811. };
  23812. }
  23813. declare module BABYLON {
  23814. /** @hidden */
  23815. export var bumpFragmentMainFunctions: {
  23816. name: string;
  23817. shader: string;
  23818. };
  23819. }
  23820. declare module BABYLON {
  23821. /** @hidden */
  23822. export var bumpFragmentFunctions: {
  23823. name: string;
  23824. shader: string;
  23825. };
  23826. }
  23827. declare module BABYLON {
  23828. /** @hidden */
  23829. export var logDepthDeclaration: {
  23830. name: string;
  23831. shader: string;
  23832. };
  23833. }
  23834. declare module BABYLON {
  23835. /** @hidden */
  23836. export var bumpFragment: {
  23837. name: string;
  23838. shader: string;
  23839. };
  23840. }
  23841. declare module BABYLON {
  23842. /** @hidden */
  23843. export var depthPrePass: {
  23844. name: string;
  23845. shader: string;
  23846. };
  23847. }
  23848. declare module BABYLON {
  23849. /** @hidden */
  23850. export var lightFragment: {
  23851. name: string;
  23852. shader: string;
  23853. };
  23854. }
  23855. declare module BABYLON {
  23856. /** @hidden */
  23857. export var logDepthFragment: {
  23858. name: string;
  23859. shader: string;
  23860. };
  23861. }
  23862. declare module BABYLON {
  23863. /** @hidden */
  23864. export var defaultPixelShader: {
  23865. name: string;
  23866. shader: string;
  23867. };
  23868. }
  23869. declare module BABYLON {
  23870. /** @hidden */
  23871. export var defaultVertexDeclaration: {
  23872. name: string;
  23873. shader: string;
  23874. };
  23875. }
  23876. declare module BABYLON {
  23877. /** @hidden */
  23878. export var prePassVertexDeclaration: {
  23879. name: string;
  23880. shader: string;
  23881. };
  23882. }
  23883. declare module BABYLON {
  23884. /** @hidden */
  23885. export var bumpVertexDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module BABYLON {
  23891. /** @hidden */
  23892. export var prePassVertex: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module BABYLON {
  23898. /** @hidden */
  23899. export var bumpVertex: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module BABYLON {
  23905. /** @hidden */
  23906. export var fogVertex: {
  23907. name: string;
  23908. shader: string;
  23909. };
  23910. }
  23911. declare module BABYLON {
  23912. /** @hidden */
  23913. export var shadowsVertex: {
  23914. name: string;
  23915. shader: string;
  23916. };
  23917. }
  23918. declare module BABYLON {
  23919. /** @hidden */
  23920. export var pointCloudVertex: {
  23921. name: string;
  23922. shader: string;
  23923. };
  23924. }
  23925. declare module BABYLON {
  23926. /** @hidden */
  23927. export var logDepthVertex: {
  23928. name: string;
  23929. shader: string;
  23930. };
  23931. }
  23932. declare module BABYLON {
  23933. /** @hidden */
  23934. export var defaultVertexShader: {
  23935. name: string;
  23936. shader: string;
  23937. };
  23938. }
  23939. declare module BABYLON {
  23940. /**
  23941. * @hidden
  23942. */
  23943. export interface IMaterialDetailMapDefines {
  23944. DETAIL: boolean;
  23945. DETAILDIRECTUV: number;
  23946. DETAIL_NORMALBLENDMETHOD: number;
  23947. /** @hidden */
  23948. _areTexturesDirty: boolean;
  23949. }
  23950. /**
  23951. * Define the code related to the detail map parameters of a material
  23952. *
  23953. * Inspired from:
  23954. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  23955. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23956. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23957. */
  23958. export class DetailMapConfiguration {
  23959. private _texture;
  23960. /**
  23961. * The detail texture of the material.
  23962. */
  23963. texture: Nullable<BaseTexture>;
  23964. /**
  23965. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23966. * Bigger values mean stronger blending
  23967. */
  23968. diffuseBlendLevel: number;
  23969. /**
  23970. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23971. * Bigger values mean stronger blending. Only used with PBR materials
  23972. */
  23973. roughnessBlendLevel: number;
  23974. /**
  23975. * Defines how strong the bump effect from the detail map is
  23976. * Bigger values mean stronger effect
  23977. */
  23978. bumpLevel: number;
  23979. private _normalBlendMethod;
  23980. /**
  23981. * The method used to blend the bump and detail normals together
  23982. */
  23983. normalBlendMethod: number;
  23984. private _isEnabled;
  23985. /**
  23986. * Enable or disable the detail map on this material
  23987. */
  23988. isEnabled: boolean;
  23989. /** @hidden */
  23990. private _internalMarkAllSubMeshesAsTexturesDirty;
  23991. /** @hidden */
  23992. _markAllSubMeshesAsTexturesDirty(): void;
  23993. /**
  23994. * Instantiate a new detail map
  23995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23996. */
  23997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23998. /**
  23999. * Gets whether the submesh is ready to be used or not.
  24000. * @param defines the list of "defines" to update.
  24001. * @param scene defines the scene the material belongs to.
  24002. * @returns - boolean indicating that the submesh is ready or not.
  24003. */
  24004. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24005. /**
  24006. * Update the defines for detail map usage
  24007. * @param defines the list of "defines" to update.
  24008. * @param scene defines the scene the material belongs to.
  24009. */
  24010. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24011. /**
  24012. * Binds the material data.
  24013. * @param uniformBuffer defines the Uniform buffer to fill in.
  24014. * @param scene defines the scene the material belongs to.
  24015. * @param isFrozen defines whether the material is frozen or not.
  24016. */
  24017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24018. /**
  24019. * Checks to see if a texture is used in the material.
  24020. * @param texture - Base texture to use.
  24021. * @returns - Boolean specifying if a texture is used in the material.
  24022. */
  24023. hasTexture(texture: BaseTexture): boolean;
  24024. /**
  24025. * Returns an array of the actively used textures.
  24026. * @param activeTextures Array of BaseTextures
  24027. */
  24028. getActiveTextures(activeTextures: BaseTexture[]): void;
  24029. /**
  24030. * Returns the animatable textures.
  24031. * @param animatables Array of animatable textures.
  24032. */
  24033. getAnimatables(animatables: IAnimatable[]): void;
  24034. /**
  24035. * Disposes the resources of the material.
  24036. * @param forceDisposeTextures - Forces the disposal of all textures.
  24037. */
  24038. dispose(forceDisposeTextures?: boolean): void;
  24039. /**
  24040. * Get the current class name useful for serialization or dynamic coding.
  24041. * @returns "DetailMap"
  24042. */
  24043. getClassName(): string;
  24044. /**
  24045. * Add the required uniforms to the current list.
  24046. * @param uniforms defines the current uniform list.
  24047. */
  24048. static AddUniforms(uniforms: string[]): void;
  24049. /**
  24050. * Add the required samplers to the current list.
  24051. * @param samplers defines the current sampler list.
  24052. */
  24053. static AddSamplers(samplers: string[]): void;
  24054. /**
  24055. * Add the required uniforms to the current buffer.
  24056. * @param uniformBuffer defines the current uniform buffer.
  24057. */
  24058. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24059. /**
  24060. * Makes a duplicate of the current instance into another one.
  24061. * @param detailMap define the instance where to copy the info
  24062. */
  24063. copyTo(detailMap: DetailMapConfiguration): void;
  24064. /**
  24065. * Serializes this detail map instance
  24066. * @returns - An object with the serialized instance.
  24067. */
  24068. serialize(): any;
  24069. /**
  24070. * Parses a detail map setting from a serialized object.
  24071. * @param source - Serialized object.
  24072. * @param scene Defines the scene we are parsing for
  24073. * @param rootUrl Defines the rootUrl to load from
  24074. */
  24075. parse(source: any, scene: Scene, rootUrl: string): void;
  24076. }
  24077. }
  24078. declare module BABYLON {
  24079. /** @hidden */
  24080. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24081. MAINUV1: boolean;
  24082. MAINUV2: boolean;
  24083. DIFFUSE: boolean;
  24084. DIFFUSEDIRECTUV: number;
  24085. DETAIL: boolean;
  24086. DETAILDIRECTUV: number;
  24087. DETAIL_NORMALBLENDMETHOD: number;
  24088. AMBIENT: boolean;
  24089. AMBIENTDIRECTUV: number;
  24090. OPACITY: boolean;
  24091. OPACITYDIRECTUV: number;
  24092. OPACITYRGB: boolean;
  24093. REFLECTION: boolean;
  24094. EMISSIVE: boolean;
  24095. EMISSIVEDIRECTUV: number;
  24096. SPECULAR: boolean;
  24097. SPECULARDIRECTUV: number;
  24098. BUMP: boolean;
  24099. BUMPDIRECTUV: number;
  24100. PARALLAX: boolean;
  24101. PARALLAXOCCLUSION: boolean;
  24102. SPECULAROVERALPHA: boolean;
  24103. CLIPPLANE: boolean;
  24104. CLIPPLANE2: boolean;
  24105. CLIPPLANE3: boolean;
  24106. CLIPPLANE4: boolean;
  24107. CLIPPLANE5: boolean;
  24108. CLIPPLANE6: boolean;
  24109. ALPHATEST: boolean;
  24110. DEPTHPREPASS: boolean;
  24111. ALPHAFROMDIFFUSE: boolean;
  24112. POINTSIZE: boolean;
  24113. FOG: boolean;
  24114. SPECULARTERM: boolean;
  24115. DIFFUSEFRESNEL: boolean;
  24116. OPACITYFRESNEL: boolean;
  24117. REFLECTIONFRESNEL: boolean;
  24118. REFRACTIONFRESNEL: boolean;
  24119. EMISSIVEFRESNEL: boolean;
  24120. FRESNEL: boolean;
  24121. NORMAL: boolean;
  24122. UV1: boolean;
  24123. UV2: boolean;
  24124. VERTEXCOLOR: boolean;
  24125. VERTEXALPHA: boolean;
  24126. NUM_BONE_INFLUENCERS: number;
  24127. BonesPerMesh: number;
  24128. BONETEXTURE: boolean;
  24129. BONES_VELOCITY_ENABLED: boolean;
  24130. INSTANCES: boolean;
  24131. THIN_INSTANCES: boolean;
  24132. GLOSSINESS: boolean;
  24133. ROUGHNESS: boolean;
  24134. EMISSIVEASILLUMINATION: boolean;
  24135. LINKEMISSIVEWITHDIFFUSE: boolean;
  24136. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24137. LIGHTMAP: boolean;
  24138. LIGHTMAPDIRECTUV: number;
  24139. OBJECTSPACE_NORMALMAP: boolean;
  24140. USELIGHTMAPASSHADOWMAP: boolean;
  24141. REFLECTIONMAP_3D: boolean;
  24142. REFLECTIONMAP_SPHERICAL: boolean;
  24143. REFLECTIONMAP_PLANAR: boolean;
  24144. REFLECTIONMAP_CUBIC: boolean;
  24145. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24146. REFLECTIONMAP_PROJECTION: boolean;
  24147. REFLECTIONMAP_SKYBOX: boolean;
  24148. REFLECTIONMAP_EXPLICIT: boolean;
  24149. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24150. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24151. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24152. INVERTCUBICMAP: boolean;
  24153. LOGARITHMICDEPTH: boolean;
  24154. REFRACTION: boolean;
  24155. REFRACTIONMAP_3D: boolean;
  24156. REFLECTIONOVERALPHA: boolean;
  24157. TWOSIDEDLIGHTING: boolean;
  24158. SHADOWFLOAT: boolean;
  24159. MORPHTARGETS: boolean;
  24160. MORPHTARGETS_NORMAL: boolean;
  24161. MORPHTARGETS_TANGENT: boolean;
  24162. MORPHTARGETS_UV: boolean;
  24163. NUM_MORPH_INFLUENCERS: number;
  24164. NONUNIFORMSCALING: boolean;
  24165. PREMULTIPLYALPHA: boolean;
  24166. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24167. ALPHABLEND: boolean;
  24168. PREPASS: boolean;
  24169. PREPASS_IRRADIANCE: boolean;
  24170. PREPASS_IRRADIANCE_INDEX: number;
  24171. PREPASS_ALBEDO: boolean;
  24172. PREPASS_ALBEDO_INDEX: number;
  24173. PREPASS_DEPTHNORMAL: boolean;
  24174. PREPASS_DEPTHNORMAL_INDEX: number;
  24175. PREPASS_POSITION: boolean;
  24176. PREPASS_POSITION_INDEX: number;
  24177. PREPASS_VELOCITY: boolean;
  24178. PREPASS_VELOCITY_INDEX: number;
  24179. PREPASS_REFLECTIVITY: boolean;
  24180. PREPASS_REFLECTIVITY_INDEX: number;
  24181. SCENE_MRT_COUNT: number;
  24182. RGBDLIGHTMAP: boolean;
  24183. RGBDREFLECTION: boolean;
  24184. RGBDREFRACTION: boolean;
  24185. IMAGEPROCESSING: boolean;
  24186. VIGNETTE: boolean;
  24187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24188. VIGNETTEBLENDMODEOPAQUE: boolean;
  24189. TONEMAPPING: boolean;
  24190. TONEMAPPING_ACES: boolean;
  24191. CONTRAST: boolean;
  24192. COLORCURVES: boolean;
  24193. COLORGRADING: boolean;
  24194. COLORGRADING3D: boolean;
  24195. SAMPLER3DGREENDEPTH: boolean;
  24196. SAMPLER3DBGRMAP: boolean;
  24197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24198. MULTIVIEW: boolean;
  24199. /**
  24200. * If the reflection texture on this material is in linear color space
  24201. * @hidden
  24202. */
  24203. IS_REFLECTION_LINEAR: boolean;
  24204. /**
  24205. * If the refraction texture on this material is in linear color space
  24206. * @hidden
  24207. */
  24208. IS_REFRACTION_LINEAR: boolean;
  24209. EXPOSURE: boolean;
  24210. constructor();
  24211. setReflectionMode(modeToEnable: string): void;
  24212. }
  24213. /**
  24214. * This is the default material used in Babylon. It is the best trade off between quality
  24215. * and performances.
  24216. * @see https://doc.babylonjs.com/babylon101/materials
  24217. */
  24218. export class StandardMaterial extends PushMaterial {
  24219. private _diffuseTexture;
  24220. /**
  24221. * The basic texture of the material as viewed under a light.
  24222. */
  24223. diffuseTexture: Nullable<BaseTexture>;
  24224. private _ambientTexture;
  24225. /**
  24226. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24227. */
  24228. ambientTexture: Nullable<BaseTexture>;
  24229. private _opacityTexture;
  24230. /**
  24231. * Define the transparency of the material from a texture.
  24232. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24233. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24234. */
  24235. opacityTexture: Nullable<BaseTexture>;
  24236. private _reflectionTexture;
  24237. /**
  24238. * Define the texture used to display the reflection.
  24239. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24240. */
  24241. reflectionTexture: Nullable<BaseTexture>;
  24242. private _emissiveTexture;
  24243. /**
  24244. * Define texture of the material as if self lit.
  24245. * This will be mixed in the final result even in the absence of light.
  24246. */
  24247. emissiveTexture: Nullable<BaseTexture>;
  24248. private _specularTexture;
  24249. /**
  24250. * Define how the color and intensity of the highlight given by the light in the material.
  24251. */
  24252. specularTexture: Nullable<BaseTexture>;
  24253. private _bumpTexture;
  24254. /**
  24255. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24256. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  24257. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24258. */
  24259. bumpTexture: Nullable<BaseTexture>;
  24260. private _lightmapTexture;
  24261. /**
  24262. * Complex lighting can be computationally expensive to compute at runtime.
  24263. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24264. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24265. */
  24266. lightmapTexture: Nullable<BaseTexture>;
  24267. private _refractionTexture;
  24268. /**
  24269. * Define the texture used to display the refraction.
  24270. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24271. */
  24272. refractionTexture: Nullable<BaseTexture>;
  24273. /**
  24274. * The color of the material lit by the environmental background lighting.
  24275. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24276. */
  24277. ambientColor: Color3;
  24278. /**
  24279. * The basic color of the material as viewed under a light.
  24280. */
  24281. diffuseColor: Color3;
  24282. /**
  24283. * Define how the color and intensity of the highlight given by the light in the material.
  24284. */
  24285. specularColor: Color3;
  24286. /**
  24287. * Define the color of the material as if self lit.
  24288. * This will be mixed in the final result even in the absence of light.
  24289. */
  24290. emissiveColor: Color3;
  24291. /**
  24292. * Defines how sharp are the highlights in the material.
  24293. * The bigger the value the sharper giving a more glossy feeling to the result.
  24294. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24295. */
  24296. specularPower: number;
  24297. private _useAlphaFromDiffuseTexture;
  24298. /**
  24299. * Does the transparency come from the diffuse texture alpha channel.
  24300. */
  24301. useAlphaFromDiffuseTexture: boolean;
  24302. private _useEmissiveAsIllumination;
  24303. /**
  24304. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24305. */
  24306. useEmissiveAsIllumination: boolean;
  24307. private _linkEmissiveWithDiffuse;
  24308. /**
  24309. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24310. * the emissive level when the final color is close to one.
  24311. */
  24312. linkEmissiveWithDiffuse: boolean;
  24313. private _useSpecularOverAlpha;
  24314. /**
  24315. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24316. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24317. */
  24318. useSpecularOverAlpha: boolean;
  24319. private _useReflectionOverAlpha;
  24320. /**
  24321. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24322. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24323. */
  24324. useReflectionOverAlpha: boolean;
  24325. private _disableLighting;
  24326. /**
  24327. * Does lights from the scene impacts this material.
  24328. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24329. */
  24330. disableLighting: boolean;
  24331. private _useObjectSpaceNormalMap;
  24332. /**
  24333. * Allows using an object space normal map (instead of tangent space).
  24334. */
  24335. useObjectSpaceNormalMap: boolean;
  24336. private _useParallax;
  24337. /**
  24338. * Is parallax enabled or not.
  24339. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24340. */
  24341. useParallax: boolean;
  24342. private _useParallaxOcclusion;
  24343. /**
  24344. * Is parallax occlusion enabled or not.
  24345. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24346. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24347. */
  24348. useParallaxOcclusion: boolean;
  24349. /**
  24350. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  24351. */
  24352. parallaxScaleBias: number;
  24353. private _roughness;
  24354. /**
  24355. * Helps to define how blurry the reflections should appears in the material.
  24356. */
  24357. roughness: number;
  24358. /**
  24359. * In case of refraction, define the value of the index of refraction.
  24360. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24361. */
  24362. indexOfRefraction: number;
  24363. /**
  24364. * Invert the refraction texture alongside the y axis.
  24365. * It can be useful with procedural textures or probe for instance.
  24366. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24367. */
  24368. invertRefractionY: boolean;
  24369. /**
  24370. * Defines the alpha limits in alpha test mode.
  24371. */
  24372. alphaCutOff: number;
  24373. private _useLightmapAsShadowmap;
  24374. /**
  24375. * In case of light mapping, define whether the map contains light or shadow informations.
  24376. */
  24377. useLightmapAsShadowmap: boolean;
  24378. private _diffuseFresnelParameters;
  24379. /**
  24380. * Define the diffuse fresnel parameters of the material.
  24381. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24382. */
  24383. diffuseFresnelParameters: FresnelParameters;
  24384. private _opacityFresnelParameters;
  24385. /**
  24386. * Define the opacity fresnel parameters of the material.
  24387. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24388. */
  24389. opacityFresnelParameters: FresnelParameters;
  24390. private _reflectionFresnelParameters;
  24391. /**
  24392. * Define the reflection fresnel parameters of the material.
  24393. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24394. */
  24395. reflectionFresnelParameters: FresnelParameters;
  24396. private _refractionFresnelParameters;
  24397. /**
  24398. * Define the refraction fresnel parameters of the material.
  24399. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24400. */
  24401. refractionFresnelParameters: FresnelParameters;
  24402. private _emissiveFresnelParameters;
  24403. /**
  24404. * Define the emissive fresnel parameters of the material.
  24405. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24406. */
  24407. emissiveFresnelParameters: FresnelParameters;
  24408. private _useReflectionFresnelFromSpecular;
  24409. /**
  24410. * If true automatically deducts the fresnels values from the material specularity.
  24411. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24412. */
  24413. useReflectionFresnelFromSpecular: boolean;
  24414. private _useGlossinessFromSpecularMapAlpha;
  24415. /**
  24416. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24417. */
  24418. useGlossinessFromSpecularMapAlpha: boolean;
  24419. private _maxSimultaneousLights;
  24420. /**
  24421. * Defines the maximum number of lights that can be used in the material
  24422. */
  24423. maxSimultaneousLights: number;
  24424. private _invertNormalMapX;
  24425. /**
  24426. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24427. */
  24428. invertNormalMapX: boolean;
  24429. private _invertNormalMapY;
  24430. /**
  24431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24432. */
  24433. invertNormalMapY: boolean;
  24434. private _twoSidedLighting;
  24435. /**
  24436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24437. */
  24438. twoSidedLighting: boolean;
  24439. /**
  24440. * Default configuration related to image processing available in the standard Material.
  24441. */
  24442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24443. /**
  24444. * Gets the image processing configuration used either in this material.
  24445. */
  24446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24447. /**
  24448. * Sets the Default image processing configuration used either in the this material.
  24449. *
  24450. * If sets to null, the scene one is in use.
  24451. */
  24452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24453. /**
  24454. * Keep track of the image processing observer to allow dispose and replace.
  24455. */
  24456. private _imageProcessingObserver;
  24457. /**
  24458. * Attaches a new image processing configuration to the Standard Material.
  24459. * @param configuration
  24460. */
  24461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24462. /**
  24463. * Defines additionnal PrePass parameters for the material.
  24464. */
  24465. readonly prePassConfiguration: PrePassConfiguration;
  24466. /**
  24467. * Gets wether the color curves effect is enabled.
  24468. */
  24469. get cameraColorCurvesEnabled(): boolean;
  24470. /**
  24471. * Sets wether the color curves effect is enabled.
  24472. */
  24473. set cameraColorCurvesEnabled(value: boolean);
  24474. /**
  24475. * Gets wether the color grading effect is enabled.
  24476. */
  24477. get cameraColorGradingEnabled(): boolean;
  24478. /**
  24479. * Gets wether the color grading effect is enabled.
  24480. */
  24481. set cameraColorGradingEnabled(value: boolean);
  24482. /**
  24483. * Gets wether tonemapping is enabled or not.
  24484. */
  24485. get cameraToneMappingEnabled(): boolean;
  24486. /**
  24487. * Sets wether tonemapping is enabled or not
  24488. */
  24489. set cameraToneMappingEnabled(value: boolean);
  24490. /**
  24491. * The camera exposure used on this material.
  24492. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24493. * This corresponds to a photographic exposure.
  24494. */
  24495. get cameraExposure(): number;
  24496. /**
  24497. * The camera exposure used on this material.
  24498. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24499. * This corresponds to a photographic exposure.
  24500. */
  24501. set cameraExposure(value: number);
  24502. /**
  24503. * Gets The camera contrast used on this material.
  24504. */
  24505. get cameraContrast(): number;
  24506. /**
  24507. * Sets The camera contrast used on this material.
  24508. */
  24509. set cameraContrast(value: number);
  24510. /**
  24511. * Gets the Color Grading 2D Lookup Texture.
  24512. */
  24513. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24514. /**
  24515. * Sets the Color Grading 2D Lookup Texture.
  24516. */
  24517. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24518. /**
  24519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24521. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24523. */
  24524. get cameraColorCurves(): Nullable<ColorCurves>;
  24525. /**
  24526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24528. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24530. */
  24531. set cameraColorCurves(value: Nullable<ColorCurves>);
  24532. /**
  24533. * Can this material render to several textures at once
  24534. */
  24535. get canRenderToMRT(): boolean;
  24536. /**
  24537. * Defines the detail map parameters for the material.
  24538. */
  24539. readonly detailMap: DetailMapConfiguration;
  24540. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24541. protected _worldViewProjectionMatrix: Matrix;
  24542. protected _globalAmbientColor: Color3;
  24543. protected _useLogarithmicDepth: boolean;
  24544. protected _rebuildInParallel: boolean;
  24545. /**
  24546. * Instantiates a new standard material.
  24547. * This is the default material used in Babylon. It is the best trade off between quality
  24548. * and performances.
  24549. * @see https://doc.babylonjs.com/babylon101/materials
  24550. * @param name Define the name of the material in the scene
  24551. * @param scene Define the scene the material belong to
  24552. */
  24553. constructor(name: string, scene: Scene);
  24554. /**
  24555. * Gets a boolean indicating that current material needs to register RTT
  24556. */
  24557. get hasRenderTargetTextures(): boolean;
  24558. /**
  24559. * Gets the current class name of the material e.g. "StandardMaterial"
  24560. * Mainly use in serialization.
  24561. * @returns the class name
  24562. */
  24563. getClassName(): string;
  24564. /**
  24565. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24566. * You can try switching to logarithmic depth.
  24567. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24568. */
  24569. get useLogarithmicDepth(): boolean;
  24570. set useLogarithmicDepth(value: boolean);
  24571. /**
  24572. * Specifies if the material will require alpha blending
  24573. * @returns a boolean specifying if alpha blending is needed
  24574. */
  24575. needAlphaBlending(): boolean;
  24576. /**
  24577. * Specifies if this material should be rendered in alpha test mode
  24578. * @returns a boolean specifying if an alpha test is needed.
  24579. */
  24580. needAlphaTesting(): boolean;
  24581. /**
  24582. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24583. */
  24584. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24585. /**
  24586. * Specifies whether or not there is a usable alpha channel for transparency.
  24587. */
  24588. protected _hasAlphaChannel(): boolean;
  24589. /**
  24590. * Get the texture used for alpha test purpose.
  24591. * @returns the diffuse texture in case of the standard material.
  24592. */
  24593. getAlphaTestTexture(): Nullable<BaseTexture>;
  24594. /**
  24595. * Get if the submesh is ready to be used and all its information available.
  24596. * Child classes can use it to update shaders
  24597. * @param mesh defines the mesh to check
  24598. * @param subMesh defines which submesh to check
  24599. * @param useInstances specifies that instances should be used
  24600. * @returns a boolean indicating that the submesh is ready or not
  24601. */
  24602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24603. /**
  24604. * Builds the material UBO layouts.
  24605. * Used internally during the effect preparation.
  24606. */
  24607. buildUniformLayout(): void;
  24608. /**
  24609. * Unbinds the material from the mesh
  24610. */
  24611. unbind(): void;
  24612. /**
  24613. * Binds the submesh to this material by preparing the effect and shader to draw
  24614. * @param world defines the world transformation matrix
  24615. * @param mesh defines the mesh containing the submesh
  24616. * @param subMesh defines the submesh to bind the material to
  24617. */
  24618. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24619. /**
  24620. * Get the list of animatables in the material.
  24621. * @returns the list of animatables object used in the material
  24622. */
  24623. getAnimatables(): IAnimatable[];
  24624. /**
  24625. * Gets the active textures from the material
  24626. * @returns an array of textures
  24627. */
  24628. getActiveTextures(): BaseTexture[];
  24629. /**
  24630. * Specifies if the material uses a texture
  24631. * @param texture defines the texture to check against the material
  24632. * @returns a boolean specifying if the material uses the texture
  24633. */
  24634. hasTexture(texture: BaseTexture): boolean;
  24635. /**
  24636. * Disposes the material
  24637. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24638. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24639. */
  24640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24641. /**
  24642. * Makes a duplicate of the material, and gives it a new name
  24643. * @param name defines the new name for the duplicated material
  24644. * @returns the cloned material
  24645. */
  24646. clone(name: string): StandardMaterial;
  24647. /**
  24648. * Serializes this material in a JSON representation
  24649. * @returns the serialized material object
  24650. */
  24651. serialize(): any;
  24652. /**
  24653. * Creates a standard material from parsed material data
  24654. * @param source defines the JSON representation of the material
  24655. * @param scene defines the hosting scene
  24656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24657. * @returns a new standard material
  24658. */
  24659. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24660. /**
  24661. * Are diffuse textures enabled in the application.
  24662. */
  24663. static get DiffuseTextureEnabled(): boolean;
  24664. static set DiffuseTextureEnabled(value: boolean);
  24665. /**
  24666. * Are detail textures enabled in the application.
  24667. */
  24668. static get DetailTextureEnabled(): boolean;
  24669. static set DetailTextureEnabled(value: boolean);
  24670. /**
  24671. * Are ambient textures enabled in the application.
  24672. */
  24673. static get AmbientTextureEnabled(): boolean;
  24674. static set AmbientTextureEnabled(value: boolean);
  24675. /**
  24676. * Are opacity textures enabled in the application.
  24677. */
  24678. static get OpacityTextureEnabled(): boolean;
  24679. static set OpacityTextureEnabled(value: boolean);
  24680. /**
  24681. * Are reflection textures enabled in the application.
  24682. */
  24683. static get ReflectionTextureEnabled(): boolean;
  24684. static set ReflectionTextureEnabled(value: boolean);
  24685. /**
  24686. * Are emissive textures enabled in the application.
  24687. */
  24688. static get EmissiveTextureEnabled(): boolean;
  24689. static set EmissiveTextureEnabled(value: boolean);
  24690. /**
  24691. * Are specular textures enabled in the application.
  24692. */
  24693. static get SpecularTextureEnabled(): boolean;
  24694. static set SpecularTextureEnabled(value: boolean);
  24695. /**
  24696. * Are bump textures enabled in the application.
  24697. */
  24698. static get BumpTextureEnabled(): boolean;
  24699. static set BumpTextureEnabled(value: boolean);
  24700. /**
  24701. * Are lightmap textures enabled in the application.
  24702. */
  24703. static get LightmapTextureEnabled(): boolean;
  24704. static set LightmapTextureEnabled(value: boolean);
  24705. /**
  24706. * Are refraction textures enabled in the application.
  24707. */
  24708. static get RefractionTextureEnabled(): boolean;
  24709. static set RefractionTextureEnabled(value: boolean);
  24710. /**
  24711. * Are color grading textures enabled in the application.
  24712. */
  24713. static get ColorGradingTextureEnabled(): boolean;
  24714. static set ColorGradingTextureEnabled(value: boolean);
  24715. /**
  24716. * Are fresnels enabled in the application.
  24717. */
  24718. static get FresnelEnabled(): boolean;
  24719. static set FresnelEnabled(value: boolean);
  24720. }
  24721. }
  24722. declare module BABYLON {
  24723. /** @hidden */
  24724. export var rgbdDecodePixelShader: {
  24725. name: string;
  24726. shader: string;
  24727. };
  24728. }
  24729. declare module BABYLON {
  24730. /**
  24731. * Class used to host RGBD texture specific utilities
  24732. */
  24733. export class RGBDTextureTools {
  24734. /**
  24735. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24736. * @param texture the texture to expand.
  24737. */
  24738. static ExpandRGBDTexture(texture: Texture): void;
  24739. }
  24740. }
  24741. declare module BABYLON {
  24742. /**
  24743. * Class used to host texture specific utilities
  24744. */
  24745. export class BRDFTextureTools {
  24746. /**
  24747. * Prevents texture cache collision
  24748. */
  24749. private static _instanceNumber;
  24750. /**
  24751. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24752. * @param scene defines the hosting scene
  24753. * @returns the environment BRDF texture
  24754. */
  24755. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24756. private static _environmentBRDFBase64Texture;
  24757. }
  24758. }
  24759. declare module BABYLON {
  24760. /**
  24761. * @hidden
  24762. */
  24763. export interface IMaterialClearCoatDefines {
  24764. CLEARCOAT: boolean;
  24765. CLEARCOAT_DEFAULTIOR: boolean;
  24766. CLEARCOAT_TEXTURE: boolean;
  24767. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24768. CLEARCOAT_TEXTUREDIRECTUV: number;
  24769. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24770. CLEARCOAT_BUMP: boolean;
  24771. CLEARCOAT_BUMPDIRECTUV: number;
  24772. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24773. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24774. CLEARCOAT_REMAP_F0: boolean;
  24775. CLEARCOAT_TINT: boolean;
  24776. CLEARCOAT_TINT_TEXTURE: boolean;
  24777. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24778. /** @hidden */
  24779. _areTexturesDirty: boolean;
  24780. }
  24781. /**
  24782. * Define the code related to the clear coat parameters of the pbr material.
  24783. */
  24784. export class PBRClearCoatConfiguration {
  24785. /**
  24786. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24787. * The default fits with a polyurethane material.
  24788. */
  24789. private static readonly _DefaultIndexOfRefraction;
  24790. private _isEnabled;
  24791. /**
  24792. * Defines if the clear coat is enabled in the material.
  24793. */
  24794. isEnabled: boolean;
  24795. /**
  24796. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24797. */
  24798. intensity: number;
  24799. /**
  24800. * Defines the clear coat layer roughness.
  24801. */
  24802. roughness: number;
  24803. private _indexOfRefraction;
  24804. /**
  24805. * Defines the index of refraction of the clear coat.
  24806. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24807. * The default fits with a polyurethane material.
  24808. * Changing the default value is more performance intensive.
  24809. */
  24810. indexOfRefraction: number;
  24811. private _texture;
  24812. /**
  24813. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24814. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24815. * if textureRoughness is not empty, else no texture roughness is used
  24816. */
  24817. texture: Nullable<BaseTexture>;
  24818. private _useRoughnessFromMainTexture;
  24819. /**
  24820. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24821. * If false, the green channel from textureRoughness is used for roughness
  24822. */
  24823. useRoughnessFromMainTexture: boolean;
  24824. private _textureRoughness;
  24825. /**
  24826. * Stores the clear coat roughness in a texture (green channel)
  24827. * Not used if useRoughnessFromMainTexture is true
  24828. */
  24829. textureRoughness: Nullable<BaseTexture>;
  24830. private _remapF0OnInterfaceChange;
  24831. /**
  24832. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24833. */
  24834. remapF0OnInterfaceChange: boolean;
  24835. private _bumpTexture;
  24836. /**
  24837. * Define the clear coat specific bump texture.
  24838. */
  24839. bumpTexture: Nullable<BaseTexture>;
  24840. private _isTintEnabled;
  24841. /**
  24842. * Defines if the clear coat tint is enabled in the material.
  24843. */
  24844. isTintEnabled: boolean;
  24845. /**
  24846. * Defines the clear coat tint of the material.
  24847. * This is only use if tint is enabled
  24848. */
  24849. tintColor: Color3;
  24850. /**
  24851. * Defines the distance at which the tint color should be found in the
  24852. * clear coat media.
  24853. * This is only use if tint is enabled
  24854. */
  24855. tintColorAtDistance: number;
  24856. /**
  24857. * Defines the clear coat layer thickness.
  24858. * This is only use if tint is enabled
  24859. */
  24860. tintThickness: number;
  24861. private _tintTexture;
  24862. /**
  24863. * Stores the clear tint values in a texture.
  24864. * rgb is tint
  24865. * a is a thickness factor
  24866. */
  24867. tintTexture: Nullable<BaseTexture>;
  24868. /** @hidden */
  24869. private _internalMarkAllSubMeshesAsTexturesDirty;
  24870. /** @hidden */
  24871. _markAllSubMeshesAsTexturesDirty(): void;
  24872. /**
  24873. * Instantiate a new istance of clear coat configuration.
  24874. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24875. */
  24876. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24877. /**
  24878. * Gets wehter the submesh is ready to be used or not.
  24879. * @param defines the list of "defines" to update.
  24880. * @param scene defines the scene the material belongs to.
  24881. * @param engine defines the engine the material belongs to.
  24882. * @param disableBumpMap defines wether the material disables bump or not.
  24883. * @returns - boolean indicating that the submesh is ready or not.
  24884. */
  24885. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24886. /**
  24887. * Checks to see if a texture is used in the material.
  24888. * @param defines the list of "defines" to update.
  24889. * @param scene defines the scene to the material belongs to.
  24890. */
  24891. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24892. /**
  24893. * Binds the material data.
  24894. * @param uniformBuffer defines the Uniform buffer to fill in.
  24895. * @param scene defines the scene the material belongs to.
  24896. * @param engine defines the engine the material belongs to.
  24897. * @param disableBumpMap defines wether the material disables bump or not.
  24898. * @param isFrozen defines wether the material is frozen or not.
  24899. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24900. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24901. * @param subMesh the submesh to bind data for
  24902. */
  24903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24904. /**
  24905. * Checks to see if a texture is used in the material.
  24906. * @param texture - Base texture to use.
  24907. * @returns - Boolean specifying if a texture is used in the material.
  24908. */
  24909. hasTexture(texture: BaseTexture): boolean;
  24910. /**
  24911. * Returns an array of the actively used textures.
  24912. * @param activeTextures Array of BaseTextures
  24913. */
  24914. getActiveTextures(activeTextures: BaseTexture[]): void;
  24915. /**
  24916. * Returns the animatable textures.
  24917. * @param animatables Array of animatable textures.
  24918. */
  24919. getAnimatables(animatables: IAnimatable[]): void;
  24920. /**
  24921. * Disposes the resources of the material.
  24922. * @param forceDisposeTextures - Forces the disposal of all textures.
  24923. */
  24924. dispose(forceDisposeTextures?: boolean): void;
  24925. /**
  24926. * Get the current class name of the texture useful for serialization or dynamic coding.
  24927. * @returns "PBRClearCoatConfiguration"
  24928. */
  24929. getClassName(): string;
  24930. /**
  24931. * Add fallbacks to the effect fallbacks list.
  24932. * @param defines defines the Base texture to use.
  24933. * @param fallbacks defines the current fallback list.
  24934. * @param currentRank defines the current fallback rank.
  24935. * @returns the new fallback rank.
  24936. */
  24937. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24938. /**
  24939. * Add the required uniforms to the current list.
  24940. * @param uniforms defines the current uniform list.
  24941. */
  24942. static AddUniforms(uniforms: string[]): void;
  24943. /**
  24944. * Add the required samplers to the current list.
  24945. * @param samplers defines the current sampler list.
  24946. */
  24947. static AddSamplers(samplers: string[]): void;
  24948. /**
  24949. * Add the required uniforms to the current buffer.
  24950. * @param uniformBuffer defines the current uniform buffer.
  24951. */
  24952. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24953. /**
  24954. * Makes a duplicate of the current configuration into another one.
  24955. * @param clearCoatConfiguration define the config where to copy the info
  24956. */
  24957. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24958. /**
  24959. * Serializes this clear coat configuration.
  24960. * @returns - An object with the serialized config.
  24961. */
  24962. serialize(): any;
  24963. /**
  24964. * Parses a anisotropy Configuration from a serialized object.
  24965. * @param source - Serialized object.
  24966. * @param scene Defines the scene we are parsing for
  24967. * @param rootUrl Defines the rootUrl to load from
  24968. */
  24969. parse(source: any, scene: Scene, rootUrl: string): void;
  24970. }
  24971. }
  24972. declare module BABYLON {
  24973. /**
  24974. * @hidden
  24975. */
  24976. export interface IMaterialAnisotropicDefines {
  24977. ANISOTROPIC: boolean;
  24978. ANISOTROPIC_TEXTURE: boolean;
  24979. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24980. MAINUV1: boolean;
  24981. _areTexturesDirty: boolean;
  24982. _needUVs: boolean;
  24983. }
  24984. /**
  24985. * Define the code related to the anisotropic parameters of the pbr material.
  24986. */
  24987. export class PBRAnisotropicConfiguration {
  24988. private _isEnabled;
  24989. /**
  24990. * Defines if the anisotropy is enabled in the material.
  24991. */
  24992. isEnabled: boolean;
  24993. /**
  24994. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24995. */
  24996. intensity: number;
  24997. /**
  24998. * Defines if the effect is along the tangents, bitangents or in between.
  24999. * By default, the effect is "strectching" the highlights along the tangents.
  25000. */
  25001. direction: Vector2;
  25002. private _texture;
  25003. /**
  25004. * Stores the anisotropy values in a texture.
  25005. * rg is direction (like normal from -1 to 1)
  25006. * b is a intensity
  25007. */
  25008. texture: Nullable<BaseTexture>;
  25009. /** @hidden */
  25010. private _internalMarkAllSubMeshesAsTexturesDirty;
  25011. /** @hidden */
  25012. _markAllSubMeshesAsTexturesDirty(): void;
  25013. /**
  25014. * Instantiate a new istance of anisotropy configuration.
  25015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25016. */
  25017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25018. /**
  25019. * Specifies that the submesh is ready to be used.
  25020. * @param defines the list of "defines" to update.
  25021. * @param scene defines the scene the material belongs to.
  25022. * @returns - boolean indicating that the submesh is ready or not.
  25023. */
  25024. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25025. /**
  25026. * Checks to see if a texture is used in the material.
  25027. * @param defines the list of "defines" to update.
  25028. * @param mesh the mesh we are preparing the defines for.
  25029. * @param scene defines the scene the material belongs to.
  25030. */
  25031. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25032. /**
  25033. * Binds the material data.
  25034. * @param uniformBuffer defines the Uniform buffer to fill in.
  25035. * @param scene defines the scene the material belongs to.
  25036. * @param isFrozen defines wether the material is frozen or not.
  25037. */
  25038. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25039. /**
  25040. * Checks to see if a texture is used in the material.
  25041. * @param texture - Base texture to use.
  25042. * @returns - Boolean specifying if a texture is used in the material.
  25043. */
  25044. hasTexture(texture: BaseTexture): boolean;
  25045. /**
  25046. * Returns an array of the actively used textures.
  25047. * @param activeTextures Array of BaseTextures
  25048. */
  25049. getActiveTextures(activeTextures: BaseTexture[]): void;
  25050. /**
  25051. * Returns the animatable textures.
  25052. * @param animatables Array of animatable textures.
  25053. */
  25054. getAnimatables(animatables: IAnimatable[]): void;
  25055. /**
  25056. * Disposes the resources of the material.
  25057. * @param forceDisposeTextures - Forces the disposal of all textures.
  25058. */
  25059. dispose(forceDisposeTextures?: boolean): void;
  25060. /**
  25061. * Get the current class name of the texture useful for serialization or dynamic coding.
  25062. * @returns "PBRAnisotropicConfiguration"
  25063. */
  25064. getClassName(): string;
  25065. /**
  25066. * Add fallbacks to the effect fallbacks list.
  25067. * @param defines defines the Base texture to use.
  25068. * @param fallbacks defines the current fallback list.
  25069. * @param currentRank defines the current fallback rank.
  25070. * @returns the new fallback rank.
  25071. */
  25072. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25073. /**
  25074. * Add the required uniforms to the current list.
  25075. * @param uniforms defines the current uniform list.
  25076. */
  25077. static AddUniforms(uniforms: string[]): void;
  25078. /**
  25079. * Add the required uniforms to the current buffer.
  25080. * @param uniformBuffer defines the current uniform buffer.
  25081. */
  25082. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25083. /**
  25084. * Add the required samplers to the current list.
  25085. * @param samplers defines the current sampler list.
  25086. */
  25087. static AddSamplers(samplers: string[]): void;
  25088. /**
  25089. * Makes a duplicate of the current configuration into another one.
  25090. * @param anisotropicConfiguration define the config where to copy the info
  25091. */
  25092. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25093. /**
  25094. * Serializes this anisotropy configuration.
  25095. * @returns - An object with the serialized config.
  25096. */
  25097. serialize(): any;
  25098. /**
  25099. * Parses a anisotropy Configuration from a serialized object.
  25100. * @param source - Serialized object.
  25101. * @param scene Defines the scene we are parsing for
  25102. * @param rootUrl Defines the rootUrl to load from
  25103. */
  25104. parse(source: any, scene: Scene, rootUrl: string): void;
  25105. }
  25106. }
  25107. declare module BABYLON {
  25108. /**
  25109. * @hidden
  25110. */
  25111. export interface IMaterialBRDFDefines {
  25112. BRDF_V_HEIGHT_CORRELATED: boolean;
  25113. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25114. SPHERICAL_HARMONICS: boolean;
  25115. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25116. /** @hidden */
  25117. _areMiscDirty: boolean;
  25118. }
  25119. /**
  25120. * Define the code related to the BRDF parameters of the pbr material.
  25121. */
  25122. export class PBRBRDFConfiguration {
  25123. /**
  25124. * Default value used for the energy conservation.
  25125. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25126. */
  25127. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25128. /**
  25129. * Default value used for the Smith Visibility Height Correlated mode.
  25130. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25131. */
  25132. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25133. /**
  25134. * Default value used for the IBL diffuse part.
  25135. * This can help switching back to the polynomials mode globally which is a tiny bit
  25136. * less GPU intensive at the drawback of a lower quality.
  25137. */
  25138. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25139. /**
  25140. * Default value used for activating energy conservation for the specular workflow.
  25141. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25142. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25143. */
  25144. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25145. private _useEnergyConservation;
  25146. /**
  25147. * Defines if the material uses energy conservation.
  25148. */
  25149. useEnergyConservation: boolean;
  25150. private _useSmithVisibilityHeightCorrelated;
  25151. /**
  25152. * LEGACY Mode set to false
  25153. * Defines if the material uses height smith correlated visibility term.
  25154. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25155. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25156. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25157. * Not relying on height correlated will also disable energy conservation.
  25158. */
  25159. useSmithVisibilityHeightCorrelated: boolean;
  25160. private _useSphericalHarmonics;
  25161. /**
  25162. * LEGACY Mode set to false
  25163. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25164. * diffuse part of the IBL.
  25165. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25166. * to the ground truth.
  25167. */
  25168. useSphericalHarmonics: boolean;
  25169. private _useSpecularGlossinessInputEnergyConservation;
  25170. /**
  25171. * Defines if the material uses energy conservation, when the specular workflow is active.
  25172. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25173. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25174. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25175. */
  25176. useSpecularGlossinessInputEnergyConservation: boolean;
  25177. /** @hidden */
  25178. private _internalMarkAllSubMeshesAsMiscDirty;
  25179. /** @hidden */
  25180. _markAllSubMeshesAsMiscDirty(): void;
  25181. /**
  25182. * Instantiate a new istance of clear coat configuration.
  25183. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25184. */
  25185. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25186. /**
  25187. * Checks to see if a texture is used in the material.
  25188. * @param defines the list of "defines" to update.
  25189. */
  25190. prepareDefines(defines: IMaterialBRDFDefines): void;
  25191. /**
  25192. * Get the current class name of the texture useful for serialization or dynamic coding.
  25193. * @returns "PBRClearCoatConfiguration"
  25194. */
  25195. getClassName(): string;
  25196. /**
  25197. * Makes a duplicate of the current configuration into another one.
  25198. * @param brdfConfiguration define the config where to copy the info
  25199. */
  25200. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25201. /**
  25202. * Serializes this BRDF configuration.
  25203. * @returns - An object with the serialized config.
  25204. */
  25205. serialize(): any;
  25206. /**
  25207. * Parses a anisotropy Configuration from a serialized object.
  25208. * @param source - Serialized object.
  25209. * @param scene Defines the scene we are parsing for
  25210. * @param rootUrl Defines the rootUrl to load from
  25211. */
  25212. parse(source: any, scene: Scene, rootUrl: string): void;
  25213. }
  25214. }
  25215. declare module BABYLON {
  25216. /**
  25217. * @hidden
  25218. */
  25219. export interface IMaterialSheenDefines {
  25220. SHEEN: boolean;
  25221. SHEEN_TEXTURE: boolean;
  25222. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25223. SHEEN_TEXTUREDIRECTUV: number;
  25224. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25225. SHEEN_LINKWITHALBEDO: boolean;
  25226. SHEEN_ROUGHNESS: boolean;
  25227. SHEEN_ALBEDOSCALING: boolean;
  25228. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25229. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25230. /** @hidden */
  25231. _areTexturesDirty: boolean;
  25232. }
  25233. /**
  25234. * Define the code related to the Sheen parameters of the pbr material.
  25235. */
  25236. export class PBRSheenConfiguration {
  25237. private _isEnabled;
  25238. /**
  25239. * Defines if the material uses sheen.
  25240. */
  25241. isEnabled: boolean;
  25242. private _linkSheenWithAlbedo;
  25243. /**
  25244. * Defines if the sheen is linked to the sheen color.
  25245. */
  25246. linkSheenWithAlbedo: boolean;
  25247. /**
  25248. * Defines the sheen intensity.
  25249. */
  25250. intensity: number;
  25251. /**
  25252. * Defines the sheen color.
  25253. */
  25254. color: Color3;
  25255. private _texture;
  25256. /**
  25257. * Stores the sheen tint values in a texture.
  25258. * rgb is tint
  25259. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25260. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25261. */
  25262. texture: Nullable<BaseTexture>;
  25263. private _useRoughnessFromMainTexture;
  25264. /**
  25265. * Indicates that the alpha channel of the texture property will be used for roughness.
  25266. * Has no effect if the roughness (and texture!) property is not defined
  25267. */
  25268. useRoughnessFromMainTexture: boolean;
  25269. private _roughness;
  25270. /**
  25271. * Defines the sheen roughness.
  25272. * It is not taken into account if linkSheenWithAlbedo is true.
  25273. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25274. */
  25275. roughness: Nullable<number>;
  25276. private _textureRoughness;
  25277. /**
  25278. * Stores the sheen roughness in a texture.
  25279. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25280. */
  25281. textureRoughness: Nullable<BaseTexture>;
  25282. private _albedoScaling;
  25283. /**
  25284. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25285. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25286. * making it easier to setup and tweak the effect
  25287. */
  25288. albedoScaling: boolean;
  25289. /** @hidden */
  25290. private _internalMarkAllSubMeshesAsTexturesDirty;
  25291. /** @hidden */
  25292. _markAllSubMeshesAsTexturesDirty(): void;
  25293. /**
  25294. * Instantiate a new istance of clear coat configuration.
  25295. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25296. */
  25297. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25298. /**
  25299. * Specifies that the submesh is ready to be used.
  25300. * @param defines the list of "defines" to update.
  25301. * @param scene defines the scene the material belongs to.
  25302. * @returns - boolean indicating that the submesh is ready or not.
  25303. */
  25304. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25305. /**
  25306. * Checks to see if a texture is used in the material.
  25307. * @param defines the list of "defines" to update.
  25308. * @param scene defines the scene the material belongs to.
  25309. */
  25310. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25311. /**
  25312. * Binds the material data.
  25313. * @param uniformBuffer defines the Uniform buffer to fill in.
  25314. * @param scene defines the scene the material belongs to.
  25315. * @param isFrozen defines wether the material is frozen or not.
  25316. * @param subMesh the submesh to bind data for
  25317. */
  25318. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25319. /**
  25320. * Checks to see if a texture is used in the material.
  25321. * @param texture - Base texture to use.
  25322. * @returns - Boolean specifying if a texture is used in the material.
  25323. */
  25324. hasTexture(texture: BaseTexture): boolean;
  25325. /**
  25326. * Returns an array of the actively used textures.
  25327. * @param activeTextures Array of BaseTextures
  25328. */
  25329. getActiveTextures(activeTextures: BaseTexture[]): void;
  25330. /**
  25331. * Returns the animatable textures.
  25332. * @param animatables Array of animatable textures.
  25333. */
  25334. getAnimatables(animatables: IAnimatable[]): void;
  25335. /**
  25336. * Disposes the resources of the material.
  25337. * @param forceDisposeTextures - Forces the disposal of all textures.
  25338. */
  25339. dispose(forceDisposeTextures?: boolean): void;
  25340. /**
  25341. * Get the current class name of the texture useful for serialization or dynamic coding.
  25342. * @returns "PBRSheenConfiguration"
  25343. */
  25344. getClassName(): string;
  25345. /**
  25346. * Add fallbacks to the effect fallbacks list.
  25347. * @param defines defines the Base texture to use.
  25348. * @param fallbacks defines the current fallback list.
  25349. * @param currentRank defines the current fallback rank.
  25350. * @returns the new fallback rank.
  25351. */
  25352. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25353. /**
  25354. * Add the required uniforms to the current list.
  25355. * @param uniforms defines the current uniform list.
  25356. */
  25357. static AddUniforms(uniforms: string[]): void;
  25358. /**
  25359. * Add the required uniforms to the current buffer.
  25360. * @param uniformBuffer defines the current uniform buffer.
  25361. */
  25362. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25363. /**
  25364. * Add the required samplers to the current list.
  25365. * @param samplers defines the current sampler list.
  25366. */
  25367. static AddSamplers(samplers: string[]): void;
  25368. /**
  25369. * Makes a duplicate of the current configuration into another one.
  25370. * @param sheenConfiguration define the config where to copy the info
  25371. */
  25372. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25373. /**
  25374. * Serializes this BRDF configuration.
  25375. * @returns - An object with the serialized config.
  25376. */
  25377. serialize(): any;
  25378. /**
  25379. * Parses a anisotropy Configuration from a serialized object.
  25380. * @param source - Serialized object.
  25381. * @param scene Defines the scene we are parsing for
  25382. * @param rootUrl Defines the rootUrl to load from
  25383. */
  25384. parse(source: any, scene: Scene, rootUrl: string): void;
  25385. }
  25386. }
  25387. declare module BABYLON {
  25388. /**
  25389. * @hidden
  25390. */
  25391. export interface IMaterialSubSurfaceDefines {
  25392. SUBSURFACE: boolean;
  25393. SS_REFRACTION: boolean;
  25394. SS_TRANSLUCENCY: boolean;
  25395. SS_SCATTERING: boolean;
  25396. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25397. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25398. SS_REFRACTIONMAP_3D: boolean;
  25399. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25400. SS_LODINREFRACTIONALPHA: boolean;
  25401. SS_GAMMAREFRACTION: boolean;
  25402. SS_RGBDREFRACTION: boolean;
  25403. SS_LINEARSPECULARREFRACTION: boolean;
  25404. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25405. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25406. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25407. /** @hidden */
  25408. _areTexturesDirty: boolean;
  25409. }
  25410. /**
  25411. * Define the code related to the sub surface parameters of the pbr material.
  25412. */
  25413. export class PBRSubSurfaceConfiguration {
  25414. private _isRefractionEnabled;
  25415. /**
  25416. * Defines if the refraction is enabled in the material.
  25417. */
  25418. isRefractionEnabled: boolean;
  25419. private _isTranslucencyEnabled;
  25420. /**
  25421. * Defines if the translucency is enabled in the material.
  25422. */
  25423. isTranslucencyEnabled: boolean;
  25424. private _isScatteringEnabled;
  25425. /**
  25426. * Defines if the sub surface scattering is enabled in the material.
  25427. */
  25428. isScatteringEnabled: boolean;
  25429. private _scatteringDiffusionProfileIndex;
  25430. /**
  25431. * Diffusion profile for subsurface scattering.
  25432. * Useful for better scattering in the skins or foliages.
  25433. */
  25434. get scatteringDiffusionProfile(): Nullable<Color3>;
  25435. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25436. /**
  25437. * Defines the refraction intensity of the material.
  25438. * The refraction when enabled replaces the Diffuse part of the material.
  25439. * The intensity helps transitionning between diffuse and refraction.
  25440. */
  25441. refractionIntensity: number;
  25442. /**
  25443. * Defines the translucency intensity of the material.
  25444. * When translucency has been enabled, this defines how much of the "translucency"
  25445. * is addded to the diffuse part of the material.
  25446. */
  25447. translucencyIntensity: number;
  25448. /**
  25449. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25450. */
  25451. useAlbedoToTintRefraction: boolean;
  25452. private _thicknessTexture;
  25453. /**
  25454. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25455. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25456. * 0 would mean minimumThickness
  25457. * 1 would mean maximumThickness
  25458. * The other channels might be use as a mask to vary the different effects intensity.
  25459. */
  25460. thicknessTexture: Nullable<BaseTexture>;
  25461. private _refractionTexture;
  25462. /**
  25463. * Defines the texture to use for refraction.
  25464. */
  25465. refractionTexture: Nullable<BaseTexture>;
  25466. private _indexOfRefraction;
  25467. /**
  25468. * Index of refraction of the material base layer.
  25469. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25470. *
  25471. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25472. *
  25473. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25474. */
  25475. indexOfRefraction: number;
  25476. private _volumeIndexOfRefraction;
  25477. /**
  25478. * Index of refraction of the material's volume.
  25479. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25480. *
  25481. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25482. * the volume will use the same IOR as the surface.
  25483. */
  25484. get volumeIndexOfRefraction(): number;
  25485. set volumeIndexOfRefraction(value: number);
  25486. private _invertRefractionY;
  25487. /**
  25488. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25489. */
  25490. invertRefractionY: boolean;
  25491. private _linkRefractionWithTransparency;
  25492. /**
  25493. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25494. * Materials half opaque for instance using refraction could benefit from this control.
  25495. */
  25496. linkRefractionWithTransparency: boolean;
  25497. /**
  25498. * Defines the minimum thickness stored in the thickness map.
  25499. * If no thickness map is defined, this value will be used to simulate thickness.
  25500. */
  25501. minimumThickness: number;
  25502. /**
  25503. * Defines the maximum thickness stored in the thickness map.
  25504. */
  25505. maximumThickness: number;
  25506. /**
  25507. * Defines the volume tint of the material.
  25508. * This is used for both translucency and scattering.
  25509. */
  25510. tintColor: Color3;
  25511. /**
  25512. * Defines the distance at which the tint color should be found in the media.
  25513. * This is used for refraction only.
  25514. */
  25515. tintColorAtDistance: number;
  25516. /**
  25517. * Defines how far each channel transmit through the media.
  25518. * It is defined as a color to simplify it selection.
  25519. */
  25520. diffusionDistance: Color3;
  25521. private _useMaskFromThicknessTexture;
  25522. /**
  25523. * Stores the intensity of the different subsurface effects in the thickness texture.
  25524. * * the green channel is the translucency intensity.
  25525. * * the blue channel is the scattering intensity.
  25526. * * the alpha channel is the refraction intensity.
  25527. */
  25528. useMaskFromThicknessTexture: boolean;
  25529. private _scene;
  25530. /** @hidden */
  25531. private _internalMarkAllSubMeshesAsTexturesDirty;
  25532. private _internalMarkScenePrePassDirty;
  25533. /** @hidden */
  25534. _markAllSubMeshesAsTexturesDirty(): void;
  25535. /** @hidden */
  25536. _markScenePrePassDirty(): void;
  25537. /**
  25538. * Instantiate a new istance of sub surface configuration.
  25539. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25540. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25541. * @param scene The scene
  25542. */
  25543. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25544. /**
  25545. * Gets wehter the submesh is ready to be used or not.
  25546. * @param defines the list of "defines" to update.
  25547. * @param scene defines the scene the material belongs to.
  25548. * @returns - boolean indicating that the submesh is ready or not.
  25549. */
  25550. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25551. /**
  25552. * Checks to see if a texture is used in the material.
  25553. * @param defines the list of "defines" to update.
  25554. * @param scene defines the scene to the material belongs to.
  25555. */
  25556. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25557. /**
  25558. * Binds the material data.
  25559. * @param uniformBuffer defines the Uniform buffer to fill in.
  25560. * @param scene defines the scene the material belongs to.
  25561. * @param engine defines the engine the material belongs to.
  25562. * @param isFrozen defines whether the material is frozen or not.
  25563. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25564. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25565. */
  25566. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25567. /**
  25568. * Unbinds the material from the mesh.
  25569. * @param activeEffect defines the effect that should be unbound from.
  25570. * @returns true if unbound, otherwise false
  25571. */
  25572. unbind(activeEffect: Effect): boolean;
  25573. /**
  25574. * Returns the texture used for refraction or null if none is used.
  25575. * @param scene defines the scene the material belongs to.
  25576. * @returns - Refraction texture if present. If no refraction texture and refraction
  25577. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25578. */
  25579. private _getRefractionTexture;
  25580. /**
  25581. * Returns true if alpha blending should be disabled.
  25582. */
  25583. get disableAlphaBlending(): boolean;
  25584. /**
  25585. * Fills the list of render target textures.
  25586. * @param renderTargets the list of render targets to update
  25587. */
  25588. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25589. /**
  25590. * Checks to see if a texture is used in the material.
  25591. * @param texture - Base texture to use.
  25592. * @returns - Boolean specifying if a texture is used in the material.
  25593. */
  25594. hasTexture(texture: BaseTexture): boolean;
  25595. /**
  25596. * Gets a boolean indicating that current material needs to register RTT
  25597. * @returns true if this uses a render target otherwise false.
  25598. */
  25599. hasRenderTargetTextures(): boolean;
  25600. /**
  25601. * Returns an array of the actively used textures.
  25602. * @param activeTextures Array of BaseTextures
  25603. */
  25604. getActiveTextures(activeTextures: BaseTexture[]): void;
  25605. /**
  25606. * Returns the animatable textures.
  25607. * @param animatables Array of animatable textures.
  25608. */
  25609. getAnimatables(animatables: IAnimatable[]): void;
  25610. /**
  25611. * Disposes the resources of the material.
  25612. * @param forceDisposeTextures - Forces the disposal of all textures.
  25613. */
  25614. dispose(forceDisposeTextures?: boolean): void;
  25615. /**
  25616. * Get the current class name of the texture useful for serialization or dynamic coding.
  25617. * @returns "PBRSubSurfaceConfiguration"
  25618. */
  25619. getClassName(): string;
  25620. /**
  25621. * Add fallbacks to the effect fallbacks list.
  25622. * @param defines defines the Base texture to use.
  25623. * @param fallbacks defines the current fallback list.
  25624. * @param currentRank defines the current fallback rank.
  25625. * @returns the new fallback rank.
  25626. */
  25627. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25628. /**
  25629. * Add the required uniforms to the current list.
  25630. * @param uniforms defines the current uniform list.
  25631. */
  25632. static AddUniforms(uniforms: string[]): void;
  25633. /**
  25634. * Add the required samplers to the current list.
  25635. * @param samplers defines the current sampler list.
  25636. */
  25637. static AddSamplers(samplers: string[]): void;
  25638. /**
  25639. * Add the required uniforms to the current buffer.
  25640. * @param uniformBuffer defines the current uniform buffer.
  25641. */
  25642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25643. /**
  25644. * Makes a duplicate of the current configuration into another one.
  25645. * @param configuration define the config where to copy the info
  25646. */
  25647. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25648. /**
  25649. * Serializes this Sub Surface configuration.
  25650. * @returns - An object with the serialized config.
  25651. */
  25652. serialize(): any;
  25653. /**
  25654. * Parses a anisotropy Configuration from a serialized object.
  25655. * @param source - Serialized object.
  25656. * @param scene Defines the scene we are parsing for
  25657. * @param rootUrl Defines the rootUrl to load from
  25658. */
  25659. parse(source: any, scene: Scene, rootUrl: string): void;
  25660. }
  25661. }
  25662. declare module BABYLON {
  25663. /**
  25664. * Class representing spherical harmonics coefficients to the 3rd degree
  25665. */
  25666. export class SphericalHarmonics {
  25667. /**
  25668. * Defines whether or not the harmonics have been prescaled for rendering.
  25669. */
  25670. preScaled: boolean;
  25671. /**
  25672. * The l0,0 coefficients of the spherical harmonics
  25673. */
  25674. l00: Vector3;
  25675. /**
  25676. * The l1,-1 coefficients of the spherical harmonics
  25677. */
  25678. l1_1: Vector3;
  25679. /**
  25680. * The l1,0 coefficients of the spherical harmonics
  25681. */
  25682. l10: Vector3;
  25683. /**
  25684. * The l1,1 coefficients of the spherical harmonics
  25685. */
  25686. l11: Vector3;
  25687. /**
  25688. * The l2,-2 coefficients of the spherical harmonics
  25689. */
  25690. l2_2: Vector3;
  25691. /**
  25692. * The l2,-1 coefficients of the spherical harmonics
  25693. */
  25694. l2_1: Vector3;
  25695. /**
  25696. * The l2,0 coefficients of the spherical harmonics
  25697. */
  25698. l20: Vector3;
  25699. /**
  25700. * The l2,1 coefficients of the spherical harmonics
  25701. */
  25702. l21: Vector3;
  25703. /**
  25704. * The l2,2 coefficients of the spherical harmonics
  25705. */
  25706. l22: Vector3;
  25707. /**
  25708. * Adds a light to the spherical harmonics
  25709. * @param direction the direction of the light
  25710. * @param color the color of the light
  25711. * @param deltaSolidAngle the delta solid angle of the light
  25712. */
  25713. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25714. /**
  25715. * Scales the spherical harmonics by the given amount
  25716. * @param scale the amount to scale
  25717. */
  25718. scaleInPlace(scale: number): void;
  25719. /**
  25720. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25721. *
  25722. * ```
  25723. * E_lm = A_l * L_lm
  25724. * ```
  25725. *
  25726. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25727. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25728. * the scaling factors are given in equation 9.
  25729. */
  25730. convertIncidentRadianceToIrradiance(): void;
  25731. /**
  25732. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25733. *
  25734. * ```
  25735. * L = (1/pi) * E * rho
  25736. * ```
  25737. *
  25738. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25739. */
  25740. convertIrradianceToLambertianRadiance(): void;
  25741. /**
  25742. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25743. * required operations at run time.
  25744. *
  25745. * This is simply done by scaling back the SH with Ylm constants parameter.
  25746. * The trigonometric part being applied by the shader at run time.
  25747. */
  25748. preScaleForRendering(): void;
  25749. /**
  25750. * Constructs a spherical harmonics from an array.
  25751. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25752. * @returns the spherical harmonics
  25753. */
  25754. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25755. /**
  25756. * Gets the spherical harmonics from polynomial
  25757. * @param polynomial the spherical polynomial
  25758. * @returns the spherical harmonics
  25759. */
  25760. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25761. }
  25762. /**
  25763. * Class representing spherical polynomial coefficients to the 3rd degree
  25764. */
  25765. export class SphericalPolynomial {
  25766. private _harmonics;
  25767. /**
  25768. * The spherical harmonics used to create the polynomials.
  25769. */
  25770. get preScaledHarmonics(): SphericalHarmonics;
  25771. /**
  25772. * The x coefficients of the spherical polynomial
  25773. */
  25774. x: Vector3;
  25775. /**
  25776. * The y coefficients of the spherical polynomial
  25777. */
  25778. y: Vector3;
  25779. /**
  25780. * The z coefficients of the spherical polynomial
  25781. */
  25782. z: Vector3;
  25783. /**
  25784. * The xx coefficients of the spherical polynomial
  25785. */
  25786. xx: Vector3;
  25787. /**
  25788. * The yy coefficients of the spherical polynomial
  25789. */
  25790. yy: Vector3;
  25791. /**
  25792. * The zz coefficients of the spherical polynomial
  25793. */
  25794. zz: Vector3;
  25795. /**
  25796. * The xy coefficients of the spherical polynomial
  25797. */
  25798. xy: Vector3;
  25799. /**
  25800. * The yz coefficients of the spherical polynomial
  25801. */
  25802. yz: Vector3;
  25803. /**
  25804. * The zx coefficients of the spherical polynomial
  25805. */
  25806. zx: Vector3;
  25807. /**
  25808. * Adds an ambient color to the spherical polynomial
  25809. * @param color the color to add
  25810. */
  25811. addAmbient(color: Color3): void;
  25812. /**
  25813. * Scales the spherical polynomial by the given amount
  25814. * @param scale the amount to scale
  25815. */
  25816. scaleInPlace(scale: number): void;
  25817. /**
  25818. * Gets the spherical polynomial from harmonics
  25819. * @param harmonics the spherical harmonics
  25820. * @returns the spherical polynomial
  25821. */
  25822. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25823. /**
  25824. * Constructs a spherical polynomial from an array.
  25825. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25826. * @returns the spherical polynomial
  25827. */
  25828. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25829. }
  25830. }
  25831. declare module BABYLON {
  25832. /**
  25833. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25834. */
  25835. export interface CubeMapInfo {
  25836. /**
  25837. * The pixel array for the front face.
  25838. * This is stored in format, left to right, up to down format.
  25839. */
  25840. front: Nullable<ArrayBufferView>;
  25841. /**
  25842. * The pixel array for the back face.
  25843. * This is stored in format, left to right, up to down format.
  25844. */
  25845. back: Nullable<ArrayBufferView>;
  25846. /**
  25847. * The pixel array for the left face.
  25848. * This is stored in format, left to right, up to down format.
  25849. */
  25850. left: Nullable<ArrayBufferView>;
  25851. /**
  25852. * The pixel array for the right face.
  25853. * This is stored in format, left to right, up to down format.
  25854. */
  25855. right: Nullable<ArrayBufferView>;
  25856. /**
  25857. * The pixel array for the up face.
  25858. * This is stored in format, left to right, up to down format.
  25859. */
  25860. up: Nullable<ArrayBufferView>;
  25861. /**
  25862. * The pixel array for the down face.
  25863. * This is stored in format, left to right, up to down format.
  25864. */
  25865. down: Nullable<ArrayBufferView>;
  25866. /**
  25867. * The size of the cubemap stored.
  25868. *
  25869. * Each faces will be size * size pixels.
  25870. */
  25871. size: number;
  25872. /**
  25873. * The format of the texture.
  25874. *
  25875. * RGBA, RGB.
  25876. */
  25877. format: number;
  25878. /**
  25879. * The type of the texture data.
  25880. *
  25881. * UNSIGNED_INT, FLOAT.
  25882. */
  25883. type: number;
  25884. /**
  25885. * Specifies whether the texture is in gamma space.
  25886. */
  25887. gammaSpace: boolean;
  25888. }
  25889. /**
  25890. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25891. */
  25892. export class PanoramaToCubeMapTools {
  25893. private static FACE_LEFT;
  25894. private static FACE_RIGHT;
  25895. private static FACE_FRONT;
  25896. private static FACE_BACK;
  25897. private static FACE_DOWN;
  25898. private static FACE_UP;
  25899. /**
  25900. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25901. *
  25902. * @param float32Array The source data.
  25903. * @param inputWidth The width of the input panorama.
  25904. * @param inputHeight The height of the input panorama.
  25905. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25906. * @return The cubemap data
  25907. */
  25908. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25909. private static CreateCubemapTexture;
  25910. private static CalcProjectionSpherical;
  25911. }
  25912. }
  25913. declare module BABYLON {
  25914. /**
  25915. * Helper class dealing with the extraction of spherical polynomial dataArray
  25916. * from a cube map.
  25917. */
  25918. export class CubeMapToSphericalPolynomialTools {
  25919. private static FileFaces;
  25920. /**
  25921. * Converts a texture to the according Spherical Polynomial data.
  25922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25923. *
  25924. * @param texture The texture to extract the information from.
  25925. * @return The Spherical Polynomial data.
  25926. */
  25927. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25928. /**
  25929. * Converts a cubemap to the according Spherical Polynomial data.
  25930. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25931. *
  25932. * @param cubeInfo The Cube map to extract the information from.
  25933. * @return The Spherical Polynomial data.
  25934. */
  25935. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25936. }
  25937. }
  25938. declare module BABYLON {
  25939. interface BaseTexture {
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. }
  25947. }
  25948. declare module BABYLON {
  25949. /** @hidden */
  25950. export var pbrFragmentDeclaration: {
  25951. name: string;
  25952. shader: string;
  25953. };
  25954. }
  25955. declare module BABYLON {
  25956. /** @hidden */
  25957. export var pbrUboDeclaration: {
  25958. name: string;
  25959. shader: string;
  25960. };
  25961. }
  25962. declare module BABYLON {
  25963. /** @hidden */
  25964. export var pbrFragmentExtraDeclaration: {
  25965. name: string;
  25966. shader: string;
  25967. };
  25968. }
  25969. declare module BABYLON {
  25970. /** @hidden */
  25971. export var pbrFragmentSamplersDeclaration: {
  25972. name: string;
  25973. shader: string;
  25974. };
  25975. }
  25976. declare module BABYLON {
  25977. /** @hidden */
  25978. export var subSurfaceScatteringFunctions: {
  25979. name: string;
  25980. shader: string;
  25981. };
  25982. }
  25983. declare module BABYLON {
  25984. /** @hidden */
  25985. export var importanceSampling: {
  25986. name: string;
  25987. shader: string;
  25988. };
  25989. }
  25990. declare module BABYLON {
  25991. /** @hidden */
  25992. export var pbrHelperFunctions: {
  25993. name: string;
  25994. shader: string;
  25995. };
  25996. }
  25997. declare module BABYLON {
  25998. /** @hidden */
  25999. export var harmonicsFunctions: {
  26000. name: string;
  26001. shader: string;
  26002. };
  26003. }
  26004. declare module BABYLON {
  26005. /** @hidden */
  26006. export var pbrDirectLightingSetupFunctions: {
  26007. name: string;
  26008. shader: string;
  26009. };
  26010. }
  26011. declare module BABYLON {
  26012. /** @hidden */
  26013. export var pbrDirectLightingFalloffFunctions: {
  26014. name: string;
  26015. shader: string;
  26016. };
  26017. }
  26018. declare module BABYLON {
  26019. /** @hidden */
  26020. export var pbrBRDFFunctions: {
  26021. name: string;
  26022. shader: string;
  26023. };
  26024. }
  26025. declare module BABYLON {
  26026. /** @hidden */
  26027. export var hdrFilteringFunctions: {
  26028. name: string;
  26029. shader: string;
  26030. };
  26031. }
  26032. declare module BABYLON {
  26033. /** @hidden */
  26034. export var pbrDirectLightingFunctions: {
  26035. name: string;
  26036. shader: string;
  26037. };
  26038. }
  26039. declare module BABYLON {
  26040. /** @hidden */
  26041. export var pbrIBLFunctions: {
  26042. name: string;
  26043. shader: string;
  26044. };
  26045. }
  26046. declare module BABYLON {
  26047. /** @hidden */
  26048. export var pbrBlockAlbedoOpacity: {
  26049. name: string;
  26050. shader: string;
  26051. };
  26052. }
  26053. declare module BABYLON {
  26054. /** @hidden */
  26055. export var pbrBlockReflectivity: {
  26056. name: string;
  26057. shader: string;
  26058. };
  26059. }
  26060. declare module BABYLON {
  26061. /** @hidden */
  26062. export var pbrBlockAmbientOcclusion: {
  26063. name: string;
  26064. shader: string;
  26065. };
  26066. }
  26067. declare module BABYLON {
  26068. /** @hidden */
  26069. export var pbrBlockAlphaFresnel: {
  26070. name: string;
  26071. shader: string;
  26072. };
  26073. }
  26074. declare module BABYLON {
  26075. /** @hidden */
  26076. export var pbrBlockAnisotropic: {
  26077. name: string;
  26078. shader: string;
  26079. };
  26080. }
  26081. declare module BABYLON {
  26082. /** @hidden */
  26083. export var pbrBlockReflection: {
  26084. name: string;
  26085. shader: string;
  26086. };
  26087. }
  26088. declare module BABYLON {
  26089. /** @hidden */
  26090. export var pbrBlockSheen: {
  26091. name: string;
  26092. shader: string;
  26093. };
  26094. }
  26095. declare module BABYLON {
  26096. /** @hidden */
  26097. export var pbrBlockClearcoat: {
  26098. name: string;
  26099. shader: string;
  26100. };
  26101. }
  26102. declare module BABYLON {
  26103. /** @hidden */
  26104. export var pbrBlockSubSurface: {
  26105. name: string;
  26106. shader: string;
  26107. };
  26108. }
  26109. declare module BABYLON {
  26110. /** @hidden */
  26111. export var pbrBlockNormalGeometric: {
  26112. name: string;
  26113. shader: string;
  26114. };
  26115. }
  26116. declare module BABYLON {
  26117. /** @hidden */
  26118. export var pbrBlockNormalFinal: {
  26119. name: string;
  26120. shader: string;
  26121. };
  26122. }
  26123. declare module BABYLON {
  26124. /** @hidden */
  26125. export var pbrBlockLightmapInit: {
  26126. name: string;
  26127. shader: string;
  26128. };
  26129. }
  26130. declare module BABYLON {
  26131. /** @hidden */
  26132. export var pbrBlockGeometryInfo: {
  26133. name: string;
  26134. shader: string;
  26135. };
  26136. }
  26137. declare module BABYLON {
  26138. /** @hidden */
  26139. export var pbrBlockReflectance0: {
  26140. name: string;
  26141. shader: string;
  26142. };
  26143. }
  26144. declare module BABYLON {
  26145. /** @hidden */
  26146. export var pbrBlockReflectance: {
  26147. name: string;
  26148. shader: string;
  26149. };
  26150. }
  26151. declare module BABYLON {
  26152. /** @hidden */
  26153. export var pbrBlockDirectLighting: {
  26154. name: string;
  26155. shader: string;
  26156. };
  26157. }
  26158. declare module BABYLON {
  26159. /** @hidden */
  26160. export var pbrBlockFinalLitComponents: {
  26161. name: string;
  26162. shader: string;
  26163. };
  26164. }
  26165. declare module BABYLON {
  26166. /** @hidden */
  26167. export var pbrBlockFinalUnlitComponents: {
  26168. name: string;
  26169. shader: string;
  26170. };
  26171. }
  26172. declare module BABYLON {
  26173. /** @hidden */
  26174. export var pbrBlockFinalColorComposition: {
  26175. name: string;
  26176. shader: string;
  26177. };
  26178. }
  26179. declare module BABYLON {
  26180. /** @hidden */
  26181. export var pbrBlockImageProcessing: {
  26182. name: string;
  26183. shader: string;
  26184. };
  26185. }
  26186. declare module BABYLON {
  26187. /** @hidden */
  26188. export var pbrDebug: {
  26189. name: string;
  26190. shader: string;
  26191. };
  26192. }
  26193. declare module BABYLON {
  26194. /** @hidden */
  26195. export var pbrPixelShader: {
  26196. name: string;
  26197. shader: string;
  26198. };
  26199. }
  26200. declare module BABYLON {
  26201. /** @hidden */
  26202. export var pbrVertexDeclaration: {
  26203. name: string;
  26204. shader: string;
  26205. };
  26206. }
  26207. declare module BABYLON {
  26208. /** @hidden */
  26209. export var pbrVertexShader: {
  26210. name: string;
  26211. shader: string;
  26212. };
  26213. }
  26214. declare module BABYLON {
  26215. /**
  26216. * Manages the defines for the PBR Material.
  26217. * @hidden
  26218. */
  26219. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26220. PBR: boolean;
  26221. NUM_SAMPLES: string;
  26222. REALTIME_FILTERING: boolean;
  26223. MAINUV1: boolean;
  26224. MAINUV2: boolean;
  26225. UV1: boolean;
  26226. UV2: boolean;
  26227. ALBEDO: boolean;
  26228. GAMMAALBEDO: boolean;
  26229. ALBEDODIRECTUV: number;
  26230. VERTEXCOLOR: boolean;
  26231. DETAIL: boolean;
  26232. DETAILDIRECTUV: number;
  26233. DETAIL_NORMALBLENDMETHOD: number;
  26234. AMBIENT: boolean;
  26235. AMBIENTDIRECTUV: number;
  26236. AMBIENTINGRAYSCALE: boolean;
  26237. OPACITY: boolean;
  26238. VERTEXALPHA: boolean;
  26239. OPACITYDIRECTUV: number;
  26240. OPACITYRGB: boolean;
  26241. ALPHATEST: boolean;
  26242. DEPTHPREPASS: boolean;
  26243. ALPHABLEND: boolean;
  26244. ALPHAFROMALBEDO: boolean;
  26245. ALPHATESTVALUE: string;
  26246. SPECULAROVERALPHA: boolean;
  26247. RADIANCEOVERALPHA: boolean;
  26248. ALPHAFRESNEL: boolean;
  26249. LINEARALPHAFRESNEL: boolean;
  26250. PREMULTIPLYALPHA: boolean;
  26251. EMISSIVE: boolean;
  26252. EMISSIVEDIRECTUV: number;
  26253. REFLECTIVITY: boolean;
  26254. REFLECTIVITYDIRECTUV: number;
  26255. SPECULARTERM: boolean;
  26256. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26257. MICROSURFACEAUTOMATIC: boolean;
  26258. LODBASEDMICROSFURACE: boolean;
  26259. MICROSURFACEMAP: boolean;
  26260. MICROSURFACEMAPDIRECTUV: number;
  26261. METALLICWORKFLOW: boolean;
  26262. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26263. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26264. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26265. AOSTOREINMETALMAPRED: boolean;
  26266. METALLIC_REFLECTANCE: boolean;
  26267. METALLIC_REFLECTANCEDIRECTUV: number;
  26268. ENVIRONMENTBRDF: boolean;
  26269. ENVIRONMENTBRDF_RGBD: boolean;
  26270. NORMAL: boolean;
  26271. TANGENT: boolean;
  26272. BUMP: boolean;
  26273. BUMPDIRECTUV: number;
  26274. OBJECTSPACE_NORMALMAP: boolean;
  26275. PARALLAX: boolean;
  26276. PARALLAXOCCLUSION: boolean;
  26277. NORMALXYSCALE: boolean;
  26278. LIGHTMAP: boolean;
  26279. LIGHTMAPDIRECTUV: number;
  26280. USELIGHTMAPASSHADOWMAP: boolean;
  26281. GAMMALIGHTMAP: boolean;
  26282. RGBDLIGHTMAP: boolean;
  26283. REFLECTION: boolean;
  26284. REFLECTIONMAP_3D: boolean;
  26285. REFLECTIONMAP_SPHERICAL: boolean;
  26286. REFLECTIONMAP_PLANAR: boolean;
  26287. REFLECTIONMAP_CUBIC: boolean;
  26288. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26289. REFLECTIONMAP_PROJECTION: boolean;
  26290. REFLECTIONMAP_SKYBOX: boolean;
  26291. REFLECTIONMAP_EXPLICIT: boolean;
  26292. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26293. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26294. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26295. INVERTCUBICMAP: boolean;
  26296. USESPHERICALFROMREFLECTIONMAP: boolean;
  26297. USEIRRADIANCEMAP: boolean;
  26298. SPHERICAL_HARMONICS: boolean;
  26299. USESPHERICALINVERTEX: boolean;
  26300. REFLECTIONMAP_OPPOSITEZ: boolean;
  26301. LODINREFLECTIONALPHA: boolean;
  26302. GAMMAREFLECTION: boolean;
  26303. RGBDREFLECTION: boolean;
  26304. LINEARSPECULARREFLECTION: boolean;
  26305. RADIANCEOCCLUSION: boolean;
  26306. HORIZONOCCLUSION: boolean;
  26307. INSTANCES: boolean;
  26308. THIN_INSTANCES: boolean;
  26309. PREPASS: boolean;
  26310. PREPASS_IRRADIANCE: boolean;
  26311. PREPASS_IRRADIANCE_INDEX: number;
  26312. PREPASS_ALBEDO: boolean;
  26313. PREPASS_ALBEDO_INDEX: number;
  26314. PREPASS_DEPTHNORMAL: boolean;
  26315. PREPASS_DEPTHNORMAL_INDEX: number;
  26316. PREPASS_POSITION: boolean;
  26317. PREPASS_POSITION_INDEX: number;
  26318. PREPASS_VELOCITY: boolean;
  26319. PREPASS_VELOCITY_INDEX: number;
  26320. PREPASS_REFLECTIVITY: boolean;
  26321. PREPASS_REFLECTIVITY_INDEX: number;
  26322. SCENE_MRT_COUNT: number;
  26323. NUM_BONE_INFLUENCERS: number;
  26324. BonesPerMesh: number;
  26325. BONETEXTURE: boolean;
  26326. BONES_VELOCITY_ENABLED: boolean;
  26327. NONUNIFORMSCALING: boolean;
  26328. MORPHTARGETS: boolean;
  26329. MORPHTARGETS_NORMAL: boolean;
  26330. MORPHTARGETS_TANGENT: boolean;
  26331. MORPHTARGETS_UV: boolean;
  26332. NUM_MORPH_INFLUENCERS: number;
  26333. IMAGEPROCESSING: boolean;
  26334. VIGNETTE: boolean;
  26335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26336. VIGNETTEBLENDMODEOPAQUE: boolean;
  26337. TONEMAPPING: boolean;
  26338. TONEMAPPING_ACES: boolean;
  26339. CONTRAST: boolean;
  26340. COLORCURVES: boolean;
  26341. COLORGRADING: boolean;
  26342. COLORGRADING3D: boolean;
  26343. SAMPLER3DGREENDEPTH: boolean;
  26344. SAMPLER3DBGRMAP: boolean;
  26345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26346. EXPOSURE: boolean;
  26347. MULTIVIEW: boolean;
  26348. USEPHYSICALLIGHTFALLOFF: boolean;
  26349. USEGLTFLIGHTFALLOFF: boolean;
  26350. TWOSIDEDLIGHTING: boolean;
  26351. SHADOWFLOAT: boolean;
  26352. CLIPPLANE: boolean;
  26353. CLIPPLANE2: boolean;
  26354. CLIPPLANE3: boolean;
  26355. CLIPPLANE4: boolean;
  26356. CLIPPLANE5: boolean;
  26357. CLIPPLANE6: boolean;
  26358. POINTSIZE: boolean;
  26359. FOG: boolean;
  26360. LOGARITHMICDEPTH: boolean;
  26361. FORCENORMALFORWARD: boolean;
  26362. SPECULARAA: boolean;
  26363. CLEARCOAT: boolean;
  26364. CLEARCOAT_DEFAULTIOR: boolean;
  26365. CLEARCOAT_TEXTURE: boolean;
  26366. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26367. CLEARCOAT_TEXTUREDIRECTUV: number;
  26368. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26369. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26370. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26371. CLEARCOAT_BUMP: boolean;
  26372. CLEARCOAT_BUMPDIRECTUV: number;
  26373. CLEARCOAT_REMAP_F0: boolean;
  26374. CLEARCOAT_TINT: boolean;
  26375. CLEARCOAT_TINT_TEXTURE: boolean;
  26376. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26377. ANISOTROPIC: boolean;
  26378. ANISOTROPIC_TEXTURE: boolean;
  26379. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26380. BRDF_V_HEIGHT_CORRELATED: boolean;
  26381. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26382. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26383. SHEEN: boolean;
  26384. SHEEN_TEXTURE: boolean;
  26385. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26386. SHEEN_TEXTUREDIRECTUV: number;
  26387. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26388. SHEEN_LINKWITHALBEDO: boolean;
  26389. SHEEN_ROUGHNESS: boolean;
  26390. SHEEN_ALBEDOSCALING: boolean;
  26391. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26392. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26393. SUBSURFACE: boolean;
  26394. SS_REFRACTION: boolean;
  26395. SS_TRANSLUCENCY: boolean;
  26396. SS_SCATTERING: boolean;
  26397. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26398. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26399. SS_REFRACTIONMAP_3D: boolean;
  26400. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26401. SS_LODINREFRACTIONALPHA: boolean;
  26402. SS_GAMMAREFRACTION: boolean;
  26403. SS_RGBDREFRACTION: boolean;
  26404. SS_LINEARSPECULARREFRACTION: boolean;
  26405. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26406. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26407. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26408. UNLIT: boolean;
  26409. DEBUGMODE: number;
  26410. /**
  26411. * Initializes the PBR Material defines.
  26412. */
  26413. constructor();
  26414. /**
  26415. * Resets the PBR Material defines.
  26416. */
  26417. reset(): void;
  26418. }
  26419. /**
  26420. * The Physically based material base class of BJS.
  26421. *
  26422. * This offers the main features of a standard PBR material.
  26423. * For more information, please refer to the documentation :
  26424. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26425. */
  26426. export abstract class PBRBaseMaterial extends PushMaterial {
  26427. /**
  26428. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26429. */
  26430. static readonly PBRMATERIAL_OPAQUE: number;
  26431. /**
  26432. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26433. */
  26434. static readonly PBRMATERIAL_ALPHATEST: number;
  26435. /**
  26436. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26437. */
  26438. static readonly PBRMATERIAL_ALPHABLEND: number;
  26439. /**
  26440. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26441. * They are also discarded below the alpha cutoff threshold to improve performances.
  26442. */
  26443. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26444. /**
  26445. * Defines the default value of how much AO map is occluding the analytical lights
  26446. * (point spot...).
  26447. */
  26448. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26449. /**
  26450. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26451. */
  26452. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26453. /**
  26454. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26455. * to enhance interoperability with other engines.
  26456. */
  26457. static readonly LIGHTFALLOFF_GLTF: number;
  26458. /**
  26459. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26460. * to enhance interoperability with other materials.
  26461. */
  26462. static readonly LIGHTFALLOFF_STANDARD: number;
  26463. /**
  26464. * Intensity of the direct lights e.g. the four lights available in your scene.
  26465. * This impacts both the direct diffuse and specular highlights.
  26466. */
  26467. protected _directIntensity: number;
  26468. /**
  26469. * Intensity of the emissive part of the material.
  26470. * This helps controlling the emissive effect without modifying the emissive color.
  26471. */
  26472. protected _emissiveIntensity: number;
  26473. /**
  26474. * Intensity of the environment e.g. how much the environment will light the object
  26475. * either through harmonics for rough material or through the refelction for shiny ones.
  26476. */
  26477. protected _environmentIntensity: number;
  26478. /**
  26479. * This is a special control allowing the reduction of the specular highlights coming from the
  26480. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26481. */
  26482. protected _specularIntensity: number;
  26483. /**
  26484. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26485. */
  26486. private _lightingInfos;
  26487. /**
  26488. * Debug Control allowing disabling the bump map on this material.
  26489. */
  26490. protected _disableBumpMap: boolean;
  26491. /**
  26492. * AKA Diffuse Texture in standard nomenclature.
  26493. */
  26494. protected _albedoTexture: Nullable<BaseTexture>;
  26495. /**
  26496. * AKA Occlusion Texture in other nomenclature.
  26497. */
  26498. protected _ambientTexture: Nullable<BaseTexture>;
  26499. /**
  26500. * AKA Occlusion Texture Intensity in other nomenclature.
  26501. */
  26502. protected _ambientTextureStrength: number;
  26503. /**
  26504. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26505. * 1 means it completely occludes it
  26506. * 0 mean it has no impact
  26507. */
  26508. protected _ambientTextureImpactOnAnalyticalLights: number;
  26509. /**
  26510. * Stores the alpha values in a texture.
  26511. */
  26512. protected _opacityTexture: Nullable<BaseTexture>;
  26513. /**
  26514. * Stores the reflection values in a texture.
  26515. */
  26516. protected _reflectionTexture: Nullable<BaseTexture>;
  26517. /**
  26518. * Stores the emissive values in a texture.
  26519. */
  26520. protected _emissiveTexture: Nullable<BaseTexture>;
  26521. /**
  26522. * AKA Specular texture in other nomenclature.
  26523. */
  26524. protected _reflectivityTexture: Nullable<BaseTexture>;
  26525. /**
  26526. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26527. */
  26528. protected _metallicTexture: Nullable<BaseTexture>;
  26529. /**
  26530. * Specifies the metallic scalar of the metallic/roughness workflow.
  26531. * Can also be used to scale the metalness values of the metallic texture.
  26532. */
  26533. protected _metallic: Nullable<number>;
  26534. /**
  26535. * Specifies the roughness scalar of the metallic/roughness workflow.
  26536. * Can also be used to scale the roughness values of the metallic texture.
  26537. */
  26538. protected _roughness: Nullable<number>;
  26539. /**
  26540. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26541. * By default the indexOfrefraction is used to compute F0;
  26542. *
  26543. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26544. *
  26545. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26546. * F90 = metallicReflectanceColor;
  26547. */
  26548. protected _metallicF0Factor: number;
  26549. /**
  26550. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26551. * By default the F90 is always 1;
  26552. *
  26553. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26554. *
  26555. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26556. * F90 = metallicReflectanceColor;
  26557. */
  26558. protected _metallicReflectanceColor: Color3;
  26559. /**
  26560. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26561. * This is multiply against the scalar values defined in the material.
  26562. */
  26563. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26564. /**
  26565. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26566. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26567. */
  26568. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26569. /**
  26570. * Stores surface normal data used to displace a mesh in a texture.
  26571. */
  26572. protected _bumpTexture: Nullable<BaseTexture>;
  26573. /**
  26574. * Stores the pre-calculated light information of a mesh in a texture.
  26575. */
  26576. protected _lightmapTexture: Nullable<BaseTexture>;
  26577. /**
  26578. * The color of a material in ambient lighting.
  26579. */
  26580. protected _ambientColor: Color3;
  26581. /**
  26582. * AKA Diffuse Color in other nomenclature.
  26583. */
  26584. protected _albedoColor: Color3;
  26585. /**
  26586. * AKA Specular Color in other nomenclature.
  26587. */
  26588. protected _reflectivityColor: Color3;
  26589. /**
  26590. * The color applied when light is reflected from a material.
  26591. */
  26592. protected _reflectionColor: Color3;
  26593. /**
  26594. * The color applied when light is emitted from a material.
  26595. */
  26596. protected _emissiveColor: Color3;
  26597. /**
  26598. * AKA Glossiness in other nomenclature.
  26599. */
  26600. protected _microSurface: number;
  26601. /**
  26602. * Specifies that the material will use the light map as a show map.
  26603. */
  26604. protected _useLightmapAsShadowmap: boolean;
  26605. /**
  26606. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26607. * makes the reflect vector face the model (under horizon).
  26608. */
  26609. protected _useHorizonOcclusion: boolean;
  26610. /**
  26611. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26612. * too much the area relying on ambient texture to define their ambient occlusion.
  26613. */
  26614. protected _useRadianceOcclusion: boolean;
  26615. /**
  26616. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26617. */
  26618. protected _useAlphaFromAlbedoTexture: boolean;
  26619. /**
  26620. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26621. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26622. */
  26623. protected _useSpecularOverAlpha: boolean;
  26624. /**
  26625. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26626. */
  26627. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26628. /**
  26629. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26630. */
  26631. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26632. /**
  26633. * Specifies if the metallic texture contains the roughness information in its green channel.
  26634. */
  26635. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26636. /**
  26637. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26638. */
  26639. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26640. /**
  26641. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26642. */
  26643. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26644. /**
  26645. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26646. */
  26647. protected _useAmbientInGrayScale: boolean;
  26648. /**
  26649. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26650. * The material will try to infer what glossiness each pixel should be.
  26651. */
  26652. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26653. /**
  26654. * Defines the falloff type used in this material.
  26655. * It by default is Physical.
  26656. */
  26657. protected _lightFalloff: number;
  26658. /**
  26659. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26660. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26661. */
  26662. protected _useRadianceOverAlpha: boolean;
  26663. /**
  26664. * Allows using an object space normal map (instead of tangent space).
  26665. */
  26666. protected _useObjectSpaceNormalMap: boolean;
  26667. /**
  26668. * Allows using the bump map in parallax mode.
  26669. */
  26670. protected _useParallax: boolean;
  26671. /**
  26672. * Allows using the bump map in parallax occlusion mode.
  26673. */
  26674. protected _useParallaxOcclusion: boolean;
  26675. /**
  26676. * Controls the scale bias of the parallax mode.
  26677. */
  26678. protected _parallaxScaleBias: number;
  26679. /**
  26680. * If sets to true, disables all the lights affecting the material.
  26681. */
  26682. protected _disableLighting: boolean;
  26683. /**
  26684. * Number of Simultaneous lights allowed on the material.
  26685. */
  26686. protected _maxSimultaneousLights: number;
  26687. /**
  26688. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26689. */
  26690. protected _invertNormalMapX: boolean;
  26691. /**
  26692. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26693. */
  26694. protected _invertNormalMapY: boolean;
  26695. /**
  26696. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26697. */
  26698. protected _twoSidedLighting: boolean;
  26699. /**
  26700. * Defines the alpha limits in alpha test mode.
  26701. */
  26702. protected _alphaCutOff: number;
  26703. /**
  26704. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26705. */
  26706. protected _forceAlphaTest: boolean;
  26707. /**
  26708. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26709. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26710. */
  26711. protected _useAlphaFresnel: boolean;
  26712. /**
  26713. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26714. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26715. */
  26716. protected _useLinearAlphaFresnel: boolean;
  26717. /**
  26718. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26719. * from cos thetav and roughness:
  26720. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26721. */
  26722. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26723. /**
  26724. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26725. */
  26726. protected _forceIrradianceInFragment: boolean;
  26727. private _realTimeFiltering;
  26728. /**
  26729. * Enables realtime filtering on the texture.
  26730. */
  26731. get realTimeFiltering(): boolean;
  26732. set realTimeFiltering(b: boolean);
  26733. private _realTimeFilteringQuality;
  26734. /**
  26735. * Quality switch for realtime filtering
  26736. */
  26737. get realTimeFilteringQuality(): number;
  26738. set realTimeFilteringQuality(n: number);
  26739. /**
  26740. * Can this material render to several textures at once
  26741. */
  26742. get canRenderToMRT(): boolean;
  26743. /**
  26744. * Force normal to face away from face.
  26745. */
  26746. protected _forceNormalForward: boolean;
  26747. /**
  26748. * Enables specular anti aliasing in the PBR shader.
  26749. * It will both interacts on the Geometry for analytical and IBL lighting.
  26750. * It also prefilter the roughness map based on the bump values.
  26751. */
  26752. protected _enableSpecularAntiAliasing: boolean;
  26753. /**
  26754. * Default configuration related to image processing available in the PBR Material.
  26755. */
  26756. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26757. /**
  26758. * Keep track of the image processing observer to allow dispose and replace.
  26759. */
  26760. private _imageProcessingObserver;
  26761. /**
  26762. * Attaches a new image processing configuration to the PBR Material.
  26763. * @param configuration
  26764. */
  26765. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26766. /**
  26767. * Stores the available render targets.
  26768. */
  26769. private _renderTargets;
  26770. /**
  26771. * Sets the global ambient color for the material used in lighting calculations.
  26772. */
  26773. private _globalAmbientColor;
  26774. /**
  26775. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26776. */
  26777. private _useLogarithmicDepth;
  26778. /**
  26779. * If set to true, no lighting calculations will be applied.
  26780. */
  26781. private _unlit;
  26782. private _debugMode;
  26783. /**
  26784. * @hidden
  26785. * This is reserved for the inspector.
  26786. * Defines the material debug mode.
  26787. * It helps seeing only some components of the material while troubleshooting.
  26788. */
  26789. debugMode: number;
  26790. /**
  26791. * @hidden
  26792. * This is reserved for the inspector.
  26793. * Specify from where on screen the debug mode should start.
  26794. * The value goes from -1 (full screen) to 1 (not visible)
  26795. * It helps with side by side comparison against the final render
  26796. * This defaults to -1
  26797. */
  26798. private debugLimit;
  26799. /**
  26800. * @hidden
  26801. * This is reserved for the inspector.
  26802. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26803. * You can use the factor to better multiply the final value.
  26804. */
  26805. private debugFactor;
  26806. /**
  26807. * Defines the clear coat layer parameters for the material.
  26808. */
  26809. readonly clearCoat: PBRClearCoatConfiguration;
  26810. /**
  26811. * Defines the anisotropic parameters for the material.
  26812. */
  26813. readonly anisotropy: PBRAnisotropicConfiguration;
  26814. /**
  26815. * Defines the BRDF parameters for the material.
  26816. */
  26817. readonly brdf: PBRBRDFConfiguration;
  26818. /**
  26819. * Defines the Sheen parameters for the material.
  26820. */
  26821. readonly sheen: PBRSheenConfiguration;
  26822. /**
  26823. * Defines the SubSurface parameters for the material.
  26824. */
  26825. readonly subSurface: PBRSubSurfaceConfiguration;
  26826. /**
  26827. * Defines additionnal PrePass parameters for the material.
  26828. */
  26829. readonly prePassConfiguration: PrePassConfiguration;
  26830. /**
  26831. * Defines the detail map parameters for the material.
  26832. */
  26833. readonly detailMap: DetailMapConfiguration;
  26834. protected _rebuildInParallel: boolean;
  26835. /**
  26836. * Instantiates a new PBRMaterial instance.
  26837. *
  26838. * @param name The material name
  26839. * @param scene The scene the material will be use in.
  26840. */
  26841. constructor(name: string, scene: Scene);
  26842. /**
  26843. * Gets a boolean indicating that current material needs to register RTT
  26844. */
  26845. get hasRenderTargetTextures(): boolean;
  26846. /**
  26847. * Gets the name of the material class.
  26848. */
  26849. getClassName(): string;
  26850. /**
  26851. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26852. */
  26853. get useLogarithmicDepth(): boolean;
  26854. /**
  26855. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26856. */
  26857. set useLogarithmicDepth(value: boolean);
  26858. /**
  26859. * Returns true if alpha blending should be disabled.
  26860. */
  26861. protected get _disableAlphaBlending(): boolean;
  26862. /**
  26863. * Specifies whether or not this material should be rendered in alpha blend mode.
  26864. */
  26865. needAlphaBlending(): boolean;
  26866. /**
  26867. * Specifies whether or not this material should be rendered in alpha test mode.
  26868. */
  26869. needAlphaTesting(): boolean;
  26870. /**
  26871. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26872. */
  26873. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26874. /**
  26875. * Specifies whether or not there is a usable alpha channel for transparency.
  26876. */
  26877. protected _hasAlphaChannel(): boolean;
  26878. /**
  26879. * Gets the texture used for the alpha test.
  26880. */
  26881. getAlphaTestTexture(): Nullable<BaseTexture>;
  26882. /**
  26883. * Specifies that the submesh is ready to be used.
  26884. * @param mesh - BJS mesh.
  26885. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26886. * @param useInstances - Specifies that instances should be used.
  26887. * @returns - boolean indicating that the submesh is ready or not.
  26888. */
  26889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26890. /**
  26891. * Specifies if the material uses metallic roughness workflow.
  26892. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26893. */
  26894. isMetallicWorkflow(): boolean;
  26895. private _prepareEffect;
  26896. private _prepareDefines;
  26897. /**
  26898. * Force shader compilation
  26899. */
  26900. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26901. /**
  26902. * Initializes the uniform buffer layout for the shader.
  26903. */
  26904. buildUniformLayout(): void;
  26905. /**
  26906. * Unbinds the material from the mesh
  26907. */
  26908. unbind(): void;
  26909. /**
  26910. * Binds the submesh data.
  26911. * @param world - The world matrix.
  26912. * @param mesh - The BJS mesh.
  26913. * @param subMesh - A submesh of the BJS mesh.
  26914. */
  26915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26916. /**
  26917. * Returns the animatable textures.
  26918. * @returns - Array of animatable textures.
  26919. */
  26920. getAnimatables(): IAnimatable[];
  26921. /**
  26922. * Returns the texture used for reflections.
  26923. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26924. */
  26925. private _getReflectionTexture;
  26926. /**
  26927. * Returns an array of the actively used textures.
  26928. * @returns - Array of BaseTextures
  26929. */
  26930. getActiveTextures(): BaseTexture[];
  26931. /**
  26932. * Checks to see if a texture is used in the material.
  26933. * @param texture - Base texture to use.
  26934. * @returns - Boolean specifying if a texture is used in the material.
  26935. */
  26936. hasTexture(texture: BaseTexture): boolean;
  26937. /**
  26938. * Sets the required values to the prepass renderer.
  26939. * @param prePassRenderer defines the prepass renderer to setup
  26940. */
  26941. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26942. /**
  26943. * Disposes the resources of the material.
  26944. * @param forceDisposeEffect - Forces the disposal of effects.
  26945. * @param forceDisposeTextures - Forces the disposal of all textures.
  26946. */
  26947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26948. }
  26949. }
  26950. declare module BABYLON {
  26951. /**
  26952. * The Physically based material of BJS.
  26953. *
  26954. * This offers the main features of a standard PBR material.
  26955. * For more information, please refer to the documentation :
  26956. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26957. */
  26958. export class PBRMaterial extends PBRBaseMaterial {
  26959. /**
  26960. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26961. */
  26962. static readonly PBRMATERIAL_OPAQUE: number;
  26963. /**
  26964. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26965. */
  26966. static readonly PBRMATERIAL_ALPHATEST: number;
  26967. /**
  26968. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26969. */
  26970. static readonly PBRMATERIAL_ALPHABLEND: number;
  26971. /**
  26972. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26973. * They are also discarded below the alpha cutoff threshold to improve performances.
  26974. */
  26975. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26976. /**
  26977. * Defines the default value of how much AO map is occluding the analytical lights
  26978. * (point spot...).
  26979. */
  26980. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26981. /**
  26982. * Intensity of the direct lights e.g. the four lights available in your scene.
  26983. * This impacts both the direct diffuse and specular highlights.
  26984. */
  26985. directIntensity: number;
  26986. /**
  26987. * Intensity of the emissive part of the material.
  26988. * This helps controlling the emissive effect without modifying the emissive color.
  26989. */
  26990. emissiveIntensity: number;
  26991. /**
  26992. * Intensity of the environment e.g. how much the environment will light the object
  26993. * either through harmonics for rough material or through the refelction for shiny ones.
  26994. */
  26995. environmentIntensity: number;
  26996. /**
  26997. * This is a special control allowing the reduction of the specular highlights coming from the
  26998. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26999. */
  27000. specularIntensity: number;
  27001. /**
  27002. * Debug Control allowing disabling the bump map on this material.
  27003. */
  27004. disableBumpMap: boolean;
  27005. /**
  27006. * AKA Diffuse Texture in standard nomenclature.
  27007. */
  27008. albedoTexture: BaseTexture;
  27009. /**
  27010. * AKA Occlusion Texture in other nomenclature.
  27011. */
  27012. ambientTexture: BaseTexture;
  27013. /**
  27014. * AKA Occlusion Texture Intensity in other nomenclature.
  27015. */
  27016. ambientTextureStrength: number;
  27017. /**
  27018. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27019. * 1 means it completely occludes it
  27020. * 0 mean it has no impact
  27021. */
  27022. ambientTextureImpactOnAnalyticalLights: number;
  27023. /**
  27024. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27025. */
  27026. opacityTexture: BaseTexture;
  27027. /**
  27028. * Stores the reflection values in a texture.
  27029. */
  27030. reflectionTexture: Nullable<BaseTexture>;
  27031. /**
  27032. * Stores the emissive values in a texture.
  27033. */
  27034. emissiveTexture: BaseTexture;
  27035. /**
  27036. * AKA Specular texture in other nomenclature.
  27037. */
  27038. reflectivityTexture: BaseTexture;
  27039. /**
  27040. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27041. */
  27042. metallicTexture: BaseTexture;
  27043. /**
  27044. * Specifies the metallic scalar of the metallic/roughness workflow.
  27045. * Can also be used to scale the metalness values of the metallic texture.
  27046. */
  27047. metallic: Nullable<number>;
  27048. /**
  27049. * Specifies the roughness scalar of the metallic/roughness workflow.
  27050. * Can also be used to scale the roughness values of the metallic texture.
  27051. */
  27052. roughness: Nullable<number>;
  27053. /**
  27054. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27055. * By default the indexOfrefraction is used to compute F0;
  27056. *
  27057. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27058. *
  27059. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27060. * F90 = metallicReflectanceColor;
  27061. */
  27062. metallicF0Factor: number;
  27063. /**
  27064. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27065. * By default the F90 is always 1;
  27066. *
  27067. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27068. *
  27069. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27070. * F90 = metallicReflectanceColor;
  27071. */
  27072. metallicReflectanceColor: Color3;
  27073. /**
  27074. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27075. * This is multiply against the scalar values defined in the material.
  27076. */
  27077. metallicReflectanceTexture: Nullable<BaseTexture>;
  27078. /**
  27079. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27080. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27081. */
  27082. microSurfaceTexture: BaseTexture;
  27083. /**
  27084. * Stores surface normal data used to displace a mesh in a texture.
  27085. */
  27086. bumpTexture: BaseTexture;
  27087. /**
  27088. * Stores the pre-calculated light information of a mesh in a texture.
  27089. */
  27090. lightmapTexture: BaseTexture;
  27091. /**
  27092. * Stores the refracted light information in a texture.
  27093. */
  27094. get refractionTexture(): Nullable<BaseTexture>;
  27095. set refractionTexture(value: Nullable<BaseTexture>);
  27096. /**
  27097. * The color of a material in ambient lighting.
  27098. */
  27099. ambientColor: Color3;
  27100. /**
  27101. * AKA Diffuse Color in other nomenclature.
  27102. */
  27103. albedoColor: Color3;
  27104. /**
  27105. * AKA Specular Color in other nomenclature.
  27106. */
  27107. reflectivityColor: Color3;
  27108. /**
  27109. * The color reflected from the material.
  27110. */
  27111. reflectionColor: Color3;
  27112. /**
  27113. * The color emitted from the material.
  27114. */
  27115. emissiveColor: Color3;
  27116. /**
  27117. * AKA Glossiness in other nomenclature.
  27118. */
  27119. microSurface: number;
  27120. /**
  27121. * Index of refraction of the material base layer.
  27122. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27123. *
  27124. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27125. *
  27126. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27127. */
  27128. get indexOfRefraction(): number;
  27129. set indexOfRefraction(value: number);
  27130. /**
  27131. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27132. */
  27133. get invertRefractionY(): boolean;
  27134. set invertRefractionY(value: boolean);
  27135. /**
  27136. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27137. * Materials half opaque for instance using refraction could benefit from this control.
  27138. */
  27139. get linkRefractionWithTransparency(): boolean;
  27140. set linkRefractionWithTransparency(value: boolean);
  27141. /**
  27142. * If true, the light map contains occlusion information instead of lighting info.
  27143. */
  27144. useLightmapAsShadowmap: boolean;
  27145. /**
  27146. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27147. */
  27148. useAlphaFromAlbedoTexture: boolean;
  27149. /**
  27150. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27151. */
  27152. forceAlphaTest: boolean;
  27153. /**
  27154. * Defines the alpha limits in alpha test mode.
  27155. */
  27156. alphaCutOff: number;
  27157. /**
  27158. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27159. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27160. */
  27161. useSpecularOverAlpha: boolean;
  27162. /**
  27163. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27164. */
  27165. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27166. /**
  27167. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27168. */
  27169. useRoughnessFromMetallicTextureAlpha: boolean;
  27170. /**
  27171. * Specifies if the metallic texture contains the roughness information in its green channel.
  27172. */
  27173. useRoughnessFromMetallicTextureGreen: boolean;
  27174. /**
  27175. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27176. */
  27177. useMetallnessFromMetallicTextureBlue: boolean;
  27178. /**
  27179. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27180. */
  27181. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27182. /**
  27183. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27184. */
  27185. useAmbientInGrayScale: boolean;
  27186. /**
  27187. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27188. * The material will try to infer what glossiness each pixel should be.
  27189. */
  27190. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27191. /**
  27192. * BJS is using an harcoded light falloff based on a manually sets up range.
  27193. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27194. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27195. */
  27196. get usePhysicalLightFalloff(): boolean;
  27197. /**
  27198. * BJS is using an harcoded light falloff based on a manually sets up range.
  27199. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27200. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27201. */
  27202. set usePhysicalLightFalloff(value: boolean);
  27203. /**
  27204. * In order to support the falloff compatibility with gltf, a special mode has been added
  27205. * to reproduce the gltf light falloff.
  27206. */
  27207. get useGLTFLightFalloff(): boolean;
  27208. /**
  27209. * In order to support the falloff compatibility with gltf, a special mode has been added
  27210. * to reproduce the gltf light falloff.
  27211. */
  27212. set useGLTFLightFalloff(value: boolean);
  27213. /**
  27214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27216. */
  27217. useRadianceOverAlpha: boolean;
  27218. /**
  27219. * Allows using an object space normal map (instead of tangent space).
  27220. */
  27221. useObjectSpaceNormalMap: boolean;
  27222. /**
  27223. * Allows using the bump map in parallax mode.
  27224. */
  27225. useParallax: boolean;
  27226. /**
  27227. * Allows using the bump map in parallax occlusion mode.
  27228. */
  27229. useParallaxOcclusion: boolean;
  27230. /**
  27231. * Controls the scale bias of the parallax mode.
  27232. */
  27233. parallaxScaleBias: number;
  27234. /**
  27235. * If sets to true, disables all the lights affecting the material.
  27236. */
  27237. disableLighting: boolean;
  27238. /**
  27239. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27240. */
  27241. forceIrradianceInFragment: boolean;
  27242. /**
  27243. * Number of Simultaneous lights allowed on the material.
  27244. */
  27245. maxSimultaneousLights: number;
  27246. /**
  27247. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27248. */
  27249. invertNormalMapX: boolean;
  27250. /**
  27251. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27252. */
  27253. invertNormalMapY: boolean;
  27254. /**
  27255. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27256. */
  27257. twoSidedLighting: boolean;
  27258. /**
  27259. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27260. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27261. */
  27262. useAlphaFresnel: boolean;
  27263. /**
  27264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27265. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27266. */
  27267. useLinearAlphaFresnel: boolean;
  27268. /**
  27269. * Let user defines the brdf lookup texture used for IBL.
  27270. * A default 8bit version is embedded but you could point at :
  27271. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27272. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27273. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27274. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27275. */
  27276. environmentBRDFTexture: Nullable<BaseTexture>;
  27277. /**
  27278. * Force normal to face away from face.
  27279. */
  27280. forceNormalForward: boolean;
  27281. /**
  27282. * Enables specular anti aliasing in the PBR shader.
  27283. * It will both interacts on the Geometry for analytical and IBL lighting.
  27284. * It also prefilter the roughness map based on the bump values.
  27285. */
  27286. enableSpecularAntiAliasing: boolean;
  27287. /**
  27288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27289. * makes the reflect vector face the model (under horizon).
  27290. */
  27291. useHorizonOcclusion: boolean;
  27292. /**
  27293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27294. * too much the area relying on ambient texture to define their ambient occlusion.
  27295. */
  27296. useRadianceOcclusion: boolean;
  27297. /**
  27298. * If set to true, no lighting calculations will be applied.
  27299. */
  27300. unlit: boolean;
  27301. /**
  27302. * Gets the image processing configuration used either in this material.
  27303. */
  27304. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27305. /**
  27306. * Sets the Default image processing configuration used either in the this material.
  27307. *
  27308. * If sets to null, the scene one is in use.
  27309. */
  27310. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27311. /**
  27312. * Gets wether the color curves effect is enabled.
  27313. */
  27314. get cameraColorCurvesEnabled(): boolean;
  27315. /**
  27316. * Sets wether the color curves effect is enabled.
  27317. */
  27318. set cameraColorCurvesEnabled(value: boolean);
  27319. /**
  27320. * Gets wether the color grading effect is enabled.
  27321. */
  27322. get cameraColorGradingEnabled(): boolean;
  27323. /**
  27324. * Gets wether the color grading effect is enabled.
  27325. */
  27326. set cameraColorGradingEnabled(value: boolean);
  27327. /**
  27328. * Gets wether tonemapping is enabled or not.
  27329. */
  27330. get cameraToneMappingEnabled(): boolean;
  27331. /**
  27332. * Sets wether tonemapping is enabled or not
  27333. */
  27334. set cameraToneMappingEnabled(value: boolean);
  27335. /**
  27336. * The camera exposure used on this material.
  27337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27338. * This corresponds to a photographic exposure.
  27339. */
  27340. get cameraExposure(): number;
  27341. /**
  27342. * The camera exposure used on this material.
  27343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27344. * This corresponds to a photographic exposure.
  27345. */
  27346. set cameraExposure(value: number);
  27347. /**
  27348. * Gets The camera contrast used on this material.
  27349. */
  27350. get cameraContrast(): number;
  27351. /**
  27352. * Sets The camera contrast used on this material.
  27353. */
  27354. set cameraContrast(value: number);
  27355. /**
  27356. * Gets the Color Grading 2D Lookup Texture.
  27357. */
  27358. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27359. /**
  27360. * Sets the Color Grading 2D Lookup Texture.
  27361. */
  27362. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27363. /**
  27364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27366. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27368. */
  27369. get cameraColorCurves(): Nullable<ColorCurves>;
  27370. /**
  27371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27373. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27375. */
  27376. set cameraColorCurves(value: Nullable<ColorCurves>);
  27377. /**
  27378. * Instantiates a new PBRMaterial instance.
  27379. *
  27380. * @param name The material name
  27381. * @param scene The scene the material will be use in.
  27382. */
  27383. constructor(name: string, scene: Scene);
  27384. /**
  27385. * Returns the name of this material class.
  27386. */
  27387. getClassName(): string;
  27388. /**
  27389. * Makes a duplicate of the current material.
  27390. * @param name - name to use for the new material.
  27391. */
  27392. clone(name: string): PBRMaterial;
  27393. /**
  27394. * Serializes this PBR Material.
  27395. * @returns - An object with the serialized material.
  27396. */
  27397. serialize(): any;
  27398. /**
  27399. * Parses a PBR Material from a serialized object.
  27400. * @param source - Serialized object.
  27401. * @param scene - BJS scene instance.
  27402. * @param rootUrl - url for the scene object
  27403. * @returns - PBRMaterial
  27404. */
  27405. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27406. }
  27407. }
  27408. declare module BABYLON {
  27409. /** @hidden */
  27410. export var mrtFragmentDeclaration: {
  27411. name: string;
  27412. shader: string;
  27413. };
  27414. }
  27415. declare module BABYLON {
  27416. /** @hidden */
  27417. export var geometryPixelShader: {
  27418. name: string;
  27419. shader: string;
  27420. };
  27421. }
  27422. declare module BABYLON {
  27423. /** @hidden */
  27424. export var geometryVertexShader: {
  27425. name: string;
  27426. shader: string;
  27427. };
  27428. }
  27429. declare module BABYLON {
  27430. /** @hidden */
  27431. interface ISavedTransformationMatrix {
  27432. world: Matrix;
  27433. viewProjection: Matrix;
  27434. }
  27435. /**
  27436. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27437. */
  27438. export class GeometryBufferRenderer {
  27439. /**
  27440. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27441. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27442. */
  27443. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27444. /**
  27445. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27446. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27447. */
  27448. static readonly POSITION_TEXTURE_TYPE: number;
  27449. /**
  27450. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27451. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27452. */
  27453. static readonly VELOCITY_TEXTURE_TYPE: number;
  27454. /**
  27455. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27456. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27457. */
  27458. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27459. /**
  27460. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27461. * in order to compute objects velocities when enableVelocity is set to "true"
  27462. * @hidden
  27463. */
  27464. _previousTransformationMatrices: {
  27465. [index: number]: ISavedTransformationMatrix;
  27466. };
  27467. /**
  27468. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27469. * in order to compute objects velocities when enableVelocity is set to "true"
  27470. * @hidden
  27471. */
  27472. _previousBonesTransformationMatrices: {
  27473. [index: number]: Float32Array;
  27474. };
  27475. /**
  27476. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27477. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27478. */
  27479. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27480. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27481. renderTransparentMeshes: boolean;
  27482. private _scene;
  27483. private _resizeObserver;
  27484. private _multiRenderTarget;
  27485. private _ratio;
  27486. private _enablePosition;
  27487. private _enableVelocity;
  27488. private _enableReflectivity;
  27489. private _positionIndex;
  27490. private _velocityIndex;
  27491. private _reflectivityIndex;
  27492. private _depthNormalIndex;
  27493. private _linkedWithPrePass;
  27494. private _prePassRenderer;
  27495. private _attachments;
  27496. protected _effect: Effect;
  27497. protected _cachedDefines: string;
  27498. /**
  27499. * @hidden
  27500. * Sets up internal structures to share outputs with PrePassRenderer
  27501. * This method should only be called by the PrePassRenderer itself
  27502. */
  27503. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27504. /**
  27505. * @hidden
  27506. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27507. * This method should only be called by the PrePassRenderer itself
  27508. */
  27509. _unlinkPrePassRenderer(): void;
  27510. /**
  27511. * @hidden
  27512. * Resets the geometry buffer layout
  27513. */
  27514. _resetLayout(): void;
  27515. /**
  27516. * @hidden
  27517. * Replaces a texture in the geometry buffer renderer
  27518. * Useful when linking textures of the prepass renderer
  27519. */
  27520. _forceTextureType(geometryBufferType: number, index: number): void;
  27521. /**
  27522. * @hidden
  27523. * Sets texture attachments
  27524. * Useful when linking textures of the prepass renderer
  27525. */
  27526. _setAttachments(attachments: number[]): void;
  27527. /**
  27528. * @hidden
  27529. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27530. * Useful when linking textures of the prepass renderer
  27531. */
  27532. _linkInternalTexture(internalTexture: InternalTexture): void;
  27533. /**
  27534. * Gets the render list (meshes to be rendered) used in the G buffer.
  27535. */
  27536. get renderList(): Nullable<AbstractMesh[]>;
  27537. /**
  27538. * Set the render list (meshes to be rendered) used in the G buffer.
  27539. */
  27540. set renderList(meshes: Nullable<AbstractMesh[]>);
  27541. /**
  27542. * Gets wether or not G buffer are supported by the running hardware.
  27543. * This requires draw buffer supports
  27544. */
  27545. get isSupported(): boolean;
  27546. /**
  27547. * Returns the index of the given texture type in the G-Buffer textures array
  27548. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27549. * @returns the index of the given texture type in the G-Buffer textures array
  27550. */
  27551. getTextureIndex(textureType: number): number;
  27552. /**
  27553. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27554. */
  27555. get enablePosition(): boolean;
  27556. /**
  27557. * Sets whether or not objects positions are enabled for the G buffer.
  27558. */
  27559. set enablePosition(enable: boolean);
  27560. /**
  27561. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27562. */
  27563. get enableVelocity(): boolean;
  27564. /**
  27565. * Sets wether or not objects velocities are enabled for the G buffer.
  27566. */
  27567. set enableVelocity(enable: boolean);
  27568. /**
  27569. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27570. */
  27571. get enableReflectivity(): boolean;
  27572. /**
  27573. * Sets wether or not objects roughness are enabled for the G buffer.
  27574. */
  27575. set enableReflectivity(enable: boolean);
  27576. /**
  27577. * Gets the scene associated with the buffer.
  27578. */
  27579. get scene(): Scene;
  27580. /**
  27581. * Gets the ratio used by the buffer during its creation.
  27582. * How big is the buffer related to the main canvas.
  27583. */
  27584. get ratio(): number;
  27585. /** @hidden */
  27586. static _SceneComponentInitialization: (scene: Scene) => void;
  27587. /**
  27588. * Creates a new G Buffer for the scene
  27589. * @param scene The scene the buffer belongs to
  27590. * @param ratio How big is the buffer related to the main canvas.
  27591. */
  27592. constructor(scene: Scene, ratio?: number);
  27593. /**
  27594. * Checks wether everything is ready to render a submesh to the G buffer.
  27595. * @param subMesh the submesh to check readiness for
  27596. * @param useInstances is the mesh drawn using instance or not
  27597. * @returns true if ready otherwise false
  27598. */
  27599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27600. /**
  27601. * Gets the current underlying G Buffer.
  27602. * @returns the buffer
  27603. */
  27604. getGBuffer(): MultiRenderTarget;
  27605. /**
  27606. * Gets the number of samples used to render the buffer (anti aliasing).
  27607. */
  27608. get samples(): number;
  27609. /**
  27610. * Sets the number of samples used to render the buffer (anti aliasing).
  27611. */
  27612. set samples(value: number);
  27613. /**
  27614. * Disposes the renderer and frees up associated resources.
  27615. */
  27616. dispose(): void;
  27617. private _assignRenderTargetIndices;
  27618. protected _createRenderTargets(): void;
  27619. private _copyBonesTransformationMatrices;
  27620. }
  27621. }
  27622. declare module BABYLON {
  27623. /**
  27624. * Renders a pre pass of the scene
  27625. * This means every mesh in the scene will be rendered to a render target texture
  27626. * And then this texture will be composited to the rendering canvas with post processes
  27627. * It is necessary for effects like subsurface scattering or deferred shading
  27628. */
  27629. export class PrePassRenderer {
  27630. /** @hidden */
  27631. static _SceneComponentInitialization: (scene: Scene) => void;
  27632. private _textureFormats;
  27633. /**
  27634. * To save performance, we can excluded skinned meshes from the prepass
  27635. */
  27636. excludedSkinnedMesh: AbstractMesh[];
  27637. /**
  27638. * Force material to be excluded from the prepass
  27639. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27640. * and you don't want a material to show in the effect.
  27641. */
  27642. excludedMaterials: Material[];
  27643. private _textureIndices;
  27644. private _scene;
  27645. private _engine;
  27646. private _isDirty;
  27647. /**
  27648. * Number of textures in the multi render target texture where the scene is directly rendered
  27649. */
  27650. mrtCount: number;
  27651. /**
  27652. * The render target where the scene is directly rendered
  27653. */
  27654. prePassRT: MultiRenderTarget;
  27655. private _multiRenderAttachments;
  27656. private _defaultAttachments;
  27657. private _clearAttachments;
  27658. private _postProcesses;
  27659. private readonly _clearColor;
  27660. /**
  27661. * Image processing post process for composition
  27662. */
  27663. imageProcessingPostProcess: ImageProcessingPostProcess;
  27664. /**
  27665. * Configuration for prepass effects
  27666. */
  27667. private _effectConfigurations;
  27668. private _mrtFormats;
  27669. private _mrtLayout;
  27670. private _enabled;
  27671. /**
  27672. * Indicates if the prepass is enabled
  27673. */
  27674. get enabled(): boolean;
  27675. /**
  27676. * How many samples are used for MSAA of the scene render target
  27677. */
  27678. get samples(): number;
  27679. set samples(n: number);
  27680. private _geometryBuffer;
  27681. private _useGeometryBufferFallback;
  27682. /**
  27683. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27684. */
  27685. get useGeometryBufferFallback(): boolean;
  27686. set useGeometryBufferFallback(value: boolean);
  27687. /**
  27688. * Instanciates a prepass renderer
  27689. * @param scene The scene
  27690. */
  27691. constructor(scene: Scene);
  27692. private _initializeAttachments;
  27693. private _createCompositionEffect;
  27694. /**
  27695. * Indicates if rendering a prepass is supported
  27696. */
  27697. get isSupported(): boolean;
  27698. /**
  27699. * Sets the proper output textures to draw in the engine.
  27700. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27701. * @param subMesh Submesh on which the effect is applied
  27702. */
  27703. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27704. /**
  27705. * @hidden
  27706. */
  27707. _beforeCameraDraw(): void;
  27708. /**
  27709. * @hidden
  27710. */
  27711. _afterCameraDraw(): void;
  27712. private _checkRTSize;
  27713. private _bindFrameBuffer;
  27714. /**
  27715. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27716. */
  27717. clear(): void;
  27718. private _setState;
  27719. private _updateGeometryBufferLayout;
  27720. /**
  27721. * Adds an effect configuration to the prepass.
  27722. * If an effect has already been added, it won't add it twice and will return the configuration
  27723. * already present.
  27724. * @param cfg the effect configuration
  27725. * @return the effect configuration now used by the prepass
  27726. */
  27727. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27728. /**
  27729. * Returns the index of a texture in the multi render target texture array.
  27730. * @param type Texture type
  27731. * @return The index
  27732. */
  27733. getIndex(type: number): number;
  27734. private _enable;
  27735. private _disable;
  27736. private _resetLayout;
  27737. private _resetPostProcessChain;
  27738. private _bindPostProcessChain;
  27739. /**
  27740. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27741. */
  27742. markAsDirty(): void;
  27743. /**
  27744. * Enables a texture on the MultiRenderTarget for prepass
  27745. */
  27746. private _enableTextures;
  27747. private _update;
  27748. private _markAllMaterialsAsPrePassDirty;
  27749. /**
  27750. * Disposes the prepass renderer.
  27751. */
  27752. dispose(): void;
  27753. }
  27754. }
  27755. declare module BABYLON {
  27756. /**
  27757. * Size options for a post process
  27758. */
  27759. export type PostProcessOptions = {
  27760. width: number;
  27761. height: number;
  27762. };
  27763. /**
  27764. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27765. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27766. */
  27767. export class PostProcess {
  27768. /**
  27769. * Gets or sets the unique id of the post process
  27770. */
  27771. uniqueId: number;
  27772. /** Name of the PostProcess. */
  27773. name: string;
  27774. /**
  27775. * Width of the texture to apply the post process on
  27776. */
  27777. width: number;
  27778. /**
  27779. * Height of the texture to apply the post process on
  27780. */
  27781. height: number;
  27782. /**
  27783. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27784. */
  27785. nodeMaterialSource: Nullable<NodeMaterial>;
  27786. /**
  27787. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27788. * @hidden
  27789. */
  27790. _outputTexture: Nullable<InternalTexture>;
  27791. /**
  27792. * Sampling mode used by the shader
  27793. * See https://doc.babylonjs.com/classes/3.1/texture
  27794. */
  27795. renderTargetSamplingMode: number;
  27796. /**
  27797. * Clear color to use when screen clearing
  27798. */
  27799. clearColor: Color4;
  27800. /**
  27801. * If the buffer needs to be cleared before applying the post process. (default: true)
  27802. * Should be set to false if shader will overwrite all previous pixels.
  27803. */
  27804. autoClear: boolean;
  27805. /**
  27806. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27807. */
  27808. alphaMode: number;
  27809. /**
  27810. * Sets the setAlphaBlendConstants of the babylon engine
  27811. */
  27812. alphaConstants: Color4;
  27813. /**
  27814. * Animations to be used for the post processing
  27815. */
  27816. animations: Animation[];
  27817. /**
  27818. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27819. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27820. */
  27821. enablePixelPerfectMode: boolean;
  27822. /**
  27823. * Force the postprocess to be applied without taking in account viewport
  27824. */
  27825. forceFullscreenViewport: boolean;
  27826. /**
  27827. * List of inspectable custom properties (used by the Inspector)
  27828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27829. */
  27830. inspectableCustomProperties: IInspectable[];
  27831. /**
  27832. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27833. *
  27834. * | Value | Type | Description |
  27835. * | ----- | ----------------------------------- | ----------- |
  27836. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27837. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27838. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27839. *
  27840. */
  27841. scaleMode: number;
  27842. /**
  27843. * Force textures to be a power of two (default: false)
  27844. */
  27845. alwaysForcePOT: boolean;
  27846. private _samples;
  27847. /**
  27848. * Number of sample textures (default: 1)
  27849. */
  27850. get samples(): number;
  27851. set samples(n: number);
  27852. /**
  27853. * Modify the scale of the post process to be the same as the viewport (default: false)
  27854. */
  27855. adaptScaleToCurrentViewport: boolean;
  27856. private _camera;
  27857. protected _scene: Scene;
  27858. private _engine;
  27859. private _options;
  27860. private _reusable;
  27861. private _textureType;
  27862. private _textureFormat;
  27863. /**
  27864. * Smart array of input and output textures for the post process.
  27865. * @hidden
  27866. */
  27867. _textures: SmartArray<InternalTexture>;
  27868. /**
  27869. * The index in _textures that corresponds to the output texture.
  27870. * @hidden
  27871. */
  27872. _currentRenderTextureInd: number;
  27873. private _effect;
  27874. private _samplers;
  27875. private _fragmentUrl;
  27876. private _vertexUrl;
  27877. private _parameters;
  27878. private _scaleRatio;
  27879. protected _indexParameters: any;
  27880. private _shareOutputWithPostProcess;
  27881. private _texelSize;
  27882. private _forcedOutputTexture;
  27883. /**
  27884. * Prepass configuration in case this post process needs a texture from prepass
  27885. * @hidden
  27886. */
  27887. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27888. /**
  27889. * Returns the fragment url or shader name used in the post process.
  27890. * @returns the fragment url or name in the shader store.
  27891. */
  27892. getEffectName(): string;
  27893. /**
  27894. * An event triggered when the postprocess is activated.
  27895. */
  27896. onActivateObservable: Observable<Camera>;
  27897. private _onActivateObserver;
  27898. /**
  27899. * A function that is added to the onActivateObservable
  27900. */
  27901. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27902. /**
  27903. * An event triggered when the postprocess changes its size.
  27904. */
  27905. onSizeChangedObservable: Observable<PostProcess>;
  27906. private _onSizeChangedObserver;
  27907. /**
  27908. * A function that is added to the onSizeChangedObservable
  27909. */
  27910. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27911. /**
  27912. * An event triggered when the postprocess applies its effect.
  27913. */
  27914. onApplyObservable: Observable<Effect>;
  27915. private _onApplyObserver;
  27916. /**
  27917. * A function that is added to the onApplyObservable
  27918. */
  27919. set onApply(callback: (effect: Effect) => void);
  27920. /**
  27921. * An event triggered before rendering the postprocess
  27922. */
  27923. onBeforeRenderObservable: Observable<Effect>;
  27924. private _onBeforeRenderObserver;
  27925. /**
  27926. * A function that is added to the onBeforeRenderObservable
  27927. */
  27928. set onBeforeRender(callback: (effect: Effect) => void);
  27929. /**
  27930. * An event triggered after rendering the postprocess
  27931. */
  27932. onAfterRenderObservable: Observable<Effect>;
  27933. private _onAfterRenderObserver;
  27934. /**
  27935. * A function that is added to the onAfterRenderObservable
  27936. */
  27937. set onAfterRender(callback: (efect: Effect) => void);
  27938. /**
  27939. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  27940. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27941. */
  27942. get inputTexture(): InternalTexture;
  27943. set inputTexture(value: InternalTexture);
  27944. /**
  27945. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27946. * the only way to unset it is to use this function to restore its internal state
  27947. */
  27948. restoreDefaultInputTexture(): void;
  27949. /**
  27950. * Gets the camera which post process is applied to.
  27951. * @returns The camera the post process is applied to.
  27952. */
  27953. getCamera(): Camera;
  27954. /**
  27955. * Gets the texel size of the postprocess.
  27956. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27957. */
  27958. get texelSize(): Vector2;
  27959. /**
  27960. * Creates a new instance PostProcess
  27961. * @param name The name of the PostProcess.
  27962. * @param fragmentUrl The url of the fragment shader to be used.
  27963. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27964. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27965. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27966. * @param camera The camera to apply the render pass to.
  27967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27968. * @param engine The engine which the post process will be applied. (default: current engine)
  27969. * @param reusable If the post process can be reused on the same frame. (default: false)
  27970. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27971. * @param textureType Type of textures used when performing the post process. (default: 0)
  27972. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27973. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  27974. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27975. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27976. */
  27977. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  27978. /**
  27979. * Gets a string identifying the name of the class
  27980. * @returns "PostProcess" string
  27981. */
  27982. getClassName(): string;
  27983. /**
  27984. * Gets the engine which this post process belongs to.
  27985. * @returns The engine the post process was enabled with.
  27986. */
  27987. getEngine(): Engine;
  27988. /**
  27989. * The effect that is created when initializing the post process.
  27990. * @returns The created effect corresponding the the postprocess.
  27991. */
  27992. getEffect(): Effect;
  27993. /**
  27994. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27995. * @param postProcess The post process to share the output with.
  27996. * @returns This post process.
  27997. */
  27998. shareOutputWith(postProcess: PostProcess): PostProcess;
  27999. /**
  28000. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28001. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28002. */
  28003. useOwnOutput(): void;
  28004. /**
  28005. * Updates the effect with the current post process compile time values and recompiles the shader.
  28006. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28007. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28008. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28009. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  28010. * @param onCompiled Called when the shader has been compiled.
  28011. * @param onError Called if there is an error when compiling a shader.
  28012. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28013. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28014. */
  28015. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  28016. /**
  28017. * The post process is reusable if it can be used multiple times within one frame.
  28018. * @returns If the post process is reusable
  28019. */
  28020. isReusable(): boolean;
  28021. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28022. markTextureDirty(): void;
  28023. /**
  28024. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28025. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  28026. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28027. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28028. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28029. * @returns The target texture that was bound to be written to.
  28030. */
  28031. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28032. /**
  28033. * If the post process is supported.
  28034. */
  28035. get isSupported(): boolean;
  28036. /**
  28037. * The aspect ratio of the output texture.
  28038. */
  28039. get aspectRatio(): number;
  28040. /**
  28041. * Get a value indicating if the post-process is ready to be used
  28042. * @returns true if the post-process is ready (shader is compiled)
  28043. */
  28044. isReady(): boolean;
  28045. /**
  28046. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28047. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28048. */
  28049. apply(): Nullable<Effect>;
  28050. private _disposeTextures;
  28051. /**
  28052. * Sets the required values to the prepass renderer.
  28053. * @param prePassRenderer defines the prepass renderer to setup.
  28054. * @returns true if the pre pass is needed.
  28055. */
  28056. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28057. /**
  28058. * Disposes the post process.
  28059. * @param camera The camera to dispose the post process on.
  28060. */
  28061. dispose(camera?: Camera): void;
  28062. /**
  28063. * Serializes the particle system to a JSON object
  28064. * @returns the JSON object
  28065. */
  28066. serialize(): any;
  28067. /**
  28068. * Creates a material from parsed material data
  28069. * @param parsedPostProcess defines parsed post process data
  28070. * @param scene defines the hosting scene
  28071. * @param rootUrl defines the root URL to use to load textures
  28072. * @returns a new post process
  28073. */
  28074. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28075. }
  28076. }
  28077. declare module BABYLON {
  28078. /** @hidden */
  28079. export var kernelBlurVaryingDeclaration: {
  28080. name: string;
  28081. shader: string;
  28082. };
  28083. }
  28084. declare module BABYLON {
  28085. /** @hidden */
  28086. export var kernelBlurFragment: {
  28087. name: string;
  28088. shader: string;
  28089. };
  28090. }
  28091. declare module BABYLON {
  28092. /** @hidden */
  28093. export var kernelBlurFragment2: {
  28094. name: string;
  28095. shader: string;
  28096. };
  28097. }
  28098. declare module BABYLON {
  28099. /** @hidden */
  28100. export var kernelBlurPixelShader: {
  28101. name: string;
  28102. shader: string;
  28103. };
  28104. }
  28105. declare module BABYLON {
  28106. /** @hidden */
  28107. export var kernelBlurVertex: {
  28108. name: string;
  28109. shader: string;
  28110. };
  28111. }
  28112. declare module BABYLON {
  28113. /** @hidden */
  28114. export var kernelBlurVertexShader: {
  28115. name: string;
  28116. shader: string;
  28117. };
  28118. }
  28119. declare module BABYLON {
  28120. /**
  28121. * The Blur Post Process which blurs an image based on a kernel and direction.
  28122. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28123. */
  28124. export class BlurPostProcess extends PostProcess {
  28125. private blockCompilation;
  28126. protected _kernel: number;
  28127. protected _idealKernel: number;
  28128. protected _packedFloat: boolean;
  28129. private _staticDefines;
  28130. /** The direction in which to blur the image. */
  28131. direction: Vector2;
  28132. /**
  28133. * Sets the length in pixels of the blur sample region
  28134. */
  28135. set kernel(v: number);
  28136. /**
  28137. * Gets the length in pixels of the blur sample region
  28138. */
  28139. get kernel(): number;
  28140. /**
  28141. * Sets wether or not the blur needs to unpack/repack floats
  28142. */
  28143. set packedFloat(v: boolean);
  28144. /**
  28145. * Gets wether or not the blur is unpacking/repacking floats
  28146. */
  28147. get packedFloat(): boolean;
  28148. /**
  28149. * Gets a string identifying the name of the class
  28150. * @returns "BlurPostProcess" string
  28151. */
  28152. getClassName(): string;
  28153. /**
  28154. * Creates a new instance BlurPostProcess
  28155. * @param name The name of the effect.
  28156. * @param direction The direction in which to blur the image.
  28157. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  28158. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28159. * @param camera The camera to apply the render pass to.
  28160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28161. * @param engine The engine which the post process will be applied. (default: current engine)
  28162. * @param reusable If the post process can be reused on the same frame. (default: false)
  28163. * @param textureType Type of textures used when performing the post process. (default: 0)
  28164. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  28165. */
  28166. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  28167. /**
  28168. * Updates the effect with the current post process compile time values and recompiles the shader.
  28169. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28170. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28171. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28172. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  28173. * @param onCompiled Called when the shader has been compiled.
  28174. * @param onError Called if there is an error when compiling a shader.
  28175. */
  28176. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28177. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28178. /**
  28179. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28180. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28181. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28182. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28183. * The gaps between physical kernels are compensated for in the weighting of the samples
  28184. * @param idealKernel Ideal blur kernel.
  28185. * @return Nearest best kernel.
  28186. */
  28187. protected _nearestBestKernel(idealKernel: number): number;
  28188. /**
  28189. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28190. * @param x The point on the Gaussian distribution to sample.
  28191. * @return the value of the Gaussian function at x.
  28192. */
  28193. protected _gaussianWeight(x: number): number;
  28194. /**
  28195. * Generates a string that can be used as a floating point number in GLSL.
  28196. * @param x Value to print.
  28197. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28198. * @return GLSL float string.
  28199. */
  28200. protected _glslFloat(x: number, decimalFigures?: number): string;
  28201. /** @hidden */
  28202. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28203. }
  28204. }
  28205. declare module BABYLON {
  28206. /**
  28207. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28208. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28209. * You can then easily use it as a reflectionTexture on a flat surface.
  28210. * In case the surface is not a plane, please consider relying on reflection probes.
  28211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28212. */
  28213. export class MirrorTexture extends RenderTargetTexture {
  28214. private scene;
  28215. /**
  28216. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28217. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  28218. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28219. */
  28220. mirrorPlane: Plane;
  28221. /**
  28222. * Define the blur ratio used to blur the reflection if needed.
  28223. */
  28224. set blurRatio(value: number);
  28225. get blurRatio(): number;
  28226. /**
  28227. * Define the adaptive blur kernel used to blur the reflection if needed.
  28228. * This will autocompute the closest best match for the `blurKernel`
  28229. */
  28230. set adaptiveBlurKernel(value: number);
  28231. /**
  28232. * Define the blur kernel used to blur the reflection if needed.
  28233. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28234. */
  28235. set blurKernel(value: number);
  28236. /**
  28237. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28239. */
  28240. set blurKernelX(value: number);
  28241. get blurKernelX(): number;
  28242. /**
  28243. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28244. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28245. */
  28246. set blurKernelY(value: number);
  28247. get blurKernelY(): number;
  28248. private _autoComputeBlurKernel;
  28249. protected _onRatioRescale(): void;
  28250. private _updateGammaSpace;
  28251. private _imageProcessingConfigChangeObserver;
  28252. private _transformMatrix;
  28253. private _mirrorMatrix;
  28254. private _savedViewMatrix;
  28255. private _blurX;
  28256. private _blurY;
  28257. private _adaptiveBlurKernel;
  28258. private _blurKernelX;
  28259. private _blurKernelY;
  28260. private _blurRatio;
  28261. /**
  28262. * Instantiates a Mirror Texture.
  28263. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28264. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28265. * You can then easily use it as a reflectionTexture on a flat surface.
  28266. * In case the surface is not a plane, please consider relying on reflection probes.
  28267. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28268. * @param name
  28269. * @param size
  28270. * @param scene
  28271. * @param generateMipMaps
  28272. * @param type
  28273. * @param samplingMode
  28274. * @param generateDepthBuffer
  28275. */
  28276. constructor(name: string, size: number | {
  28277. width: number;
  28278. height: number;
  28279. } | {
  28280. ratio: number;
  28281. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28282. private _preparePostProcesses;
  28283. /**
  28284. * Clone the mirror texture.
  28285. * @returns the cloned texture
  28286. */
  28287. clone(): MirrorTexture;
  28288. /**
  28289. * Serialize the texture to a JSON representation you could use in Parse later on
  28290. * @returns the serialized JSON representation
  28291. */
  28292. serialize(): any;
  28293. /**
  28294. * Dispose the texture and release its associated resources.
  28295. */
  28296. dispose(): void;
  28297. }
  28298. }
  28299. declare module BABYLON {
  28300. /**
  28301. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28302. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28303. */
  28304. export class Texture extends BaseTexture {
  28305. /**
  28306. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28307. */
  28308. static SerializeBuffers: boolean;
  28309. /**
  28310. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  28311. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  28312. */
  28313. static ForceSerializeBuffers: boolean;
  28314. /** @hidden */
  28315. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28316. /** @hidden */
  28317. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28318. /** @hidden */
  28319. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28320. /** nearest is mag = nearest and min = nearest and mip = linear */
  28321. static readonly NEAREST_SAMPLINGMODE: number;
  28322. /** nearest is mag = nearest and min = nearest and mip = linear */
  28323. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28324. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28325. static readonly BILINEAR_SAMPLINGMODE: number;
  28326. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28327. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28328. /** Trilinear is mag = linear and min = linear and mip = linear */
  28329. static readonly TRILINEAR_SAMPLINGMODE: number;
  28330. /** Trilinear is mag = linear and min = linear and mip = linear */
  28331. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28332. /** mag = nearest and min = nearest and mip = nearest */
  28333. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28334. /** mag = nearest and min = linear and mip = nearest */
  28335. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28336. /** mag = nearest and min = linear and mip = linear */
  28337. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28338. /** mag = nearest and min = linear and mip = none */
  28339. static readonly NEAREST_LINEAR: number;
  28340. /** mag = nearest and min = nearest and mip = none */
  28341. static readonly NEAREST_NEAREST: number;
  28342. /** mag = linear and min = nearest and mip = nearest */
  28343. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28344. /** mag = linear and min = nearest and mip = linear */
  28345. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28346. /** mag = linear and min = linear and mip = none */
  28347. static readonly LINEAR_LINEAR: number;
  28348. /** mag = linear and min = nearest and mip = none */
  28349. static readonly LINEAR_NEAREST: number;
  28350. /** Explicit coordinates mode */
  28351. static readonly EXPLICIT_MODE: number;
  28352. /** Spherical coordinates mode */
  28353. static readonly SPHERICAL_MODE: number;
  28354. /** Planar coordinates mode */
  28355. static readonly PLANAR_MODE: number;
  28356. /** Cubic coordinates mode */
  28357. static readonly CUBIC_MODE: number;
  28358. /** Projection coordinates mode */
  28359. static readonly PROJECTION_MODE: number;
  28360. /** Inverse Cubic coordinates mode */
  28361. static readonly SKYBOX_MODE: number;
  28362. /** Inverse Cubic coordinates mode */
  28363. static readonly INVCUBIC_MODE: number;
  28364. /** Equirectangular coordinates mode */
  28365. static readonly EQUIRECTANGULAR_MODE: number;
  28366. /** Equirectangular Fixed coordinates mode */
  28367. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28368. /** Equirectangular Fixed Mirrored coordinates mode */
  28369. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28370. /** Texture is not repeating outside of 0..1 UVs */
  28371. static readonly CLAMP_ADDRESSMODE: number;
  28372. /** Texture is repeating outside of 0..1 UVs */
  28373. static readonly WRAP_ADDRESSMODE: number;
  28374. /** Texture is repeating and mirrored */
  28375. static readonly MIRROR_ADDRESSMODE: number;
  28376. /**
  28377. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  28378. */
  28379. static UseSerializedUrlIfAny: boolean;
  28380. /**
  28381. * Define the url of the texture.
  28382. */
  28383. url: Nullable<string>;
  28384. /**
  28385. * Define an offset on the texture to offset the u coordinates of the UVs
  28386. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28387. */
  28388. uOffset: number;
  28389. /**
  28390. * Define an offset on the texture to offset the v coordinates of the UVs
  28391. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28392. */
  28393. vOffset: number;
  28394. /**
  28395. * Define an offset on the texture to scale the u coordinates of the UVs
  28396. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28397. */
  28398. uScale: number;
  28399. /**
  28400. * Define an offset on the texture to scale the v coordinates of the UVs
  28401. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28402. */
  28403. vScale: number;
  28404. /**
  28405. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28406. * @see https://doc.babylonjs.com/how_to/more_materials
  28407. */
  28408. uAng: number;
  28409. /**
  28410. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28411. * @see https://doc.babylonjs.com/how_to/more_materials
  28412. */
  28413. vAng: number;
  28414. /**
  28415. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28416. * @see https://doc.babylonjs.com/how_to/more_materials
  28417. */
  28418. wAng: number;
  28419. /**
  28420. * Defines the center of rotation (U)
  28421. */
  28422. uRotationCenter: number;
  28423. /**
  28424. * Defines the center of rotation (V)
  28425. */
  28426. vRotationCenter: number;
  28427. /**
  28428. * Defines the center of rotation (W)
  28429. */
  28430. wRotationCenter: number;
  28431. /**
  28432. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28433. */
  28434. homogeneousRotationInUVTransform: boolean;
  28435. /**
  28436. * Are mip maps generated for this texture or not.
  28437. */
  28438. get noMipmap(): boolean;
  28439. /**
  28440. * List of inspectable custom properties (used by the Inspector)
  28441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28442. */
  28443. inspectableCustomProperties: Nullable<IInspectable[]>;
  28444. private _noMipmap;
  28445. /** @hidden */
  28446. _invertY: boolean;
  28447. private _rowGenerationMatrix;
  28448. private _cachedTextureMatrix;
  28449. private _projectionModeMatrix;
  28450. private _t0;
  28451. private _t1;
  28452. private _t2;
  28453. private _cachedUOffset;
  28454. private _cachedVOffset;
  28455. private _cachedUScale;
  28456. private _cachedVScale;
  28457. private _cachedUAng;
  28458. private _cachedVAng;
  28459. private _cachedWAng;
  28460. private _cachedProjectionMatrixId;
  28461. private _cachedURotationCenter;
  28462. private _cachedVRotationCenter;
  28463. private _cachedWRotationCenter;
  28464. private _cachedHomogeneousRotationInUVTransform;
  28465. private _cachedCoordinatesMode;
  28466. /** @hidden */
  28467. protected _initialSamplingMode: number;
  28468. /** @hidden */
  28469. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28470. private _deleteBuffer;
  28471. protected _format: Nullable<number>;
  28472. private _delayedOnLoad;
  28473. private _delayedOnError;
  28474. private _mimeType?;
  28475. private _loaderOptions?;
  28476. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28477. get mimeType(): string | undefined;
  28478. /**
  28479. * Observable triggered once the texture has been loaded.
  28480. */
  28481. onLoadObservable: Observable<Texture>;
  28482. protected _isBlocking: boolean;
  28483. /**
  28484. * Is the texture preventing material to render while loading.
  28485. * If false, a default texture will be used instead of the loading one during the preparation step.
  28486. */
  28487. set isBlocking(value: boolean);
  28488. get isBlocking(): boolean;
  28489. /**
  28490. * Get the current sampling mode associated with the texture.
  28491. */
  28492. get samplingMode(): number;
  28493. /**
  28494. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28495. */
  28496. get invertY(): boolean;
  28497. /**
  28498. * Instantiates a new texture.
  28499. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28500. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28501. * @param url defines the url of the picture to load as a texture
  28502. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28503. * @param noMipmap defines if the texture will require mip maps or not
  28504. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28505. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28506. * @param onLoad defines a callback triggered when the texture has been loaded
  28507. * @param onError defines a callback triggered when an error occurred during the loading session
  28508. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28509. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28510. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28511. * @param mimeType defines an optional mime type information
  28512. * @param loaderOptions options to be passed to the loader
  28513. */
  28514. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  28515. /**
  28516. * Update the url (and optional buffer) of this texture if url was null during construction.
  28517. * @param url the url of the texture
  28518. * @param buffer the buffer of the texture (defaults to null)
  28519. * @param onLoad callback called when the texture is loaded (defaults to null)
  28520. */
  28521. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28522. /**
  28523. * Finish the loading sequence of a texture flagged as delayed load.
  28524. * @hidden
  28525. */
  28526. delayLoad(): void;
  28527. private _prepareRowForTextureGeneration;
  28528. /**
  28529. * Checks if the texture has the same transform matrix than another texture
  28530. * @param texture texture to check against
  28531. * @returns true if the transforms are the same, else false
  28532. */
  28533. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28534. /**
  28535. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28536. * @returns the transform matrix of the texture.
  28537. */
  28538. getTextureMatrix(uBase?: number): Matrix;
  28539. /**
  28540. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28541. * @returns The reflection texture transform
  28542. */
  28543. getReflectionTextureMatrix(): Matrix;
  28544. /**
  28545. * Clones the texture.
  28546. * @returns the cloned texture
  28547. */
  28548. clone(): Texture;
  28549. /**
  28550. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28551. * @returns The JSON representation of the texture
  28552. */
  28553. serialize(): any;
  28554. /**
  28555. * Get the current class name of the texture useful for serialization or dynamic coding.
  28556. * @returns "Texture"
  28557. */
  28558. getClassName(): string;
  28559. /**
  28560. * Dispose the texture and release its associated resources.
  28561. */
  28562. dispose(): void;
  28563. /**
  28564. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28565. * @param parsedTexture Define the JSON representation of the texture
  28566. * @param scene Define the scene the parsed texture should be instantiated in
  28567. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28568. * @returns The parsed texture if successful
  28569. */
  28570. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28571. /**
  28572. * Creates a texture from its base 64 representation.
  28573. * @param data Define the base64 payload without the data: prefix
  28574. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28575. * @param scene Define the scene the texture should belong to
  28576. * @param noMipmap Forces the texture to not create mip map information if true
  28577. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28578. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28579. * @param onLoad define a callback triggered when the texture has been loaded
  28580. * @param onError define a callback triggered when an error occurred during the loading session
  28581. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28582. * @returns the created texture
  28583. */
  28584. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28585. /**
  28586. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28587. * @param data Define the base64 payload without the data: prefix
  28588. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28589. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28590. * @param scene Define the scene the texture should belong to
  28591. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28592. * @param noMipmap Forces the texture to not create mip map information if true
  28593. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28594. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28595. * @param onLoad define a callback triggered when the texture has been loaded
  28596. * @param onError define a callback triggered when an error occurred during the loading session
  28597. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28598. * @returns the created texture
  28599. */
  28600. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  28601. }
  28602. }
  28603. declare module BABYLON {
  28604. /**
  28605. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28606. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28607. */
  28608. export class PostProcessManager {
  28609. private _scene;
  28610. private _indexBuffer;
  28611. private _vertexBuffers;
  28612. /**
  28613. * Creates a new instance PostProcess
  28614. * @param scene The scene that the post process is associated with.
  28615. */
  28616. constructor(scene: Scene);
  28617. private _prepareBuffers;
  28618. private _buildIndexBuffer;
  28619. /**
  28620. * Rebuilds the vertex buffers of the manager.
  28621. * @hidden
  28622. */
  28623. _rebuild(): void;
  28624. /**
  28625. * Prepares a frame to be run through a post process.
  28626. * @param sourceTexture The input texture to the post procesess. (default: null)
  28627. * @param postProcesses An array of post processes to be run. (default: null)
  28628. * @returns True if the post processes were able to be run.
  28629. * @hidden
  28630. */
  28631. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28632. /**
  28633. * Manually render a set of post processes to a texture.
  28634. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28635. * @param postProcesses An array of post processes to be run.
  28636. * @param targetTexture The target texture to render to.
  28637. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28638. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28639. * @param lodLevel defines which lod of the texture to render to
  28640. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28641. */
  28642. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28643. /**
  28644. * Finalize the result of the output of the postprocesses.
  28645. * @param doNotPresent If true the result will not be displayed to the screen.
  28646. * @param targetTexture The target texture to render to.
  28647. * @param faceIndex The index of the face to bind the target texture to.
  28648. * @param postProcesses The array of post processes to render.
  28649. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28650. * @hidden
  28651. */
  28652. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28653. /**
  28654. * Disposes of the post process manager.
  28655. */
  28656. dispose(): void;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * This Helps creating a texture that will be created from a camera in your scene.
  28662. * It is basically a dynamic texture that could be used to create special effects for instance.
  28663. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28664. */
  28665. export class RenderTargetTexture extends Texture {
  28666. /**
  28667. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28668. */
  28669. static readonly REFRESHRATE_RENDER_ONCE: number;
  28670. /**
  28671. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28672. */
  28673. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28674. /**
  28675. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28676. * the central point of your effect and can save a lot of performances.
  28677. */
  28678. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28679. /**
  28680. * Use this predicate to dynamically define the list of mesh you want to render.
  28681. * If set, the renderList property will be overwritten.
  28682. */
  28683. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28684. private _renderList;
  28685. /**
  28686. * Use this list to define the list of mesh you want to render.
  28687. */
  28688. get renderList(): Nullable<Array<AbstractMesh>>;
  28689. set renderList(value: Nullable<Array<AbstractMesh>>);
  28690. /**
  28691. * Use this function to overload the renderList array at rendering time.
  28692. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28693. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28694. * the cube (if the RTT is a cube, else layerOrFace=0).
  28695. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28696. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28697. * hold dummy elements!
  28698. */
  28699. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28700. private _hookArray;
  28701. /**
  28702. * Define if particles should be rendered in your texture.
  28703. */
  28704. renderParticles: boolean;
  28705. /**
  28706. * Define if sprites should be rendered in your texture.
  28707. */
  28708. renderSprites: boolean;
  28709. /**
  28710. * Define the camera used to render the texture.
  28711. */
  28712. activeCamera: Nullable<Camera>;
  28713. /**
  28714. * Override the mesh isReady function with your own one.
  28715. */
  28716. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28717. /**
  28718. * Override the render function of the texture with your own one.
  28719. */
  28720. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28721. /**
  28722. * Define if camera post processes should be use while rendering the texture.
  28723. */
  28724. useCameraPostProcesses: boolean;
  28725. /**
  28726. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28727. */
  28728. ignoreCameraViewport: boolean;
  28729. private _postProcessManager;
  28730. private _postProcesses;
  28731. private _resizeObserver;
  28732. /**
  28733. * An event triggered when the texture is unbind.
  28734. */
  28735. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28736. /**
  28737. * An event triggered when the texture is unbind.
  28738. */
  28739. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28740. private _onAfterUnbindObserver;
  28741. /**
  28742. * Set a after unbind callback in the texture.
  28743. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28744. */
  28745. set onAfterUnbind(callback: () => void);
  28746. /**
  28747. * An event triggered before rendering the texture
  28748. */
  28749. onBeforeRenderObservable: Observable<number>;
  28750. private _onBeforeRenderObserver;
  28751. /**
  28752. * Set a before render callback in the texture.
  28753. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28754. */
  28755. set onBeforeRender(callback: (faceIndex: number) => void);
  28756. /**
  28757. * An event triggered after rendering the texture
  28758. */
  28759. onAfterRenderObservable: Observable<number>;
  28760. private _onAfterRenderObserver;
  28761. /**
  28762. * Set a after render callback in the texture.
  28763. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28764. */
  28765. set onAfterRender(callback: (faceIndex: number) => void);
  28766. /**
  28767. * An event triggered after the texture clear
  28768. */
  28769. onClearObservable: Observable<Engine>;
  28770. private _onClearObserver;
  28771. /**
  28772. * Set a clear callback in the texture.
  28773. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28774. */
  28775. set onClear(callback: (Engine: Engine) => void);
  28776. /**
  28777. * An event triggered when the texture is resized.
  28778. */
  28779. onResizeObservable: Observable<RenderTargetTexture>;
  28780. /**
  28781. * Define the clear color of the Render Target if it should be different from the scene.
  28782. */
  28783. clearColor: Color4;
  28784. protected _size: number | {
  28785. width: number;
  28786. height: number;
  28787. layers?: number;
  28788. };
  28789. protected _initialSizeParameter: number | {
  28790. width: number;
  28791. height: number;
  28792. } | {
  28793. ratio: number;
  28794. };
  28795. protected _sizeRatio: Nullable<number>;
  28796. /** @hidden */
  28797. _generateMipMaps: boolean;
  28798. protected _renderingManager: RenderingManager;
  28799. /** @hidden */
  28800. _waitingRenderList?: string[];
  28801. protected _doNotChangeAspectRatio: boolean;
  28802. protected _currentRefreshId: number;
  28803. protected _refreshRate: number;
  28804. protected _textureMatrix: Matrix;
  28805. protected _samples: number;
  28806. protected _renderTargetOptions: RenderTargetCreationOptions;
  28807. /**
  28808. * Gets render target creation options that were used.
  28809. */
  28810. get renderTargetOptions(): RenderTargetCreationOptions;
  28811. protected _onRatioRescale(): void;
  28812. /**
  28813. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28814. * It must define where the camera used to render the texture is set
  28815. */
  28816. boundingBoxPosition: Vector3;
  28817. private _boundingBoxSize;
  28818. /**
  28819. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28820. * When defined, the cubemap will switch to local mode
  28821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28822. * @example https://www.babylonjs-playground.com/#RNASML
  28823. */
  28824. set boundingBoxSize(value: Vector3);
  28825. get boundingBoxSize(): Vector3;
  28826. /**
  28827. * In case the RTT has been created with a depth texture, get the associated
  28828. * depth texture.
  28829. * Otherwise, return null.
  28830. */
  28831. get depthStencilTexture(): Nullable<InternalTexture>;
  28832. /**
  28833. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28834. * or used a shadow, depth texture...
  28835. * @param name The friendly name of the texture
  28836. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  28837. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28838. * @param generateMipMaps True if mip maps need to be generated after render.
  28839. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28840. * @param type The type of the buffer in the RTT (int, half float, float...)
  28841. * @param isCube True if a cube texture needs to be created
  28842. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28843. * @param generateDepthBuffer True to generate a depth buffer
  28844. * @param generateStencilBuffer True to generate a stencil buffer
  28845. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28846. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28847. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28848. */
  28849. constructor(name: string, size: number | {
  28850. width: number;
  28851. height: number;
  28852. layers?: number;
  28853. } | {
  28854. ratio: number;
  28855. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28856. /**
  28857. * Creates a depth stencil texture.
  28858. * This is only available in WebGL 2 or with the depth texture extension available.
  28859. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28860. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28861. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28862. */
  28863. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28864. private _processSizeParameter;
  28865. /**
  28866. * Define the number of samples to use in case of MSAA.
  28867. * It defaults to one meaning no MSAA has been enabled.
  28868. */
  28869. get samples(): number;
  28870. set samples(value: number);
  28871. /**
  28872. * Resets the refresh counter of the texture and start bak from scratch.
  28873. * Could be useful to regenerate the texture if it is setup to render only once.
  28874. */
  28875. resetRefreshCounter(): void;
  28876. /**
  28877. * Define the refresh rate of the texture or the rendering frequency.
  28878. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28879. */
  28880. get refreshRate(): number;
  28881. set refreshRate(value: number);
  28882. /**
  28883. * Adds a post process to the render target rendering passes.
  28884. * @param postProcess define the post process to add
  28885. */
  28886. addPostProcess(postProcess: PostProcess): void;
  28887. /**
  28888. * Clear all the post processes attached to the render target
  28889. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28890. */
  28891. clearPostProcesses(dispose?: boolean): void;
  28892. /**
  28893. * Remove one of the post process from the list of attached post processes to the texture
  28894. * @param postProcess define the post process to remove from the list
  28895. */
  28896. removePostProcess(postProcess: PostProcess): void;
  28897. /** @hidden */
  28898. _shouldRender(): boolean;
  28899. /**
  28900. * Gets the actual render size of the texture.
  28901. * @returns the width of the render size
  28902. */
  28903. getRenderSize(): number;
  28904. /**
  28905. * Gets the actual render width of the texture.
  28906. * @returns the width of the render size
  28907. */
  28908. getRenderWidth(): number;
  28909. /**
  28910. * Gets the actual render height of the texture.
  28911. * @returns the height of the render size
  28912. */
  28913. getRenderHeight(): number;
  28914. /**
  28915. * Gets the actual number of layers of the texture.
  28916. * @returns the number of layers
  28917. */
  28918. getRenderLayers(): number;
  28919. /**
  28920. * Get if the texture can be rescaled or not.
  28921. */
  28922. get canRescale(): boolean;
  28923. /**
  28924. * Resize the texture using a ratio.
  28925. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28926. */
  28927. scale(ratio: number): void;
  28928. /**
  28929. * Get the texture reflection matrix used to rotate/transform the reflection.
  28930. * @returns the reflection matrix
  28931. */
  28932. getReflectionTextureMatrix(): Matrix;
  28933. /**
  28934. * Resize the texture to a new desired size.
  28935. * Be carrefull as it will recreate all the data in the new texture.
  28936. * @param size Define the new size. It can be:
  28937. * - a number for squared texture,
  28938. * - an object containing { width: number, height: number }
  28939. * - or an object containing a ratio { ratio: number }
  28940. */
  28941. resize(size: number | {
  28942. width: number;
  28943. height: number;
  28944. } | {
  28945. ratio: number;
  28946. }): void;
  28947. private _defaultRenderListPrepared;
  28948. /**
  28949. * Renders all the objects from the render list into the texture.
  28950. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28951. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28952. */
  28953. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28954. private _bestReflectionRenderTargetDimension;
  28955. private _prepareRenderingManager;
  28956. /**
  28957. * @hidden
  28958. * @param faceIndex face index to bind to if this is a cubetexture
  28959. * @param layer defines the index of the texture to bind in the array
  28960. */
  28961. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28962. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28963. private renderToTarget;
  28964. /**
  28965. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28966. * This allowed control for front to back rendering or reversly depending of the special needs.
  28967. *
  28968. * @param renderingGroupId The rendering group id corresponding to its index
  28969. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28970. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28971. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28972. */
  28973. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  28974. /**
  28975. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28976. *
  28977. * @param renderingGroupId The rendering group id corresponding to its index
  28978. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28979. */
  28980. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28981. /**
  28982. * Clones the texture.
  28983. * @returns the cloned texture
  28984. */
  28985. clone(): RenderTargetTexture;
  28986. /**
  28987. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28988. * @returns The JSON representation of the texture
  28989. */
  28990. serialize(): any;
  28991. /**
  28992. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28993. */
  28994. disposeFramebufferObjects(): void;
  28995. /**
  28996. * Dispose the texture and release its associated resources.
  28997. */
  28998. dispose(): void;
  28999. /** @hidden */
  29000. _rebuild(): void;
  29001. /**
  29002. * Clear the info related to rendering groups preventing retention point in material dispose.
  29003. */
  29004. freeRenderingGroups(): void;
  29005. /**
  29006. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29007. * @returns the view count
  29008. */
  29009. getViewCount(): number;
  29010. }
  29011. }
  29012. declare module BABYLON {
  29013. /**
  29014. * Class used to manipulate GUIDs
  29015. */
  29016. export class GUID {
  29017. /**
  29018. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29019. * Be aware Math.random() could cause collisions, but:
  29020. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  29021. * @returns a pseudo random id
  29022. */
  29023. static RandomId(): string;
  29024. }
  29025. }
  29026. declare module BABYLON {
  29027. /**
  29028. * Options to be used when creating a shadow depth material
  29029. */
  29030. export interface IIOptionShadowDepthMaterial {
  29031. /** Variables in the vertex shader code that need to have their names remapped.
  29032. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29033. * "var_name" should be either: worldPos or vNormalW
  29034. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29035. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29036. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29037. */
  29038. remappedVariables?: string[];
  29039. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29040. standalone?: boolean;
  29041. }
  29042. /**
  29043. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29044. */
  29045. export class ShadowDepthWrapper {
  29046. private _scene;
  29047. private _options?;
  29048. private _baseMaterial;
  29049. private _onEffectCreatedObserver;
  29050. private _subMeshToEffect;
  29051. private _subMeshToDepthEffect;
  29052. private _meshes;
  29053. /** @hidden */
  29054. _matriceNames: any;
  29055. /** Gets the standalone status of the wrapper */
  29056. get standalone(): boolean;
  29057. /** Gets the base material the wrapper is built upon */
  29058. get baseMaterial(): Material;
  29059. /**
  29060. * Instantiate a new shadow depth wrapper.
  29061. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29062. * generate the shadow depth map. For more information, please refer to the documentation:
  29063. * https://doc.babylonjs.com/babylon101/shadows
  29064. * @param baseMaterial Material to wrap
  29065. * @param scene Define the scene the material belongs to
  29066. * @param options Options used to create the wrapper
  29067. */
  29068. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29069. /**
  29070. * Gets the effect to use to generate the depth map
  29071. * @param subMesh subMesh to get the effect for
  29072. * @param shadowGenerator shadow generator to get the effect for
  29073. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29074. */
  29075. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29076. /**
  29077. * Specifies that the submesh is ready to be used for depth rendering
  29078. * @param subMesh submesh to check
  29079. * @param defines the list of defines to take into account when checking the effect
  29080. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29081. * @param useInstances specifies that instances should be used
  29082. * @returns a boolean indicating that the submesh is ready or not
  29083. */
  29084. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29085. /**
  29086. * Disposes the resources
  29087. */
  29088. dispose(): void;
  29089. private _makeEffect;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * Options for compiling materials.
  29095. */
  29096. export interface IMaterialCompilationOptions {
  29097. /**
  29098. * Defines whether clip planes are enabled.
  29099. */
  29100. clipPlane: boolean;
  29101. /**
  29102. * Defines whether instances are enabled.
  29103. */
  29104. useInstances: boolean;
  29105. }
  29106. /**
  29107. * Options passed when calling customShaderNameResolve
  29108. */
  29109. export interface ICustomShaderNameResolveOptions {
  29110. /**
  29111. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  29112. */
  29113. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29114. }
  29115. /**
  29116. * Base class for the main features of a material in Babylon.js
  29117. */
  29118. export class Material implements IAnimatable {
  29119. /**
  29120. * Returns the triangle fill mode
  29121. */
  29122. static readonly TriangleFillMode: number;
  29123. /**
  29124. * Returns the wireframe mode
  29125. */
  29126. static readonly WireFrameFillMode: number;
  29127. /**
  29128. * Returns the point fill mode
  29129. */
  29130. static readonly PointFillMode: number;
  29131. /**
  29132. * Returns the point list draw mode
  29133. */
  29134. static readonly PointListDrawMode: number;
  29135. /**
  29136. * Returns the line list draw mode
  29137. */
  29138. static readonly LineListDrawMode: number;
  29139. /**
  29140. * Returns the line loop draw mode
  29141. */
  29142. static readonly LineLoopDrawMode: number;
  29143. /**
  29144. * Returns the line strip draw mode
  29145. */
  29146. static readonly LineStripDrawMode: number;
  29147. /**
  29148. * Returns the triangle strip draw mode
  29149. */
  29150. static readonly TriangleStripDrawMode: number;
  29151. /**
  29152. * Returns the triangle fan draw mode
  29153. */
  29154. static readonly TriangleFanDrawMode: number;
  29155. /**
  29156. * Stores the clock-wise side orientation
  29157. */
  29158. static readonly ClockWiseSideOrientation: number;
  29159. /**
  29160. * Stores the counter clock-wise side orientation
  29161. */
  29162. static readonly CounterClockWiseSideOrientation: number;
  29163. /**
  29164. * The dirty texture flag value
  29165. */
  29166. static readonly TextureDirtyFlag: number;
  29167. /**
  29168. * The dirty light flag value
  29169. */
  29170. static readonly LightDirtyFlag: number;
  29171. /**
  29172. * The dirty fresnel flag value
  29173. */
  29174. static readonly FresnelDirtyFlag: number;
  29175. /**
  29176. * The dirty attribute flag value
  29177. */
  29178. static readonly AttributesDirtyFlag: number;
  29179. /**
  29180. * The dirty misc flag value
  29181. */
  29182. static readonly MiscDirtyFlag: number;
  29183. /**
  29184. * The dirty prepass flag value
  29185. */
  29186. static readonly PrePassDirtyFlag: number;
  29187. /**
  29188. * The all dirty flag value
  29189. */
  29190. static readonly AllDirtyFlag: number;
  29191. /**
  29192. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29193. */
  29194. static readonly MATERIAL_OPAQUE: number;
  29195. /**
  29196. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29197. */
  29198. static readonly MATERIAL_ALPHATEST: number;
  29199. /**
  29200. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29201. */
  29202. static readonly MATERIAL_ALPHABLEND: number;
  29203. /**
  29204. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29205. * They are also discarded below the alpha cutoff threshold to improve performances.
  29206. */
  29207. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29208. /**
  29209. * The Whiteout method is used to blend normals.
  29210. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29211. */
  29212. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29213. /**
  29214. * The Reoriented Normal Mapping method is used to blend normals.
  29215. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29216. */
  29217. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29218. /**
  29219. * Custom callback helping to override the default shader used in the material.
  29220. */
  29221. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29222. /**
  29223. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29224. */
  29225. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29226. /**
  29227. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29228. * This means that the material can keep using a previous shader while a new one is being compiled.
  29229. * This is mostly used when shader parallel compilation is supported (true by default)
  29230. */
  29231. allowShaderHotSwapping: boolean;
  29232. /**
  29233. * The ID of the material
  29234. */
  29235. id: string;
  29236. /**
  29237. * Gets or sets the unique id of the material
  29238. */
  29239. uniqueId: number;
  29240. /**
  29241. * The name of the material
  29242. */
  29243. name: string;
  29244. /**
  29245. * Gets or sets user defined metadata
  29246. */
  29247. metadata: any;
  29248. /**
  29249. * For internal use only. Please do not use.
  29250. */
  29251. reservedDataStore: any;
  29252. /**
  29253. * Specifies if the ready state should be checked on each call
  29254. */
  29255. checkReadyOnEveryCall: boolean;
  29256. /**
  29257. * Specifies if the ready state should be checked once
  29258. */
  29259. checkReadyOnlyOnce: boolean;
  29260. /**
  29261. * The state of the material
  29262. */
  29263. state: string;
  29264. /**
  29265. * If the material can be rendered to several textures with MRT extension
  29266. */
  29267. get canRenderToMRT(): boolean;
  29268. /**
  29269. * The alpha value of the material
  29270. */
  29271. protected _alpha: number;
  29272. /**
  29273. * List of inspectable custom properties (used by the Inspector)
  29274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29275. */
  29276. inspectableCustomProperties: IInspectable[];
  29277. /**
  29278. * Sets the alpha value of the material
  29279. */
  29280. set alpha(value: number);
  29281. /**
  29282. * Gets the alpha value of the material
  29283. */
  29284. get alpha(): number;
  29285. /**
  29286. * Specifies if back face culling is enabled
  29287. */
  29288. protected _backFaceCulling: boolean;
  29289. /**
  29290. * Sets the back-face culling state
  29291. */
  29292. set backFaceCulling(value: boolean);
  29293. /**
  29294. * Gets the back-face culling state
  29295. */
  29296. get backFaceCulling(): boolean;
  29297. /**
  29298. * Stores the value for side orientation
  29299. */
  29300. sideOrientation: number;
  29301. /**
  29302. * Callback triggered when the material is compiled
  29303. */
  29304. onCompiled: Nullable<(effect: Effect) => void>;
  29305. /**
  29306. * Callback triggered when an error occurs
  29307. */
  29308. onError: Nullable<(effect: Effect, errors: string) => void>;
  29309. /**
  29310. * Callback triggered to get the render target textures
  29311. */
  29312. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29313. /**
  29314. * Gets a boolean indicating that current material needs to register RTT
  29315. */
  29316. get hasRenderTargetTextures(): boolean;
  29317. /**
  29318. * Specifies if the material should be serialized
  29319. */
  29320. doNotSerialize: boolean;
  29321. /**
  29322. * @hidden
  29323. */
  29324. _storeEffectOnSubMeshes: boolean;
  29325. /**
  29326. * Stores the animations for the material
  29327. */
  29328. animations: Nullable<Array<Animation>>;
  29329. /**
  29330. * An event triggered when the material is disposed
  29331. */
  29332. onDisposeObservable: Observable<Material>;
  29333. /**
  29334. * An observer which watches for dispose events
  29335. */
  29336. private _onDisposeObserver;
  29337. private _onUnBindObservable;
  29338. /**
  29339. * Called during a dispose event
  29340. */
  29341. set onDispose(callback: () => void);
  29342. private _onBindObservable;
  29343. /**
  29344. * An event triggered when the material is bound
  29345. */
  29346. get onBindObservable(): Observable<AbstractMesh>;
  29347. /**
  29348. * An observer which watches for bind events
  29349. */
  29350. private _onBindObserver;
  29351. /**
  29352. * Called during a bind event
  29353. */
  29354. set onBind(callback: (Mesh: AbstractMesh) => void);
  29355. /**
  29356. * An event triggered when the material is unbound
  29357. */
  29358. get onUnBindObservable(): Observable<Material>;
  29359. protected _onEffectCreatedObservable: Nullable<Observable<{
  29360. effect: Effect;
  29361. subMesh: Nullable<SubMesh>;
  29362. }>>;
  29363. /**
  29364. * An event triggered when the effect is (re)created
  29365. */
  29366. get onEffectCreatedObservable(): Observable<{
  29367. effect: Effect;
  29368. subMesh: Nullable<SubMesh>;
  29369. }>;
  29370. /**
  29371. * Stores the value of the alpha mode
  29372. */
  29373. private _alphaMode;
  29374. /**
  29375. * Sets the value of the alpha mode.
  29376. *
  29377. * | Value | Type | Description |
  29378. * | --- | --- | --- |
  29379. * | 0 | ALPHA_DISABLE | |
  29380. * | 1 | ALPHA_ADD | |
  29381. * | 2 | ALPHA_COMBINE | |
  29382. * | 3 | ALPHA_SUBTRACT | |
  29383. * | 4 | ALPHA_MULTIPLY | |
  29384. * | 5 | ALPHA_MAXIMIZED | |
  29385. * | 6 | ALPHA_ONEONE | |
  29386. * | 7 | ALPHA_PREMULTIPLIED | |
  29387. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29388. * | 9 | ALPHA_INTERPOLATE | |
  29389. * | 10 | ALPHA_SCREENMODE | |
  29390. *
  29391. */
  29392. set alphaMode(value: number);
  29393. /**
  29394. * Gets the value of the alpha mode
  29395. */
  29396. get alphaMode(): number;
  29397. /**
  29398. * Stores the state of the need depth pre-pass value
  29399. */
  29400. private _needDepthPrePass;
  29401. /**
  29402. * Sets the need depth pre-pass value
  29403. */
  29404. set needDepthPrePass(value: boolean);
  29405. /**
  29406. * Gets the depth pre-pass value
  29407. */
  29408. get needDepthPrePass(): boolean;
  29409. /**
  29410. * Specifies if depth writing should be disabled
  29411. */
  29412. disableDepthWrite: boolean;
  29413. /**
  29414. * Specifies if color writing should be disabled
  29415. */
  29416. disableColorWrite: boolean;
  29417. /**
  29418. * Specifies if depth writing should be forced
  29419. */
  29420. forceDepthWrite: boolean;
  29421. /**
  29422. * Specifies the depth function that should be used. 0 means the default engine function
  29423. */
  29424. depthFunction: number;
  29425. /**
  29426. * Specifies if there should be a separate pass for culling
  29427. */
  29428. separateCullingPass: boolean;
  29429. /**
  29430. * Stores the state specifing if fog should be enabled
  29431. */
  29432. private _fogEnabled;
  29433. /**
  29434. * Sets the state for enabling fog
  29435. */
  29436. set fogEnabled(value: boolean);
  29437. /**
  29438. * Gets the value of the fog enabled state
  29439. */
  29440. get fogEnabled(): boolean;
  29441. /**
  29442. * Stores the size of points
  29443. */
  29444. pointSize: number;
  29445. /**
  29446. * Stores the z offset value
  29447. */
  29448. zOffset: number;
  29449. get wireframe(): boolean;
  29450. /**
  29451. * Sets the state of wireframe mode
  29452. */
  29453. set wireframe(value: boolean);
  29454. /**
  29455. * Gets the value specifying if point clouds are enabled
  29456. */
  29457. get pointsCloud(): boolean;
  29458. /**
  29459. * Sets the state of point cloud mode
  29460. */
  29461. set pointsCloud(value: boolean);
  29462. /**
  29463. * Gets the material fill mode
  29464. */
  29465. get fillMode(): number;
  29466. /**
  29467. * Sets the material fill mode
  29468. */
  29469. set fillMode(value: number);
  29470. /**
  29471. * @hidden
  29472. * Stores the effects for the material
  29473. */
  29474. _effect: Nullable<Effect>;
  29475. /**
  29476. * Specifies if uniform buffers should be used
  29477. */
  29478. private _useUBO;
  29479. /**
  29480. * Stores a reference to the scene
  29481. */
  29482. private _scene;
  29483. /**
  29484. * Stores the fill mode state
  29485. */
  29486. private _fillMode;
  29487. /**
  29488. * Specifies if the depth write state should be cached
  29489. */
  29490. private _cachedDepthWriteState;
  29491. /**
  29492. * Specifies if the color write state should be cached
  29493. */
  29494. private _cachedColorWriteState;
  29495. /**
  29496. * Specifies if the depth function state should be cached
  29497. */
  29498. private _cachedDepthFunctionState;
  29499. /**
  29500. * Stores the uniform buffer
  29501. */
  29502. protected _uniformBuffer: UniformBuffer;
  29503. /** @hidden */
  29504. _indexInSceneMaterialArray: number;
  29505. /** @hidden */
  29506. meshMap: Nullable<{
  29507. [id: string]: AbstractMesh | undefined;
  29508. }>;
  29509. /**
  29510. * Creates a material instance
  29511. * @param name defines the name of the material
  29512. * @param scene defines the scene to reference
  29513. * @param doNotAdd specifies if the material should be added to the scene
  29514. */
  29515. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29516. /**
  29517. * Returns a string representation of the current material
  29518. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29519. * @returns a string with material information
  29520. */
  29521. toString(fullDetails?: boolean): string;
  29522. /**
  29523. * Gets the class name of the material
  29524. * @returns a string with the class name of the material
  29525. */
  29526. getClassName(): string;
  29527. /**
  29528. * Specifies if updates for the material been locked
  29529. */
  29530. get isFrozen(): boolean;
  29531. /**
  29532. * Locks updates for the material
  29533. */
  29534. freeze(): void;
  29535. /**
  29536. * Unlocks updates for the material
  29537. */
  29538. unfreeze(): void;
  29539. /**
  29540. * Specifies if the material is ready to be used
  29541. * @param mesh defines the mesh to check
  29542. * @param useInstances specifies if instances should be used
  29543. * @returns a boolean indicating if the material is ready to be used
  29544. */
  29545. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29546. /**
  29547. * Specifies that the submesh is ready to be used
  29548. * @param mesh defines the mesh to check
  29549. * @param subMesh defines which submesh to check
  29550. * @param useInstances specifies that instances should be used
  29551. * @returns a boolean indicating that the submesh is ready or not
  29552. */
  29553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29554. /**
  29555. * Returns the material effect
  29556. * @returns the effect associated with the material
  29557. */
  29558. getEffect(): Nullable<Effect>;
  29559. /**
  29560. * Returns the current scene
  29561. * @returns a Scene
  29562. */
  29563. getScene(): Scene;
  29564. /**
  29565. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29566. */
  29567. protected _forceAlphaTest: boolean;
  29568. /**
  29569. * The transparency mode of the material.
  29570. */
  29571. protected _transparencyMode: Nullable<number>;
  29572. /**
  29573. * Gets the current transparency mode.
  29574. */
  29575. get transparencyMode(): Nullable<number>;
  29576. /**
  29577. * Sets the transparency mode of the material.
  29578. *
  29579. * | Value | Type | Description |
  29580. * | ----- | ----------------------------------- | ----------- |
  29581. * | 0 | OPAQUE | |
  29582. * | 1 | ALPHATEST | |
  29583. * | 2 | ALPHABLEND | |
  29584. * | 3 | ALPHATESTANDBLEND | |
  29585. *
  29586. */
  29587. set transparencyMode(value: Nullable<number>);
  29588. /**
  29589. * Returns true if alpha blending should be disabled.
  29590. */
  29591. protected get _disableAlphaBlending(): boolean;
  29592. /**
  29593. * Specifies whether or not this material should be rendered in alpha blend mode.
  29594. * @returns a boolean specifying if alpha blending is needed
  29595. */
  29596. needAlphaBlending(): boolean;
  29597. /**
  29598. * Specifies if the mesh will require alpha blending
  29599. * @param mesh defines the mesh to check
  29600. * @returns a boolean specifying if alpha blending is needed for the mesh
  29601. */
  29602. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29603. /**
  29604. * Specifies whether or not this material should be rendered in alpha test mode.
  29605. * @returns a boolean specifying if an alpha test is needed.
  29606. */
  29607. needAlphaTesting(): boolean;
  29608. /**
  29609. * Specifies if material alpha testing should be turned on for the mesh
  29610. * @param mesh defines the mesh to check
  29611. */
  29612. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29613. /**
  29614. * Gets the texture used for the alpha test
  29615. * @returns the texture to use for alpha testing
  29616. */
  29617. getAlphaTestTexture(): Nullable<BaseTexture>;
  29618. /**
  29619. * Marks the material to indicate that it needs to be re-calculated
  29620. */
  29621. markDirty(): void;
  29622. /** @hidden */
  29623. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29624. /**
  29625. * Binds the material to the mesh
  29626. * @param world defines the world transformation matrix
  29627. * @param mesh defines the mesh to bind the material to
  29628. */
  29629. bind(world: Matrix, mesh?: Mesh): void;
  29630. /**
  29631. * Binds the submesh to the material
  29632. * @param world defines the world transformation matrix
  29633. * @param mesh defines the mesh containing the submesh
  29634. * @param subMesh defines the submesh to bind the material to
  29635. */
  29636. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29637. /**
  29638. * Binds the world matrix to the material
  29639. * @param world defines the world transformation matrix
  29640. */
  29641. bindOnlyWorldMatrix(world: Matrix): void;
  29642. /**
  29643. * Binds the scene's uniform buffer to the effect.
  29644. * @param effect defines the effect to bind to the scene uniform buffer
  29645. * @param sceneUbo defines the uniform buffer storing scene data
  29646. */
  29647. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29648. /**
  29649. * Binds the view matrix to the effect
  29650. * @param effect defines the effect to bind the view matrix to
  29651. */
  29652. bindView(effect: Effect): void;
  29653. /**
  29654. * Binds the view projection matrix to the effect
  29655. * @param effect defines the effect to bind the view projection matrix to
  29656. */
  29657. bindViewProjection(effect: Effect): void;
  29658. /**
  29659. * Processes to execute after binding the material to a mesh
  29660. * @param mesh defines the rendered mesh
  29661. */
  29662. protected _afterBind(mesh?: Mesh): void;
  29663. /**
  29664. * Unbinds the material from the mesh
  29665. */
  29666. unbind(): void;
  29667. /**
  29668. * Gets the active textures from the material
  29669. * @returns an array of textures
  29670. */
  29671. getActiveTextures(): BaseTexture[];
  29672. /**
  29673. * Specifies if the material uses a texture
  29674. * @param texture defines the texture to check against the material
  29675. * @returns a boolean specifying if the material uses the texture
  29676. */
  29677. hasTexture(texture: BaseTexture): boolean;
  29678. /**
  29679. * Makes a duplicate of the material, and gives it a new name
  29680. * @param name defines the new name for the duplicated material
  29681. * @returns the cloned material
  29682. */
  29683. clone(name: string): Nullable<Material>;
  29684. /**
  29685. * Gets the meshes bound to the material
  29686. * @returns an array of meshes bound to the material
  29687. */
  29688. getBindedMeshes(): AbstractMesh[];
  29689. /**
  29690. * Force shader compilation
  29691. * @param mesh defines the mesh associated with this material
  29692. * @param onCompiled defines a function to execute once the material is compiled
  29693. * @param options defines the options to configure the compilation
  29694. * @param onError defines a function to execute if the material fails compiling
  29695. */
  29696. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29697. /**
  29698. * Force shader compilation
  29699. * @param mesh defines the mesh that will use this material
  29700. * @param options defines additional options for compiling the shaders
  29701. * @returns a promise that resolves when the compilation completes
  29702. */
  29703. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29704. private static readonly _AllDirtyCallBack;
  29705. private static readonly _ImageProcessingDirtyCallBack;
  29706. private static readonly _TextureDirtyCallBack;
  29707. private static readonly _FresnelDirtyCallBack;
  29708. private static readonly _MiscDirtyCallBack;
  29709. private static readonly _PrePassDirtyCallBack;
  29710. private static readonly _LightsDirtyCallBack;
  29711. private static readonly _AttributeDirtyCallBack;
  29712. private static _FresnelAndMiscDirtyCallBack;
  29713. private static _TextureAndMiscDirtyCallBack;
  29714. private static readonly _DirtyCallbackArray;
  29715. private static readonly _RunDirtyCallBacks;
  29716. /**
  29717. * Marks a define in the material to indicate that it needs to be re-computed
  29718. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29719. */
  29720. markAsDirty(flag: number): void;
  29721. /**
  29722. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29723. * @param func defines a function which checks material defines against the submeshes
  29724. */
  29725. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29726. /**
  29727. * Indicates that the scene should check if the rendering now needs a prepass
  29728. */
  29729. protected _markScenePrePassDirty(): void;
  29730. /**
  29731. * Indicates that we need to re-calculated for all submeshes
  29732. */
  29733. protected _markAllSubMeshesAsAllDirty(): void;
  29734. /**
  29735. * Indicates that image processing needs to be re-calculated for all submeshes
  29736. */
  29737. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29738. /**
  29739. * Indicates that textures need to be re-calculated for all submeshes
  29740. */
  29741. protected _markAllSubMeshesAsTexturesDirty(): void;
  29742. /**
  29743. * Indicates that fresnel needs to be re-calculated for all submeshes
  29744. */
  29745. protected _markAllSubMeshesAsFresnelDirty(): void;
  29746. /**
  29747. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29748. */
  29749. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29750. /**
  29751. * Indicates that lights need to be re-calculated for all submeshes
  29752. */
  29753. protected _markAllSubMeshesAsLightsDirty(): void;
  29754. /**
  29755. * Indicates that attributes need to be re-calculated for all submeshes
  29756. */
  29757. protected _markAllSubMeshesAsAttributesDirty(): void;
  29758. /**
  29759. * Indicates that misc needs to be re-calculated for all submeshes
  29760. */
  29761. protected _markAllSubMeshesAsMiscDirty(): void;
  29762. /**
  29763. * Indicates that prepass needs to be re-calculated for all submeshes
  29764. */
  29765. protected _markAllSubMeshesAsPrePassDirty(): void;
  29766. /**
  29767. * Indicates that textures and misc need to be re-calculated for all submeshes
  29768. */
  29769. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29770. /**
  29771. * Sets the required values to the prepass renderer.
  29772. * @param prePassRenderer defines the prepass renderer to setup.
  29773. * @returns true if the pre pass is needed.
  29774. */
  29775. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29776. /**
  29777. * Disposes the material
  29778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29780. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29781. */
  29782. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29783. /** @hidden */
  29784. private releaseVertexArrayObject;
  29785. /**
  29786. * Serializes this material
  29787. * @returns the serialized material object
  29788. */
  29789. serialize(): any;
  29790. /**
  29791. * Creates a material from parsed material data
  29792. * @param parsedMaterial defines parsed material data
  29793. * @param scene defines the hosting scene
  29794. * @param rootUrl defines the root URL to use to load textures
  29795. * @returns a new material
  29796. */
  29797. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29798. }
  29799. }
  29800. declare module BABYLON {
  29801. /**
  29802. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29803. * separate meshes. This can be use to improve performances.
  29804. * @see https://doc.babylonjs.com/how_to/multi_materials
  29805. */
  29806. export class MultiMaterial extends Material {
  29807. private _subMaterials;
  29808. /**
  29809. * Gets or Sets the list of Materials used within the multi material.
  29810. * They need to be ordered according to the submeshes order in the associated mesh
  29811. */
  29812. get subMaterials(): Nullable<Material>[];
  29813. set subMaterials(value: Nullable<Material>[]);
  29814. /**
  29815. * Function used to align with Node.getChildren()
  29816. * @returns the list of Materials used within the multi material
  29817. */
  29818. getChildren(): Nullable<Material>[];
  29819. /**
  29820. * Instantiates a new Multi Material
  29821. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29822. * separate meshes. This can be use to improve performances.
  29823. * @see https://doc.babylonjs.com/how_to/multi_materials
  29824. * @param name Define the name in the scene
  29825. * @param scene Define the scene the material belongs to
  29826. */
  29827. constructor(name: string, scene: Scene);
  29828. private _hookArray;
  29829. /**
  29830. * Get one of the submaterial by its index in the submaterials array
  29831. * @param index The index to look the sub material at
  29832. * @returns The Material if the index has been defined
  29833. */
  29834. getSubMaterial(index: number): Nullable<Material>;
  29835. /**
  29836. * Get the list of active textures for the whole sub materials list.
  29837. * @returns All the textures that will be used during the rendering
  29838. */
  29839. getActiveTextures(): BaseTexture[];
  29840. /**
  29841. * Gets the current class name of the material e.g. "MultiMaterial"
  29842. * Mainly use in serialization.
  29843. * @returns the class name
  29844. */
  29845. getClassName(): string;
  29846. /**
  29847. * Checks if the material is ready to render the requested sub mesh
  29848. * @param mesh Define the mesh the submesh belongs to
  29849. * @param subMesh Define the sub mesh to look readyness for
  29850. * @param useInstances Define whether or not the material is used with instances
  29851. * @returns true if ready, otherwise false
  29852. */
  29853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29854. /**
  29855. * Clones the current material and its related sub materials
  29856. * @param name Define the name of the newly cloned material
  29857. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29858. * @returns the cloned material
  29859. */
  29860. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29861. /**
  29862. * Serializes the materials into a JSON representation.
  29863. * @returns the JSON representation
  29864. */
  29865. serialize(): any;
  29866. /**
  29867. * Dispose the material and release its associated resources
  29868. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  29869. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  29870. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  29871. */
  29872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29873. /**
  29874. * Creates a MultiMaterial from parsed MultiMaterial data.
  29875. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29876. * @param scene defines the hosting scene
  29877. * @returns a new MultiMaterial
  29878. */
  29879. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29880. }
  29881. }
  29882. declare module BABYLON {
  29883. /**
  29884. * Defines a subdivision inside a mesh
  29885. */
  29886. export class SubMesh implements ICullable {
  29887. /** the material index to use */
  29888. materialIndex: number;
  29889. /** vertex index start */
  29890. verticesStart: number;
  29891. /** vertices count */
  29892. verticesCount: number;
  29893. /** index start */
  29894. indexStart: number;
  29895. /** indices count */
  29896. indexCount: number;
  29897. /** @hidden */
  29898. _materialDefines: Nullable<MaterialDefines>;
  29899. /** @hidden */
  29900. _materialEffect: Nullable<Effect>;
  29901. /** @hidden */
  29902. _effectOverride: Nullable<Effect>;
  29903. /**
  29904. * Gets material defines used by the effect associated to the sub mesh
  29905. */
  29906. get materialDefines(): Nullable<MaterialDefines>;
  29907. /**
  29908. * Sets material defines used by the effect associated to the sub mesh
  29909. */
  29910. set materialDefines(defines: Nullable<MaterialDefines>);
  29911. /**
  29912. * Gets associated effect
  29913. */
  29914. get effect(): Nullable<Effect>;
  29915. /**
  29916. * Sets associated effect (effect used to render this submesh)
  29917. * @param effect defines the effect to associate with
  29918. * @param defines defines the set of defines used to compile this effect
  29919. */
  29920. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29921. /** @hidden */
  29922. _linesIndexCount: number;
  29923. private _mesh;
  29924. private _renderingMesh;
  29925. private _boundingInfo;
  29926. private _linesIndexBuffer;
  29927. /** @hidden */
  29928. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29929. /** @hidden */
  29930. _trianglePlanes: Plane[];
  29931. /** @hidden */
  29932. _lastColliderTransformMatrix: Nullable<Matrix>;
  29933. /** @hidden */
  29934. _renderId: number;
  29935. /** @hidden */
  29936. _alphaIndex: number;
  29937. /** @hidden */
  29938. _distanceToCamera: number;
  29939. /** @hidden */
  29940. _id: number;
  29941. private _currentMaterial;
  29942. /**
  29943. * Add a new submesh to a mesh
  29944. * @param materialIndex defines the material index to use
  29945. * @param verticesStart defines vertex index start
  29946. * @param verticesCount defines vertices count
  29947. * @param indexStart defines index start
  29948. * @param indexCount defines indices count
  29949. * @param mesh defines the parent mesh
  29950. * @param renderingMesh defines an optional rendering mesh
  29951. * @param createBoundingBox defines if bounding box should be created for this submesh
  29952. * @returns the new submesh
  29953. */
  29954. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29955. /**
  29956. * Creates a new submesh
  29957. * @param materialIndex defines the material index to use
  29958. * @param verticesStart defines vertex index start
  29959. * @param verticesCount defines vertices count
  29960. * @param indexStart defines index start
  29961. * @param indexCount defines indices count
  29962. * @param mesh defines the parent mesh
  29963. * @param renderingMesh defines an optional rendering mesh
  29964. * @param createBoundingBox defines if bounding box should be created for this submesh
  29965. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29966. */
  29967. constructor(
  29968. /** the material index to use */
  29969. materialIndex: number,
  29970. /** vertex index start */
  29971. verticesStart: number,
  29972. /** vertices count */
  29973. verticesCount: number,
  29974. /** index start */
  29975. indexStart: number,
  29976. /** indices count */
  29977. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29978. /**
  29979. * Returns true if this submesh covers the entire parent mesh
  29980. * @ignorenaming
  29981. */
  29982. get IsGlobal(): boolean;
  29983. /**
  29984. * Returns the submesh BoudingInfo object
  29985. * @returns current bounding info (or mesh's one if the submesh is global)
  29986. */
  29987. getBoundingInfo(): BoundingInfo;
  29988. /**
  29989. * Sets the submesh BoundingInfo
  29990. * @param boundingInfo defines the new bounding info to use
  29991. * @returns the SubMesh
  29992. */
  29993. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29994. /**
  29995. * Returns the mesh of the current submesh
  29996. * @return the parent mesh
  29997. */
  29998. getMesh(): AbstractMesh;
  29999. /**
  30000. * Returns the rendering mesh of the submesh
  30001. * @returns the rendering mesh (could be different from parent mesh)
  30002. */
  30003. getRenderingMesh(): Mesh;
  30004. /**
  30005. * Returns the replacement mesh of the submesh
  30006. * @returns the replacement mesh (could be different from parent mesh)
  30007. */
  30008. getReplacementMesh(): Nullable<AbstractMesh>;
  30009. /**
  30010. * Returns the effective mesh of the submesh
  30011. * @returns the effective mesh (could be different from parent mesh)
  30012. */
  30013. getEffectiveMesh(): AbstractMesh;
  30014. /**
  30015. * Returns the submesh material
  30016. * @returns null or the current material
  30017. */
  30018. getMaterial(): Nullable<Material>;
  30019. private _IsMultiMaterial;
  30020. /**
  30021. * Sets a new updated BoundingInfo object to the submesh
  30022. * @param data defines an optional position array to use to determine the bounding info
  30023. * @returns the SubMesh
  30024. */
  30025. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30026. /** @hidden */
  30027. _checkCollision(collider: Collider): boolean;
  30028. /**
  30029. * Updates the submesh BoundingInfo
  30030. * @param world defines the world matrix to use to update the bounding info
  30031. * @returns the submesh
  30032. */
  30033. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30034. /**
  30035. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30036. * @param frustumPlanes defines the frustum planes
  30037. * @returns true if the submesh is intersecting with the frustum
  30038. */
  30039. isInFrustum(frustumPlanes: Plane[]): boolean;
  30040. /**
  30041. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30042. * @param frustumPlanes defines the frustum planes
  30043. * @returns true if the submesh is inside the frustum
  30044. */
  30045. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30046. /**
  30047. * Renders the submesh
  30048. * @param enableAlphaMode defines if alpha needs to be used
  30049. * @returns the submesh
  30050. */
  30051. render(enableAlphaMode: boolean): SubMesh;
  30052. /**
  30053. * @hidden
  30054. */
  30055. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30056. /**
  30057. * Checks if the submesh intersects with a ray
  30058. * @param ray defines the ray to test
  30059. * @returns true is the passed ray intersects the submesh bounding box
  30060. */
  30061. canIntersects(ray: Ray): boolean;
  30062. /**
  30063. * Intersects current submesh with a ray
  30064. * @param ray defines the ray to test
  30065. * @param positions defines mesh's positions array
  30066. * @param indices defines mesh's indices array
  30067. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30068. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30069. * @returns intersection info or null if no intersection
  30070. */
  30071. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30072. /** @hidden */
  30073. private _intersectLines;
  30074. /** @hidden */
  30075. private _intersectUnIndexedLines;
  30076. /** @hidden */
  30077. private _intersectTriangles;
  30078. /** @hidden */
  30079. private _intersectUnIndexedTriangles;
  30080. /** @hidden */
  30081. _rebuild(): void;
  30082. /**
  30083. * Creates a new submesh from the passed mesh
  30084. * @param newMesh defines the new hosting mesh
  30085. * @param newRenderingMesh defines an optional rendering mesh
  30086. * @returns the new submesh
  30087. */
  30088. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30089. /**
  30090. * Release associated resources
  30091. */
  30092. dispose(): void;
  30093. /**
  30094. * Gets the class name
  30095. * @returns the string "SubMesh".
  30096. */
  30097. getClassName(): string;
  30098. /**
  30099. * Creates a new submesh from indices data
  30100. * @param materialIndex the index of the main mesh material
  30101. * @param startIndex the index where to start the copy in the mesh indices array
  30102. * @param indexCount the number of indices to copy then from the startIndex
  30103. * @param mesh the main mesh to create the submesh from
  30104. * @param renderingMesh the optional rendering mesh
  30105. * @returns a new submesh
  30106. */
  30107. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30108. }
  30109. }
  30110. declare module BABYLON {
  30111. /**
  30112. * Class used to represent data loading progression
  30113. */
  30114. export class SceneLoaderFlags {
  30115. private static _ForceFullSceneLoadingForIncremental;
  30116. private static _ShowLoadingScreen;
  30117. private static _CleanBoneMatrixWeights;
  30118. private static _loggingLevel;
  30119. /**
  30120. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30121. */
  30122. static get ForceFullSceneLoadingForIncremental(): boolean;
  30123. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30124. /**
  30125. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30126. */
  30127. static get ShowLoadingScreen(): boolean;
  30128. static set ShowLoadingScreen(value: boolean);
  30129. /**
  30130. * Defines the current logging level (while loading the scene)
  30131. * @ignorenaming
  30132. */
  30133. static get loggingLevel(): number;
  30134. static set loggingLevel(value: number);
  30135. /**
  30136. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30137. */
  30138. static get CleanBoneMatrixWeights(): boolean;
  30139. static set CleanBoneMatrixWeights(value: boolean);
  30140. }
  30141. }
  30142. declare module BABYLON {
  30143. /**
  30144. * Class used to store geometry data (vertex buffers + index buffer)
  30145. */
  30146. export class Geometry implements IGetSetVerticesData {
  30147. /**
  30148. * Gets or sets the ID of the geometry
  30149. */
  30150. id: string;
  30151. /**
  30152. * Gets or sets the unique ID of the geometry
  30153. */
  30154. uniqueId: number;
  30155. /**
  30156. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30157. */
  30158. delayLoadState: number;
  30159. /**
  30160. * Gets the file containing the data to load when running in delay load state
  30161. */
  30162. delayLoadingFile: Nullable<string>;
  30163. /**
  30164. * Callback called when the geometry is updated
  30165. */
  30166. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30167. private _scene;
  30168. private _engine;
  30169. private _meshes;
  30170. private _totalVertices;
  30171. /** @hidden */
  30172. _indices: IndicesArray;
  30173. /** @hidden */
  30174. _vertexBuffers: {
  30175. [key: string]: VertexBuffer;
  30176. };
  30177. private _isDisposed;
  30178. private _extend;
  30179. private _boundingBias;
  30180. /** @hidden */
  30181. _delayInfo: Array<string>;
  30182. private _indexBuffer;
  30183. private _indexBufferIsUpdatable;
  30184. /** @hidden */
  30185. _boundingInfo: Nullable<BoundingInfo>;
  30186. /** @hidden */
  30187. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30188. /** @hidden */
  30189. _softwareSkinningFrameId: number;
  30190. private _vertexArrayObjects;
  30191. private _updatable;
  30192. /** @hidden */
  30193. _positions: Nullable<Vector3[]>;
  30194. private _positionsCache;
  30195. /**
  30196. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  30197. */
  30198. get boundingBias(): Vector2;
  30199. /**
  30200. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  30201. */
  30202. set boundingBias(value: Vector2);
  30203. /**
  30204. * Static function used to attach a new empty geometry to a mesh
  30205. * @param mesh defines the mesh to attach the geometry to
  30206. * @returns the new Geometry
  30207. */
  30208. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30209. /** Get the list of meshes using this geometry */
  30210. get meshes(): Mesh[];
  30211. /**
  30212. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  30213. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30214. */
  30215. useBoundingInfoFromGeometry: boolean;
  30216. /**
  30217. * Creates a new geometry
  30218. * @param id defines the unique ID
  30219. * @param scene defines the hosting scene
  30220. * @param vertexData defines the VertexData used to get geometry data
  30221. * @param updatable defines if geometry must be updatable (false by default)
  30222. * @param mesh defines the mesh that will be associated with the geometry
  30223. */
  30224. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30225. /**
  30226. * Gets the current extend of the geometry
  30227. */
  30228. get extend(): {
  30229. minimum: Vector3;
  30230. maximum: Vector3;
  30231. };
  30232. /**
  30233. * Gets the hosting scene
  30234. * @returns the hosting Scene
  30235. */
  30236. getScene(): Scene;
  30237. /**
  30238. * Gets the hosting engine
  30239. * @returns the hosting Engine
  30240. */
  30241. getEngine(): Engine;
  30242. /**
  30243. * Defines if the geometry is ready to use
  30244. * @returns true if the geometry is ready to be used
  30245. */
  30246. isReady(): boolean;
  30247. /**
  30248. * Gets a value indicating that the geometry should not be serialized
  30249. */
  30250. get doNotSerialize(): boolean;
  30251. /** @hidden */
  30252. _rebuild(): void;
  30253. /**
  30254. * Affects all geometry data in one call
  30255. * @param vertexData defines the geometry data
  30256. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30257. */
  30258. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30259. /**
  30260. * Set specific vertex data
  30261. * @param kind defines the data kind (Position, normal, etc...)
  30262. * @param data defines the vertex data to use
  30263. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30264. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30265. */
  30266. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30267. /**
  30268. * Removes a specific vertex data
  30269. * @param kind defines the data kind (Position, normal, etc...)
  30270. */
  30271. removeVerticesData(kind: string): void;
  30272. /**
  30273. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30274. * @param buffer defines the vertex buffer to use
  30275. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30276. */
  30277. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30278. /**
  30279. * Update a specific vertex buffer
  30280. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30281. * It will do nothing if the buffer is not updatable
  30282. * @param kind defines the data kind (Position, normal, etc...)
  30283. * @param data defines the data to use
  30284. * @param offset defines the offset in the target buffer where to store the data
  30285. * @param useBytes set to true if the offset is in bytes
  30286. */
  30287. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30288. /**
  30289. * Update a specific vertex buffer
  30290. * This function will create a new buffer if the current one is not updatable
  30291. * @param kind defines the data kind (Position, normal, etc...)
  30292. * @param data defines the data to use
  30293. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30294. */
  30295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30296. private _updateBoundingInfo;
  30297. /** @hidden */
  30298. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30299. /**
  30300. * Gets total number of vertices
  30301. * @returns the total number of vertices
  30302. */
  30303. getTotalVertices(): number;
  30304. /**
  30305. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30306. * @param kind defines the data kind (Position, normal, etc...)
  30307. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30309. * @returns a float array containing vertex data
  30310. */
  30311. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30312. /**
  30313. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30314. * @param kind defines the data kind (Position, normal, etc...)
  30315. * @returns true if the vertex buffer with the specified kind is updatable
  30316. */
  30317. isVertexBufferUpdatable(kind: string): boolean;
  30318. /**
  30319. * Gets a specific vertex buffer
  30320. * @param kind defines the data kind (Position, normal, etc...)
  30321. * @returns a VertexBuffer
  30322. */
  30323. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30324. /**
  30325. * Returns all vertex buffers
  30326. * @return an object holding all vertex buffers indexed by kind
  30327. */
  30328. getVertexBuffers(): Nullable<{
  30329. [key: string]: VertexBuffer;
  30330. }>;
  30331. /**
  30332. * Gets a boolean indicating if specific vertex buffer is present
  30333. * @param kind defines the data kind (Position, normal, etc...)
  30334. * @returns true if data is present
  30335. */
  30336. isVerticesDataPresent(kind: string): boolean;
  30337. /**
  30338. * Gets a list of all attached data kinds (Position, normal, etc...)
  30339. * @returns a list of string containing all kinds
  30340. */
  30341. getVerticesDataKinds(): string[];
  30342. /**
  30343. * Update index buffer
  30344. * @param indices defines the indices to store in the index buffer
  30345. * @param offset defines the offset in the target buffer where to store the data
  30346. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  30347. */
  30348. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30349. /**
  30350. * Creates a new index buffer
  30351. * @param indices defines the indices to store in the index buffer
  30352. * @param totalVertices defines the total number of vertices (could be null)
  30353. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30354. */
  30355. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30356. /**
  30357. * Return the total number of indices
  30358. * @returns the total number of indices
  30359. */
  30360. getTotalIndices(): number;
  30361. /**
  30362. * Gets the index buffer array
  30363. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30364. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30365. * @returns the index buffer array
  30366. */
  30367. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30368. /**
  30369. * Gets the index buffer
  30370. * @return the index buffer
  30371. */
  30372. getIndexBuffer(): Nullable<DataBuffer>;
  30373. /** @hidden */
  30374. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30375. /**
  30376. * Release the associated resources for a specific mesh
  30377. * @param mesh defines the source mesh
  30378. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30379. */
  30380. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30381. /**
  30382. * Apply current geometry to a given mesh
  30383. * @param mesh defines the mesh to apply geometry to
  30384. */
  30385. applyToMesh(mesh: Mesh): void;
  30386. private _updateExtend;
  30387. private _applyToMesh;
  30388. private notifyUpdate;
  30389. /**
  30390. * Load the geometry if it was flagged as delay loaded
  30391. * @param scene defines the hosting scene
  30392. * @param onLoaded defines a callback called when the geometry is loaded
  30393. */
  30394. load(scene: Scene, onLoaded?: () => void): void;
  30395. private _queueLoad;
  30396. /**
  30397. * Invert the geometry to move from a right handed system to a left handed one.
  30398. */
  30399. toLeftHanded(): void;
  30400. /** @hidden */
  30401. _resetPointsArrayCache(): void;
  30402. /** @hidden */
  30403. _generatePointsArray(): boolean;
  30404. /**
  30405. * Gets a value indicating if the geometry is disposed
  30406. * @returns true if the geometry was disposed
  30407. */
  30408. isDisposed(): boolean;
  30409. private _disposeVertexArrayObjects;
  30410. /**
  30411. * Free all associated resources
  30412. */
  30413. dispose(): void;
  30414. /**
  30415. * Clone the current geometry into a new geometry
  30416. * @param id defines the unique ID of the new geometry
  30417. * @returns a new geometry object
  30418. */
  30419. copy(id: string): Geometry;
  30420. /**
  30421. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30422. * @return a JSON representation of the current geometry data (without the vertices data)
  30423. */
  30424. serialize(): any;
  30425. private toNumberArray;
  30426. /**
  30427. * Serialize all vertices data into a JSON oject
  30428. * @returns a JSON representation of the current geometry data
  30429. */
  30430. serializeVerticeData(): any;
  30431. /**
  30432. * Extracts a clone of a mesh geometry
  30433. * @param mesh defines the source mesh
  30434. * @param id defines the unique ID of the new geometry object
  30435. * @returns the new geometry object
  30436. */
  30437. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30438. /**
  30439. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30440. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30441. * Be aware Math.random() could cause collisions, but:
  30442. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  30443. * @returns a string containing a new GUID
  30444. */
  30445. static RandomId(): string;
  30446. /** @hidden */
  30447. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30448. private static _CleanMatricesWeights;
  30449. /**
  30450. * Create a new geometry from persisted data (Using .babylon file format)
  30451. * @param parsedVertexData defines the persisted data
  30452. * @param scene defines the hosting scene
  30453. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30454. * @returns the new geometry object
  30455. */
  30456. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30457. }
  30458. }
  30459. declare module BABYLON {
  30460. /**
  30461. * Define an interface for all classes that will get and set the data on vertices
  30462. */
  30463. export interface IGetSetVerticesData {
  30464. /**
  30465. * Gets a boolean indicating if specific vertex data is present
  30466. * @param kind defines the vertex data kind to use
  30467. * @returns true is data kind is present
  30468. */
  30469. isVerticesDataPresent(kind: string): boolean;
  30470. /**
  30471. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30472. * @param kind defines the data kind (Position, normal, etc...)
  30473. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30475. * @returns a float array containing vertex data
  30476. */
  30477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30478. /**
  30479. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30480. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  30481. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30482. * @returns the indices array or an empty array if the mesh has no geometry
  30483. */
  30484. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30485. /**
  30486. * Set specific vertex data
  30487. * @param kind defines the data kind (Position, normal, etc...)
  30488. * @param data defines the vertex data to use
  30489. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30490. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30491. */
  30492. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30493. /**
  30494. * Update a specific associated vertex buffer
  30495. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30496. * - VertexBuffer.PositionKind
  30497. * - VertexBuffer.UVKind
  30498. * - VertexBuffer.UV2Kind
  30499. * - VertexBuffer.UV3Kind
  30500. * - VertexBuffer.UV4Kind
  30501. * - VertexBuffer.UV5Kind
  30502. * - VertexBuffer.UV6Kind
  30503. * - VertexBuffer.ColorKind
  30504. * - VertexBuffer.MatricesIndicesKind
  30505. * - VertexBuffer.MatricesIndicesExtraKind
  30506. * - VertexBuffer.MatricesWeightsKind
  30507. * - VertexBuffer.MatricesWeightsExtraKind
  30508. * @param data defines the data source
  30509. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30510. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  30511. */
  30512. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30513. /**
  30514. * Creates a new index buffer
  30515. * @param indices defines the indices to store in the index buffer
  30516. * @param totalVertices defines the total number of vertices (could be null)
  30517. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30518. */
  30519. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30520. }
  30521. /**
  30522. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30523. */
  30524. export class VertexData {
  30525. /**
  30526. * Mesh side orientation : usually the external or front surface
  30527. */
  30528. static readonly FRONTSIDE: number;
  30529. /**
  30530. * Mesh side orientation : usually the internal or back surface
  30531. */
  30532. static readonly BACKSIDE: number;
  30533. /**
  30534. * Mesh side orientation : both internal and external or front and back surfaces
  30535. */
  30536. static readonly DOUBLESIDE: number;
  30537. /**
  30538. * Mesh side orientation : by default, `FRONTSIDE`
  30539. */
  30540. static readonly DEFAULTSIDE: number;
  30541. /**
  30542. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30543. */
  30544. positions: Nullable<FloatArray>;
  30545. /**
  30546. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30547. */
  30548. normals: Nullable<FloatArray>;
  30549. /**
  30550. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30551. */
  30552. tangents: Nullable<FloatArray>;
  30553. /**
  30554. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30555. */
  30556. uvs: Nullable<FloatArray>;
  30557. /**
  30558. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30559. */
  30560. uvs2: Nullable<FloatArray>;
  30561. /**
  30562. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30563. */
  30564. uvs3: Nullable<FloatArray>;
  30565. /**
  30566. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30567. */
  30568. uvs4: Nullable<FloatArray>;
  30569. /**
  30570. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30571. */
  30572. uvs5: Nullable<FloatArray>;
  30573. /**
  30574. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30575. */
  30576. uvs6: Nullable<FloatArray>;
  30577. /**
  30578. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30579. */
  30580. colors: Nullable<FloatArray>;
  30581. /**
  30582. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  30583. */
  30584. matricesIndices: Nullable<FloatArray>;
  30585. /**
  30586. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30587. */
  30588. matricesWeights: Nullable<FloatArray>;
  30589. /**
  30590. * An array extending the number of possible indices
  30591. */
  30592. matricesIndicesExtra: Nullable<FloatArray>;
  30593. /**
  30594. * An array extending the number of possible weights when the number of indices is extended
  30595. */
  30596. matricesWeightsExtra: Nullable<FloatArray>;
  30597. /**
  30598. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30599. */
  30600. indices: Nullable<IndicesArray>;
  30601. /**
  30602. * Uses the passed data array to set the set the values for the specified kind of data
  30603. * @param data a linear array of floating numbers
  30604. * @param kind the type of data that is being set, eg positions, colors etc
  30605. */
  30606. set(data: FloatArray, kind: string): void;
  30607. /**
  30608. * Associates the vertexData to the passed Mesh.
  30609. * Sets it as updatable or not (default `false`)
  30610. * @param mesh the mesh the vertexData is applied to
  30611. * @param updatable when used and having the value true allows new data to update the vertexData
  30612. * @returns the VertexData
  30613. */
  30614. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30615. /**
  30616. * Associates the vertexData to the passed Geometry.
  30617. * Sets it as updatable or not (default `false`)
  30618. * @param geometry the geometry the vertexData is applied to
  30619. * @param updatable when used and having the value true allows new data to update the vertexData
  30620. * @returns VertexData
  30621. */
  30622. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30623. /**
  30624. * Updates the associated mesh
  30625. * @param mesh the mesh to be updated
  30626. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30627. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  30628. * @returns VertexData
  30629. */
  30630. updateMesh(mesh: Mesh): VertexData;
  30631. /**
  30632. * Updates the associated geometry
  30633. * @param geometry the geometry to be updated
  30634. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30635. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  30636. * @returns VertexData.
  30637. */
  30638. updateGeometry(geometry: Geometry): VertexData;
  30639. private _applyTo;
  30640. private _update;
  30641. /**
  30642. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30643. * @param matrix the transforming matrix
  30644. * @returns the VertexData
  30645. */
  30646. transform(matrix: Matrix): VertexData;
  30647. /**
  30648. * Merges the passed VertexData into the current one
  30649. * @param other the VertexData to be merged into the current one
  30650. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30651. * @returns the modified VertexData
  30652. */
  30653. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30654. private _mergeElement;
  30655. private _validate;
  30656. /**
  30657. * Serializes the VertexData
  30658. * @returns a serialized object
  30659. */
  30660. serialize(): any;
  30661. /**
  30662. * Extracts the vertexData from a mesh
  30663. * @param mesh the mesh from which to extract the VertexData
  30664. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30665. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30666. * @returns the object VertexData associated to the passed mesh
  30667. */
  30668. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30669. /**
  30670. * Extracts the vertexData from the geometry
  30671. * @param geometry the geometry from which to extract the VertexData
  30672. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30673. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30674. * @returns the object VertexData associated to the passed mesh
  30675. */
  30676. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30677. private static _ExtractFrom;
  30678. /**
  30679. * Creates the VertexData for a Ribbon
  30680. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30681. * * pathArray array of paths, each of which an array of successive Vector3
  30682. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30683. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30684. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  30685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30686. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30687. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30688. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30689. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30690. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30691. * @returns the VertexData of the ribbon
  30692. */
  30693. static CreateRibbon(options: {
  30694. pathArray: Vector3[][];
  30695. closeArray?: boolean;
  30696. closePath?: boolean;
  30697. offset?: number;
  30698. sideOrientation?: number;
  30699. frontUVs?: Vector4;
  30700. backUVs?: Vector4;
  30701. invertUV?: boolean;
  30702. uvs?: Vector2[];
  30703. colors?: Color4[];
  30704. }): VertexData;
  30705. /**
  30706. * Creates the VertexData for a box
  30707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30708. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30709. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30710. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30711. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30712. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30713. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30715. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30716. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30717. * @returns the VertexData of the box
  30718. */
  30719. static CreateBox(options: {
  30720. size?: number;
  30721. width?: number;
  30722. height?: number;
  30723. depth?: number;
  30724. faceUV?: Vector4[];
  30725. faceColors?: Color4[];
  30726. sideOrientation?: number;
  30727. frontUVs?: Vector4;
  30728. backUVs?: Vector4;
  30729. }): VertexData;
  30730. /**
  30731. * Creates the VertexData for a tiled box
  30732. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30733. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30734. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30735. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30737. * @returns the VertexData of the box
  30738. */
  30739. static CreateTiledBox(options: {
  30740. pattern?: number;
  30741. width?: number;
  30742. height?: number;
  30743. depth?: number;
  30744. tileSize?: number;
  30745. tileWidth?: number;
  30746. tileHeight?: number;
  30747. alignHorizontal?: number;
  30748. alignVertical?: number;
  30749. faceUV?: Vector4[];
  30750. faceColors?: Color4[];
  30751. sideOrientation?: number;
  30752. }): VertexData;
  30753. /**
  30754. * Creates the VertexData for a tiled plane
  30755. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30756. * * pattern a limited pattern arrangement depending on the number
  30757. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30758. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30759. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30760. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30761. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30762. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30763. * @returns the VertexData of the tiled plane
  30764. */
  30765. static CreateTiledPlane(options: {
  30766. pattern?: number;
  30767. tileSize?: number;
  30768. tileWidth?: number;
  30769. tileHeight?: number;
  30770. size?: number;
  30771. width?: number;
  30772. height?: number;
  30773. alignHorizontal?: number;
  30774. alignVertical?: number;
  30775. sideOrientation?: number;
  30776. frontUVs?: Vector4;
  30777. backUVs?: Vector4;
  30778. }): VertexData;
  30779. /**
  30780. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30781. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30782. * * segments sets the number of horizontal strips optional, default 32
  30783. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30784. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30785. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30786. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30787. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  30788. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  30789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30790. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30791. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30792. * @returns the VertexData of the ellipsoid
  30793. */
  30794. static CreateSphere(options: {
  30795. segments?: number;
  30796. diameter?: number;
  30797. diameterX?: number;
  30798. diameterY?: number;
  30799. diameterZ?: number;
  30800. arc?: number;
  30801. slice?: number;
  30802. sideOrientation?: number;
  30803. frontUVs?: Vector4;
  30804. backUVs?: Vector4;
  30805. }): VertexData;
  30806. /**
  30807. * Creates the VertexData for a cylinder, cone or prism
  30808. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30809. * * height sets the height (y direction) of the cylinder, optional, default 2
  30810. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30811. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30812. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30813. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30814. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30815. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  30816. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30817. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30818. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30819. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30821. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30822. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30823. * @returns the VertexData of the cylinder, cone or prism
  30824. */
  30825. static CreateCylinder(options: {
  30826. height?: number;
  30827. diameterTop?: number;
  30828. diameterBottom?: number;
  30829. diameter?: number;
  30830. tessellation?: number;
  30831. subdivisions?: number;
  30832. arc?: number;
  30833. faceColors?: Color4[];
  30834. faceUV?: Vector4[];
  30835. hasRings?: boolean;
  30836. enclose?: boolean;
  30837. sideOrientation?: number;
  30838. frontUVs?: Vector4;
  30839. backUVs?: Vector4;
  30840. }): VertexData;
  30841. /**
  30842. * Creates the VertexData for a torus
  30843. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30844. * * diameter the diameter of the torus, optional default 1
  30845. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30846. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30848. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30849. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30850. * @returns the VertexData of the torus
  30851. */
  30852. static CreateTorus(options: {
  30853. diameter?: number;
  30854. thickness?: number;
  30855. tessellation?: number;
  30856. sideOrientation?: number;
  30857. frontUVs?: Vector4;
  30858. backUVs?: Vector4;
  30859. }): VertexData;
  30860. /**
  30861. * Creates the VertexData of the LineSystem
  30862. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30863. * - lines an array of lines, each line being an array of successive Vector3
  30864. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30865. * @returns the VertexData of the LineSystem
  30866. */
  30867. static CreateLineSystem(options: {
  30868. lines: Vector3[][];
  30869. colors?: Nullable<Color4[][]>;
  30870. }): VertexData;
  30871. /**
  30872. * Create the VertexData for a DashedLines
  30873. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30874. * - points an array successive Vector3
  30875. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30876. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30877. * - dashNb the intended total number of dashes, optional, default 200
  30878. * @returns the VertexData for the DashedLines
  30879. */
  30880. static CreateDashedLines(options: {
  30881. points: Vector3[];
  30882. dashSize?: number;
  30883. gapSize?: number;
  30884. dashNb?: number;
  30885. }): VertexData;
  30886. /**
  30887. * Creates the VertexData for a Ground
  30888. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30889. * - width the width (x direction) of the ground, optional, default 1
  30890. * - height the height (z direction) of the ground, optional, default 1
  30891. * - subdivisions the number of subdivisions per side, optional, default 1
  30892. * @returns the VertexData of the Ground
  30893. */
  30894. static CreateGround(options: {
  30895. width?: number;
  30896. height?: number;
  30897. subdivisions?: number;
  30898. subdivisionsX?: number;
  30899. subdivisionsY?: number;
  30900. }): VertexData;
  30901. /**
  30902. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30903. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30904. * * xmin the ground minimum X coordinate, optional, default -1
  30905. * * zmin the ground minimum Z coordinate, optional, default -1
  30906. * * xmax the ground maximum X coordinate, optional, default 1
  30907. * * zmax the ground maximum Z coordinate, optional, default 1
  30908. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  30909. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  30910. * @returns the VertexData of the TiledGround
  30911. */
  30912. static CreateTiledGround(options: {
  30913. xmin: number;
  30914. zmin: number;
  30915. xmax: number;
  30916. zmax: number;
  30917. subdivisions?: {
  30918. w: number;
  30919. h: number;
  30920. };
  30921. precision?: {
  30922. w: number;
  30923. h: number;
  30924. };
  30925. }): VertexData;
  30926. /**
  30927. * Creates the VertexData of the Ground designed from a heightmap
  30928. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30929. * * width the width (x direction) of the ground
  30930. * * height the height (z direction) of the ground
  30931. * * subdivisions the number of subdivisions per side
  30932. * * minHeight the minimum altitude on the ground, optional, default 0
  30933. * * maxHeight the maximum altitude on the ground, optional default 1
  30934. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30935. * * buffer the array holding the image color data
  30936. * * bufferWidth the width of image
  30937. * * bufferHeight the height of image
  30938. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30939. * @returns the VertexData of the Ground designed from a heightmap
  30940. */
  30941. static CreateGroundFromHeightMap(options: {
  30942. width: number;
  30943. height: number;
  30944. subdivisions: number;
  30945. minHeight: number;
  30946. maxHeight: number;
  30947. colorFilter: Color3;
  30948. buffer: Uint8Array;
  30949. bufferWidth: number;
  30950. bufferHeight: number;
  30951. alphaFilter: number;
  30952. }): VertexData;
  30953. /**
  30954. * Creates the VertexData for a Plane
  30955. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30956. * * size sets the width and height of the plane to the value of size, optional default 1
  30957. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30958. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30960. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30961. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30962. * @returns the VertexData of the box
  30963. */
  30964. static CreatePlane(options: {
  30965. size?: number;
  30966. width?: number;
  30967. height?: number;
  30968. sideOrientation?: number;
  30969. frontUVs?: Vector4;
  30970. backUVs?: Vector4;
  30971. }): VertexData;
  30972. /**
  30973. * Creates the VertexData of the Disc or regular Polygon
  30974. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30975. * * radius the radius of the disc, optional default 0.5
  30976. * * tessellation the number of polygon sides, optional, default 64
  30977. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  30978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30979. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30980. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  30981. * @returns the VertexData of the box
  30982. */
  30983. static CreateDisc(options: {
  30984. radius?: number;
  30985. tessellation?: number;
  30986. arc?: number;
  30987. sideOrientation?: number;
  30988. frontUVs?: Vector4;
  30989. backUVs?: Vector4;
  30990. }): VertexData;
  30991. /**
  30992. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30993. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30994. * @param polygon a mesh built from polygonTriangulation.build()
  30995. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30996. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30997. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30998. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  30999. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31000. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31001. * @returns the VertexData of the Polygon
  31002. */
  31003. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31004. /**
  31005. * Creates the VertexData of the IcoSphere
  31006. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31007. * * radius the radius of the IcoSphere, optional default 1
  31008. * * radiusX allows stretching in the x direction, optional, default radius
  31009. * * radiusY allows stretching in the y direction, optional, default radius
  31010. * * radiusZ allows stretching in the z direction, optional, default radius
  31011. * * flat when true creates a flat shaded mesh, optional, default true
  31012. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31014. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31015. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31016. * @returns the VertexData of the IcoSphere
  31017. */
  31018. static CreateIcoSphere(options: {
  31019. radius?: number;
  31020. radiusX?: number;
  31021. radiusY?: number;
  31022. radiusZ?: number;
  31023. flat?: boolean;
  31024. subdivisions?: number;
  31025. sideOrientation?: number;
  31026. frontUVs?: Vector4;
  31027. backUVs?: Vector4;
  31028. }): VertexData;
  31029. /**
  31030. * Creates the VertexData for a Polyhedron
  31031. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31032. * * type provided types are:
  31033. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31034. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  31035. * * size the size of the IcoSphere, optional default 1
  31036. * * sizeX allows stretching in the x direction, optional, default size
  31037. * * sizeY allows stretching in the y direction, optional, default size
  31038. * * sizeZ allows stretching in the z direction, optional, default size
  31039. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  31040. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31041. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31042. * * flat when true creates a flat shaded mesh, optional, default true
  31043. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31045. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31046. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31047. * @returns the VertexData of the Polyhedron
  31048. */
  31049. static CreatePolyhedron(options: {
  31050. type?: number;
  31051. size?: number;
  31052. sizeX?: number;
  31053. sizeY?: number;
  31054. sizeZ?: number;
  31055. custom?: any;
  31056. faceUV?: Vector4[];
  31057. faceColors?: Color4[];
  31058. flat?: boolean;
  31059. sideOrientation?: number;
  31060. frontUVs?: Vector4;
  31061. backUVs?: Vector4;
  31062. }): VertexData;
  31063. /**
  31064. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31065. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31066. * @returns the VertexData of the Capsule
  31067. */
  31068. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31069. /**
  31070. * Creates the VertexData for a TorusKnot
  31071. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31072. * * radius the radius of the torus knot, optional, default 2
  31073. * * tube the thickness of the tube, optional, default 0.5
  31074. * * radialSegments the number of sides on each tube segments, optional, default 32
  31075. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31076. * * p the number of windings around the z axis, optional, default 2
  31077. * * q the number of windings around the x axis, optional, default 3
  31078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31079. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  31080. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  31081. * @returns the VertexData of the Torus Knot
  31082. */
  31083. static CreateTorusKnot(options: {
  31084. radius?: number;
  31085. tube?: number;
  31086. radialSegments?: number;
  31087. tubularSegments?: number;
  31088. p?: number;
  31089. q?: number;
  31090. sideOrientation?: number;
  31091. frontUVs?: Vector4;
  31092. backUVs?: Vector4;
  31093. }): VertexData;
  31094. /**
  31095. * Compute normals for given positions and indices
  31096. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31097. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31098. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31099. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31100. * * facetNormals : optional array of facet normals (vector3)
  31101. * * facetPositions : optional array of facet positions (vector3)
  31102. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31103. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31104. * * bInfo : optional bounding info, required for facetPartitioning computation
  31105. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31106. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31107. * * useRightHandedSystem: optional boolean to for right handed system computation
  31108. * * depthSort : optional boolean to enable the facet depth sort computation
  31109. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31110. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31111. */
  31112. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31113. facetNormals?: any;
  31114. facetPositions?: any;
  31115. facetPartitioning?: any;
  31116. ratio?: number;
  31117. bInfo?: any;
  31118. bbSize?: Vector3;
  31119. subDiv?: any;
  31120. useRightHandedSystem?: boolean;
  31121. depthSort?: boolean;
  31122. distanceTo?: Vector3;
  31123. depthSortedFacets?: any;
  31124. }): void;
  31125. /** @hidden */
  31126. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31127. /**
  31128. * Applies VertexData created from the imported parameters to the geometry
  31129. * @param parsedVertexData the parsed data from an imported file
  31130. * @param geometry the geometry to apply the VertexData to
  31131. */
  31132. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31133. }
  31134. }
  31135. declare module BABYLON {
  31136. /**
  31137. * Defines a target to use with MorphTargetManager
  31138. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31139. */
  31140. export class MorphTarget implements IAnimatable {
  31141. /** defines the name of the target */
  31142. name: string;
  31143. /**
  31144. * Gets or sets the list of animations
  31145. */
  31146. animations: Animation[];
  31147. private _scene;
  31148. private _positions;
  31149. private _normals;
  31150. private _tangents;
  31151. private _uvs;
  31152. private _influence;
  31153. private _uniqueId;
  31154. /**
  31155. * Observable raised when the influence changes
  31156. */
  31157. onInfluenceChanged: Observable<boolean>;
  31158. /** @hidden */
  31159. _onDataLayoutChanged: Observable<void>;
  31160. /**
  31161. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31162. */
  31163. get influence(): number;
  31164. set influence(influence: number);
  31165. /**
  31166. * Gets or sets the id of the morph Target
  31167. */
  31168. id: string;
  31169. private _animationPropertiesOverride;
  31170. /**
  31171. * Gets or sets the animation properties override
  31172. */
  31173. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31174. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31175. /**
  31176. * Creates a new MorphTarget
  31177. * @param name defines the name of the target
  31178. * @param influence defines the influence to use
  31179. * @param scene defines the scene the morphtarget belongs to
  31180. */
  31181. constructor(
  31182. /** defines the name of the target */
  31183. name: string, influence?: number, scene?: Nullable<Scene>);
  31184. /**
  31185. * Gets the unique ID of this manager
  31186. */
  31187. get uniqueId(): number;
  31188. /**
  31189. * Gets a boolean defining if the target contains position data
  31190. */
  31191. get hasPositions(): boolean;
  31192. /**
  31193. * Gets a boolean defining if the target contains normal data
  31194. */
  31195. get hasNormals(): boolean;
  31196. /**
  31197. * Gets a boolean defining if the target contains tangent data
  31198. */
  31199. get hasTangents(): boolean;
  31200. /**
  31201. * Gets a boolean defining if the target contains texture coordinates data
  31202. */
  31203. get hasUVs(): boolean;
  31204. /**
  31205. * Affects position data to this target
  31206. * @param data defines the position data to use
  31207. */
  31208. setPositions(data: Nullable<FloatArray>): void;
  31209. /**
  31210. * Gets the position data stored in this target
  31211. * @returns a FloatArray containing the position data (or null if not present)
  31212. */
  31213. getPositions(): Nullable<FloatArray>;
  31214. /**
  31215. * Affects normal data to this target
  31216. * @param data defines the normal data to use
  31217. */
  31218. setNormals(data: Nullable<FloatArray>): void;
  31219. /**
  31220. * Gets the normal data stored in this target
  31221. * @returns a FloatArray containing the normal data (or null if not present)
  31222. */
  31223. getNormals(): Nullable<FloatArray>;
  31224. /**
  31225. * Affects tangent data to this target
  31226. * @param data defines the tangent data to use
  31227. */
  31228. setTangents(data: Nullable<FloatArray>): void;
  31229. /**
  31230. * Gets the tangent data stored in this target
  31231. * @returns a FloatArray containing the tangent data (or null if not present)
  31232. */
  31233. getTangents(): Nullable<FloatArray>;
  31234. /**
  31235. * Affects texture coordinates data to this target
  31236. * @param data defines the texture coordinates data to use
  31237. */
  31238. setUVs(data: Nullable<FloatArray>): void;
  31239. /**
  31240. * Gets the texture coordinates data stored in this target
  31241. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31242. */
  31243. getUVs(): Nullable<FloatArray>;
  31244. /**
  31245. * Clone the current target
  31246. * @returns a new MorphTarget
  31247. */
  31248. clone(): MorphTarget;
  31249. /**
  31250. * Serializes the current target into a Serialization object
  31251. * @returns the serialized object
  31252. */
  31253. serialize(): any;
  31254. /**
  31255. * Returns the string "MorphTarget"
  31256. * @returns "MorphTarget"
  31257. */
  31258. getClassName(): string;
  31259. /**
  31260. * Creates a new target from serialized data
  31261. * @param serializationObject defines the serialized data to use
  31262. * @returns a new MorphTarget
  31263. */
  31264. static Parse(serializationObject: any): MorphTarget;
  31265. /**
  31266. * Creates a MorphTarget from mesh data
  31267. * @param mesh defines the source mesh
  31268. * @param name defines the name to use for the new target
  31269. * @param influence defines the influence to attach to the target
  31270. * @returns a new MorphTarget
  31271. */
  31272. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31273. }
  31274. }
  31275. declare module BABYLON {
  31276. /**
  31277. * This class is used to deform meshes using morphing between different targets
  31278. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31279. */
  31280. export class MorphTargetManager {
  31281. private _targets;
  31282. private _targetInfluenceChangedObservers;
  31283. private _targetDataLayoutChangedObservers;
  31284. private _activeTargets;
  31285. private _scene;
  31286. private _influences;
  31287. private _supportsNormals;
  31288. private _supportsTangents;
  31289. private _supportsUVs;
  31290. private _vertexCount;
  31291. private _uniqueId;
  31292. private _tempInfluences;
  31293. /**
  31294. * Gets or sets a boolean indicating if normals must be morphed
  31295. */
  31296. enableNormalMorphing: boolean;
  31297. /**
  31298. * Gets or sets a boolean indicating if tangents must be morphed
  31299. */
  31300. enableTangentMorphing: boolean;
  31301. /**
  31302. * Gets or sets a boolean indicating if UV must be morphed
  31303. */
  31304. enableUVMorphing: boolean;
  31305. /**
  31306. * Creates a new MorphTargetManager
  31307. * @param scene defines the current scene
  31308. */
  31309. constructor(scene?: Nullable<Scene>);
  31310. /**
  31311. * Gets the unique ID of this manager
  31312. */
  31313. get uniqueId(): number;
  31314. /**
  31315. * Gets the number of vertices handled by this manager
  31316. */
  31317. get vertexCount(): number;
  31318. /**
  31319. * Gets a boolean indicating if this manager supports morphing of normals
  31320. */
  31321. get supportsNormals(): boolean;
  31322. /**
  31323. * Gets a boolean indicating if this manager supports morphing of tangents
  31324. */
  31325. get supportsTangents(): boolean;
  31326. /**
  31327. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31328. */
  31329. get supportsUVs(): boolean;
  31330. /**
  31331. * Gets the number of targets stored in this manager
  31332. */
  31333. get numTargets(): number;
  31334. /**
  31335. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31336. */
  31337. get numInfluencers(): number;
  31338. /**
  31339. * Gets the list of influences (one per target)
  31340. */
  31341. get influences(): Float32Array;
  31342. /**
  31343. * Gets the active target at specified index. An active target is a target with an influence > 0
  31344. * @param index defines the index to check
  31345. * @returns the requested target
  31346. */
  31347. getActiveTarget(index: number): MorphTarget;
  31348. /**
  31349. * Gets the target at specified index
  31350. * @param index defines the index to check
  31351. * @returns the requested target
  31352. */
  31353. getTarget(index: number): MorphTarget;
  31354. /**
  31355. * Add a new target to this manager
  31356. * @param target defines the target to add
  31357. */
  31358. addTarget(target: MorphTarget): void;
  31359. /**
  31360. * Removes a target from the manager
  31361. * @param target defines the target to remove
  31362. */
  31363. removeTarget(target: MorphTarget): void;
  31364. /**
  31365. * Clone the current manager
  31366. * @returns a new MorphTargetManager
  31367. */
  31368. clone(): MorphTargetManager;
  31369. /**
  31370. * Serializes the current manager into a Serialization object
  31371. * @returns the serialized object
  31372. */
  31373. serialize(): any;
  31374. private _syncActiveTargets;
  31375. /**
  31376. * Syncrhonize the targets with all the meshes using this morph target manager
  31377. */
  31378. synchronize(): void;
  31379. /**
  31380. * Creates a new MorphTargetManager from serialized data
  31381. * @param serializationObject defines the serialized data
  31382. * @param scene defines the hosting scene
  31383. * @returns the new MorphTargetManager
  31384. */
  31385. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31386. }
  31387. }
  31388. declare module BABYLON {
  31389. /**
  31390. * Class used to represent a specific level of detail of a mesh
  31391. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31392. */
  31393. export class MeshLODLevel {
  31394. /** Defines the distance where this level should start being displayed */
  31395. distance: number;
  31396. /** Defines the mesh to use to render this level */
  31397. mesh: Nullable<Mesh>;
  31398. /**
  31399. * Creates a new LOD level
  31400. * @param distance defines the distance where this level should star being displayed
  31401. * @param mesh defines the mesh to use to render this level
  31402. */
  31403. constructor(
  31404. /** Defines the distance where this level should start being displayed */
  31405. distance: number,
  31406. /** Defines the mesh to use to render this level */
  31407. mesh: Nullable<Mesh>);
  31408. }
  31409. }
  31410. declare module BABYLON {
  31411. /**
  31412. * Helper class used to generate a canvas to manipulate images
  31413. */
  31414. export class CanvasGenerator {
  31415. /**
  31416. * Create a new canvas (or offscreen canvas depending on the context)
  31417. * @param width defines the expected width
  31418. * @param height defines the expected height
  31419. * @return a new canvas or offscreen canvas
  31420. */
  31421. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31422. }
  31423. }
  31424. declare module BABYLON {
  31425. /**
  31426. * Mesh representing the gorund
  31427. */
  31428. export class GroundMesh extends Mesh {
  31429. /** If octree should be generated */
  31430. generateOctree: boolean;
  31431. private _heightQuads;
  31432. /** @hidden */
  31433. _subdivisionsX: number;
  31434. /** @hidden */
  31435. _subdivisionsY: number;
  31436. /** @hidden */
  31437. _width: number;
  31438. /** @hidden */
  31439. _height: number;
  31440. /** @hidden */
  31441. _minX: number;
  31442. /** @hidden */
  31443. _maxX: number;
  31444. /** @hidden */
  31445. _minZ: number;
  31446. /** @hidden */
  31447. _maxZ: number;
  31448. constructor(name: string, scene: Scene);
  31449. /**
  31450. * "GroundMesh"
  31451. * @returns "GroundMesh"
  31452. */
  31453. getClassName(): string;
  31454. /**
  31455. * The minimum of x and y subdivisions
  31456. */
  31457. get subdivisions(): number;
  31458. /**
  31459. * X subdivisions
  31460. */
  31461. get subdivisionsX(): number;
  31462. /**
  31463. * Y subdivisions
  31464. */
  31465. get subdivisionsY(): number;
  31466. /**
  31467. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31468. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31469. * @param chunksCount the number of subdivisions for x and y
  31470. * @param octreeBlocksSize (Default: 32)
  31471. */
  31472. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31473. /**
  31474. * Returns a height (y) value in the Worl system :
  31475. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31476. * @param x x coordinate
  31477. * @param z z coordinate
  31478. * @returns the ground y position if (x, z) are outside the ground surface.
  31479. */
  31480. getHeightAtCoordinates(x: number, z: number): number;
  31481. /**
  31482. * Returns a normalized vector (Vector3) orthogonal to the ground
  31483. * at the ground coordinates (x, z) expressed in the World system.
  31484. * @param x x coordinate
  31485. * @param z z coordinate
  31486. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31487. */
  31488. getNormalAtCoordinates(x: number, z: number): Vector3;
  31489. /**
  31490. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31491. * at the ground coordinates (x, z) expressed in the World system.
  31492. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31493. * @param x x coordinate
  31494. * @param z z coordinate
  31495. * @param ref vector to store the result
  31496. * @returns the GroundMesh.
  31497. */
  31498. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31499. /**
  31500. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31501. * if the ground has been updated.
  31502. * This can be used in the render loop.
  31503. * @returns the GroundMesh.
  31504. */
  31505. updateCoordinateHeights(): GroundMesh;
  31506. private _getFacetAt;
  31507. private _initHeightQuads;
  31508. private _computeHeightQuads;
  31509. /**
  31510. * Serializes this ground mesh
  31511. * @param serializationObject object to write serialization to
  31512. */
  31513. serialize(serializationObject: any): void;
  31514. /**
  31515. * Parses a serialized ground mesh
  31516. * @param parsedMesh the serialized mesh
  31517. * @param scene the scene to create the ground mesh in
  31518. * @returns the created ground mesh
  31519. */
  31520. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31521. }
  31522. }
  31523. declare module BABYLON {
  31524. /**
  31525. * Interface for Physics-Joint data
  31526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31527. */
  31528. export interface PhysicsJointData {
  31529. /**
  31530. * The main pivot of the joint
  31531. */
  31532. mainPivot?: Vector3;
  31533. /**
  31534. * The connected pivot of the joint
  31535. */
  31536. connectedPivot?: Vector3;
  31537. /**
  31538. * The main axis of the joint
  31539. */
  31540. mainAxis?: Vector3;
  31541. /**
  31542. * The connected axis of the joint
  31543. */
  31544. connectedAxis?: Vector3;
  31545. /**
  31546. * The collision of the joint
  31547. */
  31548. collision?: boolean;
  31549. /**
  31550. * Native Oimo/Cannon/Energy data
  31551. */
  31552. nativeParams?: any;
  31553. }
  31554. /**
  31555. * This is a holder class for the physics joint created by the physics plugin
  31556. * It holds a set of functions to control the underlying joint
  31557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31558. */
  31559. export class PhysicsJoint {
  31560. /**
  31561. * The type of the physics joint
  31562. */
  31563. type: number;
  31564. /**
  31565. * The data for the physics joint
  31566. */
  31567. jointData: PhysicsJointData;
  31568. private _physicsJoint;
  31569. protected _physicsPlugin: IPhysicsEnginePlugin;
  31570. /**
  31571. * Initializes the physics joint
  31572. * @param type The type of the physics joint
  31573. * @param jointData The data for the physics joint
  31574. */
  31575. constructor(
  31576. /**
  31577. * The type of the physics joint
  31578. */
  31579. type: number,
  31580. /**
  31581. * The data for the physics joint
  31582. */
  31583. jointData: PhysicsJointData);
  31584. /**
  31585. * Gets the physics joint
  31586. */
  31587. get physicsJoint(): any;
  31588. /**
  31589. * Sets the physics joint
  31590. */
  31591. set physicsJoint(newJoint: any);
  31592. /**
  31593. * Sets the physics plugin
  31594. */
  31595. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31596. /**
  31597. * Execute a function that is physics-plugin specific.
  31598. * @param {Function} func the function that will be executed.
  31599. * It accepts two parameters: the physics world and the physics joint
  31600. */
  31601. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31602. /**
  31603. * Distance-Joint type
  31604. */
  31605. static DistanceJoint: number;
  31606. /**
  31607. * Hinge-Joint type
  31608. */
  31609. static HingeJoint: number;
  31610. /**
  31611. * Ball-and-Socket joint type
  31612. */
  31613. static BallAndSocketJoint: number;
  31614. /**
  31615. * Wheel-Joint type
  31616. */
  31617. static WheelJoint: number;
  31618. /**
  31619. * Slider-Joint type
  31620. */
  31621. static SliderJoint: number;
  31622. /**
  31623. * Prismatic-Joint type
  31624. */
  31625. static PrismaticJoint: number;
  31626. /**
  31627. * Universal-Joint type
  31628. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31629. */
  31630. static UniversalJoint: number;
  31631. /**
  31632. * Hinge-Joint 2 type
  31633. */
  31634. static Hinge2Joint: number;
  31635. /**
  31636. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31637. */
  31638. static PointToPointJoint: number;
  31639. /**
  31640. * Spring-Joint type
  31641. */
  31642. static SpringJoint: number;
  31643. /**
  31644. * Lock-Joint type
  31645. */
  31646. static LockJoint: number;
  31647. }
  31648. /**
  31649. * A class representing a physics distance joint
  31650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31651. */
  31652. export class DistanceJoint extends PhysicsJoint {
  31653. /**
  31654. *
  31655. * @param jointData The data for the Distance-Joint
  31656. */
  31657. constructor(jointData: DistanceJointData);
  31658. /**
  31659. * Update the predefined distance.
  31660. * @param maxDistance The maximum preferred distance
  31661. * @param minDistance The minimum preferred distance
  31662. */
  31663. updateDistance(maxDistance: number, minDistance?: number): void;
  31664. }
  31665. /**
  31666. * Represents a Motor-Enabled Joint
  31667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31668. */
  31669. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31670. /**
  31671. * Initializes the Motor-Enabled Joint
  31672. * @param type The type of the joint
  31673. * @param jointData The physica joint data for the joint
  31674. */
  31675. constructor(type: number, jointData: PhysicsJointData);
  31676. /**
  31677. * Set the motor values.
  31678. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31679. * @param force the force to apply
  31680. * @param maxForce max force for this motor.
  31681. */
  31682. setMotor(force?: number, maxForce?: number): void;
  31683. /**
  31684. * Set the motor's limits.
  31685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31686. * @param upperLimit The upper limit of the motor
  31687. * @param lowerLimit The lower limit of the motor
  31688. */
  31689. setLimit(upperLimit: number, lowerLimit?: number): void;
  31690. }
  31691. /**
  31692. * This class represents a single physics Hinge-Joint
  31693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31694. */
  31695. export class HingeJoint extends MotorEnabledJoint {
  31696. /**
  31697. * Initializes the Hinge-Joint
  31698. * @param jointData The joint data for the Hinge-Joint
  31699. */
  31700. constructor(jointData: PhysicsJointData);
  31701. /**
  31702. * Set the motor values.
  31703. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31704. * @param {number} force the force to apply
  31705. * @param {number} maxForce max force for this motor.
  31706. */
  31707. setMotor(force?: number, maxForce?: number): void;
  31708. /**
  31709. * Set the motor's limits.
  31710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31711. * @param upperLimit The upper limit of the motor
  31712. * @param lowerLimit The lower limit of the motor
  31713. */
  31714. setLimit(upperLimit: number, lowerLimit?: number): void;
  31715. }
  31716. /**
  31717. * This class represents a dual hinge physics joint (same as wheel joint)
  31718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31719. */
  31720. export class Hinge2Joint extends MotorEnabledJoint {
  31721. /**
  31722. * Initializes the Hinge2-Joint
  31723. * @param jointData The joint data for the Hinge2-Joint
  31724. */
  31725. constructor(jointData: PhysicsJointData);
  31726. /**
  31727. * Set the motor values.
  31728. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31729. * @param {number} targetSpeed the speed the motor is to reach
  31730. * @param {number} maxForce max force for this motor.
  31731. * @param {motorIndex} the motor's index, 0 or 1.
  31732. */
  31733. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31734. /**
  31735. * Set the motor limits.
  31736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31737. * @param {number} upperLimit the upper limit
  31738. * @param {number} lowerLimit lower limit
  31739. * @param {motorIndex} the motor's index, 0 or 1.
  31740. */
  31741. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31742. }
  31743. /**
  31744. * Interface for a motor enabled joint
  31745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31746. */
  31747. export interface IMotorEnabledJoint {
  31748. /**
  31749. * Physics joint
  31750. */
  31751. physicsJoint: any;
  31752. /**
  31753. * Sets the motor of the motor-enabled joint
  31754. * @param force The force of the motor
  31755. * @param maxForce The maximum force of the motor
  31756. * @param motorIndex The index of the motor
  31757. */
  31758. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31759. /**
  31760. * Sets the limit of the motor
  31761. * @param upperLimit The upper limit of the motor
  31762. * @param lowerLimit The lower limit of the motor
  31763. * @param motorIndex The index of the motor
  31764. */
  31765. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31766. }
  31767. /**
  31768. * Joint data for a Distance-Joint
  31769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31770. */
  31771. export interface DistanceJointData extends PhysicsJointData {
  31772. /**
  31773. * Max distance the 2 joint objects can be apart
  31774. */
  31775. maxDistance: number;
  31776. }
  31777. /**
  31778. * Joint data from a spring joint
  31779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31780. */
  31781. export interface SpringJointData extends PhysicsJointData {
  31782. /**
  31783. * Length of the spring
  31784. */
  31785. length: number;
  31786. /**
  31787. * Stiffness of the spring
  31788. */
  31789. stiffness: number;
  31790. /**
  31791. * Damping of the spring
  31792. */
  31793. damping: number;
  31794. /** this callback will be called when applying the force to the impostors. */
  31795. forceApplicationCallback: () => void;
  31796. }
  31797. }
  31798. declare module BABYLON {
  31799. /**
  31800. * Holds the data for the raycast result
  31801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31802. */
  31803. export class PhysicsRaycastResult {
  31804. private _hasHit;
  31805. private _hitDistance;
  31806. private _hitNormalWorld;
  31807. private _hitPointWorld;
  31808. private _rayFromWorld;
  31809. private _rayToWorld;
  31810. /**
  31811. * Gets if there was a hit
  31812. */
  31813. get hasHit(): boolean;
  31814. /**
  31815. * Gets the distance from the hit
  31816. */
  31817. get hitDistance(): number;
  31818. /**
  31819. * Gets the hit normal/direction in the world
  31820. */
  31821. get hitNormalWorld(): Vector3;
  31822. /**
  31823. * Gets the hit point in the world
  31824. */
  31825. get hitPointWorld(): Vector3;
  31826. /**
  31827. * Gets the ray "start point" of the ray in the world
  31828. */
  31829. get rayFromWorld(): Vector3;
  31830. /**
  31831. * Gets the ray "end point" of the ray in the world
  31832. */
  31833. get rayToWorld(): Vector3;
  31834. /**
  31835. * Sets the hit data (normal & point in world space)
  31836. * @param hitNormalWorld defines the normal in world space
  31837. * @param hitPointWorld defines the point in world space
  31838. */
  31839. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31840. /**
  31841. * Sets the distance from the start point to the hit point
  31842. * @param distance
  31843. */
  31844. setHitDistance(distance: number): void;
  31845. /**
  31846. * Calculates the distance manually
  31847. */
  31848. calculateHitDistance(): void;
  31849. /**
  31850. * Resets all the values to default
  31851. * @param from The from point on world space
  31852. * @param to The to point on world space
  31853. */
  31854. reset(from?: Vector3, to?: Vector3): void;
  31855. }
  31856. /**
  31857. * Interface for the size containing width and height
  31858. */
  31859. interface IXYZ {
  31860. /**
  31861. * X
  31862. */
  31863. x: number;
  31864. /**
  31865. * Y
  31866. */
  31867. y: number;
  31868. /**
  31869. * Z
  31870. */
  31871. z: number;
  31872. }
  31873. }
  31874. declare module BABYLON {
  31875. /**
  31876. * Interface used to describe a physics joint
  31877. */
  31878. export interface PhysicsImpostorJoint {
  31879. /** Defines the main impostor to which the joint is linked */
  31880. mainImpostor: PhysicsImpostor;
  31881. /** Defines the impostor that is connected to the main impostor using this joint */
  31882. connectedImpostor: PhysicsImpostor;
  31883. /** Defines the joint itself */
  31884. joint: PhysicsJoint;
  31885. }
  31886. /** @hidden */
  31887. export interface IPhysicsEnginePlugin {
  31888. world: any;
  31889. name: string;
  31890. setGravity(gravity: Vector3): void;
  31891. setTimeStep(timeStep: number): void;
  31892. getTimeStep(): number;
  31893. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31895. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31896. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31897. removePhysicsBody(impostor: PhysicsImpostor): void;
  31898. generateJoint(joint: PhysicsImpostorJoint): void;
  31899. removeJoint(joint: PhysicsImpostorJoint): void;
  31900. isSupported(): boolean;
  31901. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31902. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31903. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31904. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31905. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31906. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31907. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31908. getBodyMass(impostor: PhysicsImpostor): number;
  31909. getBodyFriction(impostor: PhysicsImpostor): number;
  31910. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31911. getBodyRestitution(impostor: PhysicsImpostor): number;
  31912. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31913. getBodyPressure?(impostor: PhysicsImpostor): number;
  31914. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31915. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31916. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31917. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31918. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31919. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31920. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31921. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31922. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31923. sleepBody(impostor: PhysicsImpostor): void;
  31924. wakeUpBody(impostor: PhysicsImpostor): void;
  31925. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31926. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31927. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31928. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31929. getRadius(impostor: PhysicsImpostor): number;
  31930. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31931. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31932. dispose(): void;
  31933. }
  31934. /**
  31935. * Interface used to define a physics engine
  31936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31937. */
  31938. export interface IPhysicsEngine {
  31939. /**
  31940. * Gets the gravity vector used by the simulation
  31941. */
  31942. gravity: Vector3;
  31943. /**
  31944. * Sets the gravity vector used by the simulation
  31945. * @param gravity defines the gravity vector to use
  31946. */
  31947. setGravity(gravity: Vector3): void;
  31948. /**
  31949. * Set the time step of the physics engine.
  31950. * Default is 1/60.
  31951. * To slow it down, enter 1/600 for example.
  31952. * To speed it up, 1/30
  31953. * @param newTimeStep the new timestep to apply to this world.
  31954. */
  31955. setTimeStep(newTimeStep: number): void;
  31956. /**
  31957. * Get the time step of the physics engine.
  31958. * @returns the current time step
  31959. */
  31960. getTimeStep(): number;
  31961. /**
  31962. * Set the sub time step of the physics engine.
  31963. * Default is 0 meaning there is no sub steps
  31964. * To increase physics resolution precision, set a small value (like 1 ms)
  31965. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31966. */
  31967. setSubTimeStep(subTimeStep: number): void;
  31968. /**
  31969. * Get the sub time step of the physics engine.
  31970. * @returns the current sub time step
  31971. */
  31972. getSubTimeStep(): number;
  31973. /**
  31974. * Release all resources
  31975. */
  31976. dispose(): void;
  31977. /**
  31978. * Gets the name of the current physics plugin
  31979. * @returns the name of the plugin
  31980. */
  31981. getPhysicsPluginName(): string;
  31982. /**
  31983. * Adding a new impostor for the impostor tracking.
  31984. * This will be done by the impostor itself.
  31985. * @param impostor the impostor to add
  31986. */
  31987. addImpostor(impostor: PhysicsImpostor): void;
  31988. /**
  31989. * Remove an impostor from the engine.
  31990. * This impostor and its mesh will not longer be updated by the physics engine.
  31991. * @param impostor the impostor to remove
  31992. */
  31993. removeImpostor(impostor: PhysicsImpostor): void;
  31994. /**
  31995. * Add a joint to the physics engine
  31996. * @param mainImpostor defines the main impostor to which the joint is added.
  31997. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31998. * @param joint defines the joint that will connect both impostors.
  31999. */
  32000. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32001. /**
  32002. * Removes a joint from the simulation
  32003. * @param mainImpostor defines the impostor used with the joint
  32004. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32005. * @param joint defines the joint to remove
  32006. */
  32007. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32008. /**
  32009. * Gets the current plugin used to run the simulation
  32010. * @returns current plugin
  32011. */
  32012. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32013. /**
  32014. * Gets the list of physic impostors
  32015. * @returns an array of PhysicsImpostor
  32016. */
  32017. getImpostors(): Array<PhysicsImpostor>;
  32018. /**
  32019. * Gets the impostor for a physics enabled object
  32020. * @param object defines the object impersonated by the impostor
  32021. * @returns the PhysicsImpostor or null if not found
  32022. */
  32023. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32024. /**
  32025. * Gets the impostor for a physics body object
  32026. * @param body defines physics body used by the impostor
  32027. * @returns the PhysicsImpostor or null if not found
  32028. */
  32029. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32030. /**
  32031. * Does a raycast in the physics world
  32032. * @param from when should the ray start?
  32033. * @param to when should the ray end?
  32034. * @returns PhysicsRaycastResult
  32035. */
  32036. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32037. /**
  32038. * Called by the scene. No need to call it.
  32039. * @param delta defines the timespam between frames
  32040. */
  32041. _step(delta: number): void;
  32042. }
  32043. }
  32044. declare module BABYLON {
  32045. /**
  32046. * The interface for the physics imposter parameters
  32047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32048. */
  32049. export interface PhysicsImpostorParameters {
  32050. /**
  32051. * The mass of the physics imposter
  32052. */
  32053. mass: number;
  32054. /**
  32055. * The friction of the physics imposter
  32056. */
  32057. friction?: number;
  32058. /**
  32059. * The coefficient of restitution of the physics imposter
  32060. */
  32061. restitution?: number;
  32062. /**
  32063. * The native options of the physics imposter
  32064. */
  32065. nativeOptions?: any;
  32066. /**
  32067. * Specifies if the parent should be ignored
  32068. */
  32069. ignoreParent?: boolean;
  32070. /**
  32071. * Specifies if bi-directional transformations should be disabled
  32072. */
  32073. disableBidirectionalTransformation?: boolean;
  32074. /**
  32075. * The pressure inside the physics imposter, soft object only
  32076. */
  32077. pressure?: number;
  32078. /**
  32079. * The stiffness the physics imposter, soft object only
  32080. */
  32081. stiffness?: number;
  32082. /**
  32083. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32084. */
  32085. velocityIterations?: number;
  32086. /**
  32087. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32088. */
  32089. positionIterations?: number;
  32090. /**
  32091. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32092. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32093. * Add to fix multiple points
  32094. */
  32095. fixedPoints?: number;
  32096. /**
  32097. * The collision margin around a soft object
  32098. */
  32099. margin?: number;
  32100. /**
  32101. * The collision margin around a soft object
  32102. */
  32103. damping?: number;
  32104. /**
  32105. * The path for a rope based on an extrusion
  32106. */
  32107. path?: any;
  32108. /**
  32109. * The shape of an extrusion used for a rope based on an extrusion
  32110. */
  32111. shape?: any;
  32112. }
  32113. /**
  32114. * Interface for a physics-enabled object
  32115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32116. */
  32117. export interface IPhysicsEnabledObject {
  32118. /**
  32119. * The position of the physics-enabled object
  32120. */
  32121. position: Vector3;
  32122. /**
  32123. * The rotation of the physics-enabled object
  32124. */
  32125. rotationQuaternion: Nullable<Quaternion>;
  32126. /**
  32127. * The scale of the physics-enabled object
  32128. */
  32129. scaling: Vector3;
  32130. /**
  32131. * The rotation of the physics-enabled object
  32132. */
  32133. rotation?: Vector3;
  32134. /**
  32135. * The parent of the physics-enabled object
  32136. */
  32137. parent?: any;
  32138. /**
  32139. * The bounding info of the physics-enabled object
  32140. * @returns The bounding info of the physics-enabled object
  32141. */
  32142. getBoundingInfo(): BoundingInfo;
  32143. /**
  32144. * Computes the world matrix
  32145. * @param force Specifies if the world matrix should be computed by force
  32146. * @returns A world matrix
  32147. */
  32148. computeWorldMatrix(force: boolean): Matrix;
  32149. /**
  32150. * Gets the world matrix
  32151. * @returns A world matrix
  32152. */
  32153. getWorldMatrix?(): Matrix;
  32154. /**
  32155. * Gets the child meshes
  32156. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32157. * @returns An array of abstract meshes
  32158. */
  32159. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32160. /**
  32161. * Gets the vertex data
  32162. * @param kind The type of vertex data
  32163. * @returns A nullable array of numbers, or a float32 array
  32164. */
  32165. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32166. /**
  32167. * Gets the indices from the mesh
  32168. * @returns A nullable array of index arrays
  32169. */
  32170. getIndices?(): Nullable<IndicesArray>;
  32171. /**
  32172. * Gets the scene from the mesh
  32173. * @returns the indices array or null
  32174. */
  32175. getScene?(): Scene;
  32176. /**
  32177. * Gets the absolute position from the mesh
  32178. * @returns the absolute position
  32179. */
  32180. getAbsolutePosition(): Vector3;
  32181. /**
  32182. * Gets the absolute pivot point from the mesh
  32183. * @returns the absolute pivot point
  32184. */
  32185. getAbsolutePivotPoint(): Vector3;
  32186. /**
  32187. * Rotates the mesh
  32188. * @param axis The axis of rotation
  32189. * @param amount The amount of rotation
  32190. * @param space The space of the rotation
  32191. * @returns The rotation transform node
  32192. */
  32193. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32194. /**
  32195. * Translates the mesh
  32196. * @param axis The axis of translation
  32197. * @param distance The distance of translation
  32198. * @param space The space of the translation
  32199. * @returns The transform node
  32200. */
  32201. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32202. /**
  32203. * Sets the absolute position of the mesh
  32204. * @param absolutePosition The absolute position of the mesh
  32205. * @returns The transform node
  32206. */
  32207. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32208. /**
  32209. * Gets the class name of the mesh
  32210. * @returns The class name
  32211. */
  32212. getClassName(): string;
  32213. }
  32214. /**
  32215. * Represents a physics imposter
  32216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32217. */
  32218. export class PhysicsImpostor {
  32219. /**
  32220. * The physics-enabled object used as the physics imposter
  32221. */
  32222. object: IPhysicsEnabledObject;
  32223. /**
  32224. * The type of the physics imposter
  32225. */
  32226. type: number;
  32227. private _options;
  32228. private _scene?;
  32229. /**
  32230. * The default object size of the imposter
  32231. */
  32232. static DEFAULT_OBJECT_SIZE: Vector3;
  32233. /**
  32234. * The identity quaternion of the imposter
  32235. */
  32236. static IDENTITY_QUATERNION: Quaternion;
  32237. /** @hidden */
  32238. _pluginData: any;
  32239. private _physicsEngine;
  32240. private _physicsBody;
  32241. private _bodyUpdateRequired;
  32242. private _onBeforePhysicsStepCallbacks;
  32243. private _onAfterPhysicsStepCallbacks;
  32244. /** @hidden */
  32245. _onPhysicsCollideCallbacks: Array<{
  32246. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32247. otherImpostors: Array<PhysicsImpostor>;
  32248. }>;
  32249. private _deltaPosition;
  32250. private _deltaRotation;
  32251. private _deltaRotationConjugated;
  32252. /** @hidden */
  32253. _isFromLine: boolean;
  32254. private _parent;
  32255. private _isDisposed;
  32256. private static _tmpVecs;
  32257. private static _tmpQuat;
  32258. /**
  32259. * Specifies if the physics imposter is disposed
  32260. */
  32261. get isDisposed(): boolean;
  32262. /**
  32263. * Gets the mass of the physics imposter
  32264. */
  32265. get mass(): number;
  32266. set mass(value: number);
  32267. /**
  32268. * Gets the coefficient of friction
  32269. */
  32270. get friction(): number;
  32271. /**
  32272. * Sets the coefficient of friction
  32273. */
  32274. set friction(value: number);
  32275. /**
  32276. * Gets the coefficient of restitution
  32277. */
  32278. get restitution(): number;
  32279. /**
  32280. * Sets the coefficient of restitution
  32281. */
  32282. set restitution(value: number);
  32283. /**
  32284. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32285. */
  32286. get pressure(): number;
  32287. /**
  32288. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32289. */
  32290. set pressure(value: number);
  32291. /**
  32292. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32293. */
  32294. get stiffness(): number;
  32295. /**
  32296. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32297. */
  32298. set stiffness(value: number);
  32299. /**
  32300. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32301. */
  32302. get velocityIterations(): number;
  32303. /**
  32304. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32305. */
  32306. set velocityIterations(value: number);
  32307. /**
  32308. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32309. */
  32310. get positionIterations(): number;
  32311. /**
  32312. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32313. */
  32314. set positionIterations(value: number);
  32315. /**
  32316. * The unique id of the physics imposter
  32317. * set by the physics engine when adding this impostor to the array
  32318. */
  32319. uniqueId: number;
  32320. /**
  32321. * @hidden
  32322. */
  32323. soft: boolean;
  32324. /**
  32325. * @hidden
  32326. */
  32327. segments: number;
  32328. private _joints;
  32329. /**
  32330. * Initializes the physics imposter
  32331. * @param object The physics-enabled object used as the physics imposter
  32332. * @param type The type of the physics imposter
  32333. * @param _options The options for the physics imposter
  32334. * @param _scene The Babylon scene
  32335. */
  32336. constructor(
  32337. /**
  32338. * The physics-enabled object used as the physics imposter
  32339. */
  32340. object: IPhysicsEnabledObject,
  32341. /**
  32342. * The type of the physics imposter
  32343. */
  32344. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32345. /**
  32346. * This function will completly initialize this impostor.
  32347. * It will create a new body - but only if this mesh has no parent.
  32348. * If it has, this impostor will not be used other than to define the impostor
  32349. * of the child mesh.
  32350. * @hidden
  32351. */
  32352. _init(): void;
  32353. private _getPhysicsParent;
  32354. /**
  32355. * Should a new body be generated.
  32356. * @returns boolean specifying if body initialization is required
  32357. */
  32358. isBodyInitRequired(): boolean;
  32359. /**
  32360. * Sets the updated scaling
  32361. * @param updated Specifies if the scaling is updated
  32362. */
  32363. setScalingUpdated(): void;
  32364. /**
  32365. * Force a regeneration of this or the parent's impostor's body.
  32366. * Use under cautious - This will remove all joints already implemented.
  32367. */
  32368. forceUpdate(): void;
  32369. /**
  32370. * Gets the body that holds this impostor. Either its own, or its parent.
  32371. */
  32372. get physicsBody(): any;
  32373. /**
  32374. * Get the parent of the physics imposter
  32375. * @returns Physics imposter or null
  32376. */
  32377. get parent(): Nullable<PhysicsImpostor>;
  32378. /**
  32379. * Sets the parent of the physics imposter
  32380. */
  32381. set parent(value: Nullable<PhysicsImpostor>);
  32382. /**
  32383. * Set the physics body. Used mainly by the physics engine/plugin
  32384. */
  32385. set physicsBody(physicsBody: any);
  32386. /**
  32387. * Resets the update flags
  32388. */
  32389. resetUpdateFlags(): void;
  32390. /**
  32391. * Gets the object extend size
  32392. * @returns the object extend size
  32393. */
  32394. getObjectExtendSize(): Vector3;
  32395. /**
  32396. * Gets the object center
  32397. * @returns The object center
  32398. */
  32399. getObjectCenter(): Vector3;
  32400. /**
  32401. * Get a specific parameter from the options parameters
  32402. * @param paramName The object parameter name
  32403. * @returns The object parameter
  32404. */
  32405. getParam(paramName: string): any;
  32406. /**
  32407. * Sets a specific parameter in the options given to the physics plugin
  32408. * @param paramName The parameter name
  32409. * @param value The value of the parameter
  32410. */
  32411. setParam(paramName: string, value: number): void;
  32412. /**
  32413. * Specifically change the body's mass option. Won't recreate the physics body object
  32414. * @param mass The mass of the physics imposter
  32415. */
  32416. setMass(mass: number): void;
  32417. /**
  32418. * Gets the linear velocity
  32419. * @returns linear velocity or null
  32420. */
  32421. getLinearVelocity(): Nullable<Vector3>;
  32422. /**
  32423. * Sets the linear velocity
  32424. * @param velocity linear velocity or null
  32425. */
  32426. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32427. /**
  32428. * Gets the angular velocity
  32429. * @returns angular velocity or null
  32430. */
  32431. getAngularVelocity(): Nullable<Vector3>;
  32432. /**
  32433. * Sets the angular velocity
  32434. * @param velocity The velocity or null
  32435. */
  32436. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32437. /**
  32438. * Execute a function with the physics plugin native code
  32439. * Provide a function the will have two variables - the world object and the physics body object
  32440. * @param func The function to execute with the physics plugin native code
  32441. */
  32442. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32443. /**
  32444. * Register a function that will be executed before the physics world is stepping forward
  32445. * @param func The function to execute before the physics world is stepped forward
  32446. */
  32447. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32448. /**
  32449. * Unregister a function that will be executed before the physics world is stepping forward
  32450. * @param func The function to execute before the physics world is stepped forward
  32451. */
  32452. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32453. /**
  32454. * Register a function that will be executed after the physics step
  32455. * @param func The function to execute after physics step
  32456. */
  32457. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32458. /**
  32459. * Unregisters a function that will be executed after the physics step
  32460. * @param func The function to execute after physics step
  32461. */
  32462. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32463. /**
  32464. * register a function that will be executed when this impostor collides against a different body
  32465. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32466. * @param func Callback that is executed on collision
  32467. */
  32468. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32469. /**
  32470. * Unregisters the physics imposter on contact
  32471. * @param collideAgainst The physics object to collide against
  32472. * @param func Callback to execute on collision
  32473. */
  32474. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32475. private _tmpQuat;
  32476. private _tmpQuat2;
  32477. /**
  32478. * Get the parent rotation
  32479. * @returns The parent rotation
  32480. */
  32481. getParentsRotation(): Quaternion;
  32482. /**
  32483. * this function is executed by the physics engine.
  32484. */
  32485. beforeStep: () => void;
  32486. /**
  32487. * this function is executed by the physics engine
  32488. */
  32489. afterStep: () => void;
  32490. /**
  32491. * Legacy collision detection event support
  32492. */
  32493. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32494. /**
  32495. * event and body object due to cannon's event-based architecture.
  32496. */
  32497. onCollide: (e: {
  32498. body: any;
  32499. point: Nullable<Vector3>;
  32500. }) => void;
  32501. /**
  32502. * Apply a force
  32503. * @param force The force to apply
  32504. * @param contactPoint The contact point for the force
  32505. * @returns The physics imposter
  32506. */
  32507. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32508. /**
  32509. * Apply an impulse
  32510. * @param force The impulse force
  32511. * @param contactPoint The contact point for the impulse force
  32512. * @returns The physics imposter
  32513. */
  32514. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32515. /**
  32516. * A help function to create a joint
  32517. * @param otherImpostor A physics imposter used to create a joint
  32518. * @param jointType The type of joint
  32519. * @param jointData The data for the joint
  32520. * @returns The physics imposter
  32521. */
  32522. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32523. /**
  32524. * Add a joint to this impostor with a different impostor
  32525. * @param otherImpostor A physics imposter used to add a joint
  32526. * @param joint The joint to add
  32527. * @returns The physics imposter
  32528. */
  32529. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32530. /**
  32531. * Add an anchor to a cloth impostor
  32532. * @param otherImpostor rigid impostor to anchor to
  32533. * @param width ratio across width from 0 to 1
  32534. * @param height ratio up height from 0 to 1
  32535. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32536. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32537. * @returns impostor the soft imposter
  32538. */
  32539. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32540. /**
  32541. * Add a hook to a rope impostor
  32542. * @param otherImpostor rigid impostor to anchor to
  32543. * @param length ratio across rope from 0 to 1
  32544. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32545. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32546. * @returns impostor the rope imposter
  32547. */
  32548. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32549. /**
  32550. * Will keep this body still, in a sleep mode.
  32551. * @returns the physics imposter
  32552. */
  32553. sleep(): PhysicsImpostor;
  32554. /**
  32555. * Wake the body up.
  32556. * @returns The physics imposter
  32557. */
  32558. wakeUp(): PhysicsImpostor;
  32559. /**
  32560. * Clones the physics imposter
  32561. * @param newObject The physics imposter clones to this physics-enabled object
  32562. * @returns A nullable physics imposter
  32563. */
  32564. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32565. /**
  32566. * Disposes the physics imposter
  32567. */
  32568. dispose(): void;
  32569. /**
  32570. * Sets the delta position
  32571. * @param position The delta position amount
  32572. */
  32573. setDeltaPosition(position: Vector3): void;
  32574. /**
  32575. * Sets the delta rotation
  32576. * @param rotation The delta rotation amount
  32577. */
  32578. setDeltaRotation(rotation: Quaternion): void;
  32579. /**
  32580. * Gets the box size of the physics imposter and stores the result in the input parameter
  32581. * @param result Stores the box size
  32582. * @returns The physics imposter
  32583. */
  32584. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32585. /**
  32586. * Gets the radius of the physics imposter
  32587. * @returns Radius of the physics imposter
  32588. */
  32589. getRadius(): number;
  32590. /**
  32591. * Sync a bone with this impostor
  32592. * @param bone The bone to sync to the impostor.
  32593. * @param boneMesh The mesh that the bone is influencing.
  32594. * @param jointPivot The pivot of the joint / bone in local space.
  32595. * @param distToJoint Optional distance from the impostor to the joint.
  32596. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32597. */
  32598. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32599. /**
  32600. * Sync impostor to a bone
  32601. * @param bone The bone that the impostor will be synced to.
  32602. * @param boneMesh The mesh that the bone is influencing.
  32603. * @param jointPivot The pivot of the joint / bone in local space.
  32604. * @param distToJoint Optional distance from the impostor to the joint.
  32605. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32606. * @param boneAxis Optional vector3 axis the bone is aligned with
  32607. */
  32608. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32609. /**
  32610. * No-Imposter type
  32611. */
  32612. static NoImpostor: number;
  32613. /**
  32614. * Sphere-Imposter type
  32615. */
  32616. static SphereImpostor: number;
  32617. /**
  32618. * Box-Imposter type
  32619. */
  32620. static BoxImpostor: number;
  32621. /**
  32622. * Plane-Imposter type
  32623. */
  32624. static PlaneImpostor: number;
  32625. /**
  32626. * Mesh-imposter type
  32627. */
  32628. static MeshImpostor: number;
  32629. /**
  32630. * Capsule-Impostor type (Ammo.js plugin only)
  32631. */
  32632. static CapsuleImpostor: number;
  32633. /**
  32634. * Cylinder-Imposter type
  32635. */
  32636. static CylinderImpostor: number;
  32637. /**
  32638. * Particle-Imposter type
  32639. */
  32640. static ParticleImpostor: number;
  32641. /**
  32642. * Heightmap-Imposter type
  32643. */
  32644. static HeightmapImpostor: number;
  32645. /**
  32646. * ConvexHull-Impostor type (Ammo.js plugin only)
  32647. */
  32648. static ConvexHullImpostor: number;
  32649. /**
  32650. * Custom-Imposter type (Ammo.js plugin only)
  32651. */
  32652. static CustomImpostor: number;
  32653. /**
  32654. * Rope-Imposter type
  32655. */
  32656. static RopeImpostor: number;
  32657. /**
  32658. * Cloth-Imposter type
  32659. */
  32660. static ClothImpostor: number;
  32661. /**
  32662. * Softbody-Imposter type
  32663. */
  32664. static SoftbodyImpostor: number;
  32665. }
  32666. }
  32667. declare module BABYLON {
  32668. /**
  32669. * @hidden
  32670. **/
  32671. export class _CreationDataStorage {
  32672. closePath?: boolean;
  32673. closeArray?: boolean;
  32674. idx: number[];
  32675. dashSize: number;
  32676. gapSize: number;
  32677. path3D: Path3D;
  32678. pathArray: Vector3[][];
  32679. arc: number;
  32680. radius: number;
  32681. cap: number;
  32682. tessellation: number;
  32683. }
  32684. /**
  32685. * @hidden
  32686. **/
  32687. class _InstanceDataStorage {
  32688. visibleInstances: any;
  32689. batchCache: _InstancesBatch;
  32690. instancesBufferSize: number;
  32691. instancesBuffer: Nullable<Buffer>;
  32692. instancesData: Float32Array;
  32693. overridenInstanceCount: number;
  32694. isFrozen: boolean;
  32695. previousBatch: Nullable<_InstancesBatch>;
  32696. hardwareInstancedRendering: boolean;
  32697. sideOrientation: number;
  32698. manualUpdate: boolean;
  32699. previousRenderId: number;
  32700. }
  32701. /**
  32702. * @hidden
  32703. **/
  32704. export class _InstancesBatch {
  32705. mustReturn: boolean;
  32706. visibleInstances: Nullable<InstancedMesh[]>[];
  32707. renderSelf: boolean[];
  32708. hardwareInstancedRendering: boolean[];
  32709. }
  32710. /**
  32711. * @hidden
  32712. **/
  32713. class _ThinInstanceDataStorage {
  32714. instancesCount: number;
  32715. matrixBuffer: Nullable<Buffer>;
  32716. matrixBufferSize: number;
  32717. matrixData: Nullable<Float32Array>;
  32718. boundingVectors: Array<Vector3>;
  32719. worldMatrices: Nullable<Matrix[]>;
  32720. }
  32721. /**
  32722. * Class used to represent renderable models
  32723. */
  32724. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32725. /**
  32726. * Mesh side orientation : usually the external or front surface
  32727. */
  32728. static readonly FRONTSIDE: number;
  32729. /**
  32730. * Mesh side orientation : usually the internal or back surface
  32731. */
  32732. static readonly BACKSIDE: number;
  32733. /**
  32734. * Mesh side orientation : both internal and external or front and back surfaces
  32735. */
  32736. static readonly DOUBLESIDE: number;
  32737. /**
  32738. * Mesh side orientation : by default, `FRONTSIDE`
  32739. */
  32740. static readonly DEFAULTSIDE: number;
  32741. /**
  32742. * Mesh cap setting : no cap
  32743. */
  32744. static readonly NO_CAP: number;
  32745. /**
  32746. * Mesh cap setting : one cap at the beginning of the mesh
  32747. */
  32748. static readonly CAP_START: number;
  32749. /**
  32750. * Mesh cap setting : one cap at the end of the mesh
  32751. */
  32752. static readonly CAP_END: number;
  32753. /**
  32754. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32755. */
  32756. static readonly CAP_ALL: number;
  32757. /**
  32758. * Mesh pattern setting : no flip or rotate
  32759. */
  32760. static readonly NO_FLIP: number;
  32761. /**
  32762. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32763. */
  32764. static readonly FLIP_TILE: number;
  32765. /**
  32766. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32767. */
  32768. static readonly ROTATE_TILE: number;
  32769. /**
  32770. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32771. */
  32772. static readonly FLIP_ROW: number;
  32773. /**
  32774. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32775. */
  32776. static readonly ROTATE_ROW: number;
  32777. /**
  32778. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32779. */
  32780. static readonly FLIP_N_ROTATE_TILE: number;
  32781. /**
  32782. * Mesh pattern setting : rotate pattern and rotate
  32783. */
  32784. static readonly FLIP_N_ROTATE_ROW: number;
  32785. /**
  32786. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32787. */
  32788. static readonly CENTER: number;
  32789. /**
  32790. * Mesh tile positioning : part tiles on left
  32791. */
  32792. static readonly LEFT: number;
  32793. /**
  32794. * Mesh tile positioning : part tiles on right
  32795. */
  32796. static readonly RIGHT: number;
  32797. /**
  32798. * Mesh tile positioning : part tiles on top
  32799. */
  32800. static readonly TOP: number;
  32801. /**
  32802. * Mesh tile positioning : part tiles on bottom
  32803. */
  32804. static readonly BOTTOM: number;
  32805. /**
  32806. * Gets the default side orientation.
  32807. * @param orientation the orientation to value to attempt to get
  32808. * @returns the default orientation
  32809. * @hidden
  32810. */
  32811. static _GetDefaultSideOrientation(orientation?: number): number;
  32812. private _internalMeshDataInfo;
  32813. get computeBonesUsingShaders(): boolean;
  32814. set computeBonesUsingShaders(value: boolean);
  32815. /**
  32816. * An event triggered before rendering the mesh
  32817. */
  32818. get onBeforeRenderObservable(): Observable<Mesh>;
  32819. /**
  32820. * An event triggered before binding the mesh
  32821. */
  32822. get onBeforeBindObservable(): Observable<Mesh>;
  32823. /**
  32824. * An event triggered after rendering the mesh
  32825. */
  32826. get onAfterRenderObservable(): Observable<Mesh>;
  32827. /**
  32828. * An event triggered before drawing the mesh
  32829. */
  32830. get onBeforeDrawObservable(): Observable<Mesh>;
  32831. private _onBeforeDrawObserver;
  32832. /**
  32833. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32834. */
  32835. set onBeforeDraw(callback: () => void);
  32836. get hasInstances(): boolean;
  32837. get hasThinInstances(): boolean;
  32838. /**
  32839. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32840. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32841. */
  32842. delayLoadState: number;
  32843. /**
  32844. * Gets the list of instances created from this mesh
  32845. * it is not supposed to be modified manually.
  32846. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32847. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32848. */
  32849. instances: InstancedMesh[];
  32850. /**
  32851. * Gets the file containing delay loading data for this mesh
  32852. */
  32853. delayLoadingFile: string;
  32854. /** @hidden */
  32855. _binaryInfo: any;
  32856. /**
  32857. * User defined function used to change how LOD level selection is done
  32858. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32859. */
  32860. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32861. /**
  32862. * Gets or sets the morph target manager
  32863. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32864. */
  32865. get morphTargetManager(): Nullable<MorphTargetManager>;
  32866. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32867. /** @hidden */
  32868. _creationDataStorage: Nullable<_CreationDataStorage>;
  32869. /** @hidden */
  32870. _geometry: Nullable<Geometry>;
  32871. /** @hidden */
  32872. _delayInfo: Array<string>;
  32873. /** @hidden */
  32874. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32875. /** @hidden */
  32876. _instanceDataStorage: _InstanceDataStorage;
  32877. /** @hidden */
  32878. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32879. private _effectiveMaterial;
  32880. /** @hidden */
  32881. _shouldGenerateFlatShading: boolean;
  32882. /** @hidden */
  32883. _originalBuilderSideOrientation: number;
  32884. /**
  32885. * Use this property to change the original side orientation defined at construction time
  32886. */
  32887. overrideMaterialSideOrientation: Nullable<number>;
  32888. /**
  32889. * Gets the source mesh (the one used to clone this one from)
  32890. */
  32891. get source(): Nullable<Mesh>;
  32892. /**
  32893. * Gets the list of clones of this mesh
  32894. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32895. * Note that useClonedMeshMap=true is the default setting
  32896. */
  32897. get cloneMeshMap(): Nullable<{
  32898. [id: string]: Mesh | undefined;
  32899. }>;
  32900. /**
  32901. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32902. */
  32903. get isUnIndexed(): boolean;
  32904. set isUnIndexed(value: boolean);
  32905. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32906. get worldMatrixInstancedBuffer(): Float32Array;
  32907. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32908. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32909. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32910. /**
  32911. * @constructor
  32912. * @param name The value used by scene.getMeshByName() to do a lookup.
  32913. * @param scene The scene to add this mesh to.
  32914. * @param parent The parent of this mesh, if it has one
  32915. * @param source An optional Mesh from which geometry is shared, cloned.
  32916. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32917. * When false, achieved by calling a clone(), also passing False.
  32918. * This will make creation of children, recursive.
  32919. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32920. */
  32921. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32922. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32923. doNotInstantiate: boolean;
  32924. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32925. /**
  32926. * Gets the class name
  32927. * @returns the string "Mesh".
  32928. */
  32929. getClassName(): string;
  32930. /** @hidden */
  32931. get _isMesh(): boolean;
  32932. /**
  32933. * Returns a description of this mesh
  32934. * @param fullDetails define if full details about this mesh must be used
  32935. * @returns a descriptive string representing this mesh
  32936. */
  32937. toString(fullDetails?: boolean): string;
  32938. /** @hidden */
  32939. _unBindEffect(): void;
  32940. /**
  32941. * Gets a boolean indicating if this mesh has LOD
  32942. */
  32943. get hasLODLevels(): boolean;
  32944. /**
  32945. * Gets the list of MeshLODLevel associated with the current mesh
  32946. * @returns an array of MeshLODLevel
  32947. */
  32948. getLODLevels(): MeshLODLevel[];
  32949. private _sortLODLevels;
  32950. /**
  32951. * Add a mesh as LOD level triggered at the given distance.
  32952. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32953. * @param distance The distance from the center of the object to show this level
  32954. * @param mesh The mesh to be added as LOD level (can be null)
  32955. * @return This mesh (for chaining)
  32956. */
  32957. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32958. /**
  32959. * Returns the LOD level mesh at the passed distance or null if not found.
  32960. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32961. * @param distance The distance from the center of the object to show this level
  32962. * @returns a Mesh or `null`
  32963. */
  32964. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32965. /**
  32966. * Remove a mesh from the LOD array
  32967. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32968. * @param mesh defines the mesh to be removed
  32969. * @return This mesh (for chaining)
  32970. */
  32971. removeLODLevel(mesh: Mesh): Mesh;
  32972. /**
  32973. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32974. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32975. * @param camera defines the camera to use to compute distance
  32976. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32977. * @return This mesh (for chaining)
  32978. */
  32979. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32980. /**
  32981. * Gets the mesh internal Geometry object
  32982. */
  32983. get geometry(): Nullable<Geometry>;
  32984. /**
  32985. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32986. * @returns the total number of vertices
  32987. */
  32988. getTotalVertices(): number;
  32989. /**
  32990. * Returns the content of an associated vertex buffer
  32991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32992. * - VertexBuffer.PositionKind
  32993. * - VertexBuffer.UVKind
  32994. * - VertexBuffer.UV2Kind
  32995. * - VertexBuffer.UV3Kind
  32996. * - VertexBuffer.UV4Kind
  32997. * - VertexBuffer.UV5Kind
  32998. * - VertexBuffer.UV6Kind
  32999. * - VertexBuffer.ColorKind
  33000. * - VertexBuffer.MatricesIndicesKind
  33001. * - VertexBuffer.MatricesIndicesExtraKind
  33002. * - VertexBuffer.MatricesWeightsKind
  33003. * - VertexBuffer.MatricesWeightsExtraKind
  33004. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  33005. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33006. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33007. */
  33008. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33009. /**
  33010. * Returns the mesh VertexBuffer object from the requested `kind`
  33011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33012. * - VertexBuffer.PositionKind
  33013. * - VertexBuffer.NormalKind
  33014. * - VertexBuffer.UVKind
  33015. * - VertexBuffer.UV2Kind
  33016. * - VertexBuffer.UV3Kind
  33017. * - VertexBuffer.UV4Kind
  33018. * - VertexBuffer.UV5Kind
  33019. * - VertexBuffer.UV6Kind
  33020. * - VertexBuffer.ColorKind
  33021. * - VertexBuffer.MatricesIndicesKind
  33022. * - VertexBuffer.MatricesIndicesExtraKind
  33023. * - VertexBuffer.MatricesWeightsKind
  33024. * - VertexBuffer.MatricesWeightsExtraKind
  33025. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33026. */
  33027. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33028. /**
  33029. * Tests if a specific vertex buffer is associated with this mesh
  33030. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33031. * - VertexBuffer.PositionKind
  33032. * - VertexBuffer.NormalKind
  33033. * - VertexBuffer.UVKind
  33034. * - VertexBuffer.UV2Kind
  33035. * - VertexBuffer.UV3Kind
  33036. * - VertexBuffer.UV4Kind
  33037. * - VertexBuffer.UV5Kind
  33038. * - VertexBuffer.UV6Kind
  33039. * - VertexBuffer.ColorKind
  33040. * - VertexBuffer.MatricesIndicesKind
  33041. * - VertexBuffer.MatricesIndicesExtraKind
  33042. * - VertexBuffer.MatricesWeightsKind
  33043. * - VertexBuffer.MatricesWeightsExtraKind
  33044. * @returns a boolean
  33045. */
  33046. isVerticesDataPresent(kind: string): boolean;
  33047. /**
  33048. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33049. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33050. * - VertexBuffer.PositionKind
  33051. * - VertexBuffer.UVKind
  33052. * - VertexBuffer.UV2Kind
  33053. * - VertexBuffer.UV3Kind
  33054. * - VertexBuffer.UV4Kind
  33055. * - VertexBuffer.UV5Kind
  33056. * - VertexBuffer.UV6Kind
  33057. * - VertexBuffer.ColorKind
  33058. * - VertexBuffer.MatricesIndicesKind
  33059. * - VertexBuffer.MatricesIndicesExtraKind
  33060. * - VertexBuffer.MatricesWeightsKind
  33061. * - VertexBuffer.MatricesWeightsExtraKind
  33062. * @returns a boolean
  33063. */
  33064. isVertexBufferUpdatable(kind: string): boolean;
  33065. /**
  33066. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33067. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33068. * - VertexBuffer.PositionKind
  33069. * - VertexBuffer.NormalKind
  33070. * - VertexBuffer.UVKind
  33071. * - VertexBuffer.UV2Kind
  33072. * - VertexBuffer.UV3Kind
  33073. * - VertexBuffer.UV4Kind
  33074. * - VertexBuffer.UV5Kind
  33075. * - VertexBuffer.UV6Kind
  33076. * - VertexBuffer.ColorKind
  33077. * - VertexBuffer.MatricesIndicesKind
  33078. * - VertexBuffer.MatricesIndicesExtraKind
  33079. * - VertexBuffer.MatricesWeightsKind
  33080. * - VertexBuffer.MatricesWeightsExtraKind
  33081. * @returns an array of strings
  33082. */
  33083. getVerticesDataKinds(): string[];
  33084. /**
  33085. * Returns a positive integer : the total number of indices in this mesh geometry.
  33086. * @returns the numner of indices or zero if the mesh has no geometry.
  33087. */
  33088. getTotalIndices(): number;
  33089. /**
  33090. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33091. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  33092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33093. * @returns the indices array or an empty array if the mesh has no geometry
  33094. */
  33095. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33096. get isBlocked(): boolean;
  33097. /**
  33098. * Determine if the current mesh is ready to be rendered
  33099. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33100. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33101. * @returns true if all associated assets are ready (material, textures, shaders)
  33102. */
  33103. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33104. /**
  33105. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  33106. */
  33107. get areNormalsFrozen(): boolean;
  33108. /**
  33109. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  33110. * @returns the current mesh
  33111. */
  33112. freezeNormals(): Mesh;
  33113. /**
  33114. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  33115. * @returns the current mesh
  33116. */
  33117. unfreezeNormals(): Mesh;
  33118. /**
  33119. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33120. */
  33121. set overridenInstanceCount(count: number);
  33122. /** @hidden */
  33123. _preActivate(): Mesh;
  33124. /** @hidden */
  33125. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33126. /** @hidden */
  33127. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33128. protected _afterComputeWorldMatrix(): void;
  33129. /** @hidden */
  33130. _postActivate(): void;
  33131. /**
  33132. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33133. * This means the mesh underlying bounding box and sphere are recomputed.
  33134. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33135. * @returns the current mesh
  33136. */
  33137. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33138. /** @hidden */
  33139. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33140. /**
  33141. * This function will subdivide the mesh into multiple submeshes
  33142. * @param count defines the expected number of submeshes
  33143. */
  33144. subdivide(count: number): void;
  33145. /**
  33146. * Copy a FloatArray into a specific associated vertex buffer
  33147. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33148. * - VertexBuffer.PositionKind
  33149. * - VertexBuffer.UVKind
  33150. * - VertexBuffer.UV2Kind
  33151. * - VertexBuffer.UV3Kind
  33152. * - VertexBuffer.UV4Kind
  33153. * - VertexBuffer.UV5Kind
  33154. * - VertexBuffer.UV6Kind
  33155. * - VertexBuffer.ColorKind
  33156. * - VertexBuffer.MatricesIndicesKind
  33157. * - VertexBuffer.MatricesIndicesExtraKind
  33158. * - VertexBuffer.MatricesWeightsKind
  33159. * - VertexBuffer.MatricesWeightsExtraKind
  33160. * @param data defines the data source
  33161. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33162. * @param stride defines the data stride size (can be null)
  33163. * @returns the current mesh
  33164. */
  33165. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33166. /**
  33167. * Delete a vertex buffer associated with this mesh
  33168. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33169. * - VertexBuffer.PositionKind
  33170. * - VertexBuffer.UVKind
  33171. * - VertexBuffer.UV2Kind
  33172. * - VertexBuffer.UV3Kind
  33173. * - VertexBuffer.UV4Kind
  33174. * - VertexBuffer.UV5Kind
  33175. * - VertexBuffer.UV6Kind
  33176. * - VertexBuffer.ColorKind
  33177. * - VertexBuffer.MatricesIndicesKind
  33178. * - VertexBuffer.MatricesIndicesExtraKind
  33179. * - VertexBuffer.MatricesWeightsKind
  33180. * - VertexBuffer.MatricesWeightsExtraKind
  33181. */
  33182. removeVerticesData(kind: string): void;
  33183. /**
  33184. * Flags an associated vertex buffer as updatable
  33185. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33186. * - VertexBuffer.PositionKind
  33187. * - VertexBuffer.UVKind
  33188. * - VertexBuffer.UV2Kind
  33189. * - VertexBuffer.UV3Kind
  33190. * - VertexBuffer.UV4Kind
  33191. * - VertexBuffer.UV5Kind
  33192. * - VertexBuffer.UV6Kind
  33193. * - VertexBuffer.ColorKind
  33194. * - VertexBuffer.MatricesIndicesKind
  33195. * - VertexBuffer.MatricesIndicesExtraKind
  33196. * - VertexBuffer.MatricesWeightsKind
  33197. * - VertexBuffer.MatricesWeightsExtraKind
  33198. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33199. */
  33200. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33201. /**
  33202. * Sets the mesh global Vertex Buffer
  33203. * @param buffer defines the buffer to use
  33204. * @returns the current mesh
  33205. */
  33206. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33207. /**
  33208. * Update a specific associated vertex buffer
  33209. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33210. * - VertexBuffer.PositionKind
  33211. * - VertexBuffer.UVKind
  33212. * - VertexBuffer.UV2Kind
  33213. * - VertexBuffer.UV3Kind
  33214. * - VertexBuffer.UV4Kind
  33215. * - VertexBuffer.UV5Kind
  33216. * - VertexBuffer.UV6Kind
  33217. * - VertexBuffer.ColorKind
  33218. * - VertexBuffer.MatricesIndicesKind
  33219. * - VertexBuffer.MatricesIndicesExtraKind
  33220. * - VertexBuffer.MatricesWeightsKind
  33221. * - VertexBuffer.MatricesWeightsExtraKind
  33222. * @param data defines the data source
  33223. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33224. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  33225. * @returns the current mesh
  33226. */
  33227. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33228. /**
  33229. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33230. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33231. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33232. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33233. * @returns the current mesh
  33234. */
  33235. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33236. /**
  33237. * Creates a un-shared specific occurence of the geometry for the mesh.
  33238. * @returns the current mesh
  33239. */
  33240. makeGeometryUnique(): Mesh;
  33241. /**
  33242. * Set the index buffer of this mesh
  33243. * @param indices defines the source data
  33244. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33245. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33246. * @returns the current mesh
  33247. */
  33248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33249. /**
  33250. * Update the current index buffer
  33251. * @param indices defines the source data
  33252. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33253. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  33254. * @returns the current mesh
  33255. */
  33256. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33257. /**
  33258. * Invert the geometry to move from a right handed system to a left handed one.
  33259. * @returns the current mesh
  33260. */
  33261. toLeftHanded(): Mesh;
  33262. /** @hidden */
  33263. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33264. /** @hidden */
  33265. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33266. /**
  33267. * Registers for this mesh a javascript function called just before the rendering process
  33268. * @param func defines the function to call before rendering this mesh
  33269. * @returns the current mesh
  33270. */
  33271. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33272. /**
  33273. * Disposes a previously registered javascript function called before the rendering
  33274. * @param func defines the function to remove
  33275. * @returns the current mesh
  33276. */
  33277. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33278. /**
  33279. * Registers for this mesh a javascript function called just after the rendering is complete
  33280. * @param func defines the function to call after rendering this mesh
  33281. * @returns the current mesh
  33282. */
  33283. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33284. /**
  33285. * Disposes a previously registered javascript function called after the rendering.
  33286. * @param func defines the function to remove
  33287. * @returns the current mesh
  33288. */
  33289. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33290. /** @hidden */
  33291. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33292. /** @hidden */
  33293. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33294. /** @hidden */
  33295. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33296. /** @hidden */
  33297. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33298. /** @hidden */
  33299. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33300. /** @hidden */
  33301. _rebuild(): void;
  33302. /** @hidden */
  33303. _freeze(): void;
  33304. /** @hidden */
  33305. _unFreeze(): void;
  33306. /**
  33307. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  33308. * @param subMesh defines the subMesh to render
  33309. * @param enableAlphaMode defines if alpha mode can be changed
  33310. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33311. * @returns the current mesh
  33312. */
  33313. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33314. private _onBeforeDraw;
  33315. /**
  33316. * Renormalize the mesh and patch it up if there are no weights
  33317. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33318. * However in the case of zero weights then we set just a single influence to 1.
  33319. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33320. */
  33321. cleanMatrixWeights(): void;
  33322. private normalizeSkinFourWeights;
  33323. private normalizeSkinWeightsAndExtra;
  33324. /**
  33325. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33326. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33327. * the user know there was an issue with importing the mesh
  33328. * @returns a validation object with skinned, valid and report string
  33329. */
  33330. validateSkinning(): {
  33331. skinned: boolean;
  33332. valid: boolean;
  33333. report: string;
  33334. };
  33335. /** @hidden */
  33336. _checkDelayState(): Mesh;
  33337. private _queueLoad;
  33338. /**
  33339. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33340. * A mesh is in the frustum if its bounding box intersects the frustum
  33341. * @param frustumPlanes defines the frustum to test
  33342. * @returns true if the mesh is in the frustum planes
  33343. */
  33344. isInFrustum(frustumPlanes: Plane[]): boolean;
  33345. /**
  33346. * Sets the mesh material by the material or multiMaterial `id` property
  33347. * @param id is a string identifying the material or the multiMaterial
  33348. * @returns the current mesh
  33349. */
  33350. setMaterialByID(id: string): Mesh;
  33351. /**
  33352. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33353. * @returns an array of IAnimatable
  33354. */
  33355. getAnimatables(): IAnimatable[];
  33356. /**
  33357. * Modifies the mesh geometry according to the passed transformation matrix.
  33358. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33359. * The mesh normals are modified using the same transformation.
  33360. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33361. * @param transform defines the transform matrix to use
  33362. * @see https://doc.babylonjs.com/resources/baking_transformations
  33363. * @returns the current mesh
  33364. */
  33365. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33366. /**
  33367. * Modifies the mesh geometry according to its own current World Matrix.
  33368. * The mesh World Matrix is then reset.
  33369. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33370. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33371. * @see https://doc.babylonjs.com/resources/baking_transformations
  33372. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33373. * @returns the current mesh
  33374. */
  33375. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33376. /** @hidden */
  33377. get _positions(): Nullable<Vector3[]>;
  33378. /** @hidden */
  33379. _resetPointsArrayCache(): Mesh;
  33380. /** @hidden */
  33381. _generatePointsArray(): boolean;
  33382. /**
  33383. * Returns a new Mesh object generated from the current mesh properties.
  33384. * This method must not get confused with createInstance()
  33385. * @param name is a string, the name given to the new mesh
  33386. * @param newParent can be any Node object (default `null`)
  33387. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33388. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33389. * @returns a new mesh
  33390. */
  33391. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33392. /**
  33393. * Releases resources associated with this mesh.
  33394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33396. */
  33397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33398. /** @hidden */
  33399. _disposeInstanceSpecificData(): void;
  33400. /** @hidden */
  33401. _disposeThinInstanceSpecificData(): void;
  33402. /**
  33403. * Modifies the mesh geometry according to a displacement map.
  33404. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  33405. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33406. * @param url is a string, the URL from the image file is to be downloaded.
  33407. * @param minHeight is the lower limit of the displacement.
  33408. * @param maxHeight is the upper limit of the displacement.
  33409. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  33410. * @param uvOffset is an optional vector2 used to offset UV.
  33411. * @param uvScale is an optional vector2 used to scale UV.
  33412. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33413. * @returns the Mesh.
  33414. */
  33415. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33416. /**
  33417. * Modifies the mesh geometry according to a displacementMap buffer.
  33418. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  33419. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33420. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33421. * @param heightMapWidth is the width of the buffer image.
  33422. * @param heightMapHeight is the height of the buffer image.
  33423. * @param minHeight is the lower limit of the displacement.
  33424. * @param maxHeight is the upper limit of the displacement.
  33425. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  33426. * @param uvOffset is an optional vector2 used to offset UV.
  33427. * @param uvScale is an optional vector2 used to scale UV.
  33428. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33429. * @returns the Mesh.
  33430. */
  33431. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33432. /**
  33433. * Modify the mesh to get a flat shading rendering.
  33434. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33435. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33436. * @returns current mesh
  33437. */
  33438. convertToFlatShadedMesh(): Mesh;
  33439. /**
  33440. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33441. * In other words, more vertices, no more indices and a single bigger VBO.
  33442. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33443. * @returns current mesh
  33444. */
  33445. convertToUnIndexedMesh(): Mesh;
  33446. /**
  33447. * Inverses facet orientations.
  33448. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33449. * @param flipNormals will also inverts the normals
  33450. * @returns current mesh
  33451. */
  33452. flipFaces(flipNormals?: boolean): Mesh;
  33453. /**
  33454. * Increase the number of facets and hence vertices in a mesh
  33455. * Vertex normals are interpolated from existing vertex normals
  33456. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33457. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33458. */
  33459. increaseVertices(numberPerEdge: number): void;
  33460. /**
  33461. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33462. * This will undo any application of covertToFlatShadedMesh
  33463. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33464. */
  33465. forceSharedVertices(): void;
  33466. /** @hidden */
  33467. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33468. /** @hidden */
  33469. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33470. /**
  33471. * Creates a new InstancedMesh object from the mesh model.
  33472. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33473. * @param name defines the name of the new instance
  33474. * @returns a new InstancedMesh
  33475. */
  33476. createInstance(name: string): InstancedMesh;
  33477. /**
  33478. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33479. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33480. * @returns the current mesh
  33481. */
  33482. synchronizeInstances(): Mesh;
  33483. /**
  33484. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33485. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33486. * This should be used together with the simplification to avoid disappearing triangles.
  33487. * @param successCallback an optional success callback to be called after the optimization finished.
  33488. * @returns the current mesh
  33489. */
  33490. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33491. /**
  33492. * Serialize current mesh
  33493. * @param serializationObject defines the object which will receive the serialization data
  33494. */
  33495. serialize(serializationObject: any): void;
  33496. /** @hidden */
  33497. _syncGeometryWithMorphTargetManager(): void;
  33498. /** @hidden */
  33499. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33500. /**
  33501. * Returns a new Mesh object parsed from the source provided.
  33502. * @param parsedMesh is the source
  33503. * @param scene defines the hosting scene
  33504. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33505. * @returns a new Mesh
  33506. */
  33507. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33508. /**
  33509. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33511. * @param name defines the name of the mesh to create
  33512. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33513. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33514. * @param closePath creates a seam between the first and the last points of each path of the path array
  33515. * @param offset is taken in account only if the `pathArray` is containing a single path
  33516. * @param scene defines the hosting scene
  33517. * @param updatable defines if the mesh must be flagged as updatable
  33518. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33519. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  33520. * @returns a new Mesh
  33521. */
  33522. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33523. /**
  33524. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33525. * @param name defines the name of the mesh to create
  33526. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33527. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  33528. * @param scene defines the hosting scene
  33529. * @param updatable defines if the mesh must be flagged as updatable
  33530. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33531. * @returns a new Mesh
  33532. */
  33533. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33534. /**
  33535. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33536. * @param name defines the name of the mesh to create
  33537. * @param size sets the size (float) of each box side (default 1)
  33538. * @param scene defines the hosting scene
  33539. * @param updatable defines if the mesh must be flagged as updatable
  33540. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33541. * @returns a new Mesh
  33542. */
  33543. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33544. /**
  33545. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33546. * @param name defines the name of the mesh to create
  33547. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33548. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33549. * @param scene defines the hosting scene
  33550. * @param updatable defines if the mesh must be flagged as updatable
  33551. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33552. * @returns a new Mesh
  33553. */
  33554. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33555. /**
  33556. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33557. * @param name defines the name of the mesh to create
  33558. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33559. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33560. * @param scene defines the hosting scene
  33561. * @returns a new Mesh
  33562. */
  33563. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33564. /**
  33565. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33566. * @param name defines the name of the mesh to create
  33567. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33568. * @param diameterTop set the top cap diameter (floats, default 1)
  33569. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33570. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33571. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33572. * @param scene defines the hosting scene
  33573. * @param updatable defines if the mesh must be flagged as updatable
  33574. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33575. * @returns a new Mesh
  33576. */
  33577. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33578. /**
  33579. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33580. * @param name defines the name of the mesh to create
  33581. * @param diameter sets the diameter size (float) of the torus (default 1)
  33582. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33583. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33584. * @param scene defines the hosting scene
  33585. * @param updatable defines if the mesh must be flagged as updatable
  33586. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33587. * @returns a new Mesh
  33588. */
  33589. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33590. /**
  33591. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33592. * @param name defines the name of the mesh to create
  33593. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33594. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33595. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33596. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33597. * @param p the number of windings on X axis (positive integers, default 2)
  33598. * @param q the number of windings on Y axis (positive integers, default 3)
  33599. * @param scene defines the hosting scene
  33600. * @param updatable defines if the mesh must be flagged as updatable
  33601. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33602. * @returns a new Mesh
  33603. */
  33604. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33605. /**
  33606. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33607. * @param name defines the name of the mesh to create
  33608. * @param points is an array successive Vector3
  33609. * @param scene defines the hosting scene
  33610. * @param updatable defines if the mesh must be flagged as updatable
  33611. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  33612. * @returns a new Mesh
  33613. */
  33614. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33615. /**
  33616. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33617. * @param name defines the name of the mesh to create
  33618. * @param points is an array successive Vector3
  33619. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33620. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33621. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33622. * @param scene defines the hosting scene
  33623. * @param updatable defines if the mesh must be flagged as updatable
  33624. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  33625. * @returns a new Mesh
  33626. */
  33627. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33628. /**
  33629. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33630. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33631. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  33632. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33633. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33634. * Remember you can only change the shape positions, not their number when updating a polygon.
  33635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33636. * @param name defines the name of the mesh to create
  33637. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  33638. * @param scene defines the hosting scene
  33639. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33640. * @param updatable defines if the mesh must be flagged as updatable
  33641. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33642. * @param earcutInjection can be used to inject your own earcut reference
  33643. * @returns a new Mesh
  33644. */
  33645. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33646. /**
  33647. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33649. * @param name defines the name of the mesh to create
  33650. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  33651. * @param depth defines the height of extrusion
  33652. * @param scene defines the hosting scene
  33653. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33654. * @param updatable defines if the mesh must be flagged as updatable
  33655. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33656. * @param earcutInjection can be used to inject your own earcut reference
  33657. * @returns a new Mesh
  33658. */
  33659. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33660. /**
  33661. * Creates an extruded shape mesh.
  33662. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  33663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33665. * @param name defines the name of the mesh to create
  33666. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  33667. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33668. * @param scale is the value to scale the shape
  33669. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  33670. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33671. * @param scene defines the hosting scene
  33672. * @param updatable defines if the mesh must be flagged as updatable
  33673. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33674. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  33675. * @returns a new Mesh
  33676. */
  33677. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33678. /**
  33679. * Creates an custom extruded shape mesh.
  33680. * The custom extrusion is a parametric shape.
  33681. * It has no predefined shape. Its final shape will depend on the input parameters.
  33682. * Please consider using the same method from the MeshBuilder class instead
  33683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33684. * @param name defines the name of the mesh to create
  33685. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  33686. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33687. * @param scaleFunction is a custom Javascript function called on each path point
  33688. * @param rotationFunction is a custom Javascript function called on each path point
  33689. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33690. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33691. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33692. * @param scene defines the hosting scene
  33693. * @param updatable defines if the mesh must be flagged as updatable
  33694. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33695. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  33696. * @returns a new Mesh
  33697. */
  33698. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33699. /**
  33700. * Creates lathe mesh.
  33701. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33702. * Please consider using the same method from the MeshBuilder class instead
  33703. * @param name defines the name of the mesh to create
  33704. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  33705. * @param radius is the radius value of the lathe
  33706. * @param tessellation is the side number of the lathe.
  33707. * @param scene defines the hosting scene
  33708. * @param updatable defines if the mesh must be flagged as updatable
  33709. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33710. * @returns a new Mesh
  33711. */
  33712. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33713. /**
  33714. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33715. * @param name defines the name of the mesh to create
  33716. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33717. * @param scene defines the hosting scene
  33718. * @param updatable defines if the mesh must be flagged as updatable
  33719. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33720. * @returns a new Mesh
  33721. */
  33722. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33723. /**
  33724. * Creates a ground mesh.
  33725. * Please consider using the same method from the MeshBuilder class instead
  33726. * @param name defines the name of the mesh to create
  33727. * @param width set the width of the ground
  33728. * @param height set the height of the ground
  33729. * @param subdivisions sets the number of subdivisions per side
  33730. * @param scene defines the hosting scene
  33731. * @param updatable defines if the mesh must be flagged as updatable
  33732. * @returns a new Mesh
  33733. */
  33734. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33735. /**
  33736. * Creates a tiled ground mesh.
  33737. * Please consider using the same method from the MeshBuilder class instead
  33738. * @param name defines the name of the mesh to create
  33739. * @param xmin set the ground minimum X coordinate
  33740. * @param zmin set the ground minimum Y coordinate
  33741. * @param xmax set the ground maximum X coordinate
  33742. * @param zmax set the ground maximum Z coordinate
  33743. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  33744. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  33745. * @param scene defines the hosting scene
  33746. * @param updatable defines if the mesh must be flagged as updatable
  33747. * @returns a new Mesh
  33748. */
  33749. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33750. w: number;
  33751. h: number;
  33752. }, precision: {
  33753. w: number;
  33754. h: number;
  33755. }, scene: Scene, updatable?: boolean): Mesh;
  33756. /**
  33757. * Creates a ground mesh from a height map.
  33758. * Please consider using the same method from the MeshBuilder class instead
  33759. * @see https://doc.babylonjs.com/babylon101/height_map
  33760. * @param name defines the name of the mesh to create
  33761. * @param url sets the URL of the height map image resource
  33762. * @param width set the ground width size
  33763. * @param height set the ground height size
  33764. * @param subdivisions sets the number of subdivision per side
  33765. * @param minHeight is the minimum altitude on the ground
  33766. * @param maxHeight is the maximum altitude on the ground
  33767. * @param scene defines the hosting scene
  33768. * @param updatable defines if the mesh must be flagged as updatable
  33769. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33770. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33771. * @returns a new Mesh
  33772. */
  33773. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  33774. /**
  33775. * Creates a tube mesh.
  33776. * The tube is a parametric shape.
  33777. * It has no predefined shape. Its final shape will depend on the input parameters.
  33778. * Please consider using the same method from the MeshBuilder class instead
  33779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33780. * @param name defines the name of the mesh to create
  33781. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33782. * @param radius sets the tube radius size
  33783. * @param tessellation is the number of sides on the tubular surface
  33784. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  33785. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33786. * @param scene defines the hosting scene
  33787. * @param updatable defines if the mesh must be flagged as updatable
  33788. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33789. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  33790. * @returns a new Mesh
  33791. */
  33792. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33793. (i: number, distance: number): number;
  33794. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33795. /**
  33796. * Creates a polyhedron mesh.
  33797. * Please consider using the same method from the MeshBuilder class instead.
  33798. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  33799. * * The parameter `size` (positive float, default 1) sets the polygon size
  33800. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33801. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  33802. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  33803. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  33804. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  33805. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  33806. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  33808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33809. * @param name defines the name of the mesh to create
  33810. * @param options defines the options used to create the mesh
  33811. * @param scene defines the hosting scene
  33812. * @returns a new Mesh
  33813. */
  33814. static CreatePolyhedron(name: string, options: {
  33815. type?: number;
  33816. size?: number;
  33817. sizeX?: number;
  33818. sizeY?: number;
  33819. sizeZ?: number;
  33820. custom?: any;
  33821. faceUV?: Vector4[];
  33822. faceColors?: Color4[];
  33823. updatable?: boolean;
  33824. sideOrientation?: number;
  33825. }, scene: Scene): Mesh;
  33826. /**
  33827. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33828. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33829. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  33830. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33831. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  33832. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  33834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33835. * @param name defines the name of the mesh
  33836. * @param options defines the options used to create the mesh
  33837. * @param scene defines the hosting scene
  33838. * @returns a new Mesh
  33839. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33840. */
  33841. static CreateIcoSphere(name: string, options: {
  33842. radius?: number;
  33843. flat?: boolean;
  33844. subdivisions?: number;
  33845. sideOrientation?: number;
  33846. updatable?: boolean;
  33847. }, scene: Scene): Mesh;
  33848. /**
  33849. * Creates a decal mesh.
  33850. * Please consider using the same method from the MeshBuilder class instead.
  33851. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33852. * @param name defines the name of the mesh
  33853. * @param sourceMesh defines the mesh receiving the decal
  33854. * @param position sets the position of the decal in world coordinates
  33855. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33856. * @param size sets the decal scaling
  33857. * @param angle sets the angle to rotate the decal
  33858. * @returns a new Mesh
  33859. */
  33860. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33861. /** Creates a Capsule Mesh
  33862. * @param name defines the name of the mesh.
  33863. * @param options the constructors options used to shape the mesh.
  33864. * @param scene defines the scene the mesh is scoped to.
  33865. * @returns the capsule mesh
  33866. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33867. */
  33868. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33869. /**
  33870. * Prepare internal position array for software CPU skinning
  33871. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33872. */
  33873. setPositionsForCPUSkinning(): Float32Array;
  33874. /**
  33875. * Prepare internal normal array for software CPU skinning
  33876. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33877. */
  33878. setNormalsForCPUSkinning(): Float32Array;
  33879. /**
  33880. * Updates the vertex buffer by applying transformation from the bones
  33881. * @param skeleton defines the skeleton to apply to current mesh
  33882. * @returns the current mesh
  33883. */
  33884. applySkeleton(skeleton: Skeleton): Mesh;
  33885. /**
  33886. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  33887. * @param meshes defines the list of meshes to scan
  33888. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33889. */
  33890. static MinMax(meshes: AbstractMesh[]): {
  33891. min: Vector3;
  33892. max: Vector3;
  33893. };
  33894. /**
  33895. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33896. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33897. * @returns a vector3
  33898. */
  33899. static Center(meshesOrMinMaxVector: {
  33900. min: Vector3;
  33901. max: Vector3;
  33902. } | AbstractMesh[]): Vector3;
  33903. /**
  33904. * Merge the array of meshes into a single mesh for performance reasons.
  33905. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33906. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33907. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33908. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33909. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33910. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33911. * @returns a new mesh
  33912. */
  33913. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33914. /** @hidden */
  33915. addInstance(instance: InstancedMesh): void;
  33916. /** @hidden */
  33917. removeInstance(instance: InstancedMesh): void;
  33918. }
  33919. }
  33920. declare module BABYLON {
  33921. /**
  33922. * This is the base class of all the camera used in the application.
  33923. * @see https://doc.babylonjs.com/features/cameras
  33924. */
  33925. export class Camera extends Node {
  33926. /** @hidden */
  33927. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33928. /**
  33929. * This is the default projection mode used by the cameras.
  33930. * It helps recreating a feeling of perspective and better appreciate depth.
  33931. * This is the best way to simulate real life cameras.
  33932. */
  33933. static readonly PERSPECTIVE_CAMERA: number;
  33934. /**
  33935. * This helps creating camera with an orthographic mode.
  33936. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  33937. */
  33938. static readonly ORTHOGRAPHIC_CAMERA: number;
  33939. /**
  33940. * This is the default FOV mode for perspective cameras.
  33941. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33942. */
  33943. static readonly FOVMODE_VERTICAL_FIXED: number;
  33944. /**
  33945. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33946. */
  33947. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33948. /**
  33949. * This specifies ther is no need for a camera rig.
  33950. * Basically only one eye is rendered corresponding to the camera.
  33951. */
  33952. static readonly RIG_MODE_NONE: number;
  33953. /**
  33954. * Simulates a camera Rig with one blue eye and one red eye.
  33955. * This can be use with 3d blue and red glasses.
  33956. */
  33957. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33958. /**
  33959. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33960. */
  33961. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33962. /**
  33963. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33964. */
  33965. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33966. /**
  33967. * Defines that both eyes of the camera will be rendered over under each other.
  33968. */
  33969. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33970. /**
  33971. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33972. */
  33973. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33974. /**
  33975. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33976. */
  33977. static readonly RIG_MODE_VR: number;
  33978. /**
  33979. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33980. */
  33981. static readonly RIG_MODE_WEBVR: number;
  33982. /**
  33983. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33984. */
  33985. static readonly RIG_MODE_CUSTOM: number;
  33986. /**
  33987. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33988. */
  33989. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33990. /**
  33991. * Define the input manager associated with the camera.
  33992. */
  33993. inputs: CameraInputsManager<Camera>;
  33994. /** @hidden */
  33995. _position: Vector3;
  33996. /**
  33997. * Define the current local position of the camera in the scene
  33998. */
  33999. get position(): Vector3;
  34000. set position(newPosition: Vector3);
  34001. protected _upVector: Vector3;
  34002. /**
  34003. * The vector the camera should consider as up.
  34004. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34005. */
  34006. set upVector(vec: Vector3);
  34007. get upVector(): Vector3;
  34008. /**
  34009. * Define the current limit on the left side for an orthographic camera
  34010. * In scene unit
  34011. */
  34012. orthoLeft: Nullable<number>;
  34013. /**
  34014. * Define the current limit on the right side for an orthographic camera
  34015. * In scene unit
  34016. */
  34017. orthoRight: Nullable<number>;
  34018. /**
  34019. * Define the current limit on the bottom side for an orthographic camera
  34020. * In scene unit
  34021. */
  34022. orthoBottom: Nullable<number>;
  34023. /**
  34024. * Define the current limit on the top side for an orthographic camera
  34025. * In scene unit
  34026. */
  34027. orthoTop: Nullable<number>;
  34028. /**
  34029. * Field Of View is set in Radians. (default is 0.8)
  34030. */
  34031. fov: number;
  34032. /**
  34033. * Define the minimum distance the camera can see from.
  34034. * This is important to note that the depth buffer are not infinite and the closer it starts
  34035. * the more your scene might encounter depth fighting issue.
  34036. */
  34037. minZ: number;
  34038. /**
  34039. * Define the maximum distance the camera can see to.
  34040. * This is important to note that the depth buffer are not infinite and the further it end
  34041. * the more your scene might encounter depth fighting issue.
  34042. */
  34043. maxZ: number;
  34044. /**
  34045. * Define the default inertia of the camera.
  34046. * This helps giving a smooth feeling to the camera movement.
  34047. */
  34048. inertia: number;
  34049. /**
  34050. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34051. */
  34052. mode: number;
  34053. /**
  34054. * Define whether the camera is intermediate.
  34055. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34056. */
  34057. isIntermediate: boolean;
  34058. /**
  34059. * Define the viewport of the camera.
  34060. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34061. */
  34062. viewport: Viewport;
  34063. /**
  34064. * Restricts the camera to viewing objects with the same layerMask.
  34065. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34066. */
  34067. layerMask: number;
  34068. /**
  34069. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34070. */
  34071. fovMode: number;
  34072. /**
  34073. * Rig mode of the camera.
  34074. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34075. * This is normally controlled byt the camera themselves as internal use.
  34076. */
  34077. cameraRigMode: number;
  34078. /**
  34079. * Defines the distance between both "eyes" in case of a RIG
  34080. */
  34081. interaxialDistance: number;
  34082. /**
  34083. * Defines if stereoscopic rendering is done side by side or over under.
  34084. */
  34085. isStereoscopicSideBySide: boolean;
  34086. /**
  34087. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  34088. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34089. * else in the scene. (Eg. security camera)
  34090. *
  34091. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  34092. */
  34093. customRenderTargets: RenderTargetTexture[];
  34094. /**
  34095. * When set, the camera will render to this render target instead of the default canvas
  34096. *
  34097. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34098. */
  34099. outputRenderTarget: Nullable<RenderTargetTexture>;
  34100. /**
  34101. * Observable triggered when the camera view matrix has changed.
  34102. */
  34103. onViewMatrixChangedObservable: Observable<Camera>;
  34104. /**
  34105. * Observable triggered when the camera Projection matrix has changed.
  34106. */
  34107. onProjectionMatrixChangedObservable: Observable<Camera>;
  34108. /**
  34109. * Observable triggered when the inputs have been processed.
  34110. */
  34111. onAfterCheckInputsObservable: Observable<Camera>;
  34112. /**
  34113. * Observable triggered when reset has been called and applied to the camera.
  34114. */
  34115. onRestoreStateObservable: Observable<Camera>;
  34116. /**
  34117. * Is this camera a part of a rig system?
  34118. */
  34119. isRigCamera: boolean;
  34120. /**
  34121. * If isRigCamera set to true this will be set with the parent camera.
  34122. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34123. */
  34124. rigParent?: Camera;
  34125. /** @hidden */
  34126. _cameraRigParams: any;
  34127. /** @hidden */
  34128. _rigCameras: Camera[];
  34129. /** @hidden */
  34130. _rigPostProcess: Nullable<PostProcess>;
  34131. protected _webvrViewMatrix: Matrix;
  34132. /** @hidden */
  34133. _skipRendering: boolean;
  34134. /** @hidden */
  34135. _projectionMatrix: Matrix;
  34136. /** @hidden */
  34137. _postProcesses: Nullable<PostProcess>[];
  34138. /** @hidden */
  34139. _activeMeshes: SmartArray<AbstractMesh>;
  34140. protected _globalPosition: Vector3;
  34141. /** @hidden */
  34142. _computedViewMatrix: Matrix;
  34143. private _doNotComputeProjectionMatrix;
  34144. private _transformMatrix;
  34145. private _frustumPlanes;
  34146. private _refreshFrustumPlanes;
  34147. private _storedFov;
  34148. private _stateStored;
  34149. /**
  34150. * Instantiates a new camera object.
  34151. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34152. * @see https://doc.babylonjs.com/features/cameras
  34153. * @param name Defines the name of the camera in the scene
  34154. * @param position Defines the position of the camera
  34155. * @param scene Defines the scene the camera belongs too
  34156. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34157. */
  34158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34159. /**
  34160. * Store current camera state (fov, position, etc..)
  34161. * @returns the camera
  34162. */
  34163. storeState(): Camera;
  34164. /**
  34165. * Restores the camera state values if it has been stored. You must call storeState() first
  34166. */
  34167. protected _restoreStateValues(): boolean;
  34168. /**
  34169. * Restored camera state. You must call storeState() first.
  34170. * @returns true if restored and false otherwise
  34171. */
  34172. restoreState(): boolean;
  34173. /**
  34174. * Gets the class name of the camera.
  34175. * @returns the class name
  34176. */
  34177. getClassName(): string;
  34178. /** @hidden */
  34179. readonly _isCamera: boolean;
  34180. /**
  34181. * Gets a string representation of the camera useful for debug purpose.
  34182. * @param fullDetails Defines that a more verboe level of logging is required
  34183. * @returns the string representation
  34184. */
  34185. toString(fullDetails?: boolean): string;
  34186. /**
  34187. * Gets the current world space position of the camera.
  34188. */
  34189. get globalPosition(): Vector3;
  34190. /**
  34191. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34192. * @returns the active meshe list
  34193. */
  34194. getActiveMeshes(): SmartArray<AbstractMesh>;
  34195. /**
  34196. * Check whether a mesh is part of the current active mesh list of the camera
  34197. * @param mesh Defines the mesh to check
  34198. * @returns true if active, false otherwise
  34199. */
  34200. isActiveMesh(mesh: Mesh): boolean;
  34201. /**
  34202. * Is this camera ready to be used/rendered
  34203. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34204. * @return true if the camera is ready
  34205. */
  34206. isReady(completeCheck?: boolean): boolean;
  34207. /** @hidden */
  34208. _initCache(): void;
  34209. /** @hidden */
  34210. _updateCache(ignoreParentClass?: boolean): void;
  34211. /** @hidden */
  34212. _isSynchronized(): boolean;
  34213. /** @hidden */
  34214. _isSynchronizedViewMatrix(): boolean;
  34215. /** @hidden */
  34216. _isSynchronizedProjectionMatrix(): boolean;
  34217. /**
  34218. * Attach the input controls to a specific dom element to get the input from.
  34219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34220. */
  34221. attachControl(noPreventDefault?: boolean): void;
  34222. /**
  34223. * Detach the current controls from the specified dom element.
  34224. */
  34225. detachControl(): void;
  34226. /**
  34227. * Update the camera state according to the different inputs gathered during the frame.
  34228. */
  34229. update(): void;
  34230. /** @hidden */
  34231. _checkInputs(): void;
  34232. /** @hidden */
  34233. get rigCameras(): Camera[];
  34234. /**
  34235. * Gets the post process used by the rig cameras
  34236. */
  34237. get rigPostProcess(): Nullable<PostProcess>;
  34238. /**
  34239. * Internal, gets the first post proces.
  34240. * @returns the first post process to be run on this camera.
  34241. */
  34242. _getFirstPostProcess(): Nullable<PostProcess>;
  34243. private _cascadePostProcessesToRigCams;
  34244. /**
  34245. * Attach a post process to the camera.
  34246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34247. * @param postProcess The post process to attach to the camera
  34248. * @param insertAt The position of the post process in case several of them are in use in the scene
  34249. * @returns the position the post process has been inserted at
  34250. */
  34251. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34252. /**
  34253. * Detach a post process to the camera.
  34254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34255. * @param postProcess The post process to detach from the camera
  34256. */
  34257. detachPostProcess(postProcess: PostProcess): void;
  34258. /**
  34259. * Gets the current world matrix of the camera
  34260. */
  34261. getWorldMatrix(): Matrix;
  34262. /** @hidden */
  34263. _getViewMatrix(): Matrix;
  34264. /**
  34265. * Gets the current view matrix of the camera.
  34266. * @param force forces the camera to recompute the matrix without looking at the cached state
  34267. * @returns the view matrix
  34268. */
  34269. getViewMatrix(force?: boolean): Matrix;
  34270. /**
  34271. * Freeze the projection matrix.
  34272. * It will prevent the cache check of the camera projection compute and can speed up perf
  34273. * if no parameter of the camera are meant to change
  34274. * @param projection Defines manually a projection if necessary
  34275. */
  34276. freezeProjectionMatrix(projection?: Matrix): void;
  34277. /**
  34278. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34279. */
  34280. unfreezeProjectionMatrix(): void;
  34281. /**
  34282. * Gets the current projection matrix of the camera.
  34283. * @param force forces the camera to recompute the matrix without looking at the cached state
  34284. * @returns the projection matrix
  34285. */
  34286. getProjectionMatrix(force?: boolean): Matrix;
  34287. /**
  34288. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34289. * @returns a Matrix
  34290. */
  34291. getTransformationMatrix(): Matrix;
  34292. private _updateFrustumPlanes;
  34293. /**
  34294. * Checks if a cullable object (mesh...) is in the camera frustum
  34295. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34296. * @param target The object to check
  34297. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34298. * @returns true if the object is in frustum otherwise false
  34299. */
  34300. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34301. /**
  34302. * Checks if a cullable object (mesh...) is in the camera frustum
  34303. * Unlike isInFrustum this cheks the full bounding box
  34304. * @param target The object to check
  34305. * @returns true if the object is in frustum otherwise false
  34306. */
  34307. isCompletelyInFrustum(target: ICullable): boolean;
  34308. /**
  34309. * Gets a ray in the forward direction from the camera.
  34310. * @param length Defines the length of the ray to create
  34311. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34312. * @param origin Defines the start point of the ray which defaults to the camera position
  34313. * @returns the forward ray
  34314. */
  34315. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34316. /**
  34317. * Gets a ray in the forward direction from the camera.
  34318. * @param refRay the ray to (re)use when setting the values
  34319. * @param length Defines the length of the ray to create
  34320. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34321. * @param origin Defines the start point of the ray which defaults to the camera position
  34322. * @returns the forward ray
  34323. */
  34324. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34325. /**
  34326. * Releases resources associated with this node.
  34327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34329. */
  34330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34331. /** @hidden */
  34332. _isLeftCamera: boolean;
  34333. /**
  34334. * Gets the left camera of a rig setup in case of Rigged Camera
  34335. */
  34336. get isLeftCamera(): boolean;
  34337. /** @hidden */
  34338. _isRightCamera: boolean;
  34339. /**
  34340. * Gets the right camera of a rig setup in case of Rigged Camera
  34341. */
  34342. get isRightCamera(): boolean;
  34343. /**
  34344. * Gets the left camera of a rig setup in case of Rigged Camera
  34345. */
  34346. get leftCamera(): Nullable<FreeCamera>;
  34347. /**
  34348. * Gets the right camera of a rig setup in case of Rigged Camera
  34349. */
  34350. get rightCamera(): Nullable<FreeCamera>;
  34351. /**
  34352. * Gets the left camera target of a rig setup in case of Rigged Camera
  34353. * @returns the target position
  34354. */
  34355. getLeftTarget(): Nullable<Vector3>;
  34356. /**
  34357. * Gets the right camera target of a rig setup in case of Rigged Camera
  34358. * @returns the target position
  34359. */
  34360. getRightTarget(): Nullable<Vector3>;
  34361. /**
  34362. * @hidden
  34363. */
  34364. setCameraRigMode(mode: number, rigParams: any): void;
  34365. /** @hidden */
  34366. static _setStereoscopicRigMode(camera: Camera): void;
  34367. /** @hidden */
  34368. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34369. /** @hidden */
  34370. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34371. /** @hidden */
  34372. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34373. /** @hidden */
  34374. _getVRProjectionMatrix(): Matrix;
  34375. protected _updateCameraRotationMatrix(): void;
  34376. protected _updateWebVRCameraRotationMatrix(): void;
  34377. /**
  34378. * This function MUST be overwritten by the different WebVR cameras available.
  34379. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34380. * @hidden
  34381. */
  34382. _getWebVRProjectionMatrix(): Matrix;
  34383. /**
  34384. * This function MUST be overwritten by the different WebVR cameras available.
  34385. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34386. * @hidden
  34387. */
  34388. _getWebVRViewMatrix(): Matrix;
  34389. /** @hidden */
  34390. setCameraRigParameter(name: string, value: any): void;
  34391. /**
  34392. * needs to be overridden by children so sub has required properties to be copied
  34393. * @hidden
  34394. */
  34395. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34396. /**
  34397. * May need to be overridden by children
  34398. * @hidden
  34399. */
  34400. _updateRigCameras(): void;
  34401. /** @hidden */
  34402. _setupInputs(): void;
  34403. /**
  34404. * Serialiaze the camera setup to a json represention
  34405. * @returns the JSON representation
  34406. */
  34407. serialize(): any;
  34408. /**
  34409. * Clones the current camera.
  34410. * @param name The cloned camera name
  34411. * @returns the cloned camera
  34412. */
  34413. clone(name: string): Camera;
  34414. /**
  34415. * Gets the direction of the camera relative to a given local axis.
  34416. * @param localAxis Defines the reference axis to provide a relative direction.
  34417. * @return the direction
  34418. */
  34419. getDirection(localAxis: Vector3): Vector3;
  34420. /**
  34421. * Returns the current camera absolute rotation
  34422. */
  34423. get absoluteRotation(): Quaternion;
  34424. /**
  34425. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34426. * @param localAxis Defines the reference axis to provide a relative direction.
  34427. * @param result Defines the vector to store the result in
  34428. */
  34429. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34430. /**
  34431. * Gets a camera constructor for a given camera type
  34432. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34433. * @param name The name of the camera the result will be able to instantiate
  34434. * @param scene The scene the result will construct the camera in
  34435. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34436. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34437. * @returns a factory method to construc the camera
  34438. */
  34439. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34440. /**
  34441. * Compute the world matrix of the camera.
  34442. * @returns the camera world matrix
  34443. */
  34444. computeWorldMatrix(): Matrix;
  34445. /**
  34446. * Parse a JSON and creates the camera from the parsed information
  34447. * @param parsedCamera The JSON to parse
  34448. * @param scene The scene to instantiate the camera in
  34449. * @returns the newly constructed camera
  34450. */
  34451. static Parse(parsedCamera: any, scene: Scene): Camera;
  34452. }
  34453. }
  34454. declare module BABYLON {
  34455. /**
  34456. * Class containing static functions to help procedurally build meshes
  34457. */
  34458. export class DiscBuilder {
  34459. /**
  34460. * Creates a plane polygonal mesh. By default, this is a disc
  34461. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34462. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  34463. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  34464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34467. * @param name defines the name of the mesh
  34468. * @param options defines the options used to create the mesh
  34469. * @param scene defines the hosting scene
  34470. * @returns the plane polygonal mesh
  34471. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34472. */
  34473. static CreateDisc(name: string, options: {
  34474. radius?: number;
  34475. tessellation?: number;
  34476. arc?: number;
  34477. updatable?: boolean;
  34478. sideOrientation?: number;
  34479. frontUVs?: Vector4;
  34480. backUVs?: Vector4;
  34481. }, scene?: Nullable<Scene>): Mesh;
  34482. }
  34483. }
  34484. declare module BABYLON {
  34485. /**
  34486. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34487. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  34488. * The SPS is also a particle system. It provides some methods to manage the particles.
  34489. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34490. *
  34491. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34492. */
  34493. export class SolidParticleSystem implements IDisposable {
  34494. /**
  34495. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34496. * Example : var p = SPS.particles[i];
  34497. */
  34498. particles: SolidParticle[];
  34499. /**
  34500. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34501. */
  34502. nbParticles: number;
  34503. /**
  34504. * If the particles must ever face the camera (default false). Useful for planar particles.
  34505. */
  34506. billboard: boolean;
  34507. /**
  34508. * Recompute normals when adding a shape
  34509. */
  34510. recomputeNormals: boolean;
  34511. /**
  34512. * This a counter ofr your own usage. It's not set by any SPS functions.
  34513. */
  34514. counter: number;
  34515. /**
  34516. * The SPS name. This name is also given to the underlying mesh.
  34517. */
  34518. name: string;
  34519. /**
  34520. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34521. */
  34522. mesh: Mesh;
  34523. /**
  34524. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34525. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34526. */
  34527. vars: any;
  34528. /**
  34529. * This array is populated when the SPS is set as 'pickable'.
  34530. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34531. * Each element of this array is an object `{idx: int, faceId: int}`.
  34532. * `idx` is the picked particle index in the `SPS.particles` array
  34533. * `faceId` is the picked face index counted within this particle.
  34534. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34535. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34536. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34537. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34538. */
  34539. pickedParticles: {
  34540. idx: number;
  34541. faceId: number;
  34542. }[];
  34543. /**
  34544. * This array is populated when the SPS is set as 'pickable'
  34545. * Each key of this array is a submesh index.
  34546. * Each element of this array is a second array defined like this :
  34547. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34548. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34549. * `idx` is the picked particle index in the `SPS.particles` array
  34550. * `faceId` is the picked face index counted within this particle.
  34551. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34552. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34553. */
  34554. pickedBySubMesh: {
  34555. idx: number;
  34556. faceId: number;
  34557. }[][];
  34558. /**
  34559. * This array is populated when `enableDepthSort` is set to true.
  34560. * Each element of this array is an instance of the class DepthSortedParticle.
  34561. */
  34562. depthSortedParticles: DepthSortedParticle[];
  34563. /**
  34564. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34565. * @hidden
  34566. */
  34567. _bSphereOnly: boolean;
  34568. /**
  34569. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34570. * @hidden
  34571. */
  34572. _bSphereRadiusFactor: number;
  34573. private _scene;
  34574. private _positions;
  34575. private _indices;
  34576. private _normals;
  34577. private _colors;
  34578. private _uvs;
  34579. private _indices32;
  34580. private _positions32;
  34581. private _normals32;
  34582. private _fixedNormal32;
  34583. private _colors32;
  34584. private _uvs32;
  34585. private _index;
  34586. private _updatable;
  34587. private _pickable;
  34588. private _isVisibilityBoxLocked;
  34589. private _alwaysVisible;
  34590. private _depthSort;
  34591. private _expandable;
  34592. private _shapeCounter;
  34593. private _copy;
  34594. private _color;
  34595. private _computeParticleColor;
  34596. private _computeParticleTexture;
  34597. private _computeParticleRotation;
  34598. private _computeParticleVertex;
  34599. private _computeBoundingBox;
  34600. private _depthSortParticles;
  34601. private _camera;
  34602. private _mustUnrotateFixedNormals;
  34603. private _particlesIntersect;
  34604. private _needs32Bits;
  34605. private _isNotBuilt;
  34606. private _lastParticleId;
  34607. private _idxOfId;
  34608. private _multimaterialEnabled;
  34609. private _useModelMaterial;
  34610. private _indicesByMaterial;
  34611. private _materialIndexes;
  34612. private _depthSortFunction;
  34613. private _materialSortFunction;
  34614. private _materials;
  34615. private _multimaterial;
  34616. private _materialIndexesById;
  34617. private _defaultMaterial;
  34618. private _autoUpdateSubMeshes;
  34619. private _tmpVertex;
  34620. /**
  34621. * Creates a SPS (Solid Particle System) object.
  34622. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34623. * @param scene (Scene) is the scene in which the SPS is added.
  34624. * @param options defines the options of the sps e.g.
  34625. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34626. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34627. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34628. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  34629. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34630. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34631. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34632. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34633. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34634. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34635. */
  34636. constructor(name: string, scene: Scene, options?: {
  34637. updatable?: boolean;
  34638. isPickable?: boolean;
  34639. enableDepthSort?: boolean;
  34640. particleIntersection?: boolean;
  34641. boundingSphereOnly?: boolean;
  34642. bSphereRadiusFactor?: number;
  34643. expandable?: boolean;
  34644. useModelMaterial?: boolean;
  34645. enableMultiMaterial?: boolean;
  34646. });
  34647. /**
  34648. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34649. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34650. * @returns the created mesh
  34651. */
  34652. buildMesh(): Mesh;
  34653. /**
  34654. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34655. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34656. * Thus the particles generated from `digest()` have their property `position` set yet.
  34657. * @param mesh ( Mesh ) is the mesh to be digested
  34658. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  34659. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34660. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34661. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34662. * @returns the current SPS
  34663. */
  34664. digest(mesh: Mesh, options?: {
  34665. facetNb?: number;
  34666. number?: number;
  34667. delta?: number;
  34668. storage?: [];
  34669. }): SolidParticleSystem;
  34670. /**
  34671. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34672. * @hidden
  34673. */
  34674. private _unrotateFixedNormals;
  34675. /**
  34676. * Resets the temporary working copy particle
  34677. * @hidden
  34678. */
  34679. private _resetCopy;
  34680. /**
  34681. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34682. * @param p the current index in the positions array to be updated
  34683. * @param ind the current index in the indices array
  34684. * @param shape a Vector3 array, the shape geometry
  34685. * @param positions the positions array to be updated
  34686. * @param meshInd the shape indices array
  34687. * @param indices the indices array to be updated
  34688. * @param meshUV the shape uv array
  34689. * @param uvs the uv array to be updated
  34690. * @param meshCol the shape color array
  34691. * @param colors the color array to be updated
  34692. * @param meshNor the shape normals array
  34693. * @param normals the normals array to be updated
  34694. * @param idx the particle index
  34695. * @param idxInShape the particle index in its shape
  34696. * @param options the addShape() method passed options
  34697. * @model the particle model
  34698. * @hidden
  34699. */
  34700. private _meshBuilder;
  34701. /**
  34702. * Returns a shape Vector3 array from positions float array
  34703. * @param positions float array
  34704. * @returns a vector3 array
  34705. * @hidden
  34706. */
  34707. private _posToShape;
  34708. /**
  34709. * Returns a shapeUV array from a float uvs (array deep copy)
  34710. * @param uvs as a float array
  34711. * @returns a shapeUV array
  34712. * @hidden
  34713. */
  34714. private _uvsToShapeUV;
  34715. /**
  34716. * Adds a new particle object in the particles array
  34717. * @param idx particle index in particles array
  34718. * @param id particle id
  34719. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34720. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34721. * @param model particle ModelShape object
  34722. * @param shapeId model shape identifier
  34723. * @param idxInShape index of the particle in the current model
  34724. * @param bInfo model bounding info object
  34725. * @param storage target storage array, if any
  34726. * @hidden
  34727. */
  34728. private _addParticle;
  34729. /**
  34730. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34731. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34732. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34733. * @param nb (positive integer) the number of particles to be created from this model
  34734. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34735. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34736. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34737. * @returns the number of shapes in the system
  34738. */
  34739. addShape(mesh: Mesh, nb: number, options?: {
  34740. positionFunction?: any;
  34741. vertexFunction?: any;
  34742. storage?: [];
  34743. }): number;
  34744. /**
  34745. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34746. * @hidden
  34747. */
  34748. private _rebuildParticle;
  34749. /**
  34750. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34751. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  34752. * @returns the SPS.
  34753. */
  34754. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34755. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34756. * Returns an array with the removed particles.
  34757. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  34758. * The SPS can't be empty so at least one particle needs to remain in place.
  34759. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34760. * @param start index of the first particle to remove
  34761. * @param end index of the last particle to remove (included)
  34762. * @returns an array populated with the removed particles
  34763. */
  34764. removeParticles(start: number, end: number): SolidParticle[];
  34765. /**
  34766. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34767. * @param solidParticleArray an array populated with Solid Particles objects
  34768. * @returns the SPS
  34769. */
  34770. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34771. /**
  34772. * Creates a new particle and modifies the SPS mesh geometry :
  34773. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34774. * - calls _addParticle() to populate the particle array
  34775. * factorized code from addShape() and insertParticlesFromArray()
  34776. * @param idx particle index in the particles array
  34777. * @param i particle index in its shape
  34778. * @param modelShape particle ModelShape object
  34779. * @param shape shape vertex array
  34780. * @param meshInd shape indices array
  34781. * @param meshUV shape uv array
  34782. * @param meshCol shape color array
  34783. * @param meshNor shape normals array
  34784. * @param bbInfo shape bounding info
  34785. * @param storage target particle storage
  34786. * @options addShape() passed options
  34787. * @hidden
  34788. */
  34789. private _insertNewParticle;
  34790. /**
  34791. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34792. * This method calls `updateParticle()` for each particle of the SPS.
  34793. * For an animated SPS, it is usually called within the render loop.
  34794. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  34795. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34796. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34797. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34798. * @returns the SPS.
  34799. */
  34800. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34801. /**
  34802. * Disposes the SPS.
  34803. */
  34804. dispose(): void;
  34805. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34806. * idx is the particle index in the SPS
  34807. * faceId is the picked face index counted within this particle.
  34808. * Returns null if the pickInfo can't identify a picked particle.
  34809. * @param pickingInfo (PickingInfo object)
  34810. * @returns {idx: number, faceId: number} or null
  34811. */
  34812. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34813. idx: number;
  34814. faceId: number;
  34815. }>;
  34816. /**
  34817. * Returns a SolidParticle object from its identifier : particle.id
  34818. * @param id (integer) the particle Id
  34819. * @returns the searched particle or null if not found in the SPS.
  34820. */
  34821. getParticleById(id: number): Nullable<SolidParticle>;
  34822. /**
  34823. * Returns a new array populated with the particles having the passed shapeId.
  34824. * @param shapeId (integer) the shape identifier
  34825. * @returns a new solid particle array
  34826. */
  34827. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34828. /**
  34829. * Populates the passed array "ref" with the particles having the passed shapeId.
  34830. * @param shapeId the shape identifier
  34831. * @returns the SPS
  34832. * @param ref
  34833. */
  34834. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34835. /**
  34836. * Computes the required SubMeshes according the materials assigned to the particles.
  34837. * @returns the solid particle system.
  34838. * Does nothing if called before the SPS mesh is built.
  34839. */
  34840. computeSubMeshes(): SolidParticleSystem;
  34841. /**
  34842. * Sorts the solid particles by material when MultiMaterial is enabled.
  34843. * Updates the indices32 array.
  34844. * Updates the indicesByMaterial array.
  34845. * Updates the mesh indices array.
  34846. * @returns the SPS
  34847. * @hidden
  34848. */
  34849. private _sortParticlesByMaterial;
  34850. /**
  34851. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34852. * @hidden
  34853. */
  34854. private _setMaterialIndexesById;
  34855. /**
  34856. * Returns an array with unique values of Materials from the passed array
  34857. * @param array the material array to be checked and filtered
  34858. * @hidden
  34859. */
  34860. private _filterUniqueMaterialId;
  34861. /**
  34862. * Sets a new Standard Material as _defaultMaterial if not already set.
  34863. * @hidden
  34864. */
  34865. private _setDefaultMaterial;
  34866. /**
  34867. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34868. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34869. * @returns the SPS.
  34870. */
  34871. refreshVisibleSize(): SolidParticleSystem;
  34872. /**
  34873. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34874. * @param size the size (float) of the visibility box
  34875. * note : this doesn't lock the SPS mesh bounding box.
  34876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34877. */
  34878. setVisibilityBox(size: number): void;
  34879. /**
  34880. * Gets whether the SPS as always visible or not
  34881. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34882. */
  34883. get isAlwaysVisible(): boolean;
  34884. /**
  34885. * Sets the SPS as always visible or not
  34886. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34887. */
  34888. set isAlwaysVisible(val: boolean);
  34889. /**
  34890. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34891. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34892. */
  34893. set isVisibilityBoxLocked(val: boolean);
  34894. /**
  34895. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34896. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34897. */
  34898. get isVisibilityBoxLocked(): boolean;
  34899. /**
  34900. * Tells to `setParticles()` to compute the particle rotations or not.
  34901. * Default value : true. The SPS is faster when it's set to false.
  34902. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34903. */
  34904. set computeParticleRotation(val: boolean);
  34905. /**
  34906. * Tells to `setParticles()` to compute the particle colors or not.
  34907. * Default value : true. The SPS is faster when it's set to false.
  34908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34909. */
  34910. set computeParticleColor(val: boolean);
  34911. set computeParticleTexture(val: boolean);
  34912. /**
  34913. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34914. * Default value : false. The SPS is faster when it's set to false.
  34915. * Note : the particle custom vertex positions aren't stored values.
  34916. */
  34917. set computeParticleVertex(val: boolean);
  34918. /**
  34919. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34920. */
  34921. set computeBoundingBox(val: boolean);
  34922. /**
  34923. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34924. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34925. * Default : `true`
  34926. */
  34927. set depthSortParticles(val: boolean);
  34928. /**
  34929. * Gets if `setParticles()` computes the particle rotations or not.
  34930. * Default value : true. The SPS is faster when it's set to false.
  34931. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34932. */
  34933. get computeParticleRotation(): boolean;
  34934. /**
  34935. * Gets if `setParticles()` computes the particle colors or not.
  34936. * Default value : true. The SPS is faster when it's set to false.
  34937. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34938. */
  34939. get computeParticleColor(): boolean;
  34940. /**
  34941. * Gets if `setParticles()` computes the particle textures or not.
  34942. * Default value : true. The SPS is faster when it's set to false.
  34943. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34944. */
  34945. get computeParticleTexture(): boolean;
  34946. /**
  34947. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34948. * Default value : false. The SPS is faster when it's set to false.
  34949. * Note : the particle custom vertex positions aren't stored values.
  34950. */
  34951. get computeParticleVertex(): boolean;
  34952. /**
  34953. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34954. */
  34955. get computeBoundingBox(): boolean;
  34956. /**
  34957. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34958. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34959. * Default : `true`
  34960. */
  34961. get depthSortParticles(): boolean;
  34962. /**
  34963. * Gets if the SPS is created as expandable at construction time.
  34964. * Default : `false`
  34965. */
  34966. get expandable(): boolean;
  34967. /**
  34968. * Gets if the SPS supports the Multi Materials
  34969. */
  34970. get multimaterialEnabled(): boolean;
  34971. /**
  34972. * Gets if the SPS uses the model materials for its own multimaterial.
  34973. */
  34974. get useModelMaterial(): boolean;
  34975. /**
  34976. * The SPS used material array.
  34977. */
  34978. get materials(): Material[];
  34979. /**
  34980. * Sets the SPS MultiMaterial from the passed materials.
  34981. * Note : the passed array is internally copied and not used then by reference.
  34982. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34983. */
  34984. setMultiMaterial(materials: Material[]): void;
  34985. /**
  34986. * The SPS computed multimaterial object
  34987. */
  34988. get multimaterial(): MultiMaterial;
  34989. set multimaterial(mm: MultiMaterial);
  34990. /**
  34991. * If the subMeshes must be updated on the next call to setParticles()
  34992. */
  34993. get autoUpdateSubMeshes(): boolean;
  34994. set autoUpdateSubMeshes(val: boolean);
  34995. /**
  34996. * This function does nothing. It may be overwritten to set all the particle first values.
  34997. * The SPS doesn't call this function, you may have to call it by your own.
  34998. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34999. */
  35000. initParticles(): void;
  35001. /**
  35002. * This function does nothing. It may be overwritten to recycle a particle.
  35003. * The SPS doesn't call this function, you may have to call it by your own.
  35004. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35005. * @param particle The particle to recycle
  35006. * @returns the recycled particle
  35007. */
  35008. recycleParticle(particle: SolidParticle): SolidParticle;
  35009. /**
  35010. * Updates a particle : this function should be overwritten by the user.
  35011. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35013. * @example : just set a particle position or velocity and recycle conditions
  35014. * @param particle The particle to update
  35015. * @returns the updated particle
  35016. */
  35017. updateParticle(particle: SolidParticle): SolidParticle;
  35018. /**
  35019. * Updates a vertex of a particle : it can be overwritten by the user.
  35020. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35021. * @param particle the current particle
  35022. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35023. * @param pt the index of the current vertex in the particle shape
  35024. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35025. * @example : just set a vertex particle position or color
  35026. * @returns the sps
  35027. */
  35028. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35029. /**
  35030. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35031. * This does nothing and may be overwritten by the user.
  35032. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35033. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35034. * @param update the boolean update value actually passed to setParticles()
  35035. */
  35036. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35037. /**
  35038. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35039. * This will be passed three parameters.
  35040. * This does nothing and may be overwritten by the user.
  35041. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35042. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35043. * @param update the boolean update value actually passed to setParticles()
  35044. */
  35045. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Represents one particle of a solid particle system.
  35051. */
  35052. export class SolidParticle {
  35053. /**
  35054. * particle global index
  35055. */
  35056. idx: number;
  35057. /**
  35058. * particle identifier
  35059. */
  35060. id: number;
  35061. /**
  35062. * The color of the particle
  35063. */
  35064. color: Nullable<Color4>;
  35065. /**
  35066. * The world space position of the particle.
  35067. */
  35068. position: Vector3;
  35069. /**
  35070. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35071. */
  35072. rotation: Vector3;
  35073. /**
  35074. * The world space rotation quaternion of the particle.
  35075. */
  35076. rotationQuaternion: Nullable<Quaternion>;
  35077. /**
  35078. * The scaling of the particle.
  35079. */
  35080. scaling: Vector3;
  35081. /**
  35082. * The uvs of the particle.
  35083. */
  35084. uvs: Vector4;
  35085. /**
  35086. * The current speed of the particle.
  35087. */
  35088. velocity: Vector3;
  35089. /**
  35090. * The pivot point in the particle local space.
  35091. */
  35092. pivot: Vector3;
  35093. /**
  35094. * Must the particle be translated from its pivot point in its local space ?
  35095. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35096. * Default : false
  35097. */
  35098. translateFromPivot: boolean;
  35099. /**
  35100. * Is the particle active or not ?
  35101. */
  35102. alive: boolean;
  35103. /**
  35104. * Is the particle visible or not ?
  35105. */
  35106. isVisible: boolean;
  35107. /**
  35108. * Index of this particle in the global "positions" array (Internal use)
  35109. * @hidden
  35110. */
  35111. _pos: number;
  35112. /**
  35113. * @hidden Index of this particle in the global "indices" array (Internal use)
  35114. */
  35115. _ind: number;
  35116. /**
  35117. * @hidden ModelShape of this particle (Internal use)
  35118. */
  35119. _model: ModelShape;
  35120. /**
  35121. * ModelShape id of this particle
  35122. */
  35123. shapeId: number;
  35124. /**
  35125. * Index of the particle in its shape id
  35126. */
  35127. idxInShape: number;
  35128. /**
  35129. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35130. */
  35131. _modelBoundingInfo: BoundingInfo;
  35132. /**
  35133. * @hidden Particle BoundingInfo object (Internal use)
  35134. */
  35135. _boundingInfo: BoundingInfo;
  35136. /**
  35137. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35138. */
  35139. _sps: SolidParticleSystem;
  35140. /**
  35141. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35142. */
  35143. _stillInvisible: boolean;
  35144. /**
  35145. * @hidden Last computed particle rotation matrix
  35146. */
  35147. _rotationMatrix: number[];
  35148. /**
  35149. * Parent particle Id, if any.
  35150. * Default null.
  35151. */
  35152. parentId: Nullable<number>;
  35153. /**
  35154. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35155. */
  35156. materialIndex: Nullable<number>;
  35157. /**
  35158. * Custom object or properties.
  35159. */
  35160. props: Nullable<any>;
  35161. /**
  35162. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35163. * The possible values are :
  35164. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35165. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35166. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35167. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35168. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35169. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35170. * */
  35171. cullingStrategy: number;
  35172. /**
  35173. * @hidden Internal global position in the SPS.
  35174. */
  35175. _globalPosition: Vector3;
  35176. /**
  35177. * Creates a Solid Particle object.
  35178. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35179. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35180. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35181. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35182. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35183. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35184. * @param shapeId (integer) is the model shape identifier in the SPS.
  35185. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35186. * @param sps defines the sps it is associated to
  35187. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35188. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35189. */
  35190. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35191. /**
  35192. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35193. * @param target the particle target
  35194. * @returns the current particle
  35195. */
  35196. copyToRef(target: SolidParticle): SolidParticle;
  35197. /**
  35198. * Legacy support, changed scale to scaling
  35199. */
  35200. get scale(): Vector3;
  35201. /**
  35202. * Legacy support, changed scale to scaling
  35203. */
  35204. set scale(scale: Vector3);
  35205. /**
  35206. * Legacy support, changed quaternion to rotationQuaternion
  35207. */
  35208. get quaternion(): Nullable<Quaternion>;
  35209. /**
  35210. * Legacy support, changed quaternion to rotationQuaternion
  35211. */
  35212. set quaternion(q: Nullable<Quaternion>);
  35213. /**
  35214. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35215. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35216. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35217. * @returns true if it intersects
  35218. */
  35219. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35220. /**
  35221. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35222. * A particle is in the frustum if its bounding box intersects the frustum
  35223. * @param frustumPlanes defines the frustum to test
  35224. * @returns true if the particle is in the frustum planes
  35225. */
  35226. isInFrustum(frustumPlanes: Plane[]): boolean;
  35227. /**
  35228. * get the rotation matrix of the particle
  35229. * @hidden
  35230. */
  35231. getRotationMatrix(m: Matrix): void;
  35232. }
  35233. /**
  35234. * Represents the shape of the model used by one particle of a solid particle system.
  35235. * SPS internal tool, don't use it manually.
  35236. */
  35237. export class ModelShape {
  35238. /**
  35239. * The shape id
  35240. * @hidden
  35241. */
  35242. shapeID: number;
  35243. /**
  35244. * flat array of model positions (internal use)
  35245. * @hidden
  35246. */
  35247. _shape: Vector3[];
  35248. /**
  35249. * flat array of model UVs (internal use)
  35250. * @hidden
  35251. */
  35252. _shapeUV: number[];
  35253. /**
  35254. * color array of the model
  35255. * @hidden
  35256. */
  35257. _shapeColors: number[];
  35258. /**
  35259. * indices array of the model
  35260. * @hidden
  35261. */
  35262. _indices: number[];
  35263. /**
  35264. * normals array of the model
  35265. * @hidden
  35266. */
  35267. _normals: number[];
  35268. /**
  35269. * length of the shape in the model indices array (internal use)
  35270. * @hidden
  35271. */
  35272. _indicesLength: number;
  35273. /**
  35274. * Custom position function (internal use)
  35275. * @hidden
  35276. */
  35277. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35278. /**
  35279. * Custom vertex function (internal use)
  35280. * @hidden
  35281. */
  35282. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35283. /**
  35284. * Model material (internal use)
  35285. * @hidden
  35286. */
  35287. _material: Nullable<Material>;
  35288. /**
  35289. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  35290. * SPS internal tool, don't use it manually.
  35291. * @hidden
  35292. */
  35293. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  35294. }
  35295. /**
  35296. * Represents a Depth Sorted Particle in the solid particle system.
  35297. * @hidden
  35298. */
  35299. export class DepthSortedParticle {
  35300. /**
  35301. * Particle index
  35302. */
  35303. idx: number;
  35304. /**
  35305. * Index of the particle in the "indices" array
  35306. */
  35307. ind: number;
  35308. /**
  35309. * Length of the particle shape in the "indices" array
  35310. */
  35311. indicesLength: number;
  35312. /**
  35313. * Squared distance from the particle to the camera
  35314. */
  35315. sqDistance: number;
  35316. /**
  35317. * Material index when used with MultiMaterials
  35318. */
  35319. materialIndex: number;
  35320. /**
  35321. * Creates a new sorted particle
  35322. * @param materialIndex
  35323. */
  35324. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35325. }
  35326. /**
  35327. * Represents a solid particle vertex
  35328. */
  35329. export class SolidParticleVertex {
  35330. /**
  35331. * Vertex position
  35332. */
  35333. position: Vector3;
  35334. /**
  35335. * Vertex color
  35336. */
  35337. color: Color4;
  35338. /**
  35339. * Vertex UV
  35340. */
  35341. uv: Vector2;
  35342. /**
  35343. * Creates a new solid particle vertex
  35344. */
  35345. constructor();
  35346. /** Vertex x coordinate */
  35347. get x(): number;
  35348. set x(val: number);
  35349. /** Vertex y coordinate */
  35350. get y(): number;
  35351. set y(val: number);
  35352. /** Vertex z coordinate */
  35353. get z(): number;
  35354. set z(val: number);
  35355. }
  35356. }
  35357. declare module BABYLON {
  35358. /**
  35359. * @hidden
  35360. */
  35361. export class _MeshCollisionData {
  35362. _checkCollisions: boolean;
  35363. _collisionMask: number;
  35364. _collisionGroup: number;
  35365. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35366. _collider: Nullable<Collider>;
  35367. _oldPositionForCollisions: Vector3;
  35368. _diffPositionForCollisions: Vector3;
  35369. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35370. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35371. _collisionResponse: boolean;
  35372. }
  35373. }
  35374. declare module BABYLON {
  35375. /** @hidden */
  35376. class _FacetDataStorage {
  35377. facetPositions: Vector3[];
  35378. facetNormals: Vector3[];
  35379. facetPartitioning: number[][];
  35380. facetNb: number;
  35381. partitioningSubdivisions: number;
  35382. partitioningBBoxRatio: number;
  35383. facetDataEnabled: boolean;
  35384. facetParameters: any;
  35385. bbSize: Vector3;
  35386. subDiv: {
  35387. max: number;
  35388. X: number;
  35389. Y: number;
  35390. Z: number;
  35391. };
  35392. facetDepthSort: boolean;
  35393. facetDepthSortEnabled: boolean;
  35394. depthSortedIndices: IndicesArray;
  35395. depthSortedFacets: {
  35396. ind: number;
  35397. sqDistance: number;
  35398. }[];
  35399. facetDepthSortFunction: (f1: {
  35400. ind: number;
  35401. sqDistance: number;
  35402. }, f2: {
  35403. ind: number;
  35404. sqDistance: number;
  35405. }) => number;
  35406. facetDepthSortFrom: Vector3;
  35407. facetDepthSortOrigin: Vector3;
  35408. invertedMatrix: Matrix;
  35409. }
  35410. /**
  35411. * @hidden
  35412. **/
  35413. class _InternalAbstractMeshDataInfo {
  35414. _hasVertexAlpha: boolean;
  35415. _useVertexColors: boolean;
  35416. _numBoneInfluencers: number;
  35417. _applyFog: boolean;
  35418. _receiveShadows: boolean;
  35419. _facetData: _FacetDataStorage;
  35420. _visibility: number;
  35421. _skeleton: Nullable<Skeleton>;
  35422. _layerMask: number;
  35423. _computeBonesUsingShaders: boolean;
  35424. _isActive: boolean;
  35425. _onlyForInstances: boolean;
  35426. _isActiveIntermediate: boolean;
  35427. _onlyForInstancesIntermediate: boolean;
  35428. _actAsRegularMesh: boolean;
  35429. _currentLOD: Nullable<AbstractMesh>;
  35430. }
  35431. /**
  35432. * Class used to store all common mesh properties
  35433. */
  35434. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35435. /** No occlusion */
  35436. static OCCLUSION_TYPE_NONE: number;
  35437. /** Occlusion set to optimisitic */
  35438. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35439. /** Occlusion set to strict */
  35440. static OCCLUSION_TYPE_STRICT: number;
  35441. /** Use an accurante occlusion algorithm */
  35442. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35443. /** Use a conservative occlusion algorithm */
  35444. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35445. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35446. * Test order :
  35447. * Is the bounding sphere outside the frustum ?
  35448. * If not, are the bounding box vertices outside the frustum ?
  35449. * It not, then the cullable object is in the frustum.
  35450. */
  35451. static readonly CULLINGSTRATEGY_STANDARD: number;
  35452. /** Culling strategy : Bounding Sphere Only.
  35453. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35454. * It's also less accurate than the standard because some not visible objects can still be selected.
  35455. * Test : is the bounding sphere outside the frustum ?
  35456. * If not, then the cullable object is in the frustum.
  35457. */
  35458. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35459. /** Culling strategy : Optimistic Inclusion.
  35460. * This in an inclusion test first, then the standard exclusion test.
  35461. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35462. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  35463. * Anyway, it's as accurate as the standard strategy.
  35464. * Test :
  35465. * Is the cullable object bounding sphere center in the frustum ?
  35466. * If not, apply the default culling strategy.
  35467. */
  35468. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35469. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35470. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35471. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35472. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  35473. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35474. * Test :
  35475. * Is the cullable object bounding sphere center in the frustum ?
  35476. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35477. */
  35478. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35479. /**
  35480. * No billboard
  35481. */
  35482. static get BILLBOARDMODE_NONE(): number;
  35483. /** Billboard on X axis */
  35484. static get BILLBOARDMODE_X(): number;
  35485. /** Billboard on Y axis */
  35486. static get BILLBOARDMODE_Y(): number;
  35487. /** Billboard on Z axis */
  35488. static get BILLBOARDMODE_Z(): number;
  35489. /** Billboard on all axes */
  35490. static get BILLBOARDMODE_ALL(): number;
  35491. /** Billboard on using position instead of orientation */
  35492. static get BILLBOARDMODE_USE_POSITION(): number;
  35493. /** @hidden */
  35494. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35495. /**
  35496. * The culling strategy to use to check whether the mesh must be rendered or not.
  35497. * This value can be changed at any time and will be used on the next render mesh selection.
  35498. * The possible values are :
  35499. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35500. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35501. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35502. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35503. * Please read each static variable documentation to get details about the culling process.
  35504. * */
  35505. cullingStrategy: number;
  35506. /**
  35507. * Gets the number of facets in the mesh
  35508. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35509. */
  35510. get facetNb(): number;
  35511. /**
  35512. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35513. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35514. */
  35515. get partitioningSubdivisions(): number;
  35516. set partitioningSubdivisions(nb: number);
  35517. /**
  35518. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35519. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35521. */
  35522. get partitioningBBoxRatio(): number;
  35523. set partitioningBBoxRatio(ratio: number);
  35524. /**
  35525. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35526. * Works only for updatable meshes.
  35527. * Doesn't work with multi-materials
  35528. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35529. */
  35530. get mustDepthSortFacets(): boolean;
  35531. set mustDepthSortFacets(sort: boolean);
  35532. /**
  35533. * The location (Vector3) where the facet depth sort must be computed from.
  35534. * By default, the active camera position.
  35535. * Used only when facet depth sort is enabled
  35536. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35537. */
  35538. get facetDepthSortFrom(): Vector3;
  35539. set facetDepthSortFrom(location: Vector3);
  35540. /**
  35541. * gets a boolean indicating if facetData is enabled
  35542. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35543. */
  35544. get isFacetDataEnabled(): boolean;
  35545. /** @hidden */
  35546. _updateNonUniformScalingState(value: boolean): boolean;
  35547. /**
  35548. * An event triggered when this mesh collides with another one
  35549. */
  35550. onCollideObservable: Observable<AbstractMesh>;
  35551. /** Set a function to call when this mesh collides with another one */
  35552. set onCollide(callback: () => void);
  35553. /**
  35554. * An event triggered when the collision's position changes
  35555. */
  35556. onCollisionPositionChangeObservable: Observable<Vector3>;
  35557. /** Set a function to call when the collision's position changes */
  35558. set onCollisionPositionChange(callback: () => void);
  35559. /**
  35560. * An event triggered when material is changed
  35561. */
  35562. onMaterialChangedObservable: Observable<AbstractMesh>;
  35563. /**
  35564. * Gets or sets the orientation for POV movement & rotation
  35565. */
  35566. definedFacingForward: boolean;
  35567. /** @hidden */
  35568. _occlusionQuery: Nullable<WebGLQuery>;
  35569. /** @hidden */
  35570. _renderingGroup: Nullable<RenderingGroup>;
  35571. /**
  35572. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35573. */
  35574. get visibility(): number;
  35575. /**
  35576. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35577. */
  35578. set visibility(value: number);
  35579. /** Gets or sets the alpha index used to sort transparent meshes
  35580. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35581. */
  35582. alphaIndex: number;
  35583. /**
  35584. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35585. */
  35586. isVisible: boolean;
  35587. /**
  35588. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35589. */
  35590. isPickable: boolean;
  35591. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35592. showSubMeshesBoundingBox: boolean;
  35593. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35594. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35595. */
  35596. isBlocker: boolean;
  35597. /**
  35598. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35599. */
  35600. enablePointerMoveEvents: boolean;
  35601. private _renderingGroupId;
  35602. /**
  35603. * Specifies the rendering group id for this mesh (0 by default)
  35604. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35605. */
  35606. get renderingGroupId(): number;
  35607. set renderingGroupId(value: number);
  35608. private _material;
  35609. /** Gets or sets current material */
  35610. get material(): Nullable<Material>;
  35611. set material(value: Nullable<Material>);
  35612. /**
  35613. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35614. * @see https://doc.babylonjs.com/babylon101/shadows
  35615. */
  35616. get receiveShadows(): boolean;
  35617. set receiveShadows(value: boolean);
  35618. /** Defines color to use when rendering outline */
  35619. outlineColor: Color3;
  35620. /** Define width to use when rendering outline */
  35621. outlineWidth: number;
  35622. /** Defines color to use when rendering overlay */
  35623. overlayColor: Color3;
  35624. /** Defines alpha to use when rendering overlay */
  35625. overlayAlpha: number;
  35626. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35627. get hasVertexAlpha(): boolean;
  35628. set hasVertexAlpha(value: boolean);
  35629. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  35630. get useVertexColors(): boolean;
  35631. set useVertexColors(value: boolean);
  35632. /**
  35633. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35634. */
  35635. get computeBonesUsingShaders(): boolean;
  35636. set computeBonesUsingShaders(value: boolean);
  35637. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35638. get numBoneInfluencers(): number;
  35639. set numBoneInfluencers(value: number);
  35640. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35641. get applyFog(): boolean;
  35642. set applyFog(value: boolean);
  35643. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35644. useOctreeForRenderingSelection: boolean;
  35645. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35646. useOctreeForPicking: boolean;
  35647. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35648. useOctreeForCollisions: boolean;
  35649. /**
  35650. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35651. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35652. */
  35653. get layerMask(): number;
  35654. set layerMask(value: number);
  35655. /**
  35656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35657. */
  35658. alwaysSelectAsActiveMesh: boolean;
  35659. /**
  35660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35661. */
  35662. doNotSyncBoundingInfo: boolean;
  35663. /**
  35664. * Gets or sets the current action manager
  35665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35666. */
  35667. actionManager: Nullable<AbstractActionManager>;
  35668. private _meshCollisionData;
  35669. /**
  35670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35671. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35672. */
  35673. ellipsoid: Vector3;
  35674. /**
  35675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35676. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35677. */
  35678. ellipsoidOffset: Vector3;
  35679. /**
  35680. * Gets or sets a collision mask used to mask collisions (default is -1).
  35681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35682. */
  35683. get collisionMask(): number;
  35684. set collisionMask(mask: number);
  35685. /**
  35686. * Gets or sets a collision response flag (default is true).
  35687. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35688. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35689. * to respond to the collision.
  35690. */
  35691. get collisionResponse(): boolean;
  35692. set collisionResponse(response: boolean);
  35693. /**
  35694. * Gets or sets the current collision group mask (-1 by default).
  35695. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35696. */
  35697. get collisionGroup(): number;
  35698. set collisionGroup(mask: number);
  35699. /**
  35700. * Gets or sets current surrounding meshes (null by default).
  35701. *
  35702. * By default collision detection is tested against every mesh in the scene.
  35703. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35704. * meshes will be tested for the collision.
  35705. *
  35706. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35707. */
  35708. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35709. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35710. /**
  35711. * Defines edge width used when edgesRenderer is enabled
  35712. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35713. */
  35714. edgesWidth: number;
  35715. /**
  35716. * Defines edge color used when edgesRenderer is enabled
  35717. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35718. */
  35719. edgesColor: Color4;
  35720. /** @hidden */
  35721. _edgesRenderer: Nullable<IEdgesRenderer>;
  35722. /** @hidden */
  35723. _masterMesh: Nullable<AbstractMesh>;
  35724. /** @hidden */
  35725. _boundingInfo: Nullable<BoundingInfo>;
  35726. /** @hidden */
  35727. _renderId: number;
  35728. /**
  35729. * Gets or sets the list of subMeshes
  35730. * @see https://doc.babylonjs.com/how_to/multi_materials
  35731. */
  35732. subMeshes: SubMesh[];
  35733. /** @hidden */
  35734. _intersectionsInProgress: AbstractMesh[];
  35735. /** @hidden */
  35736. _unIndexed: boolean;
  35737. /** @hidden */
  35738. _lightSources: Light[];
  35739. /** Gets the list of lights affecting that mesh */
  35740. get lightSources(): Light[];
  35741. /** @hidden */
  35742. get _positions(): Nullable<Vector3[]>;
  35743. /** @hidden */
  35744. _waitingData: {
  35745. lods: Nullable<any>;
  35746. actions: Nullable<any>;
  35747. freezeWorldMatrix: Nullable<boolean>;
  35748. };
  35749. /** @hidden */
  35750. _bonesTransformMatrices: Nullable<Float32Array>;
  35751. /** @hidden */
  35752. _transformMatrixTexture: Nullable<RawTexture>;
  35753. /**
  35754. * Gets or sets a skeleton to apply skining transformations
  35755. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35756. */
  35757. set skeleton(value: Nullable<Skeleton>);
  35758. get skeleton(): Nullable<Skeleton>;
  35759. /**
  35760. * An event triggered when the mesh is rebuilt.
  35761. */
  35762. onRebuildObservable: Observable<AbstractMesh>;
  35763. /**
  35764. * Creates a new AbstractMesh
  35765. * @param name defines the name of the mesh
  35766. * @param scene defines the hosting scene
  35767. */
  35768. constructor(name: string, scene?: Nullable<Scene>);
  35769. /**
  35770. * Returns the string "AbstractMesh"
  35771. * @returns "AbstractMesh"
  35772. */
  35773. getClassName(): string;
  35774. /**
  35775. * Gets a string representation of the current mesh
  35776. * @param fullDetails defines a boolean indicating if full details must be included
  35777. * @returns a string representation of the current mesh
  35778. */
  35779. toString(fullDetails?: boolean): string;
  35780. /**
  35781. * @hidden
  35782. */
  35783. protected _getEffectiveParent(): Nullable<Node>;
  35784. /** @hidden */
  35785. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35786. /** @hidden */
  35787. _rebuild(): void;
  35788. /** @hidden */
  35789. _resyncLightSources(): void;
  35790. /** @hidden */
  35791. _resyncLightSource(light: Light): void;
  35792. /** @hidden */
  35793. _unBindEffect(): void;
  35794. /** @hidden */
  35795. _removeLightSource(light: Light, dispose: boolean): void;
  35796. private _markSubMeshesAsDirty;
  35797. /** @hidden */
  35798. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35799. /** @hidden */
  35800. _markSubMeshesAsAttributesDirty(): void;
  35801. /** @hidden */
  35802. _markSubMeshesAsMiscDirty(): void;
  35803. /**
  35804. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35805. */
  35806. get scaling(): Vector3;
  35807. set scaling(newScaling: Vector3);
  35808. /**
  35809. * Returns true if the mesh is blocked. Implemented by child classes
  35810. */
  35811. get isBlocked(): boolean;
  35812. /**
  35813. * Returns the mesh itself by default. Implemented by child classes
  35814. * @param camera defines the camera to use to pick the right LOD level
  35815. * @returns the currentAbstractMesh
  35816. */
  35817. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35818. /**
  35819. * Returns 0 by default. Implemented by child classes
  35820. * @returns an integer
  35821. */
  35822. getTotalVertices(): number;
  35823. /**
  35824. * Returns a positive integer : the total number of indices in this mesh geometry.
  35825. * @returns the numner of indices or zero if the mesh has no geometry.
  35826. */
  35827. getTotalIndices(): number;
  35828. /**
  35829. * Returns null by default. Implemented by child classes
  35830. * @returns null
  35831. */
  35832. getIndices(): Nullable<IndicesArray>;
  35833. /**
  35834. * Returns the array of the requested vertex data kind. Implemented by child classes
  35835. * @param kind defines the vertex data kind to use
  35836. * @returns null
  35837. */
  35838. getVerticesData(kind: string): Nullable<FloatArray>;
  35839. /**
  35840. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35841. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35842. * Note that a new underlying VertexBuffer object is created each call.
  35843. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35844. * @param kind defines vertex data kind:
  35845. * * VertexBuffer.PositionKind
  35846. * * VertexBuffer.UVKind
  35847. * * VertexBuffer.UV2Kind
  35848. * * VertexBuffer.UV3Kind
  35849. * * VertexBuffer.UV4Kind
  35850. * * VertexBuffer.UV5Kind
  35851. * * VertexBuffer.UV6Kind
  35852. * * VertexBuffer.ColorKind
  35853. * * VertexBuffer.MatricesIndicesKind
  35854. * * VertexBuffer.MatricesIndicesExtraKind
  35855. * * VertexBuffer.MatricesWeightsKind
  35856. * * VertexBuffer.MatricesWeightsExtraKind
  35857. * @param data defines the data source
  35858. * @param updatable defines if the data must be flagged as updatable (or static)
  35859. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  35860. * @returns the current mesh
  35861. */
  35862. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35863. /**
  35864. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35865. * If the mesh has no geometry, it is simply returned as it is.
  35866. * @param kind defines vertex data kind:
  35867. * * VertexBuffer.PositionKind
  35868. * * VertexBuffer.UVKind
  35869. * * VertexBuffer.UV2Kind
  35870. * * VertexBuffer.UV3Kind
  35871. * * VertexBuffer.UV4Kind
  35872. * * VertexBuffer.UV5Kind
  35873. * * VertexBuffer.UV6Kind
  35874. * * VertexBuffer.ColorKind
  35875. * * VertexBuffer.MatricesIndicesKind
  35876. * * VertexBuffer.MatricesIndicesExtraKind
  35877. * * VertexBuffer.MatricesWeightsKind
  35878. * * VertexBuffer.MatricesWeightsExtraKind
  35879. * @param data defines the data source
  35880. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  35881. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35882. * @returns the current mesh
  35883. */
  35884. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35885. /**
  35886. * Sets the mesh indices,
  35887. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35888. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35889. * @param totalVertices Defines the total number of vertices
  35890. * @returns the current mesh
  35891. */
  35892. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35893. /**
  35894. * Gets a boolean indicating if specific vertex data is present
  35895. * @param kind defines the vertex data kind to use
  35896. * @returns true is data kind is present
  35897. */
  35898. isVerticesDataPresent(kind: string): boolean;
  35899. /**
  35900. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35901. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35902. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35903. * @returns a BoundingInfo
  35904. */
  35905. getBoundingInfo(): BoundingInfo;
  35906. /**
  35907. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35908. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35909. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35910. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35911. * @returns the current mesh
  35912. */
  35913. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35914. /**
  35915. * Overwrite the current bounding info
  35916. * @param boundingInfo defines the new bounding info
  35917. * @returns the current mesh
  35918. */
  35919. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35920. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35921. get useBones(): boolean;
  35922. /** @hidden */
  35923. _preActivate(): void;
  35924. /** @hidden */
  35925. _preActivateForIntermediateRendering(renderId: number): void;
  35926. /** @hidden */
  35927. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35928. /** @hidden */
  35929. _postActivate(): void;
  35930. /** @hidden */
  35931. _freeze(): void;
  35932. /** @hidden */
  35933. _unFreeze(): void;
  35934. /**
  35935. * Gets the current world matrix
  35936. * @returns a Matrix
  35937. */
  35938. getWorldMatrix(): Matrix;
  35939. /** @hidden */
  35940. _getWorldMatrixDeterminant(): number;
  35941. /**
  35942. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35943. */
  35944. get isAnInstance(): boolean;
  35945. /**
  35946. * Gets a boolean indicating if this mesh has instances
  35947. */
  35948. get hasInstances(): boolean;
  35949. /**
  35950. * Gets a boolean indicating if this mesh has thin instances
  35951. */
  35952. get hasThinInstances(): boolean;
  35953. /**
  35954. * Perform relative position change from the point of view of behind the front of the mesh.
  35955. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35956. * Supports definition of mesh facing forward or backward
  35957. * @param amountRight defines the distance on the right axis
  35958. * @param amountUp defines the distance on the up axis
  35959. * @param amountForward defines the distance on the forward axis
  35960. * @returns the current mesh
  35961. */
  35962. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35963. /**
  35964. * Calculate relative position change from the point of view of behind the front of the mesh.
  35965. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35966. * Supports definition of mesh facing forward or backward
  35967. * @param amountRight defines the distance on the right axis
  35968. * @param amountUp defines the distance on the up axis
  35969. * @param amountForward defines the distance on the forward axis
  35970. * @returns the new displacement vector
  35971. */
  35972. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35973. /**
  35974. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35975. * Supports definition of mesh facing forward or backward
  35976. * @param flipBack defines the flip
  35977. * @param twirlClockwise defines the twirl
  35978. * @param tiltRight defines the tilt
  35979. * @returns the current mesh
  35980. */
  35981. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35982. /**
  35983. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35984. * Supports definition of mesh facing forward or backward.
  35985. * @param flipBack defines the flip
  35986. * @param twirlClockwise defines the twirl
  35987. * @param tiltRight defines the tilt
  35988. * @returns the new rotation vector
  35989. */
  35990. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35991. /**
  35992. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35993. * This means the mesh underlying bounding box and sphere are recomputed.
  35994. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35995. * @returns the current mesh
  35996. */
  35997. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35998. /** @hidden */
  35999. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36000. /** @hidden */
  36001. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36002. /** @hidden */
  36003. _updateBoundingInfo(): AbstractMesh;
  36004. /** @hidden */
  36005. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36006. /** @hidden */
  36007. protected _afterComputeWorldMatrix(): void;
  36008. /** @hidden */
  36009. get _effectiveMesh(): AbstractMesh;
  36010. /**
  36011. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36012. * A mesh is in the frustum if its bounding box intersects the frustum
  36013. * @param frustumPlanes defines the frustum to test
  36014. * @returns true if the mesh is in the frustum planes
  36015. */
  36016. isInFrustum(frustumPlanes: Plane[]): boolean;
  36017. /**
  36018. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36019. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36020. * @param frustumPlanes defines the frustum to test
  36021. * @returns true if the mesh is completely in the frustum planes
  36022. */
  36023. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36024. /**
  36025. * True if the mesh intersects another mesh or a SolidParticle object
  36026. * @param mesh defines a target mesh or SolidParticle to test
  36027. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  36028. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36029. * @returns true if there is an intersection
  36030. */
  36031. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36032. /**
  36033. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36034. * @param point defines the point to test
  36035. * @returns true if there is an intersection
  36036. */
  36037. intersectsPoint(point: Vector3): boolean;
  36038. /**
  36039. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36040. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36041. */
  36042. get checkCollisions(): boolean;
  36043. set checkCollisions(collisionEnabled: boolean);
  36044. /**
  36045. * Gets Collider object used to compute collisions (not physics)
  36046. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36047. */
  36048. get collider(): Nullable<Collider>;
  36049. /**
  36050. * Move the mesh using collision engine
  36051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36052. * @param displacement defines the requested displacement vector
  36053. * @returns the current mesh
  36054. */
  36055. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36056. private _onCollisionPositionChange;
  36057. /** @hidden */
  36058. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36059. /** @hidden */
  36060. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36061. /** @hidden */
  36062. _checkCollision(collider: Collider): AbstractMesh;
  36063. /** @hidden */
  36064. _generatePointsArray(): boolean;
  36065. /**
  36066. * Checks if the passed Ray intersects with the mesh
  36067. * @param ray defines the ray to use
  36068. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36070. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36071. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36072. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36073. * @returns the picking info
  36074. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36075. */
  36076. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36077. /**
  36078. * Clones the current mesh
  36079. * @param name defines the mesh name
  36080. * @param newParent defines the new mesh parent
  36081. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36082. * @returns the new mesh
  36083. */
  36084. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36085. /**
  36086. * Disposes all the submeshes of the current meshnp
  36087. * @returns the current mesh
  36088. */
  36089. releaseSubMeshes(): AbstractMesh;
  36090. /**
  36091. * Releases resources associated with this abstract mesh.
  36092. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36093. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36094. */
  36095. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36096. /**
  36097. * Adds the passed mesh as a child to the current mesh
  36098. * @param mesh defines the child mesh
  36099. * @returns the current mesh
  36100. */
  36101. addChild(mesh: AbstractMesh): AbstractMesh;
  36102. /**
  36103. * Removes the passed mesh from the current mesh children list
  36104. * @param mesh defines the child mesh
  36105. * @returns the current mesh
  36106. */
  36107. removeChild(mesh: AbstractMesh): AbstractMesh;
  36108. /** @hidden */
  36109. private _initFacetData;
  36110. /**
  36111. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36112. * This method can be called within the render loop.
  36113. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  36114. * @returns the current mesh
  36115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36116. */
  36117. updateFacetData(): AbstractMesh;
  36118. /**
  36119. * Returns the facetLocalNormals array.
  36120. * The normals are expressed in the mesh local spac
  36121. * @returns an array of Vector3
  36122. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36123. */
  36124. getFacetLocalNormals(): Vector3[];
  36125. /**
  36126. * Returns the facetLocalPositions array.
  36127. * The facet positions are expressed in the mesh local space
  36128. * @returns an array of Vector3
  36129. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36130. */
  36131. getFacetLocalPositions(): Vector3[];
  36132. /**
  36133. * Returns the facetLocalPartioning array
  36134. * @returns an array of array of numbers
  36135. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36136. */
  36137. getFacetLocalPartitioning(): number[][];
  36138. /**
  36139. * Returns the i-th facet position in the world system.
  36140. * This method allocates a new Vector3 per call
  36141. * @param i defines the facet index
  36142. * @returns a new Vector3
  36143. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36144. */
  36145. getFacetPosition(i: number): Vector3;
  36146. /**
  36147. * Sets the reference Vector3 with the i-th facet position in the world system
  36148. * @param i defines the facet index
  36149. * @param ref defines the target vector
  36150. * @returns the current mesh
  36151. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36152. */
  36153. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36154. /**
  36155. * Returns the i-th facet normal in the world system.
  36156. * This method allocates a new Vector3 per call
  36157. * @param i defines the facet index
  36158. * @returns a new Vector3
  36159. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36160. */
  36161. getFacetNormal(i: number): Vector3;
  36162. /**
  36163. * Sets the reference Vector3 with the i-th facet normal in the world system
  36164. * @param i defines the facet index
  36165. * @param ref defines the target vector
  36166. * @returns the current mesh
  36167. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36168. */
  36169. getFacetNormalToRef(i: number, ref: Vector3): this;
  36170. /**
  36171. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  36172. * @param x defines x coordinate
  36173. * @param y defines y coordinate
  36174. * @param z defines z coordinate
  36175. * @returns the array of facet indexes
  36176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36177. */
  36178. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36179. /**
  36180. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36181. * @param projected sets as the (x,y,z) world projection on the facet
  36182. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  36183. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  36184. * @param x defines x coordinate
  36185. * @param y defines y coordinate
  36186. * @param z defines z coordinate
  36187. * @returns the face index if found (or null instead)
  36188. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36189. */
  36190. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36191. /**
  36192. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36193. * @param projected sets as the (x,y,z) local projection on the facet
  36194. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  36195. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  36196. * @param x defines x coordinate
  36197. * @param y defines y coordinate
  36198. * @param z defines z coordinate
  36199. * @returns the face index if found (or null instead)
  36200. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36201. */
  36202. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36203. /**
  36204. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36205. * @returns the parameters
  36206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36207. */
  36208. getFacetDataParameters(): any;
  36209. /**
  36210. * Disables the feature FacetData and frees the related memory
  36211. * @returns the current mesh
  36212. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36213. */
  36214. disableFacetData(): AbstractMesh;
  36215. /**
  36216. * Updates the AbstractMesh indices array
  36217. * @param indices defines the data source
  36218. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36219. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  36220. * @returns the current mesh
  36221. */
  36222. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36223. /**
  36224. * Creates new normals data for the mesh
  36225. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36226. * @returns the current mesh
  36227. */
  36228. createNormals(updatable: boolean): AbstractMesh;
  36229. /**
  36230. * Align the mesh with a normal
  36231. * @param normal defines the normal to use
  36232. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36233. * @returns the current mesh
  36234. */
  36235. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36236. /** @hidden */
  36237. _checkOcclusionQuery(): boolean;
  36238. /**
  36239. * Disables the mesh edge rendering mode
  36240. * @returns the currentAbstractMesh
  36241. */
  36242. disableEdgesRendering(): AbstractMesh;
  36243. /**
  36244. * Enables the edge rendering mode on the mesh.
  36245. * This mode makes the mesh edges visible
  36246. * @param epsilon defines the maximal distance between two angles to detect a face
  36247. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36248. * @returns the currentAbstractMesh
  36249. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36250. */
  36251. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36252. /**
  36253. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36254. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36255. */
  36256. getConnectedParticleSystems(): IParticleSystem[];
  36257. }
  36258. }
  36259. declare module BABYLON {
  36260. /**
  36261. * Interface used to define ActionEvent
  36262. */
  36263. export interface IActionEvent {
  36264. /** The mesh or sprite that triggered the action */
  36265. source: any;
  36266. /** The X mouse cursor position at the time of the event */
  36267. pointerX: number;
  36268. /** The Y mouse cursor position at the time of the event */
  36269. pointerY: number;
  36270. /** The mesh that is currently pointed at (can be null) */
  36271. meshUnderPointer: Nullable<AbstractMesh>;
  36272. /** the original (browser) event that triggered the ActionEvent */
  36273. sourceEvent?: any;
  36274. /** additional data for the event */
  36275. additionalData?: any;
  36276. }
  36277. /**
  36278. * ActionEvent is the event being sent when an action is triggered.
  36279. */
  36280. export class ActionEvent implements IActionEvent {
  36281. /** The mesh or sprite that triggered the action */
  36282. source: any;
  36283. /** The X mouse cursor position at the time of the event */
  36284. pointerX: number;
  36285. /** The Y mouse cursor position at the time of the event */
  36286. pointerY: number;
  36287. /** The mesh that is currently pointed at (can be null) */
  36288. meshUnderPointer: Nullable<AbstractMesh>;
  36289. /** the original (browser) event that triggered the ActionEvent */
  36290. sourceEvent?: any;
  36291. /** additional data for the event */
  36292. additionalData?: any;
  36293. /**
  36294. * Creates a new ActionEvent
  36295. * @param source The mesh or sprite that triggered the action
  36296. * @param pointerX The X mouse cursor position at the time of the event
  36297. * @param pointerY The Y mouse cursor position at the time of the event
  36298. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36299. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36300. * @param additionalData additional data for the event
  36301. */
  36302. constructor(
  36303. /** The mesh or sprite that triggered the action */
  36304. source: any,
  36305. /** The X mouse cursor position at the time of the event */
  36306. pointerX: number,
  36307. /** The Y mouse cursor position at the time of the event */
  36308. pointerY: number,
  36309. /** The mesh that is currently pointed at (can be null) */
  36310. meshUnderPointer: Nullable<AbstractMesh>,
  36311. /** the original (browser) event that triggered the ActionEvent */
  36312. sourceEvent?: any,
  36313. /** additional data for the event */
  36314. additionalData?: any);
  36315. /**
  36316. * Helper function to auto-create an ActionEvent from a source mesh.
  36317. * @param source The source mesh that triggered the event
  36318. * @param evt The original (browser) event
  36319. * @param additionalData additional data for the event
  36320. * @returns the new ActionEvent
  36321. */
  36322. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36323. /**
  36324. * Helper function to auto-create an ActionEvent from a source sprite
  36325. * @param source The source sprite that triggered the event
  36326. * @param scene Scene associated with the sprite
  36327. * @param evt The original (browser) event
  36328. * @param additionalData additional data for the event
  36329. * @returns the new ActionEvent
  36330. */
  36331. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36332. /**
  36333. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36334. * @param scene the scene where the event occurred
  36335. * @param evt The original (browser) event
  36336. * @returns the new ActionEvent
  36337. */
  36338. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36339. /**
  36340. * Helper function to auto-create an ActionEvent from a primitive
  36341. * @param prim defines the target primitive
  36342. * @param pointerPos defines the pointer position
  36343. * @param evt The original (browser) event
  36344. * @param additionalData additional data for the event
  36345. * @returns the new ActionEvent
  36346. */
  36347. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36348. }
  36349. }
  36350. declare module BABYLON {
  36351. /**
  36352. * Abstract class used to decouple action Manager from scene and meshes.
  36353. * Do not instantiate.
  36354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36355. */
  36356. export abstract class AbstractActionManager implements IDisposable {
  36357. /** Gets the list of active triggers */
  36358. static Triggers: {
  36359. [key: string]: number;
  36360. };
  36361. /** Gets the cursor to use when hovering items */
  36362. hoverCursor: string;
  36363. /** Gets the list of actions */
  36364. actions: IAction[];
  36365. /**
  36366. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36367. */
  36368. isRecursive: boolean;
  36369. /**
  36370. * Releases all associated resources
  36371. */
  36372. abstract dispose(): void;
  36373. /**
  36374. * Does this action manager has pointer triggers
  36375. */
  36376. abstract get hasPointerTriggers(): boolean;
  36377. /**
  36378. * Does this action manager has pick triggers
  36379. */
  36380. abstract get hasPickTriggers(): boolean;
  36381. /**
  36382. * Process a specific trigger
  36383. * @param trigger defines the trigger to process
  36384. * @param evt defines the event details to be processed
  36385. */
  36386. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36387. /**
  36388. * Does this action manager handles actions of any of the given triggers
  36389. * @param triggers defines the triggers to be tested
  36390. * @return a boolean indicating whether one (or more) of the triggers is handled
  36391. */
  36392. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36393. /**
  36394. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36395. * speed.
  36396. * @param triggerA defines the trigger to be tested
  36397. * @param triggerB defines the trigger to be tested
  36398. * @return a boolean indicating whether one (or more) of the triggers is handled
  36399. */
  36400. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36401. /**
  36402. * Does this action manager handles actions of a given trigger
  36403. * @param trigger defines the trigger to be tested
  36404. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36405. * @return whether the trigger is handled
  36406. */
  36407. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36408. /**
  36409. * Serialize this manager to a JSON object
  36410. * @param name defines the property name to store this manager
  36411. * @returns a JSON representation of this manager
  36412. */
  36413. abstract serialize(name: string): any;
  36414. /**
  36415. * Registers an action to this action manager
  36416. * @param action defines the action to be registered
  36417. * @return the action amended (prepared) after registration
  36418. */
  36419. abstract registerAction(action: IAction): Nullable<IAction>;
  36420. /**
  36421. * Unregisters an action to this action manager
  36422. * @param action defines the action to be unregistered
  36423. * @return a boolean indicating whether the action has been unregistered
  36424. */
  36425. abstract unregisterAction(action: IAction): Boolean;
  36426. /**
  36427. * Does exist one action manager with at least one trigger
  36428. **/
  36429. static get HasTriggers(): boolean;
  36430. /**
  36431. * Does exist one action manager with at least one pick trigger
  36432. **/
  36433. static get HasPickTriggers(): boolean;
  36434. /**
  36435. * Does exist one action manager that handles actions of a given trigger
  36436. * @param trigger defines the trigger to be tested
  36437. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36438. **/
  36439. static HasSpecificTrigger(trigger: number): boolean;
  36440. }
  36441. }
  36442. declare module BABYLON {
  36443. /**
  36444. * Defines how a node can be built from a string name.
  36445. */
  36446. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36447. /**
  36448. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36449. */
  36450. export class Node implements IBehaviorAware<Node> {
  36451. /** @hidden */
  36452. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36453. private static _NodeConstructors;
  36454. /**
  36455. * Add a new node constructor
  36456. * @param type defines the type name of the node to construct
  36457. * @param constructorFunc defines the constructor function
  36458. */
  36459. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36460. /**
  36461. * Returns a node constructor based on type name
  36462. * @param type defines the type name
  36463. * @param name defines the new node name
  36464. * @param scene defines the hosting scene
  36465. * @param options defines optional options to transmit to constructors
  36466. * @returns the new constructor or null
  36467. */
  36468. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36469. /**
  36470. * Gets or sets the name of the node
  36471. */
  36472. name: string;
  36473. /**
  36474. * Gets or sets the id of the node
  36475. */
  36476. id: string;
  36477. /**
  36478. * Gets or sets the unique id of the node
  36479. */
  36480. uniqueId: number;
  36481. /**
  36482. * Gets or sets a string used to store user defined state for the node
  36483. */
  36484. state: string;
  36485. /**
  36486. * Gets or sets an object used to store user defined information for the node
  36487. */
  36488. metadata: any;
  36489. /**
  36490. * For internal use only. Please do not use.
  36491. */
  36492. reservedDataStore: any;
  36493. /**
  36494. * List of inspectable custom properties (used by the Inspector)
  36495. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36496. */
  36497. inspectableCustomProperties: IInspectable[];
  36498. private _doNotSerialize;
  36499. /**
  36500. * Gets or sets a boolean used to define if the node must be serialized
  36501. */
  36502. get doNotSerialize(): boolean;
  36503. set doNotSerialize(value: boolean);
  36504. /** @hidden */
  36505. _isDisposed: boolean;
  36506. /**
  36507. * Gets a list of Animations associated with the node
  36508. */
  36509. animations: Animation[];
  36510. protected _ranges: {
  36511. [name: string]: Nullable<AnimationRange>;
  36512. };
  36513. /**
  36514. * Callback raised when the node is ready to be used
  36515. */
  36516. onReady: Nullable<(node: Node) => void>;
  36517. private _isEnabled;
  36518. private _isParentEnabled;
  36519. private _isReady;
  36520. /** @hidden */
  36521. _currentRenderId: number;
  36522. private _parentUpdateId;
  36523. /** @hidden */
  36524. _childUpdateId: number;
  36525. /** @hidden */
  36526. _waitingParentId: Nullable<string>;
  36527. /** @hidden */
  36528. _scene: Scene;
  36529. /** @hidden */
  36530. _cache: any;
  36531. private _parentNode;
  36532. private _children;
  36533. /** @hidden */
  36534. _worldMatrix: Matrix;
  36535. /** @hidden */
  36536. _worldMatrixDeterminant: number;
  36537. /** @hidden */
  36538. _worldMatrixDeterminantIsDirty: boolean;
  36539. /** @hidden */
  36540. private _sceneRootNodesIndex;
  36541. /**
  36542. * Gets a boolean indicating if the node has been disposed
  36543. * @returns true if the node was disposed
  36544. */
  36545. isDisposed(): boolean;
  36546. /**
  36547. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36548. * @see https://doc.babylonjs.com/how_to/parenting
  36549. */
  36550. set parent(parent: Nullable<Node>);
  36551. get parent(): Nullable<Node>;
  36552. /** @hidden */
  36553. _addToSceneRootNodes(): void;
  36554. /** @hidden */
  36555. _removeFromSceneRootNodes(): void;
  36556. private _animationPropertiesOverride;
  36557. /**
  36558. * Gets or sets the animation properties override
  36559. */
  36560. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36561. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36562. /**
  36563. * Gets a string identifying the name of the class
  36564. * @returns "Node" string
  36565. */
  36566. getClassName(): string;
  36567. /** @hidden */
  36568. readonly _isNode: boolean;
  36569. /**
  36570. * An event triggered when the mesh is disposed
  36571. */
  36572. onDisposeObservable: Observable<Node>;
  36573. private _onDisposeObserver;
  36574. /**
  36575. * Sets a callback that will be raised when the node will be disposed
  36576. */
  36577. set onDispose(callback: () => void);
  36578. /**
  36579. * Creates a new Node
  36580. * @param name the name and id to be given to this node
  36581. * @param scene the scene this node will be added to
  36582. */
  36583. constructor(name: string, scene?: Nullable<Scene>);
  36584. /**
  36585. * Gets the scene of the node
  36586. * @returns a scene
  36587. */
  36588. getScene(): Scene;
  36589. /**
  36590. * Gets the engine of the node
  36591. * @returns a Engine
  36592. */
  36593. getEngine(): Engine;
  36594. private _behaviors;
  36595. /**
  36596. * Attach a behavior to the node
  36597. * @see https://doc.babylonjs.com/features/behaviour
  36598. * @param behavior defines the behavior to attach
  36599. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36600. * @returns the current Node
  36601. */
  36602. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36603. /**
  36604. * Remove an attached behavior
  36605. * @see https://doc.babylonjs.com/features/behaviour
  36606. * @param behavior defines the behavior to attach
  36607. * @returns the current Node
  36608. */
  36609. removeBehavior(behavior: Behavior<Node>): Node;
  36610. /**
  36611. * Gets the list of attached behaviors
  36612. * @see https://doc.babylonjs.com/features/behaviour
  36613. */
  36614. get behaviors(): Behavior<Node>[];
  36615. /**
  36616. * Gets an attached behavior by name
  36617. * @param name defines the name of the behavior to look for
  36618. * @see https://doc.babylonjs.com/features/behaviour
  36619. * @returns null if behavior was not found else the requested behavior
  36620. */
  36621. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36622. /**
  36623. * Returns the latest update of the World matrix
  36624. * @returns a Matrix
  36625. */
  36626. getWorldMatrix(): Matrix;
  36627. /** @hidden */
  36628. _getWorldMatrixDeterminant(): number;
  36629. /**
  36630. * Returns directly the latest state of the mesh World matrix.
  36631. * A Matrix is returned.
  36632. */
  36633. get worldMatrixFromCache(): Matrix;
  36634. /** @hidden */
  36635. _initCache(): void;
  36636. /** @hidden */
  36637. updateCache(force?: boolean): void;
  36638. /** @hidden */
  36639. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36640. /** @hidden */
  36641. _updateCache(ignoreParentClass?: boolean): void;
  36642. /** @hidden */
  36643. _isSynchronized(): boolean;
  36644. /** @hidden */
  36645. _markSyncedWithParent(): void;
  36646. /** @hidden */
  36647. isSynchronizedWithParent(): boolean;
  36648. /** @hidden */
  36649. isSynchronized(): boolean;
  36650. /**
  36651. * Is this node ready to be used/rendered
  36652. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36653. * @return true if the node is ready
  36654. */
  36655. isReady(completeCheck?: boolean): boolean;
  36656. /**
  36657. * Is this node enabled?
  36658. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  36659. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  36660. * @return whether this node (and its parent) is enabled
  36661. */
  36662. isEnabled(checkAncestors?: boolean): boolean;
  36663. /** @hidden */
  36664. protected _syncParentEnabledState(): void;
  36665. /**
  36666. * Set the enabled state of this node
  36667. * @param value defines the new enabled state
  36668. */
  36669. setEnabled(value: boolean): void;
  36670. /**
  36671. * Is this node a descendant of the given node?
  36672. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36673. * @param ancestor defines the parent node to inspect
  36674. * @returns a boolean indicating if this node is a descendant of the given node
  36675. */
  36676. isDescendantOf(ancestor: Node): boolean;
  36677. /** @hidden */
  36678. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36679. /**
  36680. * Will return all nodes that have this node as ascendant
  36681. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  36682. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36683. * @return all children nodes of all types
  36684. */
  36685. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36686. /**
  36687. * Get all child-meshes of this node
  36688. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  36689. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36690. * @returns an array of AbstractMesh
  36691. */
  36692. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36693. /**
  36694. * Get all direct children of this node
  36695. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  36696. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  36697. * @returns an array of Node
  36698. */
  36699. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36700. /** @hidden */
  36701. _setReady(state: boolean): void;
  36702. /**
  36703. * Get an animation by name
  36704. * @param name defines the name of the animation to look for
  36705. * @returns null if not found else the requested animation
  36706. */
  36707. getAnimationByName(name: string): Nullable<Animation>;
  36708. /**
  36709. * Creates an animation range for this node
  36710. * @param name defines the name of the range
  36711. * @param from defines the starting key
  36712. * @param to defines the end key
  36713. */
  36714. createAnimationRange(name: string, from: number, to: number): void;
  36715. /**
  36716. * Delete a specific animation range
  36717. * @param name defines the name of the range to delete
  36718. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36719. */
  36720. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36721. /**
  36722. * Get an animation range by name
  36723. * @param name defines the name of the animation range to look for
  36724. * @returns null if not found else the requested animation range
  36725. */
  36726. getAnimationRange(name: string): Nullable<AnimationRange>;
  36727. /**
  36728. * Gets the list of all animation ranges defined on this node
  36729. * @returns an array
  36730. */
  36731. getAnimationRanges(): Nullable<AnimationRange>[];
  36732. /**
  36733. * Will start the animation sequence
  36734. * @param name defines the range frames for animation sequence
  36735. * @param loop defines if the animation should loop (false by default)
  36736. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36737. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36738. * @returns the object created for this animation. If range does not exist, it will return null
  36739. */
  36740. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36741. /**
  36742. * Serialize animation ranges into a JSON compatible object
  36743. * @returns serialization object
  36744. */
  36745. serializeAnimationRanges(): any;
  36746. /**
  36747. * Computes the world matrix of the node
  36748. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36749. * @returns the world matrix
  36750. */
  36751. computeWorldMatrix(force?: boolean): Matrix;
  36752. /**
  36753. * Releases resources associated with this node.
  36754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36756. */
  36757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36758. /**
  36759. * Parse animation range data from a serialization object and store them into a given node
  36760. * @param node defines where to store the animation ranges
  36761. * @param parsedNode defines the serialization object to read data from
  36762. * @param scene defines the hosting scene
  36763. */
  36764. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36765. /**
  36766. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36767. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36768. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  36769. * @returns the new bounding vectors
  36770. */
  36771. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36772. min: Vector3;
  36773. max: Vector3;
  36774. };
  36775. }
  36776. }
  36777. declare module BABYLON {
  36778. /**
  36779. * @hidden
  36780. */
  36781. export class _IAnimationState {
  36782. key: number;
  36783. repeatCount: number;
  36784. workValue?: any;
  36785. loopMode?: number;
  36786. offsetValue?: any;
  36787. highLimitValue?: any;
  36788. }
  36789. /**
  36790. * Class used to store any kind of animation
  36791. */
  36792. export class Animation {
  36793. /**Name of the animation */
  36794. name: string;
  36795. /**Property to animate */
  36796. targetProperty: string;
  36797. /**The frames per second of the animation */
  36798. framePerSecond: number;
  36799. /**The data type of the animation */
  36800. dataType: number;
  36801. /**The loop mode of the animation */
  36802. loopMode?: number | undefined;
  36803. /**Specifies if blending should be enabled */
  36804. enableBlending?: boolean | undefined;
  36805. /**
  36806. * Use matrix interpolation instead of using direct key value when animating matrices
  36807. */
  36808. static AllowMatricesInterpolation: boolean;
  36809. /**
  36810. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36811. */
  36812. static AllowMatrixDecomposeForInterpolation: boolean;
  36813. /** Define the Url to load snippets */
  36814. static SnippetUrl: string;
  36815. /** Snippet ID if the animation was created from the snippet server */
  36816. snippetId: string;
  36817. /**
  36818. * Stores the key frames of the animation
  36819. */
  36820. private _keys;
  36821. /**
  36822. * Stores the easing function of the animation
  36823. */
  36824. private _easingFunction;
  36825. /**
  36826. * @hidden Internal use only
  36827. */
  36828. _runtimeAnimations: RuntimeAnimation[];
  36829. /**
  36830. * The set of event that will be linked to this animation
  36831. */
  36832. private _events;
  36833. /**
  36834. * Stores an array of target property paths
  36835. */
  36836. targetPropertyPath: string[];
  36837. /**
  36838. * Stores the blending speed of the animation
  36839. */
  36840. blendingSpeed: number;
  36841. /**
  36842. * Stores the animation ranges for the animation
  36843. */
  36844. private _ranges;
  36845. /**
  36846. * @hidden Internal use
  36847. */
  36848. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36849. /**
  36850. * Sets up an animation
  36851. * @param property The property to animate
  36852. * @param animationType The animation type to apply
  36853. * @param framePerSecond The frames per second of the animation
  36854. * @param easingFunction The easing function used in the animation
  36855. * @returns The created animation
  36856. */
  36857. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36858. /**
  36859. * Create and start an animation on a node
  36860. * @param name defines the name of the global animation that will be run on all nodes
  36861. * @param node defines the root node where the animation will take place
  36862. * @param targetProperty defines property to animate
  36863. * @param framePerSecond defines the number of frame per second yo use
  36864. * @param totalFrame defines the number of frames in total
  36865. * @param from defines the initial value
  36866. * @param to defines the final value
  36867. * @param loopMode defines which loop mode you want to use (off by default)
  36868. * @param easingFunction defines the easing function to use (linear by default)
  36869. * @param onAnimationEnd defines the callback to call when animation end
  36870. * @returns the animatable created for this animation
  36871. */
  36872. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36873. /**
  36874. * Create and start an animation on a node and its descendants
  36875. * @param name defines the name of the global animation that will be run on all nodes
  36876. * @param node defines the root node where the animation will take place
  36877. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  36878. * @param targetProperty defines property to animate
  36879. * @param framePerSecond defines the number of frame per second to use
  36880. * @param totalFrame defines the number of frames in total
  36881. * @param from defines the initial value
  36882. * @param to defines the final value
  36883. * @param loopMode defines which loop mode you want to use (off by default)
  36884. * @param easingFunction defines the easing function to use (linear by default)
  36885. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36886. * @returns the list of animatables created for all nodes
  36887. * @example https://www.babylonjs-playground.com/#MH0VLI
  36888. */
  36889. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  36890. /**
  36891. * Creates a new animation, merges it with the existing animations and starts it
  36892. * @param name Name of the animation
  36893. * @param node Node which contains the scene that begins the animations
  36894. * @param targetProperty Specifies which property to animate
  36895. * @param framePerSecond The frames per second of the animation
  36896. * @param totalFrame The total number of frames
  36897. * @param from The frame at the beginning of the animation
  36898. * @param to The frame at the end of the animation
  36899. * @param loopMode Specifies the loop mode of the animation
  36900. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36901. * @param onAnimationEnd Callback to run once the animation is complete
  36902. * @returns Nullable animation
  36903. */
  36904. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36905. /**
  36906. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36907. * @param sourceAnimation defines the Animation containing keyframes to convert
  36908. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36909. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36910. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36911. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36912. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36913. */
  36914. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36915. /**
  36916. * Transition property of an host to the target Value
  36917. * @param property The property to transition
  36918. * @param targetValue The target Value of the property
  36919. * @param host The object where the property to animate belongs
  36920. * @param scene Scene used to run the animation
  36921. * @param frameRate Framerate (in frame/s) to use
  36922. * @param transition The transition type we want to use
  36923. * @param duration The duration of the animation, in milliseconds
  36924. * @param onAnimationEnd Callback trigger at the end of the animation
  36925. * @returns Nullable animation
  36926. */
  36927. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36928. /**
  36929. * Return the array of runtime animations currently using this animation
  36930. */
  36931. get runtimeAnimations(): RuntimeAnimation[];
  36932. /**
  36933. * Specifies if any of the runtime animations are currently running
  36934. */
  36935. get hasRunningRuntimeAnimations(): boolean;
  36936. /**
  36937. * Initializes the animation
  36938. * @param name Name of the animation
  36939. * @param targetProperty Property to animate
  36940. * @param framePerSecond The frames per second of the animation
  36941. * @param dataType The data type of the animation
  36942. * @param loopMode The loop mode of the animation
  36943. * @param enableBlending Specifies if blending should be enabled
  36944. */
  36945. constructor(
  36946. /**Name of the animation */
  36947. name: string,
  36948. /**Property to animate */
  36949. targetProperty: string,
  36950. /**The frames per second of the animation */
  36951. framePerSecond: number,
  36952. /**The data type of the animation */
  36953. dataType: number,
  36954. /**The loop mode of the animation */
  36955. loopMode?: number | undefined,
  36956. /**Specifies if blending should be enabled */
  36957. enableBlending?: boolean | undefined);
  36958. /**
  36959. * Converts the animation to a string
  36960. * @param fullDetails support for multiple levels of logging within scene loading
  36961. * @returns String form of the animation
  36962. */
  36963. toString(fullDetails?: boolean): string;
  36964. /**
  36965. * Add an event to this animation
  36966. * @param event Event to add
  36967. */
  36968. addEvent(event: AnimationEvent): void;
  36969. /**
  36970. * Remove all events found at the given frame
  36971. * @param frame The frame to remove events from
  36972. */
  36973. removeEvents(frame: number): void;
  36974. /**
  36975. * Retrieves all the events from the animation
  36976. * @returns Events from the animation
  36977. */
  36978. getEvents(): AnimationEvent[];
  36979. /**
  36980. * Creates an animation range
  36981. * @param name Name of the animation range
  36982. * @param from Starting frame of the animation range
  36983. * @param to Ending frame of the animation
  36984. */
  36985. createRange(name: string, from: number, to: number): void;
  36986. /**
  36987. * Deletes an animation range by name
  36988. * @param name Name of the animation range to delete
  36989. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36990. */
  36991. deleteRange(name: string, deleteFrames?: boolean): void;
  36992. /**
  36993. * Gets the animation range by name, or null if not defined
  36994. * @param name Name of the animation range
  36995. * @returns Nullable animation range
  36996. */
  36997. getRange(name: string): Nullable<AnimationRange>;
  36998. /**
  36999. * Gets the key frames from the animation
  37000. * @returns The key frames of the animation
  37001. */
  37002. getKeys(): Array<IAnimationKey>;
  37003. /**
  37004. * Gets the highest frame rate of the animation
  37005. * @returns Highest frame rate of the animation
  37006. */
  37007. getHighestFrame(): number;
  37008. /**
  37009. * Gets the easing function of the animation
  37010. * @returns Easing function of the animation
  37011. */
  37012. getEasingFunction(): IEasingFunction;
  37013. /**
  37014. * Sets the easing function of the animation
  37015. * @param easingFunction A custom mathematical formula for animation
  37016. */
  37017. setEasingFunction(easingFunction: EasingFunction): void;
  37018. /**
  37019. * Interpolates a scalar linearly
  37020. * @param startValue Start value of the animation curve
  37021. * @param endValue End value of the animation curve
  37022. * @param gradient Scalar amount to interpolate
  37023. * @returns Interpolated scalar value
  37024. */
  37025. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37026. /**
  37027. * Interpolates a scalar cubically
  37028. * @param startValue Start value of the animation curve
  37029. * @param outTangent End tangent of the animation
  37030. * @param endValue End value of the animation curve
  37031. * @param inTangent Start tangent of the animation curve
  37032. * @param gradient Scalar amount to interpolate
  37033. * @returns Interpolated scalar value
  37034. */
  37035. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37036. /**
  37037. * Interpolates a quaternion using a spherical linear interpolation
  37038. * @param startValue Start value of the animation curve
  37039. * @param endValue End value of the animation curve
  37040. * @param gradient Scalar amount to interpolate
  37041. * @returns Interpolated quaternion value
  37042. */
  37043. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37044. /**
  37045. * Interpolates a quaternion cubically
  37046. * @param startValue Start value of the animation curve
  37047. * @param outTangent End tangent of the animation curve
  37048. * @param endValue End value of the animation curve
  37049. * @param inTangent Start tangent of the animation curve
  37050. * @param gradient Scalar amount to interpolate
  37051. * @returns Interpolated quaternion value
  37052. */
  37053. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37054. /**
  37055. * Interpolates a Vector3 linearl
  37056. * @param startValue Start value of the animation curve
  37057. * @param endValue End value of the animation curve
  37058. * @param gradient Scalar amount to interpolate
  37059. * @returns Interpolated scalar value
  37060. */
  37061. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37062. /**
  37063. * Interpolates a Vector3 cubically
  37064. * @param startValue Start value of the animation curve
  37065. * @param outTangent End tangent of the animation
  37066. * @param endValue End value of the animation curve
  37067. * @param inTangent Start tangent of the animation curve
  37068. * @param gradient Scalar amount to interpolate
  37069. * @returns InterpolatedVector3 value
  37070. */
  37071. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37072. /**
  37073. * Interpolates a Vector2 linearly
  37074. * @param startValue Start value of the animation curve
  37075. * @param endValue End value of the animation curve
  37076. * @param gradient Scalar amount to interpolate
  37077. * @returns Interpolated Vector2 value
  37078. */
  37079. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37080. /**
  37081. * Interpolates a Vector2 cubically
  37082. * @param startValue Start value of the animation curve
  37083. * @param outTangent End tangent of the animation
  37084. * @param endValue End value of the animation curve
  37085. * @param inTangent Start tangent of the animation curve
  37086. * @param gradient Scalar amount to interpolate
  37087. * @returns Interpolated Vector2 value
  37088. */
  37089. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37090. /**
  37091. * Interpolates a size linearly
  37092. * @param startValue Start value of the animation curve
  37093. * @param endValue End value of the animation curve
  37094. * @param gradient Scalar amount to interpolate
  37095. * @returns Interpolated Size value
  37096. */
  37097. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37098. /**
  37099. * Interpolates a Color3 linearly
  37100. * @param startValue Start value of the animation curve
  37101. * @param endValue End value of the animation curve
  37102. * @param gradient Scalar amount to interpolate
  37103. * @returns Interpolated Color3 value
  37104. */
  37105. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37106. /**
  37107. * Interpolates a Color4 linearly
  37108. * @param startValue Start value of the animation curve
  37109. * @param endValue End value of the animation curve
  37110. * @param gradient Scalar amount to interpolate
  37111. * @returns Interpolated Color3 value
  37112. */
  37113. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37114. /**
  37115. * @hidden Internal use only
  37116. */
  37117. _getKeyValue(value: any): any;
  37118. /**
  37119. * @hidden Internal use only
  37120. */
  37121. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37122. /**
  37123. * Defines the function to use to interpolate matrices
  37124. * @param startValue defines the start matrix
  37125. * @param endValue defines the end matrix
  37126. * @param gradient defines the gradient between both matrices
  37127. * @param result defines an optional target matrix where to store the interpolation
  37128. * @returns the interpolated matrix
  37129. */
  37130. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37131. /**
  37132. * Makes a copy of the animation
  37133. * @returns Cloned animation
  37134. */
  37135. clone(): Animation;
  37136. /**
  37137. * Sets the key frames of the animation
  37138. * @param values The animation key frames to set
  37139. */
  37140. setKeys(values: Array<IAnimationKey>): void;
  37141. /**
  37142. * Serializes the animation to an object
  37143. * @returns Serialized object
  37144. */
  37145. serialize(): any;
  37146. /**
  37147. * Float animation type
  37148. */
  37149. static readonly ANIMATIONTYPE_FLOAT: number;
  37150. /**
  37151. * Vector3 animation type
  37152. */
  37153. static readonly ANIMATIONTYPE_VECTOR3: number;
  37154. /**
  37155. * Quaternion animation type
  37156. */
  37157. static readonly ANIMATIONTYPE_QUATERNION: number;
  37158. /**
  37159. * Matrix animation type
  37160. */
  37161. static readonly ANIMATIONTYPE_MATRIX: number;
  37162. /**
  37163. * Color3 animation type
  37164. */
  37165. static readonly ANIMATIONTYPE_COLOR3: number;
  37166. /**
  37167. * Color3 animation type
  37168. */
  37169. static readonly ANIMATIONTYPE_COLOR4: number;
  37170. /**
  37171. * Vector2 animation type
  37172. */
  37173. static readonly ANIMATIONTYPE_VECTOR2: number;
  37174. /**
  37175. * Size animation type
  37176. */
  37177. static readonly ANIMATIONTYPE_SIZE: number;
  37178. /**
  37179. * Relative Loop Mode
  37180. */
  37181. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37182. /**
  37183. * Cycle Loop Mode
  37184. */
  37185. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37186. /**
  37187. * Constant Loop Mode
  37188. */
  37189. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37190. /** @hidden */
  37191. static _UniversalLerp(left: any, right: any, amount: number): any;
  37192. /**
  37193. * Parses an animation object and creates an animation
  37194. * @param parsedAnimation Parsed animation object
  37195. * @returns Animation object
  37196. */
  37197. static Parse(parsedAnimation: any): Animation;
  37198. /**
  37199. * Appends the serialized animations from the source animations
  37200. * @param source Source containing the animations
  37201. * @param destination Target to store the animations
  37202. */
  37203. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37204. /**
  37205. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37206. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37207. * @param url defines the url to load from
  37208. * @returns a promise that will resolve to the new animation or an array of animations
  37209. */
  37210. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37211. /**
  37212. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37213. * @param snippetId defines the snippet to load
  37214. * @returns a promise that will resolve to the new animation or a new array of animations
  37215. */
  37216. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37217. }
  37218. }
  37219. declare module BABYLON {
  37220. /**
  37221. * Interface containing an array of animations
  37222. */
  37223. export interface IAnimatable {
  37224. /**
  37225. * Array of animations
  37226. */
  37227. animations: Nullable<Array<Animation>>;
  37228. }
  37229. }
  37230. declare module BABYLON {
  37231. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37232. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37233. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37234. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37235. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37236. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37237. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37238. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37239. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37240. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37241. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37242. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37243. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37244. /**
  37245. * Decorator used to define property that can be serialized as reference to a camera
  37246. * @param sourceName defines the name of the property to decorate
  37247. */
  37248. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37249. /**
  37250. * Class used to help serialization objects
  37251. */
  37252. export class SerializationHelper {
  37253. /** @hidden */
  37254. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37255. /** @hidden */
  37256. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37257. /** @hidden */
  37258. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37259. /** @hidden */
  37260. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37261. /**
  37262. * Appends the serialized animations from the source animations
  37263. * @param source Source containing the animations
  37264. * @param destination Target to store the animations
  37265. */
  37266. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37267. /**
  37268. * Static function used to serialized a specific entity
  37269. * @param entity defines the entity to serialize
  37270. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37271. * @returns a JSON compatible object representing the serialization of the entity
  37272. */
  37273. static Serialize<T>(entity: T, serializationObject?: any): any;
  37274. /**
  37275. * Creates a new entity from a serialization data object
  37276. * @param creationFunction defines a function used to instanciated the new entity
  37277. * @param source defines the source serialization data
  37278. * @param scene defines the hosting scene
  37279. * @param rootUrl defines the root url for resources
  37280. * @returns a new entity
  37281. */
  37282. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37283. /**
  37284. * Clones an object
  37285. * @param creationFunction defines the function used to instanciate the new object
  37286. * @param source defines the source object
  37287. * @returns the cloned object
  37288. */
  37289. static Clone<T>(creationFunction: () => T, source: T): T;
  37290. /**
  37291. * Instanciates a new object based on a source one (some data will be shared between both object)
  37292. * @param creationFunction defines the function used to instanciate the new object
  37293. * @param source defines the source object
  37294. * @returns the new object
  37295. */
  37296. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37297. }
  37298. }
  37299. declare module BABYLON {
  37300. /**
  37301. * Base class of all the textures in babylon.
  37302. * It groups all the common properties the materials, post process, lights... might need
  37303. * in order to make a correct use of the texture.
  37304. */
  37305. export class BaseTexture implements IAnimatable {
  37306. /**
  37307. * Default anisotropic filtering level for the application.
  37308. * It is set to 4 as a good tradeoff between perf and quality.
  37309. */
  37310. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37311. /**
  37312. * Gets or sets the unique id of the texture
  37313. */
  37314. uniqueId: number;
  37315. /**
  37316. * Define the name of the texture.
  37317. */
  37318. name: string;
  37319. /**
  37320. * Gets or sets an object used to store user defined information.
  37321. */
  37322. metadata: any;
  37323. /**
  37324. * For internal use only. Please do not use.
  37325. */
  37326. reservedDataStore: any;
  37327. private _hasAlpha;
  37328. /**
  37329. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37330. */
  37331. set hasAlpha(value: boolean);
  37332. get hasAlpha(): boolean;
  37333. /**
  37334. * Defines if the alpha value should be determined via the rgb values.
  37335. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37336. */
  37337. getAlphaFromRGB: boolean;
  37338. /**
  37339. * Intensity or strength of the texture.
  37340. * It is commonly used by materials to fine tune the intensity of the texture
  37341. */
  37342. level: number;
  37343. /**
  37344. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37345. * This is part of the texture as textures usually maps to one uv set.
  37346. */
  37347. coordinatesIndex: number;
  37348. protected _coordinatesMode: number;
  37349. /**
  37350. * How a texture is mapped.
  37351. *
  37352. * | Value | Type | Description |
  37353. * | ----- | ----------------------------------- | ----------- |
  37354. * | 0 | EXPLICIT_MODE | |
  37355. * | 1 | SPHERICAL_MODE | |
  37356. * | 2 | PLANAR_MODE | |
  37357. * | 3 | CUBIC_MODE | |
  37358. * | 4 | PROJECTION_MODE | |
  37359. * | 5 | SKYBOX_MODE | |
  37360. * | 6 | INVCUBIC_MODE | |
  37361. * | 7 | EQUIRECTANGULAR_MODE | |
  37362. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37363. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37364. */
  37365. set coordinatesMode(value: number);
  37366. get coordinatesMode(): number;
  37367. private _wrapU;
  37368. /**
  37369. * | Value | Type | Description |
  37370. * | ----- | ------------------ | ----------- |
  37371. * | 0 | CLAMP_ADDRESSMODE | |
  37372. * | 1 | WRAP_ADDRESSMODE | |
  37373. * | 2 | MIRROR_ADDRESSMODE | |
  37374. */
  37375. get wrapU(): number;
  37376. set wrapU(value: number);
  37377. private _wrapV;
  37378. /**
  37379. * | Value | Type | Description |
  37380. * | ----- | ------------------ | ----------- |
  37381. * | 0 | CLAMP_ADDRESSMODE | |
  37382. * | 1 | WRAP_ADDRESSMODE | |
  37383. * | 2 | MIRROR_ADDRESSMODE | |
  37384. */
  37385. get wrapV(): number;
  37386. set wrapV(value: number);
  37387. /**
  37388. * | Value | Type | Description |
  37389. * | ----- | ------------------ | ----------- |
  37390. * | 0 | CLAMP_ADDRESSMODE | |
  37391. * | 1 | WRAP_ADDRESSMODE | |
  37392. * | 2 | MIRROR_ADDRESSMODE | |
  37393. */
  37394. wrapR: number;
  37395. /**
  37396. * With compliant hardware and browser (supporting anisotropic filtering)
  37397. * this defines the level of anisotropic filtering in the texture.
  37398. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37399. */
  37400. anisotropicFilteringLevel: number;
  37401. /**
  37402. * Define if the texture is a cube texture or if false a 2d texture.
  37403. */
  37404. get isCube(): boolean;
  37405. set isCube(value: boolean);
  37406. /**
  37407. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37408. */
  37409. get is3D(): boolean;
  37410. set is3D(value: boolean);
  37411. /**
  37412. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37413. */
  37414. get is2DArray(): boolean;
  37415. set is2DArray(value: boolean);
  37416. private _gammaSpace;
  37417. /**
  37418. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37419. * HDR texture are usually stored in linear space.
  37420. * This only impacts the PBR and Background materials
  37421. */
  37422. get gammaSpace(): boolean;
  37423. set gammaSpace(gamma: boolean);
  37424. /**
  37425. * Gets or sets whether or not the texture contains RGBD data.
  37426. */
  37427. get isRGBD(): boolean;
  37428. set isRGBD(value: boolean);
  37429. /**
  37430. * Is Z inverted in the texture (useful in a cube texture).
  37431. */
  37432. invertZ: boolean;
  37433. /**
  37434. * Are mip maps generated for this texture or not.
  37435. */
  37436. get noMipmap(): boolean;
  37437. /**
  37438. * @hidden
  37439. */
  37440. lodLevelInAlpha: boolean;
  37441. /**
  37442. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37443. */
  37444. get lodGenerationOffset(): number;
  37445. set lodGenerationOffset(value: number);
  37446. /**
  37447. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37448. */
  37449. get lodGenerationScale(): number;
  37450. set lodGenerationScale(value: number);
  37451. /**
  37452. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37453. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37454. * average roughness values.
  37455. */
  37456. get linearSpecularLOD(): boolean;
  37457. set linearSpecularLOD(value: boolean);
  37458. /**
  37459. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37460. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37461. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37462. */
  37463. get irradianceTexture(): Nullable<BaseTexture>;
  37464. set irradianceTexture(value: Nullable<BaseTexture>);
  37465. /**
  37466. * Define if the texture is a render target.
  37467. */
  37468. isRenderTarget: boolean;
  37469. /**
  37470. * Define the unique id of the texture in the scene.
  37471. */
  37472. get uid(): string;
  37473. /** @hidden */
  37474. _prefiltered: boolean;
  37475. /**
  37476. * Return a string representation of the texture.
  37477. * @returns the texture as a string
  37478. */
  37479. toString(): string;
  37480. /**
  37481. * Get the class name of the texture.
  37482. * @returns "BaseTexture"
  37483. */
  37484. getClassName(): string;
  37485. /**
  37486. * Define the list of animation attached to the texture.
  37487. */
  37488. animations: Animation[];
  37489. /**
  37490. * An event triggered when the texture is disposed.
  37491. */
  37492. onDisposeObservable: Observable<BaseTexture>;
  37493. private _onDisposeObserver;
  37494. /**
  37495. * Callback triggered when the texture has been disposed.
  37496. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37497. */
  37498. set onDispose(callback: () => void);
  37499. /**
  37500. * Define the current state of the loading sequence when in delayed load mode.
  37501. */
  37502. delayLoadState: number;
  37503. protected _scene: Nullable<Scene>;
  37504. protected _engine: Nullable<ThinEngine>;
  37505. /** @hidden */
  37506. _texture: Nullable<InternalTexture>;
  37507. private _uid;
  37508. /**
  37509. * Define if the texture is preventinga material to render or not.
  37510. * If not and the texture is not ready, the engine will use a default black texture instead.
  37511. */
  37512. get isBlocking(): boolean;
  37513. /**
  37514. * Instantiates a new BaseTexture.
  37515. * Base class of all the textures in babylon.
  37516. * It groups all the common properties the materials, post process, lights... might need
  37517. * in order to make a correct use of the texture.
  37518. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37519. */
  37520. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37521. /**
  37522. * Get the scene the texture belongs to.
  37523. * @returns the scene or null if undefined
  37524. */
  37525. getScene(): Nullable<Scene>;
  37526. /** @hidden */
  37527. protected _getEngine(): Nullable<ThinEngine>;
  37528. /**
  37529. * Checks if the texture has the same transform matrix than another texture
  37530. * @param texture texture to check against
  37531. * @returns true if the transforms are the same, else false
  37532. */
  37533. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37534. /**
  37535. * Get the texture transform matrix used to offset tile the texture for istance.
  37536. * @returns the transformation matrix
  37537. */
  37538. getTextureMatrix(): Matrix;
  37539. /**
  37540. * Get the texture reflection matrix used to rotate/transform the reflection.
  37541. * @returns the reflection matrix
  37542. */
  37543. getReflectionTextureMatrix(): Matrix;
  37544. /**
  37545. * Get the underlying lower level texture from Babylon.
  37546. * @returns the insternal texture
  37547. */
  37548. getInternalTexture(): Nullable<InternalTexture>;
  37549. /**
  37550. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37551. * @returns true if ready or not blocking
  37552. */
  37553. isReadyOrNotBlocking(): boolean;
  37554. /**
  37555. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37556. * @returns true if fully ready
  37557. */
  37558. isReady(): boolean;
  37559. private _cachedSize;
  37560. /**
  37561. * Get the size of the texture.
  37562. * @returns the texture size.
  37563. */
  37564. getSize(): ISize;
  37565. /**
  37566. * Get the base size of the texture.
  37567. * It can be different from the size if the texture has been resized for POT for instance
  37568. * @returns the base size
  37569. */
  37570. getBaseSize(): ISize;
  37571. /**
  37572. * Update the sampling mode of the texture.
  37573. * Default is Trilinear mode.
  37574. *
  37575. * | Value | Type | Description |
  37576. * | ----- | ------------------ | ----------- |
  37577. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37578. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37579. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37580. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37581. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37582. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37583. * | 7 | NEAREST_LINEAR | |
  37584. * | 8 | NEAREST_NEAREST | |
  37585. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37586. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37587. * | 11 | LINEAR_LINEAR | |
  37588. * | 12 | LINEAR_NEAREST | |
  37589. *
  37590. * > _mag_: magnification filter (close to the viewer)
  37591. * > _min_: minification filter (far from the viewer)
  37592. * > _mip_: filter used between mip map levels
  37593. *@param samplingMode Define the new sampling mode of the texture
  37594. */
  37595. updateSamplingMode(samplingMode: number): void;
  37596. /**
  37597. * Scales the texture if is `canRescale()`
  37598. * @param ratio the resize factor we want to use to rescale
  37599. */
  37600. scale(ratio: number): void;
  37601. /**
  37602. * Get if the texture can rescale.
  37603. */
  37604. get canRescale(): boolean;
  37605. /** @hidden */
  37606. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37607. /** @hidden */
  37608. _rebuild(): void;
  37609. /**
  37610. * Triggers the load sequence in delayed load mode.
  37611. */
  37612. delayLoad(): void;
  37613. /**
  37614. * Clones the texture.
  37615. * @returns the cloned texture
  37616. */
  37617. clone(): Nullable<BaseTexture>;
  37618. /**
  37619. * Get the texture underlying type (INT, FLOAT...)
  37620. */
  37621. get textureType(): number;
  37622. /**
  37623. * Get the texture underlying format (RGB, RGBA...)
  37624. */
  37625. get textureFormat(): number;
  37626. /**
  37627. * Indicates that textures need to be re-calculated for all materials
  37628. */
  37629. protected _markAllSubMeshesAsTexturesDirty(): void;
  37630. /**
  37631. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37632. * This will returns an RGBA array buffer containing either in values (0-255) or
  37633. * float values (0-1) depending of the underlying buffer type.
  37634. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37635. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37636. * @param buffer defines a user defined buffer to fill with data (can be null)
  37637. * @returns The Array buffer containing the pixels data.
  37638. */
  37639. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37640. /**
  37641. * Release and destroy the underlying lower level texture aka internalTexture.
  37642. */
  37643. releaseInternalTexture(): void;
  37644. /** @hidden */
  37645. get _lodTextureHigh(): Nullable<BaseTexture>;
  37646. /** @hidden */
  37647. get _lodTextureMid(): Nullable<BaseTexture>;
  37648. /** @hidden */
  37649. get _lodTextureLow(): Nullable<BaseTexture>;
  37650. /**
  37651. * Dispose the texture and release its associated resources.
  37652. */
  37653. dispose(): void;
  37654. /**
  37655. * Serialize the texture into a JSON representation that can be parsed later on.
  37656. * @returns the JSON representation of the texture
  37657. */
  37658. serialize(): any;
  37659. /**
  37660. * Helper function to be called back once a list of texture contains only ready textures.
  37661. * @param textures Define the list of textures to wait for
  37662. * @param callback Define the callback triggered once the entire list will be ready
  37663. */
  37664. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37665. private static _isScene;
  37666. }
  37667. }
  37668. declare module BABYLON {
  37669. /**
  37670. * Options to be used when creating an effect.
  37671. */
  37672. export interface IEffectCreationOptions {
  37673. /**
  37674. * Atrributes that will be used in the shader.
  37675. */
  37676. attributes: string[];
  37677. /**
  37678. * Uniform varible names that will be set in the shader.
  37679. */
  37680. uniformsNames: string[];
  37681. /**
  37682. * Uniform buffer variable names that will be set in the shader.
  37683. */
  37684. uniformBuffersNames: string[];
  37685. /**
  37686. * Sampler texture variable names that will be set in the shader.
  37687. */
  37688. samplers: string[];
  37689. /**
  37690. * Define statements that will be set in the shader.
  37691. */
  37692. defines: any;
  37693. /**
  37694. * Possible fallbacks for this effect to improve performance when needed.
  37695. */
  37696. fallbacks: Nullable<IEffectFallbacks>;
  37697. /**
  37698. * Callback that will be called when the shader is compiled.
  37699. */
  37700. onCompiled: Nullable<(effect: Effect) => void>;
  37701. /**
  37702. * Callback that will be called if an error occurs during shader compilation.
  37703. */
  37704. onError: Nullable<(effect: Effect, errors: string) => void>;
  37705. /**
  37706. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37707. */
  37708. indexParameters?: any;
  37709. /**
  37710. * Max number of lights that can be used in the shader.
  37711. */
  37712. maxSimultaneousLights?: number;
  37713. /**
  37714. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37715. */
  37716. transformFeedbackVaryings?: Nullable<string[]>;
  37717. /**
  37718. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  37719. */
  37720. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37721. /**
  37722. * Is this effect rendering to several color attachments ?
  37723. */
  37724. multiTarget?: boolean;
  37725. }
  37726. /**
  37727. * Effect containing vertex and fragment shader that can be executed on an object.
  37728. */
  37729. export class Effect implements IDisposable {
  37730. /**
  37731. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37732. */
  37733. static ShadersRepository: string;
  37734. /**
  37735. * Enable logging of the shader code when a compilation error occurs
  37736. */
  37737. static LogShaderCodeOnCompilationError: boolean;
  37738. /**
  37739. * Name of the effect.
  37740. */
  37741. name: any;
  37742. /**
  37743. * String container all the define statements that should be set on the shader.
  37744. */
  37745. defines: string;
  37746. /**
  37747. * Callback that will be called when the shader is compiled.
  37748. */
  37749. onCompiled: Nullable<(effect: Effect) => void>;
  37750. /**
  37751. * Callback that will be called if an error occurs during shader compilation.
  37752. */
  37753. onError: Nullable<(effect: Effect, errors: string) => void>;
  37754. /**
  37755. * Callback that will be called when effect is bound.
  37756. */
  37757. onBind: Nullable<(effect: Effect) => void>;
  37758. /**
  37759. * Unique ID of the effect.
  37760. */
  37761. uniqueId: number;
  37762. /**
  37763. * Observable that will be called when the shader is compiled.
  37764. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37765. */
  37766. onCompileObservable: Observable<Effect>;
  37767. /**
  37768. * Observable that will be called if an error occurs during shader compilation.
  37769. */
  37770. onErrorObservable: Observable<Effect>;
  37771. /** @hidden */
  37772. _onBindObservable: Nullable<Observable<Effect>>;
  37773. /**
  37774. * @hidden
  37775. * Specifies if the effect was previously ready
  37776. */
  37777. _wasPreviouslyReady: boolean;
  37778. /**
  37779. * Observable that will be called when effect is bound.
  37780. */
  37781. get onBindObservable(): Observable<Effect>;
  37782. /** @hidden */
  37783. _bonesComputationForcedToCPU: boolean;
  37784. /** @hidden */
  37785. _multiTarget: boolean;
  37786. private static _uniqueIdSeed;
  37787. private _engine;
  37788. private _uniformBuffersNames;
  37789. private _uniformBuffersNamesList;
  37790. private _uniformsNames;
  37791. private _samplerList;
  37792. private _samplers;
  37793. private _isReady;
  37794. private _compilationError;
  37795. private _allFallbacksProcessed;
  37796. private _attributesNames;
  37797. private _attributes;
  37798. private _attributeLocationByName;
  37799. private _uniforms;
  37800. /**
  37801. * Key for the effect.
  37802. * @hidden
  37803. */
  37804. _key: string;
  37805. private _indexParameters;
  37806. private _fallbacks;
  37807. private _vertexSourceCode;
  37808. private _fragmentSourceCode;
  37809. private _vertexSourceCodeOverride;
  37810. private _fragmentSourceCodeOverride;
  37811. private _transformFeedbackVaryings;
  37812. private _rawVertexSourceCode;
  37813. private _rawFragmentSourceCode;
  37814. /**
  37815. * Compiled shader to webGL program.
  37816. * @hidden
  37817. */
  37818. _pipelineContext: Nullable<IPipelineContext>;
  37819. private _valueCache;
  37820. private static _baseCache;
  37821. /**
  37822. * Instantiates an effect.
  37823. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37824. * @param baseName Name of the effect.
  37825. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37826. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37827. * @param samplers List of sampler variables that will be passed to the shader.
  37828. * @param engine Engine to be used to render the effect
  37829. * @param defines Define statements to be added to the shader.
  37830. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37831. * @param onCompiled Callback that will be called when the shader is compiled.
  37832. * @param onError Callback that will be called if an error occurs during shader compilation.
  37833. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37834. */
  37835. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  37836. private _useFinalCode;
  37837. /**
  37838. * Unique key for this effect
  37839. */
  37840. get key(): string;
  37841. /**
  37842. * If the effect has been compiled and prepared.
  37843. * @returns if the effect is compiled and prepared.
  37844. */
  37845. isReady(): boolean;
  37846. private _isReadyInternal;
  37847. /**
  37848. * The engine the effect was initialized with.
  37849. * @returns the engine.
  37850. */
  37851. getEngine(): Engine;
  37852. /**
  37853. * The pipeline context for this effect
  37854. * @returns the associated pipeline context
  37855. */
  37856. getPipelineContext(): Nullable<IPipelineContext>;
  37857. /**
  37858. * The set of names of attribute variables for the shader.
  37859. * @returns An array of attribute names.
  37860. */
  37861. getAttributesNames(): string[];
  37862. /**
  37863. * Returns the attribute at the given index.
  37864. * @param index The index of the attribute.
  37865. * @returns The location of the attribute.
  37866. */
  37867. getAttributeLocation(index: number): number;
  37868. /**
  37869. * Returns the attribute based on the name of the variable.
  37870. * @param name of the attribute to look up.
  37871. * @returns the attribute location.
  37872. */
  37873. getAttributeLocationByName(name: string): number;
  37874. /**
  37875. * The number of attributes.
  37876. * @returns the numnber of attributes.
  37877. */
  37878. getAttributesCount(): number;
  37879. /**
  37880. * Gets the index of a uniform variable.
  37881. * @param uniformName of the uniform to look up.
  37882. * @returns the index.
  37883. */
  37884. getUniformIndex(uniformName: string): number;
  37885. /**
  37886. * Returns the attribute based on the name of the variable.
  37887. * @param uniformName of the uniform to look up.
  37888. * @returns the location of the uniform.
  37889. */
  37890. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37891. /**
  37892. * Returns an array of sampler variable names
  37893. * @returns The array of sampler variable names.
  37894. */
  37895. getSamplers(): string[];
  37896. /**
  37897. * Returns an array of uniform variable names
  37898. * @returns The array of uniform variable names.
  37899. */
  37900. getUniformNames(): string[];
  37901. /**
  37902. * Returns an array of uniform buffer variable names
  37903. * @returns The array of uniform buffer variable names.
  37904. */
  37905. getUniformBuffersNames(): string[];
  37906. /**
  37907. * Returns the index parameters used to create the effect
  37908. * @returns The index parameters object
  37909. */
  37910. getIndexParameters(): any;
  37911. /**
  37912. * The error from the last compilation.
  37913. * @returns the error string.
  37914. */
  37915. getCompilationError(): string;
  37916. /**
  37917. * Gets a boolean indicating that all fallbacks were used during compilation
  37918. * @returns true if all fallbacks were used
  37919. */
  37920. allFallbacksProcessed(): boolean;
  37921. /**
  37922. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37923. * @param func The callback to be used.
  37924. */
  37925. executeWhenCompiled(func: (effect: Effect) => void): void;
  37926. private _checkIsReady;
  37927. private _loadShader;
  37928. /**
  37929. * Gets the vertex shader source code of this effect
  37930. */
  37931. get vertexSourceCode(): string;
  37932. /**
  37933. * Gets the fragment shader source code of this effect
  37934. */
  37935. get fragmentSourceCode(): string;
  37936. /**
  37937. * Gets the vertex shader source code before it has been processed by the preprocessor
  37938. */
  37939. get rawVertexSourceCode(): string;
  37940. /**
  37941. * Gets the fragment shader source code before it has been processed by the preprocessor
  37942. */
  37943. get rawFragmentSourceCode(): string;
  37944. /**
  37945. * Recompiles the webGL program
  37946. * @param vertexSourceCode The source code for the vertex shader.
  37947. * @param fragmentSourceCode The source code for the fragment shader.
  37948. * @param onCompiled Callback called when completed.
  37949. * @param onError Callback called on error.
  37950. * @hidden
  37951. */
  37952. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37953. /**
  37954. * Prepares the effect
  37955. * @hidden
  37956. */
  37957. _prepareEffect(): void;
  37958. private _getShaderCodeAndErrorLine;
  37959. private _processCompilationErrors;
  37960. /**
  37961. * Checks if the effect is supported. (Must be called after compilation)
  37962. */
  37963. get isSupported(): boolean;
  37964. /**
  37965. * Binds a texture to the engine to be used as output of the shader.
  37966. * @param channel Name of the output variable.
  37967. * @param texture Texture to bind.
  37968. * @hidden
  37969. */
  37970. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37971. /**
  37972. * Sets a texture on the engine to be used in the shader.
  37973. * @param channel Name of the sampler variable.
  37974. * @param texture Texture to set.
  37975. */
  37976. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37977. /**
  37978. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37979. * @param channel Name of the sampler variable.
  37980. * @param texture Texture to set.
  37981. */
  37982. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37983. /**
  37984. * Sets an array of textures on the engine to be used in the shader.
  37985. * @param channel Name of the variable.
  37986. * @param textures Textures to set.
  37987. */
  37988. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37989. /**
  37990. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  37991. * @param channel Name of the sampler variable.
  37992. * @param postProcess Post process to get the input texture from.
  37993. */
  37994. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37995. /**
  37996. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37997. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  37998. * @param channel Name of the sampler variable.
  37999. * @param postProcess Post process to get the output texture from.
  38000. */
  38001. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38002. /** @hidden */
  38003. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38004. /** @hidden */
  38005. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38006. /** @hidden */
  38007. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38008. /** @hidden */
  38009. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38010. /**
  38011. * Binds a buffer to a uniform.
  38012. * @param buffer Buffer to bind.
  38013. * @param name Name of the uniform variable to bind to.
  38014. */
  38015. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38016. /**
  38017. * Binds block to a uniform.
  38018. * @param blockName Name of the block to bind.
  38019. * @param index Index to bind.
  38020. */
  38021. bindUniformBlock(blockName: string, index: number): void;
  38022. /**
  38023. * Sets an interger value on a uniform variable.
  38024. * @param uniformName Name of the variable.
  38025. * @param value Value to be set.
  38026. * @returns this effect.
  38027. */
  38028. setInt(uniformName: string, value: number): Effect;
  38029. /**
  38030. * Sets an int array on a uniform variable.
  38031. * @param uniformName Name of the variable.
  38032. * @param array array to be set.
  38033. * @returns this effect.
  38034. */
  38035. setIntArray(uniformName: string, array: Int32Array): Effect;
  38036. /**
  38037. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  38038. * @param uniformName Name of the variable.
  38039. * @param array array to be set.
  38040. * @returns this effect.
  38041. */
  38042. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38043. /**
  38044. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  38045. * @param uniformName Name of the variable.
  38046. * @param array array to be set.
  38047. * @returns this effect.
  38048. */
  38049. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38050. /**
  38051. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  38052. * @param uniformName Name of the variable.
  38053. * @param array array to be set.
  38054. * @returns this effect.
  38055. */
  38056. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38057. /**
  38058. * Sets an float array on a uniform variable.
  38059. * @param uniformName Name of the variable.
  38060. * @param array array to be set.
  38061. * @returns this effect.
  38062. */
  38063. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38064. /**
  38065. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  38066. * @param uniformName Name of the variable.
  38067. * @param array array to be set.
  38068. * @returns this effect.
  38069. */
  38070. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38071. /**
  38072. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  38073. * @param uniformName Name of the variable.
  38074. * @param array array to be set.
  38075. * @returns this effect.
  38076. */
  38077. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38078. /**
  38079. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  38080. * @param uniformName Name of the variable.
  38081. * @param array array to be set.
  38082. * @returns this effect.
  38083. */
  38084. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38085. /**
  38086. * Sets an array on a uniform variable.
  38087. * @param uniformName Name of the variable.
  38088. * @param array array to be set.
  38089. * @returns this effect.
  38090. */
  38091. setArray(uniformName: string, array: number[]): Effect;
  38092. /**
  38093. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  38094. * @param uniformName Name of the variable.
  38095. * @param array array to be set.
  38096. * @returns this effect.
  38097. */
  38098. setArray2(uniformName: string, array: number[]): Effect;
  38099. /**
  38100. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  38101. * @param uniformName Name of the variable.
  38102. * @param array array to be set.
  38103. * @returns this effect.
  38104. */
  38105. setArray3(uniformName: string, array: number[]): Effect;
  38106. /**
  38107. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  38108. * @param uniformName Name of the variable.
  38109. * @param array array to be set.
  38110. * @returns this effect.
  38111. */
  38112. setArray4(uniformName: string, array: number[]): Effect;
  38113. /**
  38114. * Sets matrices on a uniform variable.
  38115. * @param uniformName Name of the variable.
  38116. * @param matrices matrices to be set.
  38117. * @returns this effect.
  38118. */
  38119. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38120. /**
  38121. * Sets matrix on a uniform variable.
  38122. * @param uniformName Name of the variable.
  38123. * @param matrix matrix to be set.
  38124. * @returns this effect.
  38125. */
  38126. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38127. /**
  38128. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  38129. * @param uniformName Name of the variable.
  38130. * @param matrix matrix to be set.
  38131. * @returns this effect.
  38132. */
  38133. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38134. /**
  38135. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38136. * @param uniformName Name of the variable.
  38137. * @param matrix matrix to be set.
  38138. * @returns this effect.
  38139. */
  38140. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38141. /**
  38142. * Sets a float on a uniform variable.
  38143. * @param uniformName Name of the variable.
  38144. * @param value value to be set.
  38145. * @returns this effect.
  38146. */
  38147. setFloat(uniformName: string, value: number): Effect;
  38148. /**
  38149. * Sets a boolean on a uniform variable.
  38150. * @param uniformName Name of the variable.
  38151. * @param bool value to be set.
  38152. * @returns this effect.
  38153. */
  38154. setBool(uniformName: string, bool: boolean): Effect;
  38155. /**
  38156. * Sets a Vector2 on a uniform variable.
  38157. * @param uniformName Name of the variable.
  38158. * @param vector2 vector2 to be set.
  38159. * @returns this effect.
  38160. */
  38161. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38162. /**
  38163. * Sets a float2 on a uniform variable.
  38164. * @param uniformName Name of the variable.
  38165. * @param x First float in float2.
  38166. * @param y Second float in float2.
  38167. * @returns this effect.
  38168. */
  38169. setFloat2(uniformName: string, x: number, y: number): Effect;
  38170. /**
  38171. * Sets a Vector3 on a uniform variable.
  38172. * @param uniformName Name of the variable.
  38173. * @param vector3 Value to be set.
  38174. * @returns this effect.
  38175. */
  38176. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38177. /**
  38178. * Sets a float3 on a uniform variable.
  38179. * @param uniformName Name of the variable.
  38180. * @param x First float in float3.
  38181. * @param y Second float in float3.
  38182. * @param z Third float in float3.
  38183. * @returns this effect.
  38184. */
  38185. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38186. /**
  38187. * Sets a Vector4 on a uniform variable.
  38188. * @param uniformName Name of the variable.
  38189. * @param vector4 Value to be set.
  38190. * @returns this effect.
  38191. */
  38192. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38193. /**
  38194. * Sets a float4 on a uniform variable.
  38195. * @param uniformName Name of the variable.
  38196. * @param x First float in float4.
  38197. * @param y Second float in float4.
  38198. * @param z Third float in float4.
  38199. * @param w Fourth float in float4.
  38200. * @returns this effect.
  38201. */
  38202. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38203. /**
  38204. * Sets a Color3 on a uniform variable.
  38205. * @param uniformName Name of the variable.
  38206. * @param color3 Value to be set.
  38207. * @returns this effect.
  38208. */
  38209. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38210. /**
  38211. * Sets a Color4 on a uniform variable.
  38212. * @param uniformName Name of the variable.
  38213. * @param color3 Value to be set.
  38214. * @param alpha Alpha value to be set.
  38215. * @returns this effect.
  38216. */
  38217. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38218. /**
  38219. * Sets a Color4 on a uniform variable
  38220. * @param uniformName defines the name of the variable
  38221. * @param color4 defines the value to be set
  38222. * @returns this effect.
  38223. */
  38224. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38225. /** Release all associated resources */
  38226. dispose(): void;
  38227. /**
  38228. * This function will add a new shader to the shader store
  38229. * @param name the name of the shader
  38230. * @param pixelShader optional pixel shader content
  38231. * @param vertexShader optional vertex shader content
  38232. */
  38233. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38234. /**
  38235. * Store of each shader (The can be looked up using effect.key)
  38236. */
  38237. static ShadersStore: {
  38238. [key: string]: string;
  38239. };
  38240. /**
  38241. * Store of each included file for a shader (The can be looked up using effect.key)
  38242. */
  38243. static IncludesShadersStore: {
  38244. [key: string]: string;
  38245. };
  38246. /**
  38247. * Resets the cache of effects.
  38248. */
  38249. static ResetCache(): void;
  38250. }
  38251. }
  38252. declare module BABYLON {
  38253. /**
  38254. * Interface used to describe the capabilities of the engine relatively to the current browser
  38255. */
  38256. export interface EngineCapabilities {
  38257. /** Maximum textures units per fragment shader */
  38258. maxTexturesImageUnits: number;
  38259. /** Maximum texture units per vertex shader */
  38260. maxVertexTextureImageUnits: number;
  38261. /** Maximum textures units in the entire pipeline */
  38262. maxCombinedTexturesImageUnits: number;
  38263. /** Maximum texture size */
  38264. maxTextureSize: number;
  38265. /** Maximum texture samples */
  38266. maxSamples?: number;
  38267. /** Maximum cube texture size */
  38268. maxCubemapTextureSize: number;
  38269. /** Maximum render texture size */
  38270. maxRenderTextureSize: number;
  38271. /** Maximum number of vertex attributes */
  38272. maxVertexAttribs: number;
  38273. /** Maximum number of varyings */
  38274. maxVaryingVectors: number;
  38275. /** Maximum number of uniforms per vertex shader */
  38276. maxVertexUniformVectors: number;
  38277. /** Maximum number of uniforms per fragment shader */
  38278. maxFragmentUniformVectors: number;
  38279. /** Defines if standard derivates (dx/dy) are supported */
  38280. standardDerivatives: boolean;
  38281. /** Defines if s3tc texture compression is supported */
  38282. s3tc?: WEBGL_compressed_texture_s3tc;
  38283. /** Defines if pvrtc texture compression is supported */
  38284. pvrtc: any;
  38285. /** Defines if etc1 texture compression is supported */
  38286. etc1: any;
  38287. /** Defines if etc2 texture compression is supported */
  38288. etc2: any;
  38289. /** Defines if astc texture compression is supported */
  38290. astc: any;
  38291. /** Defines if bptc texture compression is supported */
  38292. bptc: any;
  38293. /** Defines if float textures are supported */
  38294. textureFloat: boolean;
  38295. /** Defines if vertex array objects are supported */
  38296. vertexArrayObject: boolean;
  38297. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38298. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38299. /** Gets the maximum level of anisotropy supported */
  38300. maxAnisotropy: number;
  38301. /** Defines if instancing is supported */
  38302. instancedArrays: boolean;
  38303. /** Defines if 32 bits indices are supported */
  38304. uintIndices: boolean;
  38305. /** Defines if high precision shaders are supported */
  38306. highPrecisionShaderSupported: boolean;
  38307. /** Defines if depth reading in the fragment shader is supported */
  38308. fragmentDepthSupported: boolean;
  38309. /** Defines if float texture linear filtering is supported*/
  38310. textureFloatLinearFiltering: boolean;
  38311. /** Defines if rendering to float textures is supported */
  38312. textureFloatRender: boolean;
  38313. /** Defines if half float textures are supported*/
  38314. textureHalfFloat: boolean;
  38315. /** Defines if half float texture linear filtering is supported*/
  38316. textureHalfFloatLinearFiltering: boolean;
  38317. /** Defines if rendering to half float textures is supported */
  38318. textureHalfFloatRender: boolean;
  38319. /** Defines if textureLOD shader command is supported */
  38320. textureLOD: boolean;
  38321. /** Defines if draw buffers extension is supported */
  38322. drawBuffersExtension: boolean;
  38323. /** Defines if depth textures are supported */
  38324. depthTextureExtension: boolean;
  38325. /** Defines if float color buffer are supported */
  38326. colorBufferFloat: boolean;
  38327. /** Gets disjoint timer query extension (null if not supported) */
  38328. timerQuery?: EXT_disjoint_timer_query;
  38329. /** Defines if timestamp can be used with timer query */
  38330. canUseTimestampForTimerQuery: boolean;
  38331. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38332. multiview?: any;
  38333. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38334. oculusMultiview?: any;
  38335. /** Function used to let the system compiles shaders in background */
  38336. parallelShaderCompile?: {
  38337. COMPLETION_STATUS_KHR: number;
  38338. };
  38339. /** Max number of texture samples for MSAA */
  38340. maxMSAASamples: number;
  38341. /** Defines if the blend min max extension is supported */
  38342. blendMinMax: boolean;
  38343. }
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * @hidden
  38348. **/
  38349. export class DepthCullingState {
  38350. private _isDepthTestDirty;
  38351. private _isDepthMaskDirty;
  38352. private _isDepthFuncDirty;
  38353. private _isCullFaceDirty;
  38354. private _isCullDirty;
  38355. private _isZOffsetDirty;
  38356. private _isFrontFaceDirty;
  38357. private _depthTest;
  38358. private _depthMask;
  38359. private _depthFunc;
  38360. private _cull;
  38361. private _cullFace;
  38362. private _zOffset;
  38363. private _frontFace;
  38364. /**
  38365. * Initializes the state.
  38366. */
  38367. constructor();
  38368. get isDirty(): boolean;
  38369. get zOffset(): number;
  38370. set zOffset(value: number);
  38371. get cullFace(): Nullable<number>;
  38372. set cullFace(value: Nullable<number>);
  38373. get cull(): Nullable<boolean>;
  38374. set cull(value: Nullable<boolean>);
  38375. get depthFunc(): Nullable<number>;
  38376. set depthFunc(value: Nullable<number>);
  38377. get depthMask(): boolean;
  38378. set depthMask(value: boolean);
  38379. get depthTest(): boolean;
  38380. set depthTest(value: boolean);
  38381. get frontFace(): Nullable<number>;
  38382. set frontFace(value: Nullable<number>);
  38383. reset(): void;
  38384. apply(gl: WebGLRenderingContext): void;
  38385. }
  38386. }
  38387. declare module BABYLON {
  38388. /**
  38389. * @hidden
  38390. **/
  38391. export class StencilState {
  38392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  38393. static readonly ALWAYS: number;
  38394. /** Passed to stencilOperation to specify that stencil value must be kept */
  38395. static readonly KEEP: number;
  38396. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38397. static readonly REPLACE: number;
  38398. private _isStencilTestDirty;
  38399. private _isStencilMaskDirty;
  38400. private _isStencilFuncDirty;
  38401. private _isStencilOpDirty;
  38402. private _stencilTest;
  38403. private _stencilMask;
  38404. private _stencilFunc;
  38405. private _stencilFuncRef;
  38406. private _stencilFuncMask;
  38407. private _stencilOpStencilFail;
  38408. private _stencilOpDepthFail;
  38409. private _stencilOpStencilDepthPass;
  38410. get isDirty(): boolean;
  38411. get stencilFunc(): number;
  38412. set stencilFunc(value: number);
  38413. get stencilFuncRef(): number;
  38414. set stencilFuncRef(value: number);
  38415. get stencilFuncMask(): number;
  38416. set stencilFuncMask(value: number);
  38417. get stencilOpStencilFail(): number;
  38418. set stencilOpStencilFail(value: number);
  38419. get stencilOpDepthFail(): number;
  38420. set stencilOpDepthFail(value: number);
  38421. get stencilOpStencilDepthPass(): number;
  38422. set stencilOpStencilDepthPass(value: number);
  38423. get stencilMask(): number;
  38424. set stencilMask(value: number);
  38425. get stencilTest(): boolean;
  38426. set stencilTest(value: boolean);
  38427. constructor();
  38428. reset(): void;
  38429. apply(gl: WebGLRenderingContext): void;
  38430. }
  38431. }
  38432. declare module BABYLON {
  38433. /**
  38434. * @hidden
  38435. **/
  38436. export class AlphaState {
  38437. private _isAlphaBlendDirty;
  38438. private _isBlendFunctionParametersDirty;
  38439. private _isBlendEquationParametersDirty;
  38440. private _isBlendConstantsDirty;
  38441. private _alphaBlend;
  38442. private _blendFunctionParameters;
  38443. private _blendEquationParameters;
  38444. private _blendConstants;
  38445. /**
  38446. * Initializes the state.
  38447. */
  38448. constructor();
  38449. get isDirty(): boolean;
  38450. get alphaBlend(): boolean;
  38451. set alphaBlend(value: boolean);
  38452. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38453. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38454. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38455. reset(): void;
  38456. apply(gl: WebGLRenderingContext): void;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /** @hidden */
  38461. export class WebGLShaderProcessor implements IShaderProcessor {
  38462. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38463. }
  38464. }
  38465. declare module BABYLON {
  38466. /** @hidden */
  38467. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38468. attributeProcessor(attribute: string): string;
  38469. varyingProcessor(varying: string, isFragment: boolean): string;
  38470. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38471. }
  38472. }
  38473. declare module BABYLON {
  38474. /**
  38475. * Interface for attribute information associated with buffer instanciation
  38476. */
  38477. export interface InstancingAttributeInfo {
  38478. /**
  38479. * Name of the GLSL attribute
  38480. * if attribute index is not specified, this is used to retrieve the index from the effect
  38481. */
  38482. attributeName: string;
  38483. /**
  38484. * Index/offset of the attribute in the vertex shader
  38485. * if not specified, this will be computes from the name.
  38486. */
  38487. index?: number;
  38488. /**
  38489. * size of the attribute, 1, 2, 3 or 4
  38490. */
  38491. attributeSize: number;
  38492. /**
  38493. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38494. */
  38495. offset: number;
  38496. /**
  38497. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38498. * default to 1
  38499. */
  38500. divisor?: number;
  38501. /**
  38502. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38503. * default is FLOAT
  38504. */
  38505. attributeType?: number;
  38506. /**
  38507. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38508. */
  38509. normalized?: boolean;
  38510. }
  38511. }
  38512. declare module BABYLON {
  38513. interface ThinEngine {
  38514. /**
  38515. * Update a video texture
  38516. * @param texture defines the texture to update
  38517. * @param video defines the video element to use
  38518. * @param invertY defines if data must be stored with Y axis inverted
  38519. */
  38520. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38521. }
  38522. }
  38523. declare module BABYLON {
  38524. interface ThinEngine {
  38525. /**
  38526. * Creates a dynamic texture
  38527. * @param width defines the width of the texture
  38528. * @param height defines the height of the texture
  38529. * @param generateMipMaps defines if the engine should generate the mip levels
  38530. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38531. * @returns the dynamic texture inside an InternalTexture
  38532. */
  38533. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38534. /**
  38535. * Update the content of a dynamic texture
  38536. * @param texture defines the texture to update
  38537. * @param canvas defines the canvas containing the source
  38538. * @param invertY defines if data must be stored with Y axis inverted
  38539. * @param premulAlpha defines if alpha is stored as premultiplied
  38540. * @param format defines the format of the data
  38541. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38542. */
  38543. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38544. }
  38545. }
  38546. declare module BABYLON {
  38547. /**
  38548. * Settings for finer control over video usage
  38549. */
  38550. export interface VideoTextureSettings {
  38551. /**
  38552. * Applies `autoplay` to video, if specified
  38553. */
  38554. autoPlay?: boolean;
  38555. /**
  38556. * Applies `muted` to video, if specified
  38557. */
  38558. muted?: boolean;
  38559. /**
  38560. * Applies `loop` to video, if specified
  38561. */
  38562. loop?: boolean;
  38563. /**
  38564. * Automatically updates internal texture from video at every frame in the render loop
  38565. */
  38566. autoUpdateTexture: boolean;
  38567. /**
  38568. * Image src displayed during the video loading or until the user interacts with the video.
  38569. */
  38570. poster?: string;
  38571. }
  38572. /**
  38573. * If you want to display a video in your scene, this is the special texture for that.
  38574. * This special texture works similar to other textures, with the exception of a few parameters.
  38575. * @see https://doc.babylonjs.com/how_to/video_texture
  38576. */
  38577. export class VideoTexture extends Texture {
  38578. /**
  38579. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38580. */
  38581. readonly autoUpdateTexture: boolean;
  38582. /**
  38583. * The video instance used by the texture internally
  38584. */
  38585. readonly video: HTMLVideoElement;
  38586. private _onUserActionRequestedObservable;
  38587. /**
  38588. * Event triggerd when a dom action is required by the user to play the video.
  38589. * This happens due to recent changes in browser policies preventing video to auto start.
  38590. */
  38591. get onUserActionRequestedObservable(): Observable<Texture>;
  38592. private _generateMipMaps;
  38593. private _stillImageCaptured;
  38594. private _displayingPosterTexture;
  38595. private _settings;
  38596. private _createInternalTextureOnEvent;
  38597. private _frameId;
  38598. private _currentSrc;
  38599. /**
  38600. * Creates a video texture.
  38601. * If you want to display a video in your scene, this is the special texture for that.
  38602. * This special texture works similar to other textures, with the exception of a few parameters.
  38603. * @see https://doc.babylonjs.com/how_to/video_texture
  38604. * @param name optional name, will detect from video source, if not defined
  38605. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38606. * @param scene is obviously the current scene.
  38607. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38608. * @param invertY is false by default but can be used to invert video on Y axis
  38609. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38610. * @param settings allows finer control over video usage
  38611. */
  38612. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38613. private _getName;
  38614. private _getVideo;
  38615. private _createInternalTexture;
  38616. private reset;
  38617. /**
  38618. * @hidden Internal method to initiate `update`.
  38619. */
  38620. _rebuild(): void;
  38621. /**
  38622. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38623. */
  38624. update(): void;
  38625. /**
  38626. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38627. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38628. */
  38629. updateTexture(isVisible: boolean): void;
  38630. protected _updateInternalTexture: () => void;
  38631. /**
  38632. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38633. * @param url New url.
  38634. */
  38635. updateURL(url: string): void;
  38636. /**
  38637. * Clones the texture.
  38638. * @returns the cloned texture
  38639. */
  38640. clone(): VideoTexture;
  38641. /**
  38642. * Dispose the texture and release its associated resources.
  38643. */
  38644. dispose(): void;
  38645. /**
  38646. * Creates a video texture straight from a stream.
  38647. * @param scene Define the scene the texture should be created in
  38648. * @param stream Define the stream the texture should be created from
  38649. * @returns The created video texture as a promise
  38650. */
  38651. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38652. /**
  38653. * Creates a video texture straight from your WebCam video feed.
  38654. * @param scene Define the scene the texture should be created in
  38655. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38656. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38657. * @returns The created video texture as a promise
  38658. */
  38659. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38660. minWidth: number;
  38661. maxWidth: number;
  38662. minHeight: number;
  38663. maxHeight: number;
  38664. deviceId: string;
  38665. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38666. /**
  38667. * Creates a video texture straight from your WebCam video feed.
  38668. * @param scene Define the scene the texture should be created in
  38669. * @param onReady Define a callback to triggered once the texture will be ready
  38670. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38671. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38672. */
  38673. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38674. minWidth: number;
  38675. maxWidth: number;
  38676. minHeight: number;
  38677. maxHeight: number;
  38678. deviceId: string;
  38679. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38680. }
  38681. }
  38682. declare module BABYLON {
  38683. /**
  38684. * Defines the interface used by objects working like Scene
  38685. * @hidden
  38686. */
  38687. export interface ISceneLike {
  38688. _addPendingData(data: any): void;
  38689. _removePendingData(data: any): void;
  38690. offlineProvider: IOfflineProvider;
  38691. }
  38692. /**
  38693. * Information about the current host
  38694. */
  38695. export interface HostInformation {
  38696. /**
  38697. * Defines if the current host is a mobile
  38698. */
  38699. isMobile: boolean;
  38700. }
  38701. /** Interface defining initialization parameters for Engine class */
  38702. export interface EngineOptions extends WebGLContextAttributes {
  38703. /**
  38704. * Defines if the engine should no exceed a specified device ratio
  38705. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38706. */
  38707. limitDeviceRatio?: number;
  38708. /**
  38709. * Defines if webvr should be enabled automatically
  38710. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38711. */
  38712. autoEnableWebVR?: boolean;
  38713. /**
  38714. * Defines if webgl2 should be turned off even if supported
  38715. * @see https://doc.babylonjs.com/features/webgl2
  38716. */
  38717. disableWebGL2Support?: boolean;
  38718. /**
  38719. * Defines if webaudio should be initialized as well
  38720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38721. */
  38722. audioEngine?: boolean;
  38723. /**
  38724. * Defines if animations should run using a deterministic lock step
  38725. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38726. */
  38727. deterministicLockstep?: boolean;
  38728. /** Defines the maximum steps to use with deterministic lock step mode */
  38729. lockstepMaxSteps?: number;
  38730. /** Defines the seconds between each deterministic lock step */
  38731. timeStep?: number;
  38732. /**
  38733. * Defines that engine should ignore context lost events
  38734. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38735. */
  38736. doNotHandleContextLost?: boolean;
  38737. /**
  38738. * Defines that engine should ignore modifying touch action attribute and style
  38739. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38740. */
  38741. doNotHandleTouchAction?: boolean;
  38742. /**
  38743. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38744. */
  38745. useHighPrecisionFloats?: boolean;
  38746. /**
  38747. * Make the canvas XR Compatible for XR sessions
  38748. */
  38749. xrCompatible?: boolean;
  38750. /**
  38751. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38752. */
  38753. useHighPrecisionMatrix?: boolean;
  38754. /**
  38755. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38756. */
  38757. failIfMajorPerformanceCaveat?: boolean;
  38758. }
  38759. /**
  38760. * The base engine class (root of all engines)
  38761. */
  38762. export class ThinEngine {
  38763. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38764. static ExceptionList: ({
  38765. key: string;
  38766. capture: string;
  38767. captureConstraint: number;
  38768. targets: string[];
  38769. } | {
  38770. key: string;
  38771. capture: null;
  38772. captureConstraint: null;
  38773. targets: string[];
  38774. })[];
  38775. /** @hidden */
  38776. static _TextureLoaders: IInternalTextureLoader[];
  38777. /**
  38778. * Returns the current npm package of the sdk
  38779. */
  38780. static get NpmPackage(): string;
  38781. /**
  38782. * Returns the current version of the framework
  38783. */
  38784. static get Version(): string;
  38785. /**
  38786. * Returns a string describing the current engine
  38787. */
  38788. get description(): string;
  38789. /**
  38790. * Gets or sets the epsilon value used by collision engine
  38791. */
  38792. static CollisionsEpsilon: number;
  38793. /**
  38794. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38795. */
  38796. static get ShadersRepository(): string;
  38797. static set ShadersRepository(value: string);
  38798. /** @hidden */
  38799. _shaderProcessor: IShaderProcessor;
  38800. /**
  38801. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38802. */
  38803. forcePOTTextures: boolean;
  38804. /**
  38805. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38806. */
  38807. isFullscreen: boolean;
  38808. /**
  38809. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38810. */
  38811. cullBackFaces: boolean;
  38812. /**
  38813. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38814. */
  38815. renderEvenInBackground: boolean;
  38816. /**
  38817. * Gets or sets a boolean indicating that cache can be kept between frames
  38818. */
  38819. preventCacheWipeBetweenFrames: boolean;
  38820. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38821. validateShaderPrograms: boolean;
  38822. /**
  38823. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38824. * This can provide greater z depth for distant objects.
  38825. */
  38826. useReverseDepthBuffer: boolean;
  38827. /**
  38828. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38829. */
  38830. disableUniformBuffers: boolean;
  38831. /** @hidden */
  38832. _uniformBuffers: UniformBuffer[];
  38833. /**
  38834. * Gets a boolean indicating that the engine supports uniform buffers
  38835. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38836. */
  38837. get supportsUniformBuffers(): boolean;
  38838. /** @hidden */
  38839. _gl: WebGLRenderingContext;
  38840. /** @hidden */
  38841. _webGLVersion: number;
  38842. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38843. protected _windowIsBackground: boolean;
  38844. protected _creationOptions: EngineOptions;
  38845. protected _highPrecisionShadersAllowed: boolean;
  38846. /** @hidden */
  38847. get _shouldUseHighPrecisionShader(): boolean;
  38848. /**
  38849. * Gets a boolean indicating that only power of 2 textures are supported
  38850. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38851. */
  38852. get needPOTTextures(): boolean;
  38853. /** @hidden */
  38854. _badOS: boolean;
  38855. /** @hidden */
  38856. _badDesktopOS: boolean;
  38857. private _hardwareScalingLevel;
  38858. /** @hidden */
  38859. _caps: EngineCapabilities;
  38860. private _isStencilEnable;
  38861. private _glVersion;
  38862. private _glRenderer;
  38863. private _glVendor;
  38864. /** @hidden */
  38865. _videoTextureSupported: boolean;
  38866. protected _renderingQueueLaunched: boolean;
  38867. protected _activeRenderLoops: (() => void)[];
  38868. /**
  38869. * Observable signaled when a context lost event is raised
  38870. */
  38871. onContextLostObservable: Observable<ThinEngine>;
  38872. /**
  38873. * Observable signaled when a context restored event is raised
  38874. */
  38875. onContextRestoredObservable: Observable<ThinEngine>;
  38876. private _onContextLost;
  38877. private _onContextRestored;
  38878. protected _contextWasLost: boolean;
  38879. /** @hidden */
  38880. _doNotHandleContextLost: boolean;
  38881. /**
  38882. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38883. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38884. */
  38885. get doNotHandleContextLost(): boolean;
  38886. set doNotHandleContextLost(value: boolean);
  38887. /**
  38888. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38889. */
  38890. disableVertexArrayObjects: boolean;
  38891. /** @hidden */
  38892. protected _colorWrite: boolean;
  38893. /** @hidden */
  38894. protected _colorWriteChanged: boolean;
  38895. /** @hidden */
  38896. protected _depthCullingState: DepthCullingState;
  38897. /** @hidden */
  38898. protected _stencilState: StencilState;
  38899. /** @hidden */
  38900. _alphaState: AlphaState;
  38901. /** @hidden */
  38902. _alphaMode: number;
  38903. /** @hidden */
  38904. _alphaEquation: number;
  38905. /** @hidden */
  38906. _internalTexturesCache: InternalTexture[];
  38907. /** @hidden */
  38908. protected _activeChannel: number;
  38909. private _currentTextureChannel;
  38910. /** @hidden */
  38911. protected _boundTexturesCache: {
  38912. [key: string]: Nullable<InternalTexture>;
  38913. };
  38914. /** @hidden */
  38915. protected _currentEffect: Nullable<Effect>;
  38916. /** @hidden */
  38917. protected _currentProgram: Nullable<WebGLProgram>;
  38918. private _compiledEffects;
  38919. private _vertexAttribArraysEnabled;
  38920. /** @hidden */
  38921. protected _cachedViewport: Nullable<IViewportLike>;
  38922. private _cachedVertexArrayObject;
  38923. /** @hidden */
  38924. protected _cachedVertexBuffers: any;
  38925. /** @hidden */
  38926. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38927. /** @hidden */
  38928. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38929. /** @hidden */
  38930. _currentRenderTarget: Nullable<InternalTexture>;
  38931. private _uintIndicesCurrentlySet;
  38932. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38933. /** @hidden */
  38934. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38935. /** @hidden */
  38936. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38937. private _currentBufferPointers;
  38938. private _currentInstanceLocations;
  38939. private _currentInstanceBuffers;
  38940. private _textureUnits;
  38941. /** @hidden */
  38942. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38943. /** @hidden */
  38944. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38945. /** @hidden */
  38946. _boundRenderFunction: any;
  38947. private _vaoRecordInProgress;
  38948. private _mustWipeVertexAttributes;
  38949. private _emptyTexture;
  38950. private _emptyCubeTexture;
  38951. private _emptyTexture3D;
  38952. private _emptyTexture2DArray;
  38953. /** @hidden */
  38954. _frameHandler: number;
  38955. private _nextFreeTextureSlots;
  38956. private _maxSimultaneousTextures;
  38957. private _activeRequests;
  38958. /** @hidden */
  38959. _transformTextureUrl: Nullable<(url: string) => string>;
  38960. /**
  38961. * Gets information about the current host
  38962. */
  38963. hostInformation: HostInformation;
  38964. protected get _supportsHardwareTextureRescaling(): boolean;
  38965. private _framebufferDimensionsObject;
  38966. /**
  38967. * sets the object from which width and height will be taken from when getting render width and height
  38968. * Will fallback to the gl object
  38969. * @param dimensions the framebuffer width and height that will be used.
  38970. */
  38971. set framebufferDimensionsObject(dimensions: Nullable<{
  38972. framebufferWidth: number;
  38973. framebufferHeight: number;
  38974. }>);
  38975. /**
  38976. * Gets the current viewport
  38977. */
  38978. get currentViewport(): Nullable<IViewportLike>;
  38979. /**
  38980. * Gets the default empty texture
  38981. */
  38982. get emptyTexture(): InternalTexture;
  38983. /**
  38984. * Gets the default empty 3D texture
  38985. */
  38986. get emptyTexture3D(): InternalTexture;
  38987. /**
  38988. * Gets the default empty 2D array texture
  38989. */
  38990. get emptyTexture2DArray(): InternalTexture;
  38991. /**
  38992. * Gets the default empty cube texture
  38993. */
  38994. get emptyCubeTexture(): InternalTexture;
  38995. /**
  38996. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38997. */
  38998. readonly premultipliedAlpha: boolean;
  38999. /**
  39000. * Observable event triggered before each texture is initialized
  39001. */
  39002. onBeforeTextureInitObservable: Observable<Texture>;
  39003. /**
  39004. * Creates a new engine
  39005. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  39006. * @param antialias defines enable antialiasing (default: false)
  39007. * @param options defines further options to be sent to the getContext() function
  39008. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39009. */
  39010. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39011. private _rebuildInternalTextures;
  39012. private _rebuildEffects;
  39013. /**
  39014. * Gets a boolean indicating if all created effects are ready
  39015. * @returns true if all effects are ready
  39016. */
  39017. areAllEffectsReady(): boolean;
  39018. protected _rebuildBuffers(): void;
  39019. protected _initGLContext(): void;
  39020. /**
  39021. * Gets version of the current webGL context
  39022. */
  39023. get webGLVersion(): number;
  39024. /**
  39025. * Gets a string identifying the name of the class
  39026. * @returns "Engine" string
  39027. */
  39028. getClassName(): string;
  39029. /**
  39030. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39031. */
  39032. get isStencilEnable(): boolean;
  39033. /** @hidden */
  39034. _prepareWorkingCanvas(): void;
  39035. /**
  39036. * Reset the texture cache to empty state
  39037. */
  39038. resetTextureCache(): void;
  39039. /**
  39040. * Gets an object containing information about the current webGL context
  39041. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39042. */
  39043. getGlInfo(): {
  39044. vendor: string;
  39045. renderer: string;
  39046. version: string;
  39047. };
  39048. /**
  39049. * Defines the hardware scaling level.
  39050. * By default the hardware scaling level is computed from the window device ratio.
  39051. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  39052. * @param level defines the level to use
  39053. */
  39054. setHardwareScalingLevel(level: number): void;
  39055. /**
  39056. * Gets the current hardware scaling level.
  39057. * By default the hardware scaling level is computed from the window device ratio.
  39058. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  39059. * @returns a number indicating the current hardware scaling level
  39060. */
  39061. getHardwareScalingLevel(): number;
  39062. /**
  39063. * Gets the list of loaded textures
  39064. * @returns an array containing all loaded textures
  39065. */
  39066. getLoadedTexturesCache(): InternalTexture[];
  39067. /**
  39068. * Gets the object containing all engine capabilities
  39069. * @returns the EngineCapabilities object
  39070. */
  39071. getCaps(): EngineCapabilities;
  39072. /**
  39073. * stop executing a render loop function and remove it from the execution array
  39074. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39075. */
  39076. stopRenderLoop(renderFunction?: () => void): void;
  39077. /** @hidden */
  39078. _renderLoop(): void;
  39079. /**
  39080. * Gets the HTML canvas attached with the current webGL context
  39081. * @returns a HTML canvas
  39082. */
  39083. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39084. /**
  39085. * Gets host window
  39086. * @returns the host window object
  39087. */
  39088. getHostWindow(): Nullable<Window>;
  39089. /**
  39090. * Gets the current render width
  39091. * @param useScreen defines if screen size must be used (or the current render target if any)
  39092. * @returns a number defining the current render width
  39093. */
  39094. getRenderWidth(useScreen?: boolean): number;
  39095. /**
  39096. * Gets the current render height
  39097. * @param useScreen defines if screen size must be used (or the current render target if any)
  39098. * @returns a number defining the current render height
  39099. */
  39100. getRenderHeight(useScreen?: boolean): number;
  39101. /**
  39102. * Can be used to override the current requestAnimationFrame requester.
  39103. * @hidden
  39104. */
  39105. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39106. /**
  39107. * Register and execute a render loop. The engine can have more than one render function
  39108. * @param renderFunction defines the function to continuously execute
  39109. */
  39110. runRenderLoop(renderFunction: () => void): void;
  39111. /**
  39112. * Clear the current render buffer or the current render target (if any is set up)
  39113. * @param color defines the color to use
  39114. * @param backBuffer defines if the back buffer must be cleared
  39115. * @param depth defines if the depth buffer must be cleared
  39116. * @param stencil defines if the stencil buffer must be cleared
  39117. */
  39118. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39119. private _viewportCached;
  39120. /** @hidden */
  39121. _viewport(x: number, y: number, width: number, height: number): void;
  39122. /**
  39123. * Set the WebGL's viewport
  39124. * @param viewport defines the viewport element to be used
  39125. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39126. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39127. */
  39128. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39129. /**
  39130. * Begin a new frame
  39131. */
  39132. beginFrame(): void;
  39133. /**
  39134. * Enf the current frame
  39135. */
  39136. endFrame(): void;
  39137. /**
  39138. * Resize the view according to the canvas' size
  39139. */
  39140. resize(): void;
  39141. /**
  39142. * Force a specific size of the canvas
  39143. * @param width defines the new canvas' width
  39144. * @param height defines the new canvas' height
  39145. * @returns true if the size was changed
  39146. */
  39147. setSize(width: number, height: number): boolean;
  39148. /**
  39149. * Binds the frame buffer to the specified texture.
  39150. * @param texture The texture to render to or null for the default canvas
  39151. * @param faceIndex The face of the texture to render to in case of cube texture
  39152. * @param requiredWidth The width of the target to render to
  39153. * @param requiredHeight The height of the target to render to
  39154. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39155. * @param lodLevel defines the lod level to bind to the frame buffer
  39156. * @param layer defines the 2d array index to bind to frame buffer to
  39157. */
  39158. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39159. /** @hidden */
  39160. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39161. /**
  39162. * Unbind the current render target texture from the webGL context
  39163. * @param texture defines the render target texture to unbind
  39164. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39165. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39166. */
  39167. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39168. /**
  39169. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39170. */
  39171. flushFramebuffer(): void;
  39172. /**
  39173. * Unbind the current render target and bind the default framebuffer
  39174. */
  39175. restoreDefaultFramebuffer(): void;
  39176. /** @hidden */
  39177. protected _resetVertexBufferBinding(): void;
  39178. /**
  39179. * Creates a vertex buffer
  39180. * @param data the data for the vertex buffer
  39181. * @returns the new WebGL static buffer
  39182. */
  39183. createVertexBuffer(data: DataArray): DataBuffer;
  39184. private _createVertexBuffer;
  39185. /**
  39186. * Creates a dynamic vertex buffer
  39187. * @param data the data for the dynamic vertex buffer
  39188. * @returns the new WebGL dynamic buffer
  39189. */
  39190. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39191. protected _resetIndexBufferBinding(): void;
  39192. /**
  39193. * Creates a new index buffer
  39194. * @param indices defines the content of the index buffer
  39195. * @param updatable defines if the index buffer must be updatable
  39196. * @returns a new webGL buffer
  39197. */
  39198. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39199. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39200. /**
  39201. * Bind a webGL buffer to the webGL context
  39202. * @param buffer defines the buffer to bind
  39203. */
  39204. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39205. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39206. private bindBuffer;
  39207. /**
  39208. * update the bound buffer with the given data
  39209. * @param data defines the data to update
  39210. */
  39211. updateArrayBuffer(data: Float32Array): void;
  39212. private _vertexAttribPointer;
  39213. /** @hidden */
  39214. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39215. private _bindVertexBuffersAttributes;
  39216. /**
  39217. * Records a vertex array object
  39218. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39219. * @param vertexBuffers defines the list of vertex buffers to store
  39220. * @param indexBuffer defines the index buffer to store
  39221. * @param effect defines the effect to store
  39222. * @returns the new vertex array object
  39223. */
  39224. recordVertexArrayObject(vertexBuffers: {
  39225. [key: string]: VertexBuffer;
  39226. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39227. /**
  39228. * Bind a specific vertex array object
  39229. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39230. * @param vertexArrayObject defines the vertex array object to bind
  39231. * @param indexBuffer defines the index buffer to bind
  39232. */
  39233. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39234. /**
  39235. * Bind webGl buffers directly to the webGL context
  39236. * @param vertexBuffer defines the vertex buffer to bind
  39237. * @param indexBuffer defines the index buffer to bind
  39238. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39239. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39240. * @param effect defines the effect associated with the vertex buffer
  39241. */
  39242. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39243. private _unbindVertexArrayObject;
  39244. /**
  39245. * Bind a list of vertex buffers to the webGL context
  39246. * @param vertexBuffers defines the list of vertex buffers to bind
  39247. * @param indexBuffer defines the index buffer to bind
  39248. * @param effect defines the effect associated with the vertex buffers
  39249. */
  39250. bindBuffers(vertexBuffers: {
  39251. [key: string]: Nullable<VertexBuffer>;
  39252. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39253. /**
  39254. * Unbind all instance attributes
  39255. */
  39256. unbindInstanceAttributes(): void;
  39257. /**
  39258. * Release and free the memory of a vertex array object
  39259. * @param vao defines the vertex array object to delete
  39260. */
  39261. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39262. /** @hidden */
  39263. _releaseBuffer(buffer: DataBuffer): boolean;
  39264. protected _deleteBuffer(buffer: DataBuffer): void;
  39265. /**
  39266. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39267. * @param instancesBuffer defines the webGL buffer to update and bind
  39268. * @param data defines the data to store in the buffer
  39269. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39270. */
  39271. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39272. /**
  39273. * Bind the content of a webGL buffer used with instantiation
  39274. * @param instancesBuffer defines the webGL buffer to bind
  39275. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39276. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39277. */
  39278. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39279. /**
  39280. * Disable the instance attribute corresponding to the name in parameter
  39281. * @param name defines the name of the attribute to disable
  39282. */
  39283. disableInstanceAttributeByName(name: string): void;
  39284. /**
  39285. * Disable the instance attribute corresponding to the location in parameter
  39286. * @param attributeLocation defines the attribute location of the attribute to disable
  39287. */
  39288. disableInstanceAttribute(attributeLocation: number): void;
  39289. /**
  39290. * Disable the attribute corresponding to the location in parameter
  39291. * @param attributeLocation defines the attribute location of the attribute to disable
  39292. */
  39293. disableAttributeByIndex(attributeLocation: number): void;
  39294. /**
  39295. * Send a draw order
  39296. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39297. * @param indexStart defines the starting index
  39298. * @param indexCount defines the number of index to draw
  39299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39300. */
  39301. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39302. /**
  39303. * Draw a list of points
  39304. * @param verticesStart defines the index of first vertex to draw
  39305. * @param verticesCount defines the count of vertices to draw
  39306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39307. */
  39308. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39309. /**
  39310. * Draw a list of unindexed primitives
  39311. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39312. * @param verticesStart defines the index of first vertex to draw
  39313. * @param verticesCount defines the count of vertices to draw
  39314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39315. */
  39316. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39317. /**
  39318. * Draw a list of indexed primitives
  39319. * @param fillMode defines the primitive to use
  39320. * @param indexStart defines the starting index
  39321. * @param indexCount defines the number of index to draw
  39322. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39323. */
  39324. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39325. /**
  39326. * Draw a list of unindexed primitives
  39327. * @param fillMode defines the primitive to use
  39328. * @param verticesStart defines the index of first vertex to draw
  39329. * @param verticesCount defines the count of vertices to draw
  39330. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39331. */
  39332. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39333. private _drawMode;
  39334. /** @hidden */
  39335. protected _reportDrawCall(): void;
  39336. /** @hidden */
  39337. _releaseEffect(effect: Effect): void;
  39338. /** @hidden */
  39339. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39340. /**
  39341. * Create a new effect (used to store vertex/fragment shaders)
  39342. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39343. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39344. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39345. * @param samplers defines an array of string used to represent textures
  39346. * @param defines defines the string containing the defines to use to compile the shaders
  39347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39348. * @param onCompiled defines a function to call when the effect creation is successful
  39349. * @param onError defines a function to call when the effect creation has failed
  39350. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39351. * @returns the new Effect
  39352. */
  39353. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  39354. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39355. private _compileShader;
  39356. private _compileRawShader;
  39357. /** @hidden */
  39358. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39359. /**
  39360. * Directly creates a webGL program
  39361. * @param pipelineContext defines the pipeline context to attach to
  39362. * @param vertexCode defines the vertex shader code to use
  39363. * @param fragmentCode defines the fragment shader code to use
  39364. * @param context defines the webGL context to use (if not set, the current one will be used)
  39365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39366. * @returns the new webGL program
  39367. */
  39368. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39369. /**
  39370. * Creates a webGL program
  39371. * @param pipelineContext defines the pipeline context to attach to
  39372. * @param vertexCode defines the vertex shader code to use
  39373. * @param fragmentCode defines the fragment shader code to use
  39374. * @param defines defines the string containing the defines to use to compile the shaders
  39375. * @param context defines the webGL context to use (if not set, the current one will be used)
  39376. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39377. * @returns the new webGL program
  39378. */
  39379. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39380. /**
  39381. * Creates a new pipeline context
  39382. * @returns the new pipeline
  39383. */
  39384. createPipelineContext(): IPipelineContext;
  39385. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39386. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39387. /** @hidden */
  39388. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39389. /** @hidden */
  39390. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39391. /** @hidden */
  39392. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39393. /**
  39394. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39395. * @param pipelineContext defines the pipeline context to use
  39396. * @param uniformsNames defines the list of uniform names
  39397. * @returns an array of webGL uniform locations
  39398. */
  39399. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39400. /**
  39401. * Gets the lsit of active attributes for a given webGL program
  39402. * @param pipelineContext defines the pipeline context to use
  39403. * @param attributesNames defines the list of attribute names to get
  39404. * @returns an array of indices indicating the offset of each attribute
  39405. */
  39406. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39407. /**
  39408. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39409. * @param effect defines the effect to activate
  39410. */
  39411. enableEffect(effect: Nullable<Effect>): void;
  39412. /**
  39413. * Set the value of an uniform to a number (int)
  39414. * @param uniform defines the webGL uniform location where to store the value
  39415. * @param value defines the int number to store
  39416. * @returns true if the value was set
  39417. */
  39418. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39419. /**
  39420. * Set the value of an uniform to an array of int32
  39421. * @param uniform defines the webGL uniform location where to store the value
  39422. * @param array defines the array of int32 to store
  39423. * @returns true if the value was set
  39424. */
  39425. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39426. /**
  39427. * Set the value of an uniform to an array of int32 (stored as vec2)
  39428. * @param uniform defines the webGL uniform location where to store the value
  39429. * @param array defines the array of int32 to store
  39430. * @returns true if the value was set
  39431. */
  39432. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39433. /**
  39434. * Set the value of an uniform to an array of int32 (stored as vec3)
  39435. * @param uniform defines the webGL uniform location where to store the value
  39436. * @param array defines the array of int32 to store
  39437. * @returns true if the value was set
  39438. */
  39439. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39440. /**
  39441. * Set the value of an uniform to an array of int32 (stored as vec4)
  39442. * @param uniform defines the webGL uniform location where to store the value
  39443. * @param array defines the array of int32 to store
  39444. * @returns true if the value was set
  39445. */
  39446. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39447. /**
  39448. * Set the value of an uniform to an array of number
  39449. * @param uniform defines the webGL uniform location where to store the value
  39450. * @param array defines the array of number to store
  39451. * @returns true if the value was set
  39452. */
  39453. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39454. /**
  39455. * Set the value of an uniform to an array of number (stored as vec2)
  39456. * @param uniform defines the webGL uniform location where to store the value
  39457. * @param array defines the array of number to store
  39458. * @returns true if the value was set
  39459. */
  39460. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39461. /**
  39462. * Set the value of an uniform to an array of number (stored as vec3)
  39463. * @param uniform defines the webGL uniform location where to store the value
  39464. * @param array defines the array of number to store
  39465. * @returns true if the value was set
  39466. */
  39467. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39468. /**
  39469. * Set the value of an uniform to an array of number (stored as vec4)
  39470. * @param uniform defines the webGL uniform location where to store the value
  39471. * @param array defines the array of number to store
  39472. * @returns true if the value was set
  39473. */
  39474. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39475. /**
  39476. * Set the value of an uniform to an array of float32 (stored as matrices)
  39477. * @param uniform defines the webGL uniform location where to store the value
  39478. * @param matrices defines the array of float32 to store
  39479. * @returns true if the value was set
  39480. */
  39481. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39482. /**
  39483. * Set the value of an uniform to a matrix (3x3)
  39484. * @param uniform defines the webGL uniform location where to store the value
  39485. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39486. * @returns true if the value was set
  39487. */
  39488. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39489. /**
  39490. * Set the value of an uniform to a matrix (2x2)
  39491. * @param uniform defines the webGL uniform location where to store the value
  39492. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39493. * @returns true if the value was set
  39494. */
  39495. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39496. /**
  39497. * Set the value of an uniform to a number (float)
  39498. * @param uniform defines the webGL uniform location where to store the value
  39499. * @param value defines the float number to store
  39500. * @returns true if the value was transfered
  39501. */
  39502. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39503. /**
  39504. * Set the value of an uniform to a vec2
  39505. * @param uniform defines the webGL uniform location where to store the value
  39506. * @param x defines the 1st component of the value
  39507. * @param y defines the 2nd component of the value
  39508. * @returns true if the value was set
  39509. */
  39510. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39511. /**
  39512. * Set the value of an uniform to a vec3
  39513. * @param uniform defines the webGL uniform location where to store the value
  39514. * @param x defines the 1st component of the value
  39515. * @param y defines the 2nd component of the value
  39516. * @param z defines the 3rd component of the value
  39517. * @returns true if the value was set
  39518. */
  39519. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39520. /**
  39521. * Set the value of an uniform to a vec4
  39522. * @param uniform defines the webGL uniform location where to store the value
  39523. * @param x defines the 1st component of the value
  39524. * @param y defines the 2nd component of the value
  39525. * @param z defines the 3rd component of the value
  39526. * @param w defines the 4th component of the value
  39527. * @returns true if the value was set
  39528. */
  39529. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39530. /**
  39531. * Apply all cached states (depth, culling, stencil and alpha)
  39532. */
  39533. applyStates(): void;
  39534. /**
  39535. * Enable or disable color writing
  39536. * @param enable defines the state to set
  39537. */
  39538. setColorWrite(enable: boolean): void;
  39539. /**
  39540. * Gets a boolean indicating if color writing is enabled
  39541. * @returns the current color writing state
  39542. */
  39543. getColorWrite(): boolean;
  39544. /**
  39545. * Gets the depth culling state manager
  39546. */
  39547. get depthCullingState(): DepthCullingState;
  39548. /**
  39549. * Gets the alpha state manager
  39550. */
  39551. get alphaState(): AlphaState;
  39552. /**
  39553. * Gets the stencil state manager
  39554. */
  39555. get stencilState(): StencilState;
  39556. /**
  39557. * Clears the list of texture accessible through engine.
  39558. * This can help preventing texture load conflict due to name collision.
  39559. */
  39560. clearInternalTexturesCache(): void;
  39561. /**
  39562. * Force the entire cache to be cleared
  39563. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39564. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39565. */
  39566. wipeCaches(bruteForce?: boolean): void;
  39567. /** @hidden */
  39568. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39569. min: number;
  39570. mag: number;
  39571. };
  39572. /** @hidden */
  39573. _createTexture(): WebGLTexture;
  39574. /**
  39575. * Usually called from Texture.ts.
  39576. * Passed information to create a WebGLTexture
  39577. * @param url defines a value which contains one of the following:
  39578. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39579. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39580. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39582. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  39583. * @param scene needed for loading to the correct scene
  39584. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39585. * @param onLoad optional callback to be called upon successful completion
  39586. * @param onError optional callback to be called upon failure
  39587. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  39588. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39589. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39590. * @param forcedExtension defines the extension to use to pick the right loader
  39591. * @param mimeType defines an optional mime type
  39592. * @param loaderOptions options to be passed to the loader
  39593. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39594. */
  39595. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39596. /**
  39597. * Loads an image as an HTMLImageElement.
  39598. * @param input url string, ArrayBuffer, or Blob to load
  39599. * @param onLoad callback called when the image successfully loads
  39600. * @param onError callback called when the image fails to load
  39601. * @param offlineProvider offline provider for caching
  39602. * @param mimeType optional mime type
  39603. * @returns the HTMLImageElement of the loaded image
  39604. * @hidden
  39605. */
  39606. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39607. /**
  39608. * @hidden
  39609. */
  39610. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39611. private _unpackFlipYCached;
  39612. /**
  39613. * In case you are sharing the context with other applications, it might
  39614. * be interested to not cache the unpack flip y state to ensure a consistent
  39615. * value would be set.
  39616. */
  39617. enableUnpackFlipYCached: boolean;
  39618. /** @hidden */
  39619. _unpackFlipY(value: boolean): void;
  39620. /** @hidden */
  39621. _getUnpackAlignement(): number;
  39622. private _getTextureTarget;
  39623. /**
  39624. * Update the sampling mode of a given texture
  39625. * @param samplingMode defines the required sampling mode
  39626. * @param texture defines the texture to update
  39627. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39628. */
  39629. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39630. /**
  39631. * Update the sampling mode of a given texture
  39632. * @param texture defines the texture to update
  39633. * @param wrapU defines the texture wrap mode of the u coordinates
  39634. * @param wrapV defines the texture wrap mode of the v coordinates
  39635. * @param wrapR defines the texture wrap mode of the r coordinates
  39636. */
  39637. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39638. /** @hidden */
  39639. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39640. width: number;
  39641. height: number;
  39642. layers?: number;
  39643. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39644. /** @hidden */
  39645. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39646. /** @hidden */
  39647. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39648. /**
  39649. * Update a portion of an internal texture
  39650. * @param texture defines the texture to update
  39651. * @param imageData defines the data to store into the texture
  39652. * @param xOffset defines the x coordinates of the update rectangle
  39653. * @param yOffset defines the y coordinates of the update rectangle
  39654. * @param width defines the width of the update rectangle
  39655. * @param height defines the height of the update rectangle
  39656. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39657. * @param lod defines the lod level to update (0 by default)
  39658. */
  39659. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39660. /** @hidden */
  39661. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39662. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39663. private _prepareWebGLTexture;
  39664. /** @hidden */
  39665. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39666. private _getDepthStencilBuffer;
  39667. /** @hidden */
  39668. _releaseFramebufferObjects(texture: InternalTexture): void;
  39669. /** @hidden */
  39670. _releaseTexture(texture: InternalTexture): void;
  39671. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39672. protected _setProgram(program: WebGLProgram): void;
  39673. protected _boundUniforms: {
  39674. [key: number]: WebGLUniformLocation;
  39675. };
  39676. /**
  39677. * Binds an effect to the webGL context
  39678. * @param effect defines the effect to bind
  39679. */
  39680. bindSamplers(effect: Effect): void;
  39681. private _activateCurrentTexture;
  39682. /** @hidden */
  39683. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39684. /** @hidden */
  39685. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39686. /**
  39687. * Unbind all textures from the webGL context
  39688. */
  39689. unbindAllTextures(): void;
  39690. /**
  39691. * Sets a texture to the according uniform.
  39692. * @param channel The texture channel
  39693. * @param uniform The uniform to set
  39694. * @param texture The texture to apply
  39695. */
  39696. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39697. private _bindSamplerUniformToChannel;
  39698. private _getTextureWrapMode;
  39699. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39700. /**
  39701. * Sets an array of texture to the webGL context
  39702. * @param channel defines the channel where the texture array must be set
  39703. * @param uniform defines the associated uniform location
  39704. * @param textures defines the array of textures to bind
  39705. */
  39706. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39707. /** @hidden */
  39708. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39709. private _setTextureParameterFloat;
  39710. private _setTextureParameterInteger;
  39711. /**
  39712. * Unbind all vertex attributes from the webGL context
  39713. */
  39714. unbindAllAttributes(): void;
  39715. /**
  39716. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  39717. */
  39718. releaseEffects(): void;
  39719. /**
  39720. * Dispose and release all associated resources
  39721. */
  39722. dispose(): void;
  39723. /**
  39724. * Attach a new callback raised when context lost event is fired
  39725. * @param callback defines the callback to call
  39726. */
  39727. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39728. /**
  39729. * Attach a new callback raised when context restored event is fired
  39730. * @param callback defines the callback to call
  39731. */
  39732. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39733. /**
  39734. * Get the current error code of the webGL context
  39735. * @returns the error code
  39736. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39737. */
  39738. getError(): number;
  39739. private _canRenderToFloatFramebuffer;
  39740. private _canRenderToHalfFloatFramebuffer;
  39741. private _canRenderToFramebuffer;
  39742. /** @hidden */
  39743. _getWebGLTextureType(type: number): number;
  39744. /** @hidden */
  39745. _getInternalFormat(format: number): number;
  39746. /** @hidden */
  39747. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39748. /** @hidden */
  39749. _getRGBAMultiSampleBufferFormat(type: number): number;
  39750. /** @hidden */
  39751. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  39752. /**
  39753. * Loads a file from a url
  39754. * @param url url to load
  39755. * @param onSuccess callback called when the file successfully loads
  39756. * @param onProgress callback called while file is loading (if the server supports this mode)
  39757. * @param offlineProvider defines the offline provider for caching
  39758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39759. * @param onError callback called when the file fails to load
  39760. * @returns a file request object
  39761. * @hidden
  39762. */
  39763. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  39764. /**
  39765. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39766. * @param x defines the x coordinate of the rectangle where pixels must be read
  39767. * @param y defines the y coordinate of the rectangle where pixels must be read
  39768. * @param width defines the width of the rectangle where pixels must be read
  39769. * @param height defines the height of the rectangle where pixels must be read
  39770. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39771. * @returns a Uint8Array containing RGBA colors
  39772. */
  39773. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39774. private static _IsSupported;
  39775. private static _HasMajorPerformanceCaveat;
  39776. /**
  39777. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39778. */
  39779. static get IsSupported(): boolean;
  39780. /**
  39781. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39782. * @returns true if the engine can be created
  39783. * @ignorenaming
  39784. */
  39785. static isSupported(): boolean;
  39786. /**
  39787. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  39788. */
  39789. static get HasMajorPerformanceCaveat(): boolean;
  39790. /**
  39791. * Find the next highest power of two.
  39792. * @param x Number to start search from.
  39793. * @return Next highest power of two.
  39794. */
  39795. static CeilingPOT(x: number): number;
  39796. /**
  39797. * Find the next lowest power of two.
  39798. * @param x Number to start search from.
  39799. * @return Next lowest power of two.
  39800. */
  39801. static FloorPOT(x: number): number;
  39802. /**
  39803. * Find the nearest power of two.
  39804. * @param x Number to start search from.
  39805. * @return Next nearest power of two.
  39806. */
  39807. static NearestPOT(x: number): number;
  39808. /**
  39809. * Get the closest exponent of two
  39810. * @param value defines the value to approximate
  39811. * @param max defines the maximum value to return
  39812. * @param mode defines how to define the closest value
  39813. * @returns closest exponent of two of the given value
  39814. */
  39815. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39816. /**
  39817. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39818. * @param func - the function to be called
  39819. * @param requester - the object that will request the next frame. Falls back to window.
  39820. * @returns frame number
  39821. */
  39822. static QueueNewFrame(func: () => void, requester?: any): number;
  39823. /**
  39824. * Gets host document
  39825. * @returns the host document object
  39826. */
  39827. getHostDocument(): Nullable<Document>;
  39828. }
  39829. }
  39830. declare module BABYLON {
  39831. /**
  39832. * Defines the source of the internal texture
  39833. */
  39834. export enum InternalTextureSource {
  39835. /**
  39836. * The source of the texture data is unknown
  39837. */
  39838. Unknown = 0,
  39839. /**
  39840. * Texture data comes from an URL
  39841. */
  39842. Url = 1,
  39843. /**
  39844. * Texture data is only used for temporary storage
  39845. */
  39846. Temp = 2,
  39847. /**
  39848. * Texture data comes from raw data (ArrayBuffer)
  39849. */
  39850. Raw = 3,
  39851. /**
  39852. * Texture content is dynamic (video or dynamic texture)
  39853. */
  39854. Dynamic = 4,
  39855. /**
  39856. * Texture content is generated by rendering to it
  39857. */
  39858. RenderTarget = 5,
  39859. /**
  39860. * Texture content is part of a multi render target process
  39861. */
  39862. MultiRenderTarget = 6,
  39863. /**
  39864. * Texture data comes from a cube data file
  39865. */
  39866. Cube = 7,
  39867. /**
  39868. * Texture data comes from a raw cube data
  39869. */
  39870. CubeRaw = 8,
  39871. /**
  39872. * Texture data come from a prefiltered cube data file
  39873. */
  39874. CubePrefiltered = 9,
  39875. /**
  39876. * Texture content is raw 3D data
  39877. */
  39878. Raw3D = 10,
  39879. /**
  39880. * Texture content is raw 2D array data
  39881. */
  39882. Raw2DArray = 11,
  39883. /**
  39884. * Texture content is a depth texture
  39885. */
  39886. Depth = 12,
  39887. /**
  39888. * Texture data comes from a raw cube data encoded with RGBD
  39889. */
  39890. CubeRawRGBD = 13
  39891. }
  39892. /**
  39893. * Class used to store data associated with WebGL texture data for the engine
  39894. * This class should not be used directly
  39895. */
  39896. export class InternalTexture {
  39897. /** @hidden */
  39898. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39899. /**
  39900. * Defines if the texture is ready
  39901. */
  39902. isReady: boolean;
  39903. /**
  39904. * Defines if the texture is a cube texture
  39905. */
  39906. isCube: boolean;
  39907. /**
  39908. * Defines if the texture contains 3D data
  39909. */
  39910. is3D: boolean;
  39911. /**
  39912. * Defines if the texture contains 2D array data
  39913. */
  39914. is2DArray: boolean;
  39915. /**
  39916. * Defines if the texture contains multiview data
  39917. */
  39918. isMultiview: boolean;
  39919. /**
  39920. * Gets the URL used to load this texture
  39921. */
  39922. url: string;
  39923. /**
  39924. * Gets the sampling mode of the texture
  39925. */
  39926. samplingMode: number;
  39927. /**
  39928. * Gets a boolean indicating if the texture needs mipmaps generation
  39929. */
  39930. generateMipMaps: boolean;
  39931. /**
  39932. * Gets the number of samples used by the texture (WebGL2+ only)
  39933. */
  39934. samples: number;
  39935. /**
  39936. * Gets the type of the texture (int, float...)
  39937. */
  39938. type: number;
  39939. /**
  39940. * Gets the format of the texture (RGB, RGBA...)
  39941. */
  39942. format: number;
  39943. /**
  39944. * Observable called when the texture is loaded
  39945. */
  39946. onLoadedObservable: Observable<InternalTexture>;
  39947. /**
  39948. * Gets the width of the texture
  39949. */
  39950. width: number;
  39951. /**
  39952. * Gets the height of the texture
  39953. */
  39954. height: number;
  39955. /**
  39956. * Gets the depth of the texture
  39957. */
  39958. depth: number;
  39959. /**
  39960. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39961. */
  39962. baseWidth: number;
  39963. /**
  39964. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39965. */
  39966. baseHeight: number;
  39967. /**
  39968. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39969. */
  39970. baseDepth: number;
  39971. /**
  39972. * Gets a boolean indicating if the texture is inverted on Y axis
  39973. */
  39974. invertY: boolean;
  39975. /** @hidden */
  39976. _invertVScale: boolean;
  39977. /** @hidden */
  39978. _associatedChannel: number;
  39979. /** @hidden */
  39980. _source: InternalTextureSource;
  39981. /** @hidden */
  39982. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39983. /** @hidden */
  39984. _bufferView: Nullable<ArrayBufferView>;
  39985. /** @hidden */
  39986. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39987. /** @hidden */
  39988. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39989. /** @hidden */
  39990. _size: number;
  39991. /** @hidden */
  39992. _extension: string;
  39993. /** @hidden */
  39994. _files: Nullable<string[]>;
  39995. /** @hidden */
  39996. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39997. /** @hidden */
  39998. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39999. /** @hidden */
  40000. _framebuffer: Nullable<WebGLFramebuffer>;
  40001. /** @hidden */
  40002. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40003. /** @hidden */
  40004. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40005. /** @hidden */
  40006. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40007. /** @hidden */
  40008. _attachments: Nullable<number[]>;
  40009. /** @hidden */
  40010. _textureArray: Nullable<InternalTexture[]>;
  40011. /** @hidden */
  40012. _cachedCoordinatesMode: Nullable<number>;
  40013. /** @hidden */
  40014. _cachedWrapU: Nullable<number>;
  40015. /** @hidden */
  40016. _cachedWrapV: Nullable<number>;
  40017. /** @hidden */
  40018. _cachedWrapR: Nullable<number>;
  40019. /** @hidden */
  40020. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40021. /** @hidden */
  40022. _isDisabled: boolean;
  40023. /** @hidden */
  40024. _compression: Nullable<string>;
  40025. /** @hidden */
  40026. _generateStencilBuffer: boolean;
  40027. /** @hidden */
  40028. _generateDepthBuffer: boolean;
  40029. /** @hidden */
  40030. _comparisonFunction: number;
  40031. /** @hidden */
  40032. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40033. /** @hidden */
  40034. _lodGenerationScale: number;
  40035. /** @hidden */
  40036. _lodGenerationOffset: number;
  40037. /** @hidden */
  40038. _depthStencilTexture: Nullable<InternalTexture>;
  40039. /** @hidden */
  40040. _colorTextureArray: Nullable<WebGLTexture>;
  40041. /** @hidden */
  40042. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40043. /** @hidden */
  40044. _lodTextureHigh: Nullable<BaseTexture>;
  40045. /** @hidden */
  40046. _lodTextureMid: Nullable<BaseTexture>;
  40047. /** @hidden */
  40048. _lodTextureLow: Nullable<BaseTexture>;
  40049. /** @hidden */
  40050. _isRGBD: boolean;
  40051. /** @hidden */
  40052. _linearSpecularLOD: boolean;
  40053. /** @hidden */
  40054. _irradianceTexture: Nullable<BaseTexture>;
  40055. /** @hidden */
  40056. _webGLTexture: Nullable<WebGLTexture>;
  40057. /** @hidden */
  40058. _references: number;
  40059. /** @hidden */
  40060. _gammaSpace: Nullable<boolean>;
  40061. private _engine;
  40062. /**
  40063. * Gets the Engine the texture belongs to.
  40064. * @returns The babylon engine
  40065. */
  40066. getEngine(): ThinEngine;
  40067. /**
  40068. * Gets the data source type of the texture
  40069. */
  40070. get source(): InternalTextureSource;
  40071. /**
  40072. * Creates a new InternalTexture
  40073. * @param engine defines the engine to use
  40074. * @param source defines the type of data that will be used
  40075. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40076. */
  40077. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40078. /**
  40079. * Increments the number of references (ie. the number of Texture that point to it)
  40080. */
  40081. incrementReferences(): void;
  40082. /**
  40083. * Change the size of the texture (not the size of the content)
  40084. * @param width defines the new width
  40085. * @param height defines the new height
  40086. * @param depth defines the new depth (1 by default)
  40087. */
  40088. updateSize(width: int, height: int, depth?: int): void;
  40089. /** @hidden */
  40090. _rebuild(): void;
  40091. /** @hidden */
  40092. _swapAndDie(target: InternalTexture): void;
  40093. /**
  40094. * Dispose the current allocated resources
  40095. */
  40096. dispose(): void;
  40097. }
  40098. }
  40099. declare module BABYLON {
  40100. /**
  40101. * Interface used to present a loading screen while loading a scene
  40102. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40103. */
  40104. export interface ILoadingScreen {
  40105. /**
  40106. * Function called to display the loading screen
  40107. */
  40108. displayLoadingUI: () => void;
  40109. /**
  40110. * Function called to hide the loading screen
  40111. */
  40112. hideLoadingUI: () => void;
  40113. /**
  40114. * Gets or sets the color to use for the background
  40115. */
  40116. loadingUIBackgroundColor: string;
  40117. /**
  40118. * Gets or sets the text to display while loading
  40119. */
  40120. loadingUIText: string;
  40121. }
  40122. /**
  40123. * Class used for the default loading screen
  40124. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40125. */
  40126. export class DefaultLoadingScreen implements ILoadingScreen {
  40127. private _renderingCanvas;
  40128. private _loadingText;
  40129. private _loadingDivBackgroundColor;
  40130. private _loadingDiv;
  40131. private _loadingTextDiv;
  40132. /** Gets or sets the logo url to use for the default loading screen */
  40133. static DefaultLogoUrl: string;
  40134. /** Gets or sets the spinner url to use for the default loading screen */
  40135. static DefaultSpinnerUrl: string;
  40136. /**
  40137. * Creates a new default loading screen
  40138. * @param _renderingCanvas defines the canvas used to render the scene
  40139. * @param _loadingText defines the default text to display
  40140. * @param _loadingDivBackgroundColor defines the default background color
  40141. */
  40142. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40143. /**
  40144. * Function called to display the loading screen
  40145. */
  40146. displayLoadingUI(): void;
  40147. /**
  40148. * Function called to hide the loading screen
  40149. */
  40150. hideLoadingUI(): void;
  40151. /**
  40152. * Gets or sets the text to display while loading
  40153. */
  40154. set loadingUIText(text: string);
  40155. get loadingUIText(): string;
  40156. /**
  40157. * Gets or sets the color to use for the background
  40158. */
  40159. get loadingUIBackgroundColor(): string;
  40160. set loadingUIBackgroundColor(color: string);
  40161. private _resizeLoadingUI;
  40162. }
  40163. }
  40164. declare module BABYLON {
  40165. /**
  40166. * Interface for any object that can request an animation frame
  40167. */
  40168. export interface ICustomAnimationFrameRequester {
  40169. /**
  40170. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40171. */
  40172. renderFunction?: Function;
  40173. /**
  40174. * Called to request the next frame to render to
  40175. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40176. */
  40177. requestAnimationFrame: Function;
  40178. /**
  40179. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40180. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40181. */
  40182. requestID?: number;
  40183. }
  40184. }
  40185. declare module BABYLON {
  40186. /**
  40187. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40188. */
  40189. export class PerformanceMonitor {
  40190. private _enabled;
  40191. private _rollingFrameTime;
  40192. private _lastFrameTimeMs;
  40193. /**
  40194. * constructor
  40195. * @param frameSampleSize The number of samples required to saturate the sliding window
  40196. */
  40197. constructor(frameSampleSize?: number);
  40198. /**
  40199. * Samples current frame
  40200. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40201. */
  40202. sampleFrame(timeMs?: number): void;
  40203. /**
  40204. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40205. */
  40206. get averageFrameTime(): number;
  40207. /**
  40208. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40209. */
  40210. get averageFrameTimeVariance(): number;
  40211. /**
  40212. * Returns the frame time of the most recent frame
  40213. */
  40214. get instantaneousFrameTime(): number;
  40215. /**
  40216. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40217. */
  40218. get averageFPS(): number;
  40219. /**
  40220. * Returns the average framerate in frames per second using the most recent frame time
  40221. */
  40222. get instantaneousFPS(): number;
  40223. /**
  40224. * Returns true if enough samples have been taken to completely fill the sliding window
  40225. */
  40226. get isSaturated(): boolean;
  40227. /**
  40228. * Enables contributions to the sliding window sample set
  40229. */
  40230. enable(): void;
  40231. /**
  40232. * Disables contributions to the sliding window sample set
  40233. * Samples will not be interpolated over the disabled period
  40234. */
  40235. disable(): void;
  40236. /**
  40237. * Returns true if sampling is enabled
  40238. */
  40239. get isEnabled(): boolean;
  40240. /**
  40241. * Resets performance monitor
  40242. */
  40243. reset(): void;
  40244. }
  40245. /**
  40246. * RollingAverage
  40247. *
  40248. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40249. */
  40250. export class RollingAverage {
  40251. /**
  40252. * Current average
  40253. */
  40254. average: number;
  40255. /**
  40256. * Current variance
  40257. */
  40258. variance: number;
  40259. protected _samples: Array<number>;
  40260. protected _sampleCount: number;
  40261. protected _pos: number;
  40262. protected _m2: number;
  40263. /**
  40264. * constructor
  40265. * @param length The number of samples required to saturate the sliding window
  40266. */
  40267. constructor(length: number);
  40268. /**
  40269. * Adds a sample to the sample set
  40270. * @param v The sample value
  40271. */
  40272. add(v: number): void;
  40273. /**
  40274. * Returns previously added values or null if outside of history or outside the sliding window domain
  40275. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40276. * @return Value previously recorded with add() or null if outside of range
  40277. */
  40278. history(i: number): number;
  40279. /**
  40280. * Returns true if enough samples have been taken to completely fill the sliding window
  40281. * @return true if sample-set saturated
  40282. */
  40283. isSaturated(): boolean;
  40284. /**
  40285. * Resets the rolling average (equivalent to 0 samples taken so far)
  40286. */
  40287. reset(): void;
  40288. /**
  40289. * Wraps a value around the sample range boundaries
  40290. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40291. * @return Wrapped position in sample range
  40292. */
  40293. protected _wrapPosition(i: number): number;
  40294. }
  40295. }
  40296. declare module BABYLON {
  40297. /**
  40298. * This class is used to track a performance counter which is number based.
  40299. * The user has access to many properties which give statistics of different nature.
  40300. *
  40301. * The implementer can track two kinds of Performance Counter: time and count.
  40302. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  40303. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  40304. */
  40305. export class PerfCounter {
  40306. /**
  40307. * Gets or sets a global boolean to turn on and off all the counters
  40308. */
  40309. static Enabled: boolean;
  40310. /**
  40311. * Returns the smallest value ever
  40312. */
  40313. get min(): number;
  40314. /**
  40315. * Returns the biggest value ever
  40316. */
  40317. get max(): number;
  40318. /**
  40319. * Returns the average value since the performance counter is running
  40320. */
  40321. get average(): number;
  40322. /**
  40323. * Returns the average value of the last second the counter was monitored
  40324. */
  40325. get lastSecAverage(): number;
  40326. /**
  40327. * Returns the current value
  40328. */
  40329. get current(): number;
  40330. /**
  40331. * Gets the accumulated total
  40332. */
  40333. get total(): number;
  40334. /**
  40335. * Gets the total value count
  40336. */
  40337. get count(): number;
  40338. /**
  40339. * Creates a new counter
  40340. */
  40341. constructor();
  40342. /**
  40343. * Call this method to start monitoring a new frame.
  40344. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  40345. */
  40346. fetchNewFrame(): void;
  40347. /**
  40348. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40349. * @param newCount the count value to add to the monitored count
  40350. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  40351. */
  40352. addCount(newCount: number, fetchResult: boolean): void;
  40353. /**
  40354. * Start monitoring this performance counter
  40355. */
  40356. beginMonitoring(): void;
  40357. /**
  40358. * Compute the time lapsed since the previous beginMonitoring() call.
  40359. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  40360. */
  40361. endMonitoring(newFrame?: boolean): void;
  40362. private _fetchResult;
  40363. private _startMonitoringTime;
  40364. private _min;
  40365. private _max;
  40366. private _average;
  40367. private _current;
  40368. private _totalValueCount;
  40369. private _totalAccumulated;
  40370. private _lastSecAverage;
  40371. private _lastSecAccumulated;
  40372. private _lastSecTime;
  40373. private _lastSecValueCount;
  40374. }
  40375. }
  40376. declare module BABYLON {
  40377. interface ThinEngine {
  40378. /** @hidden */
  40379. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40380. }
  40381. }
  40382. declare module BABYLON {
  40383. /**
  40384. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40385. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40386. */
  40387. export class Analyser {
  40388. /**
  40389. * Gets or sets the smoothing
  40390. * @ignorenaming
  40391. */
  40392. SMOOTHING: number;
  40393. /**
  40394. * Gets or sets the FFT table size
  40395. * @ignorenaming
  40396. */
  40397. FFT_SIZE: number;
  40398. /**
  40399. * Gets or sets the bar graph amplitude
  40400. * @ignorenaming
  40401. */
  40402. BARGRAPHAMPLITUDE: number;
  40403. /**
  40404. * Gets or sets the position of the debug canvas
  40405. * @ignorenaming
  40406. */
  40407. DEBUGCANVASPOS: {
  40408. x: number;
  40409. y: number;
  40410. };
  40411. /**
  40412. * Gets or sets the debug canvas size
  40413. * @ignorenaming
  40414. */
  40415. DEBUGCANVASSIZE: {
  40416. width: number;
  40417. height: number;
  40418. };
  40419. private _byteFreqs;
  40420. private _byteTime;
  40421. private _floatFreqs;
  40422. private _webAudioAnalyser;
  40423. private _debugCanvas;
  40424. private _debugCanvasContext;
  40425. private _scene;
  40426. private _registerFunc;
  40427. private _audioEngine;
  40428. /**
  40429. * Creates a new analyser
  40430. * @param scene defines hosting scene
  40431. */
  40432. constructor(scene: Scene);
  40433. /**
  40434. * Get the number of data values you will have to play with for the visualization
  40435. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40436. * @returns a number
  40437. */
  40438. getFrequencyBinCount(): number;
  40439. /**
  40440. * Gets the current frequency data as a byte array
  40441. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40442. * @returns a Uint8Array
  40443. */
  40444. getByteFrequencyData(): Uint8Array;
  40445. /**
  40446. * Gets the current waveform as a byte array
  40447. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40448. * @returns a Uint8Array
  40449. */
  40450. getByteTimeDomainData(): Uint8Array;
  40451. /**
  40452. * Gets the current frequency data as a float array
  40453. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40454. * @returns a Float32Array
  40455. */
  40456. getFloatFrequencyData(): Float32Array;
  40457. /**
  40458. * Renders the debug canvas
  40459. */
  40460. drawDebugCanvas(): void;
  40461. /**
  40462. * Stops rendering the debug canvas and removes it
  40463. */
  40464. stopDebugCanvas(): void;
  40465. /**
  40466. * Connects two audio nodes
  40467. * @param inputAudioNode defines first node to connect
  40468. * @param outputAudioNode defines second node to connect
  40469. */
  40470. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40471. /**
  40472. * Releases all associated resources
  40473. */
  40474. dispose(): void;
  40475. }
  40476. }
  40477. declare module BABYLON {
  40478. /**
  40479. * This represents an audio engine and it is responsible
  40480. * to play, synchronize and analyse sounds throughout the application.
  40481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40482. */
  40483. export interface IAudioEngine extends IDisposable {
  40484. /**
  40485. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40486. */
  40487. readonly canUseWebAudio: boolean;
  40488. /**
  40489. * Gets the current AudioContext if available.
  40490. */
  40491. readonly audioContext: Nullable<AudioContext>;
  40492. /**
  40493. * The master gain node defines the global audio volume of your audio engine.
  40494. */
  40495. readonly masterGain: GainNode;
  40496. /**
  40497. * Gets whether or not mp3 are supported by your browser.
  40498. */
  40499. readonly isMP3supported: boolean;
  40500. /**
  40501. * Gets whether or not ogg are supported by your browser.
  40502. */
  40503. readonly isOGGsupported: boolean;
  40504. /**
  40505. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40506. * @ignoreNaming
  40507. */
  40508. WarnedWebAudioUnsupported: boolean;
  40509. /**
  40510. * Defines if the audio engine relies on a custom unlocked button.
  40511. * In this case, the embedded button will not be displayed.
  40512. */
  40513. useCustomUnlockedButton: boolean;
  40514. /**
  40515. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40516. */
  40517. readonly unlocked: boolean;
  40518. /**
  40519. * Event raised when audio has been unlocked on the browser.
  40520. */
  40521. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40522. /**
  40523. * Event raised when audio has been locked on the browser.
  40524. */
  40525. onAudioLockedObservable: Observable<IAudioEngine>;
  40526. /**
  40527. * Flags the audio engine in Locked state.
  40528. * This happens due to new browser policies preventing audio to autoplay.
  40529. */
  40530. lock(): void;
  40531. /**
  40532. * Unlocks the audio engine once a user action has been done on the dom.
  40533. * This is helpful to resume play once browser policies have been satisfied.
  40534. */
  40535. unlock(): void;
  40536. /**
  40537. * Gets the global volume sets on the master gain.
  40538. * @returns the global volume if set or -1 otherwise
  40539. */
  40540. getGlobalVolume(): number;
  40541. /**
  40542. * Sets the global volume of your experience (sets on the master gain).
  40543. * @param newVolume Defines the new global volume of the application
  40544. */
  40545. setGlobalVolume(newVolume: number): void;
  40546. /**
  40547. * Connect the audio engine to an audio analyser allowing some amazing
  40548. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40550. * @param analyser The analyser to connect to the engine
  40551. */
  40552. connectToAnalyser(analyser: Analyser): void;
  40553. }
  40554. }
  40555. declare module BABYLON {
  40556. /**
  40557. * Defines the interface used by display changed events
  40558. */
  40559. export interface IDisplayChangedEventArgs {
  40560. /** Gets the vrDisplay object (if any) */
  40561. vrDisplay: Nullable<any>;
  40562. /** Gets a boolean indicating if webVR is supported */
  40563. vrSupported: boolean;
  40564. }
  40565. /**
  40566. * Defines the interface used by objects containing a viewport (like a camera)
  40567. */
  40568. interface IViewportOwnerLike {
  40569. /**
  40570. * Gets or sets the viewport
  40571. */
  40572. viewport: IViewportLike;
  40573. }
  40574. /**
  40575. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40576. */
  40577. export class Engine extends ThinEngine {
  40578. /** Defines that alpha blending is disabled */
  40579. static readonly ALPHA_DISABLE: number;
  40580. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40581. static readonly ALPHA_ADD: number;
  40582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40583. static readonly ALPHA_COMBINE: number;
  40584. /** Defines that alpha blending to DEST - SRC * DEST */
  40585. static readonly ALPHA_SUBTRACT: number;
  40586. /** Defines that alpha blending to SRC * DEST */
  40587. static readonly ALPHA_MULTIPLY: number;
  40588. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40589. static readonly ALPHA_MAXIMIZED: number;
  40590. /** Defines that alpha blending to SRC + DEST */
  40591. static readonly ALPHA_ONEONE: number;
  40592. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40593. static readonly ALPHA_PREMULTIPLIED: number;
  40594. /**
  40595. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40596. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40597. */
  40598. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40599. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40600. static readonly ALPHA_INTERPOLATE: number;
  40601. /**
  40602. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40603. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40604. */
  40605. static readonly ALPHA_SCREENMODE: number;
  40606. /** Defines that the ressource is not delayed*/
  40607. static readonly DELAYLOADSTATE_NONE: number;
  40608. /** Defines that the ressource was successfully delay loaded */
  40609. static readonly DELAYLOADSTATE_LOADED: number;
  40610. /** Defines that the ressource is currently delay loading */
  40611. static readonly DELAYLOADSTATE_LOADING: number;
  40612. /** Defines that the ressource is delayed and has not started loading */
  40613. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40615. static readonly NEVER: number;
  40616. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  40617. static readonly ALWAYS: number;
  40618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40619. static readonly LESS: number;
  40620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40621. static readonly EQUAL: number;
  40622. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  40623. static readonly LEQUAL: number;
  40624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40625. static readonly GREATER: number;
  40626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  40627. static readonly GEQUAL: number;
  40628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  40629. static readonly NOTEQUAL: number;
  40630. /** Passed to stencilOperation to specify that stencil value must be kept */
  40631. static readonly KEEP: number;
  40632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40633. static readonly REPLACE: number;
  40634. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40635. static readonly INCR: number;
  40636. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40637. static readonly DECR: number;
  40638. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40639. static readonly INVERT: number;
  40640. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40641. static readonly INCR_WRAP: number;
  40642. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40643. static readonly DECR_WRAP: number;
  40644. /** Texture is not repeating outside of 0..1 UVs */
  40645. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40646. /** Texture is repeating outside of 0..1 UVs */
  40647. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40648. /** Texture is repeating and mirrored */
  40649. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40650. /** ALPHA */
  40651. static readonly TEXTUREFORMAT_ALPHA: number;
  40652. /** LUMINANCE */
  40653. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40654. /** LUMINANCE_ALPHA */
  40655. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40656. /** RGB */
  40657. static readonly TEXTUREFORMAT_RGB: number;
  40658. /** RGBA */
  40659. static readonly TEXTUREFORMAT_RGBA: number;
  40660. /** RED */
  40661. static readonly TEXTUREFORMAT_RED: number;
  40662. /** RED (2nd reference) */
  40663. static readonly TEXTUREFORMAT_R: number;
  40664. /** RG */
  40665. static readonly TEXTUREFORMAT_RG: number;
  40666. /** RED_INTEGER */
  40667. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40668. /** RED_INTEGER (2nd reference) */
  40669. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40670. /** RG_INTEGER */
  40671. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40672. /** RGB_INTEGER */
  40673. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40674. /** RGBA_INTEGER */
  40675. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40676. /** UNSIGNED_BYTE */
  40677. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40678. /** UNSIGNED_BYTE (2nd reference) */
  40679. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40680. /** FLOAT */
  40681. static readonly TEXTURETYPE_FLOAT: number;
  40682. /** HALF_FLOAT */
  40683. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40684. /** BYTE */
  40685. static readonly TEXTURETYPE_BYTE: number;
  40686. /** SHORT */
  40687. static readonly TEXTURETYPE_SHORT: number;
  40688. /** UNSIGNED_SHORT */
  40689. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40690. /** INT */
  40691. static readonly TEXTURETYPE_INT: number;
  40692. /** UNSIGNED_INT */
  40693. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40694. /** UNSIGNED_SHORT_4_4_4_4 */
  40695. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40696. /** UNSIGNED_SHORT_5_5_5_1 */
  40697. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40698. /** UNSIGNED_SHORT_5_6_5 */
  40699. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40700. /** UNSIGNED_INT_2_10_10_10_REV */
  40701. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40702. /** UNSIGNED_INT_24_8 */
  40703. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40704. /** UNSIGNED_INT_10F_11F_11F_REV */
  40705. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40706. /** UNSIGNED_INT_5_9_9_9_REV */
  40707. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40708. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40709. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40710. /** nearest is mag = nearest and min = nearest and mip = linear */
  40711. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40713. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40714. /** Trilinear is mag = linear and min = linear and mip = linear */
  40715. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40716. /** nearest is mag = nearest and min = nearest and mip = linear */
  40717. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40718. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40719. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40720. /** Trilinear is mag = linear and min = linear and mip = linear */
  40721. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40722. /** mag = nearest and min = nearest and mip = nearest */
  40723. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40724. /** mag = nearest and min = linear and mip = nearest */
  40725. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40726. /** mag = nearest and min = linear and mip = linear */
  40727. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40728. /** mag = nearest and min = linear and mip = none */
  40729. static readonly TEXTURE_NEAREST_LINEAR: number;
  40730. /** mag = nearest and min = nearest and mip = none */
  40731. static readonly TEXTURE_NEAREST_NEAREST: number;
  40732. /** mag = linear and min = nearest and mip = nearest */
  40733. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40734. /** mag = linear and min = nearest and mip = linear */
  40735. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40736. /** mag = linear and min = linear and mip = none */
  40737. static readonly TEXTURE_LINEAR_LINEAR: number;
  40738. /** mag = linear and min = nearest and mip = none */
  40739. static readonly TEXTURE_LINEAR_NEAREST: number;
  40740. /** Explicit coordinates mode */
  40741. static readonly TEXTURE_EXPLICIT_MODE: number;
  40742. /** Spherical coordinates mode */
  40743. static readonly TEXTURE_SPHERICAL_MODE: number;
  40744. /** Planar coordinates mode */
  40745. static readonly TEXTURE_PLANAR_MODE: number;
  40746. /** Cubic coordinates mode */
  40747. static readonly TEXTURE_CUBIC_MODE: number;
  40748. /** Projection coordinates mode */
  40749. static readonly TEXTURE_PROJECTION_MODE: number;
  40750. /** Skybox coordinates mode */
  40751. static readonly TEXTURE_SKYBOX_MODE: number;
  40752. /** Inverse Cubic coordinates mode */
  40753. static readonly TEXTURE_INVCUBIC_MODE: number;
  40754. /** Equirectangular coordinates mode */
  40755. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40756. /** Equirectangular Fixed coordinates mode */
  40757. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40758. /** Equirectangular Fixed Mirrored coordinates mode */
  40759. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40760. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40761. static readonly SCALEMODE_FLOOR: number;
  40762. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40763. static readonly SCALEMODE_NEAREST: number;
  40764. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40765. static readonly SCALEMODE_CEILING: number;
  40766. /**
  40767. * Returns the current npm package of the sdk
  40768. */
  40769. static get NpmPackage(): string;
  40770. /**
  40771. * Returns the current version of the framework
  40772. */
  40773. static get Version(): string;
  40774. /** Gets the list of created engines */
  40775. static get Instances(): Engine[];
  40776. /**
  40777. * Gets the latest created engine
  40778. */
  40779. static get LastCreatedEngine(): Nullable<Engine>;
  40780. /**
  40781. * Gets the latest created scene
  40782. */
  40783. static get LastCreatedScene(): Nullable<Scene>;
  40784. /**
  40785. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40786. * @param flag defines which part of the materials must be marked as dirty
  40787. * @param predicate defines a predicate used to filter which materials should be affected
  40788. */
  40789. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40790. /**
  40791. * Method called to create the default loading screen.
  40792. * This can be overriden in your own app.
  40793. * @param canvas The rendering canvas element
  40794. * @returns The loading screen
  40795. */
  40796. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40797. /**
  40798. * Method called to create the default rescale post process on each engine.
  40799. */
  40800. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40801. /**
  40802. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40803. **/
  40804. enableOfflineSupport: boolean;
  40805. /**
  40806. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  40807. **/
  40808. disableManifestCheck: boolean;
  40809. /**
  40810. * Gets the list of created scenes
  40811. */
  40812. scenes: Scene[];
  40813. /**
  40814. * Event raised when a new scene is created
  40815. */
  40816. onNewSceneAddedObservable: Observable<Scene>;
  40817. /**
  40818. * Gets the list of created postprocesses
  40819. */
  40820. postProcesses: PostProcess[];
  40821. /**
  40822. * Gets a boolean indicating if the pointer is currently locked
  40823. */
  40824. isPointerLock: boolean;
  40825. /**
  40826. * Observable event triggered each time the rendering canvas is resized
  40827. */
  40828. onResizeObservable: Observable<Engine>;
  40829. /**
  40830. * Observable event triggered each time the canvas loses focus
  40831. */
  40832. onCanvasBlurObservable: Observable<Engine>;
  40833. /**
  40834. * Observable event triggered each time the canvas gains focus
  40835. */
  40836. onCanvasFocusObservable: Observable<Engine>;
  40837. /**
  40838. * Observable event triggered each time the canvas receives pointerout event
  40839. */
  40840. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40841. /**
  40842. * Observable raised when the engine begins a new frame
  40843. */
  40844. onBeginFrameObservable: Observable<Engine>;
  40845. /**
  40846. * If set, will be used to request the next animation frame for the render loop
  40847. */
  40848. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40849. /**
  40850. * Observable raised when the engine ends the current frame
  40851. */
  40852. onEndFrameObservable: Observable<Engine>;
  40853. /**
  40854. * Observable raised when the engine is about to compile a shader
  40855. */
  40856. onBeforeShaderCompilationObservable: Observable<Engine>;
  40857. /**
  40858. * Observable raised when the engine has jsut compiled a shader
  40859. */
  40860. onAfterShaderCompilationObservable: Observable<Engine>;
  40861. /**
  40862. * Gets the audio engine
  40863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40864. * @ignorenaming
  40865. */
  40866. static audioEngine: IAudioEngine;
  40867. /**
  40868. * Default AudioEngine factory responsible of creating the Audio Engine.
  40869. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40870. */
  40871. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40872. /**
  40873. * Default offline support factory responsible of creating a tool used to store data locally.
  40874. * By default, this will create a Database object if the workload has been embedded.
  40875. */
  40876. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40877. private _loadingScreen;
  40878. private _pointerLockRequested;
  40879. private _rescalePostProcess;
  40880. private _deterministicLockstep;
  40881. private _lockstepMaxSteps;
  40882. private _timeStep;
  40883. protected get _supportsHardwareTextureRescaling(): boolean;
  40884. private _fps;
  40885. private _deltaTime;
  40886. /** @hidden */
  40887. _drawCalls: PerfCounter;
  40888. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  40889. canvasTabIndex: number;
  40890. /**
  40891. * Turn this value on if you want to pause FPS computation when in background
  40892. */
  40893. disablePerformanceMonitorInBackground: boolean;
  40894. private _performanceMonitor;
  40895. /**
  40896. * Gets the performance monitor attached to this engine
  40897. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40898. */
  40899. get performanceMonitor(): PerformanceMonitor;
  40900. private _onFocus;
  40901. private _onBlur;
  40902. private _onCanvasPointerOut;
  40903. private _onCanvasBlur;
  40904. private _onCanvasFocus;
  40905. private _onFullscreenChange;
  40906. private _onPointerLockChange;
  40907. /**
  40908. * Gets the HTML element used to attach event listeners
  40909. * @returns a HTML element
  40910. */
  40911. getInputElement(): Nullable<HTMLElement>;
  40912. /**
  40913. * Creates a new engine
  40914. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  40915. * @param antialias defines enable antialiasing (default: false)
  40916. * @param options defines further options to be sent to the getContext() function
  40917. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40918. */
  40919. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40920. /**
  40921. * Gets current aspect ratio
  40922. * @param viewportOwner defines the camera to use to get the aspect ratio
  40923. * @param useScreen defines if screen size must be used (or the current render target if any)
  40924. * @returns a number defining the aspect ratio
  40925. */
  40926. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40927. /**
  40928. * Gets current screen aspect ratio
  40929. * @returns a number defining the aspect ratio
  40930. */
  40931. getScreenAspectRatio(): number;
  40932. /**
  40933. * Gets the client rect of the HTML canvas attached with the current webGL context
  40934. * @returns a client rectanglee
  40935. */
  40936. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40937. /**
  40938. * Gets the client rect of the HTML element used for events
  40939. * @returns a client rectanglee
  40940. */
  40941. getInputElementClientRect(): Nullable<ClientRect>;
  40942. /**
  40943. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40945. * @returns true if engine is in deterministic lock step mode
  40946. */
  40947. isDeterministicLockStep(): boolean;
  40948. /**
  40949. * Gets the max steps when engine is running in deterministic lock step
  40950. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40951. * @returns the max steps
  40952. */
  40953. getLockstepMaxSteps(): number;
  40954. /**
  40955. * Returns the time in ms between steps when using deterministic lock step.
  40956. * @returns time step in (ms)
  40957. */
  40958. getTimeStep(): number;
  40959. /**
  40960. * Force the mipmap generation for the given render target texture
  40961. * @param texture defines the render target texture to use
  40962. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40963. */
  40964. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40965. /** States */
  40966. /**
  40967. * Set various states to the webGL context
  40968. * @param culling defines backface culling state
  40969. * @param zOffset defines the value to apply to zOffset (0 by default)
  40970. * @param force defines if states must be applied even if cache is up to date
  40971. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40972. */
  40973. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40974. /**
  40975. * Set the z offset to apply to current rendering
  40976. * @param value defines the offset to apply
  40977. */
  40978. setZOffset(value: number): void;
  40979. /**
  40980. * Gets the current value of the zOffset
  40981. * @returns the current zOffset state
  40982. */
  40983. getZOffset(): number;
  40984. /**
  40985. * Enable or disable depth buffering
  40986. * @param enable defines the state to set
  40987. */
  40988. setDepthBuffer(enable: boolean): void;
  40989. /**
  40990. * Gets a boolean indicating if depth writing is enabled
  40991. * @returns the current depth writing state
  40992. */
  40993. getDepthWrite(): boolean;
  40994. /**
  40995. * Enable or disable depth writing
  40996. * @param enable defines the state to set
  40997. */
  40998. setDepthWrite(enable: boolean): void;
  40999. /**
  41000. * Gets a boolean indicating if stencil buffer is enabled
  41001. * @returns the current stencil buffer state
  41002. */
  41003. getStencilBuffer(): boolean;
  41004. /**
  41005. * Enable or disable the stencil buffer
  41006. * @param enable defines if the stencil buffer must be enabled or disabled
  41007. */
  41008. setStencilBuffer(enable: boolean): void;
  41009. /**
  41010. * Gets the current stencil mask
  41011. * @returns a number defining the new stencil mask to use
  41012. */
  41013. getStencilMask(): number;
  41014. /**
  41015. * Sets the current stencil mask
  41016. * @param mask defines the new stencil mask to use
  41017. */
  41018. setStencilMask(mask: number): void;
  41019. /**
  41020. * Gets the current stencil function
  41021. * @returns a number defining the stencil function to use
  41022. */
  41023. getStencilFunction(): number;
  41024. /**
  41025. * Gets the current stencil reference value
  41026. * @returns a number defining the stencil reference value to use
  41027. */
  41028. getStencilFunctionReference(): number;
  41029. /**
  41030. * Gets the current stencil mask
  41031. * @returns a number defining the stencil mask to use
  41032. */
  41033. getStencilFunctionMask(): number;
  41034. /**
  41035. * Sets the current stencil function
  41036. * @param stencilFunc defines the new stencil function to use
  41037. */
  41038. setStencilFunction(stencilFunc: number): void;
  41039. /**
  41040. * Sets the current stencil reference
  41041. * @param reference defines the new stencil reference to use
  41042. */
  41043. setStencilFunctionReference(reference: number): void;
  41044. /**
  41045. * Sets the current stencil mask
  41046. * @param mask defines the new stencil mask to use
  41047. */
  41048. setStencilFunctionMask(mask: number): void;
  41049. /**
  41050. * Gets the current stencil operation when stencil fails
  41051. * @returns a number defining stencil operation to use when stencil fails
  41052. */
  41053. getStencilOperationFail(): number;
  41054. /**
  41055. * Gets the current stencil operation when depth fails
  41056. * @returns a number defining stencil operation to use when depth fails
  41057. */
  41058. getStencilOperationDepthFail(): number;
  41059. /**
  41060. * Gets the current stencil operation when stencil passes
  41061. * @returns a number defining stencil operation to use when stencil passes
  41062. */
  41063. getStencilOperationPass(): number;
  41064. /**
  41065. * Sets the stencil operation to use when stencil fails
  41066. * @param operation defines the stencil operation to use when stencil fails
  41067. */
  41068. setStencilOperationFail(operation: number): void;
  41069. /**
  41070. * Sets the stencil operation to use when depth fails
  41071. * @param operation defines the stencil operation to use when depth fails
  41072. */
  41073. setStencilOperationDepthFail(operation: number): void;
  41074. /**
  41075. * Sets the stencil operation to use when stencil passes
  41076. * @param operation defines the stencil operation to use when stencil passes
  41077. */
  41078. setStencilOperationPass(operation: number): void;
  41079. /**
  41080. * Sets a boolean indicating if the dithering state is enabled or disabled
  41081. * @param value defines the dithering state
  41082. */
  41083. setDitheringState(value: boolean): void;
  41084. /**
  41085. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41086. * @param value defines the rasterizer state
  41087. */
  41088. setRasterizerState(value: boolean): void;
  41089. /**
  41090. * Gets the current depth function
  41091. * @returns a number defining the depth function
  41092. */
  41093. getDepthFunction(): Nullable<number>;
  41094. /**
  41095. * Sets the current depth function
  41096. * @param depthFunc defines the function to use
  41097. */
  41098. setDepthFunction(depthFunc: number): void;
  41099. /**
  41100. * Sets the current depth function to GREATER
  41101. */
  41102. setDepthFunctionToGreater(): void;
  41103. /**
  41104. * Sets the current depth function to GEQUAL
  41105. */
  41106. setDepthFunctionToGreaterOrEqual(): void;
  41107. /**
  41108. * Sets the current depth function to LESS
  41109. */
  41110. setDepthFunctionToLess(): void;
  41111. /**
  41112. * Sets the current depth function to LEQUAL
  41113. */
  41114. setDepthFunctionToLessOrEqual(): void;
  41115. private _cachedStencilBuffer;
  41116. private _cachedStencilFunction;
  41117. private _cachedStencilMask;
  41118. private _cachedStencilOperationPass;
  41119. private _cachedStencilOperationFail;
  41120. private _cachedStencilOperationDepthFail;
  41121. private _cachedStencilReference;
  41122. /**
  41123. * Caches the the state of the stencil buffer
  41124. */
  41125. cacheStencilState(): void;
  41126. /**
  41127. * Restores the state of the stencil buffer
  41128. */
  41129. restoreStencilState(): void;
  41130. /**
  41131. * Directly set the WebGL Viewport
  41132. * @param x defines the x coordinate of the viewport (in screen space)
  41133. * @param y defines the y coordinate of the viewport (in screen space)
  41134. * @param width defines the width of the viewport (in screen space)
  41135. * @param height defines the height of the viewport (in screen space)
  41136. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  41137. */
  41138. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41139. /**
  41140. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41141. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41142. * @param y defines the y-coordinate of the corner of the clear rectangle
  41143. * @param width defines the width of the clear rectangle
  41144. * @param height defines the height of the clear rectangle
  41145. * @param clearColor defines the clear color
  41146. */
  41147. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41148. /**
  41149. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41150. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41151. * @param y defines the y-coordinate of the corner of the clear rectangle
  41152. * @param width defines the width of the clear rectangle
  41153. * @param height defines the height of the clear rectangle
  41154. */
  41155. enableScissor(x: number, y: number, width: number, height: number): void;
  41156. /**
  41157. * Disable previously set scissor test rectangle
  41158. */
  41159. disableScissor(): void;
  41160. protected _reportDrawCall(): void;
  41161. /**
  41162. * Initializes a webVR display and starts listening to display change events
  41163. * The onVRDisplayChangedObservable will be notified upon these changes
  41164. * @returns The onVRDisplayChangedObservable
  41165. */
  41166. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41167. /** @hidden */
  41168. _prepareVRComponent(): void;
  41169. /** @hidden */
  41170. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41171. /** @hidden */
  41172. _submitVRFrame(): void;
  41173. /**
  41174. * Call this function to leave webVR mode
  41175. * Will do nothing if webVR is not supported or if there is no webVR device
  41176. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41177. */
  41178. disableVR(): void;
  41179. /**
  41180. * Gets a boolean indicating that the system is in VR mode and is presenting
  41181. * @returns true if VR mode is engaged
  41182. */
  41183. isVRPresenting(): boolean;
  41184. /** @hidden */
  41185. _requestVRFrame(): void;
  41186. /** @hidden */
  41187. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41188. /**
  41189. * Gets the source code of the vertex shader associated with a specific webGL program
  41190. * @param program defines the program to use
  41191. * @returns a string containing the source code of the vertex shader associated with the program
  41192. */
  41193. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41194. /**
  41195. * Gets the source code of the fragment shader associated with a specific webGL program
  41196. * @param program defines the program to use
  41197. * @returns a string containing the source code of the fragment shader associated with the program
  41198. */
  41199. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41200. /**
  41201. * Sets a depth stencil texture from a render target to the according uniform.
  41202. * @param channel The texture channel
  41203. * @param uniform The uniform to set
  41204. * @param texture The render target texture containing the depth stencil texture to apply
  41205. */
  41206. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41207. /**
  41208. * Sets a texture to the webGL context from a postprocess
  41209. * @param channel defines the channel to use
  41210. * @param postProcess defines the source postprocess
  41211. */
  41212. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41213. /**
  41214. * Binds the output of the passed in post process to the texture channel specified
  41215. * @param channel The channel the texture should be bound to
  41216. * @param postProcess The post process which's output should be bound
  41217. */
  41218. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41219. protected _rebuildBuffers(): void;
  41220. /** @hidden */
  41221. _renderFrame(): void;
  41222. _renderLoop(): void;
  41223. /** @hidden */
  41224. _renderViews(): boolean;
  41225. /**
  41226. * Toggle full screen mode
  41227. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41228. */
  41229. switchFullscreen(requestPointerLock: boolean): void;
  41230. /**
  41231. * Enters full screen mode
  41232. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41233. */
  41234. enterFullscreen(requestPointerLock: boolean): void;
  41235. /**
  41236. * Exits full screen mode
  41237. */
  41238. exitFullscreen(): void;
  41239. /**
  41240. * Enters Pointerlock mode
  41241. */
  41242. enterPointerlock(): void;
  41243. /**
  41244. * Exits Pointerlock mode
  41245. */
  41246. exitPointerlock(): void;
  41247. /**
  41248. * Begin a new frame
  41249. */
  41250. beginFrame(): void;
  41251. /**
  41252. * Enf the current frame
  41253. */
  41254. endFrame(): void;
  41255. resize(): void;
  41256. /**
  41257. * Force a specific size of the canvas
  41258. * @param width defines the new canvas' width
  41259. * @param height defines the new canvas' height
  41260. * @returns true if the size was changed
  41261. */
  41262. setSize(width: number, height: number): boolean;
  41263. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41265. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41266. _releaseTexture(texture: InternalTexture): void;
  41267. /**
  41268. * @hidden
  41269. * Rescales a texture
  41270. * @param source input texutre
  41271. * @param destination destination texture
  41272. * @param scene scene to use to render the resize
  41273. * @param internalFormat format to use when resizing
  41274. * @param onComplete callback to be called when resize has completed
  41275. */
  41276. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41277. /**
  41278. * Gets the current framerate
  41279. * @returns a number representing the framerate
  41280. */
  41281. getFps(): number;
  41282. /**
  41283. * Gets the time spent between current and previous frame
  41284. * @returns a number representing the delta time in ms
  41285. */
  41286. getDeltaTime(): number;
  41287. private _measureFps;
  41288. /** @hidden */
  41289. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41290. /**
  41291. * Updates the sample count of a render target texture
  41292. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41293. * @param texture defines the texture to update
  41294. * @param samples defines the sample count to set
  41295. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41296. */
  41297. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41298. /**
  41299. * Updates a depth texture Comparison Mode and Function.
  41300. * If the comparison Function is equal to 0, the mode will be set to none.
  41301. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41302. * @param texture The texture to set the comparison function for
  41303. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41304. */
  41305. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41306. /**
  41307. * Creates a webGL buffer to use with instanciation
  41308. * @param capacity defines the size of the buffer
  41309. * @returns the webGL buffer
  41310. */
  41311. createInstancesBuffer(capacity: number): DataBuffer;
  41312. /**
  41313. * Delete a webGL buffer used with instanciation
  41314. * @param buffer defines the webGL buffer to delete
  41315. */
  41316. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41317. private _clientWaitAsync;
  41318. /** @hidden */
  41319. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41320. dispose(): void;
  41321. private _disableTouchAction;
  41322. /**
  41323. * Display the loading screen
  41324. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41325. */
  41326. displayLoadingUI(): void;
  41327. /**
  41328. * Hide the loading screen
  41329. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41330. */
  41331. hideLoadingUI(): void;
  41332. /**
  41333. * Gets the current loading screen object
  41334. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41335. */
  41336. get loadingScreen(): ILoadingScreen;
  41337. /**
  41338. * Sets the current loading screen object
  41339. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41340. */
  41341. set loadingScreen(loadingScreen: ILoadingScreen);
  41342. /**
  41343. * Sets the current loading screen text
  41344. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41345. */
  41346. set loadingUIText(text: string);
  41347. /**
  41348. * Sets the current loading screen background color
  41349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41350. */
  41351. set loadingUIBackgroundColor(color: string);
  41352. /** Pointerlock and fullscreen */
  41353. /**
  41354. * Ask the browser to promote the current element to pointerlock mode
  41355. * @param element defines the DOM element to promote
  41356. */
  41357. static _RequestPointerlock(element: HTMLElement): void;
  41358. /**
  41359. * Asks the browser to exit pointerlock mode
  41360. */
  41361. static _ExitPointerlock(): void;
  41362. /**
  41363. * Ask the browser to promote the current element to fullscreen rendering mode
  41364. * @param element defines the DOM element to promote
  41365. */
  41366. static _RequestFullscreen(element: HTMLElement): void;
  41367. /**
  41368. * Asks the browser to exit fullscreen mode
  41369. */
  41370. static _ExitFullscreen(): void;
  41371. }
  41372. }
  41373. declare module BABYLON {
  41374. /**
  41375. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41376. * during the life time of the application.
  41377. */
  41378. export class EngineStore {
  41379. /** Gets the list of created engines */
  41380. static Instances: Engine[];
  41381. /** @hidden */
  41382. static _LastCreatedScene: Nullable<Scene>;
  41383. /**
  41384. * Gets the latest created engine
  41385. */
  41386. static get LastCreatedEngine(): Nullable<Engine>;
  41387. /**
  41388. * Gets the latest created scene
  41389. */
  41390. static get LastCreatedScene(): Nullable<Scene>;
  41391. /**
  41392. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41393. * @ignorenaming
  41394. */
  41395. static UseFallbackTexture: boolean;
  41396. /**
  41397. * Texture content used if a texture cannot loaded
  41398. * @ignorenaming
  41399. */
  41400. static FallbackTexture: string;
  41401. }
  41402. }
  41403. declare module BABYLON {
  41404. /**
  41405. * Helper class that provides a small promise polyfill
  41406. */
  41407. export class PromisePolyfill {
  41408. /**
  41409. * Static function used to check if the polyfill is required
  41410. * If this is the case then the function will inject the polyfill to window.Promise
  41411. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41412. */
  41413. static Apply(force?: boolean): void;
  41414. }
  41415. }
  41416. declare module BABYLON {
  41417. /**
  41418. * Interface for screenshot methods with describe argument called `size` as object with options
  41419. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41420. */
  41421. export interface IScreenshotSize {
  41422. /**
  41423. * number in pixels for canvas height
  41424. */
  41425. height?: number;
  41426. /**
  41427. * multiplier allowing render at a higher or lower resolution
  41428. * If value is defined then height and width will be ignored and taken from camera
  41429. */
  41430. precision?: number;
  41431. /**
  41432. * number in pixels for canvas width
  41433. */
  41434. width?: number;
  41435. }
  41436. }
  41437. declare module BABYLON {
  41438. interface IColor4Like {
  41439. r: float;
  41440. g: float;
  41441. b: float;
  41442. a: float;
  41443. }
  41444. /**
  41445. * Class containing a set of static utilities functions
  41446. */
  41447. export class Tools {
  41448. /**
  41449. * Gets or sets the base URL to use to load assets
  41450. */
  41451. static get BaseUrl(): string;
  41452. static set BaseUrl(value: string);
  41453. /**
  41454. * Enable/Disable Custom HTTP Request Headers globally.
  41455. * default = false
  41456. * @see CustomRequestHeaders
  41457. */
  41458. static UseCustomRequestHeaders: boolean;
  41459. /**
  41460. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41461. * i.e. when loading files, where the server/service expects an Authorization header
  41462. */
  41463. static CustomRequestHeaders: {
  41464. [key: string]: string;
  41465. };
  41466. /**
  41467. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41468. */
  41469. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41470. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41471. /**
  41472. * Default behaviour for cors in the application.
  41473. * It can be a string if the expected behavior is identical in the entire app.
  41474. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41475. */
  41476. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41477. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41478. /**
  41479. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41480. * @ignorenaming
  41481. */
  41482. static get UseFallbackTexture(): boolean;
  41483. static set UseFallbackTexture(value: boolean);
  41484. /**
  41485. * Use this object to register external classes like custom textures or material
  41486. * to allow the laoders to instantiate them
  41487. */
  41488. static get RegisteredExternalClasses(): {
  41489. [key: string]: Object;
  41490. };
  41491. static set RegisteredExternalClasses(classes: {
  41492. [key: string]: Object;
  41493. });
  41494. /**
  41495. * Texture content used if a texture cannot loaded
  41496. * @ignorenaming
  41497. */
  41498. static get fallbackTexture(): string;
  41499. static set fallbackTexture(value: string);
  41500. /**
  41501. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41502. * @param u defines the coordinate on X axis
  41503. * @param v defines the coordinate on Y axis
  41504. * @param width defines the width of the source data
  41505. * @param height defines the height of the source data
  41506. * @param pixels defines the source byte array
  41507. * @param color defines the output color
  41508. */
  41509. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41510. /**
  41511. * Interpolates between a and b via alpha
  41512. * @param a The lower value (returned when alpha = 0)
  41513. * @param b The upper value (returned when alpha = 1)
  41514. * @param alpha The interpolation-factor
  41515. * @return The mixed value
  41516. */
  41517. static Mix(a: number, b: number, alpha: number): number;
  41518. /**
  41519. * Tries to instantiate a new object from a given class name
  41520. * @param className defines the class name to instantiate
  41521. * @returns the new object or null if the system was not able to do the instantiation
  41522. */
  41523. static Instantiate(className: string): any;
  41524. /**
  41525. * Provides a slice function that will work even on IE
  41526. * @param data defines the array to slice
  41527. * @param start defines the start of the data (optional)
  41528. * @param end defines the end of the data (optional)
  41529. * @returns the new sliced array
  41530. */
  41531. static Slice<T>(data: T, start?: number, end?: number): T;
  41532. /**
  41533. * Provides a slice function that will work even on IE
  41534. * The difference between this and Slice is that this will force-convert to array
  41535. * @param data defines the array to slice
  41536. * @param start defines the start of the data (optional)
  41537. * @param end defines the end of the data (optional)
  41538. * @returns the new sliced array
  41539. */
  41540. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41541. /**
  41542. * Polyfill for setImmediate
  41543. * @param action defines the action to execute after the current execution block
  41544. */
  41545. static SetImmediate(action: () => void): void;
  41546. /**
  41547. * Function indicating if a number is an exponent of 2
  41548. * @param value defines the value to test
  41549. * @returns true if the value is an exponent of 2
  41550. */
  41551. static IsExponentOfTwo(value: number): boolean;
  41552. private static _tmpFloatArray;
  41553. /**
  41554. * Returns the nearest 32-bit single precision float representation of a Number
  41555. * @param value A Number. If the parameter is of a different type, it will get converted
  41556. * to a number or to NaN if it cannot be converted
  41557. * @returns number
  41558. */
  41559. static FloatRound(value: number): number;
  41560. /**
  41561. * Extracts the filename from a path
  41562. * @param path defines the path to use
  41563. * @returns the filename
  41564. */
  41565. static GetFilename(path: string): string;
  41566. /**
  41567. * Extracts the "folder" part of a path (everything before the filename).
  41568. * @param uri The URI to extract the info from
  41569. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41570. * @returns The "folder" part of the path
  41571. */
  41572. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41573. /**
  41574. * Extracts text content from a DOM element hierarchy
  41575. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41576. */
  41577. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41578. /**
  41579. * Convert an angle in radians to degrees
  41580. * @param angle defines the angle to convert
  41581. * @returns the angle in degrees
  41582. */
  41583. static ToDegrees(angle: number): number;
  41584. /**
  41585. * Convert an angle in degrees to radians
  41586. * @param angle defines the angle to convert
  41587. * @returns the angle in radians
  41588. */
  41589. static ToRadians(angle: number): number;
  41590. /**
  41591. * Returns an array if obj is not an array
  41592. * @param obj defines the object to evaluate as an array
  41593. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41594. * @returns either obj directly if obj is an array or a new array containing obj
  41595. */
  41596. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41597. /**
  41598. * Gets the pointer prefix to use
  41599. * @param engine defines the engine we are finding the prefix for
  41600. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41601. */
  41602. static GetPointerPrefix(engine: Engine): string;
  41603. /**
  41604. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41605. * @param url define the url we are trying
  41606. * @param element define the dom element where to configure the cors policy
  41607. */
  41608. static SetCorsBehavior(url: string | string[], element: {
  41609. crossOrigin: string | null;
  41610. }): void;
  41611. /**
  41612. * Removes unwanted characters from an url
  41613. * @param url defines the url to clean
  41614. * @returns the cleaned url
  41615. */
  41616. static CleanUrl(url: string): string;
  41617. /**
  41618. * Gets or sets a function used to pre-process url before using them to load assets
  41619. */
  41620. static get PreprocessUrl(): (url: string) => string;
  41621. static set PreprocessUrl(processor: (url: string) => string);
  41622. /**
  41623. * Loads an image as an HTMLImageElement.
  41624. * @param input url string, ArrayBuffer, or Blob to load
  41625. * @param onLoad callback called when the image successfully loads
  41626. * @param onError callback called when the image fails to load
  41627. * @param offlineProvider offline provider for caching
  41628. * @param mimeType optional mime type
  41629. * @returns the HTMLImageElement of the loaded image
  41630. */
  41631. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41632. /**
  41633. * Loads a file from a url
  41634. * @param url url string, ArrayBuffer, or Blob to load
  41635. * @param onSuccess callback called when the file successfully loads
  41636. * @param onProgress callback called while file is loading (if the server supports this mode)
  41637. * @param offlineProvider defines the offline provider for caching
  41638. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41639. * @param onError callback called when the file fails to load
  41640. * @returns a file request object
  41641. */
  41642. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  41643. /**
  41644. * Loads a file from a url
  41645. * @param url the file url to load
  41646. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41647. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41648. */
  41649. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41650. /**
  41651. * Load a script (identified by an url). When the url returns, the
  41652. * content of this file is added into a new script element, attached to the DOM (body element)
  41653. * @param scriptUrl defines the url of the script to laod
  41654. * @param onSuccess defines the callback called when the script is loaded
  41655. * @param onError defines the callback to call if an error occurs
  41656. * @param scriptId defines the id of the script element
  41657. */
  41658. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41659. /**
  41660. * Load an asynchronous script (identified by an url). When the url returns, the
  41661. * content of this file is added into a new script element, attached to the DOM (body element)
  41662. * @param scriptUrl defines the url of the script to laod
  41663. * @param scriptId defines the id of the script element
  41664. * @returns a promise request object
  41665. */
  41666. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41667. /**
  41668. * Loads a file from a blob
  41669. * @param fileToLoad defines the blob to use
  41670. * @param callback defines the callback to call when data is loaded
  41671. * @param progressCallback defines the callback to call during loading process
  41672. * @returns a file request object
  41673. */
  41674. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41675. /**
  41676. * Reads a file from a File object
  41677. * @param file defines the file to load
  41678. * @param onSuccess defines the callback to call when data is loaded
  41679. * @param onProgress defines the callback to call during loading process
  41680. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41681. * @param onError defines the callback to call when an error occurs
  41682. * @returns a file request object
  41683. */
  41684. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41685. /**
  41686. * Creates a data url from a given string content
  41687. * @param content defines the content to convert
  41688. * @returns the new data url link
  41689. */
  41690. static FileAsURL(content: string): string;
  41691. /**
  41692. * Format the given number to a specific decimal format
  41693. * @param value defines the number to format
  41694. * @param decimals defines the number of decimals to use
  41695. * @returns the formatted string
  41696. */
  41697. static Format(value: number, decimals?: number): string;
  41698. /**
  41699. * Tries to copy an object by duplicating every property
  41700. * @param source defines the source object
  41701. * @param destination defines the target object
  41702. * @param doNotCopyList defines a list of properties to avoid
  41703. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41704. */
  41705. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41706. /**
  41707. * Gets a boolean indicating if the given object has no own property
  41708. * @param obj defines the object to test
  41709. * @returns true if object has no own property
  41710. */
  41711. static IsEmpty(obj: any): boolean;
  41712. /**
  41713. * Function used to register events at window level
  41714. * @param windowElement defines the Window object to use
  41715. * @param events defines the events to register
  41716. */
  41717. static RegisterTopRootEvents(windowElement: Window, events: {
  41718. name: string;
  41719. handler: Nullable<(e: FocusEvent) => any>;
  41720. }[]): void;
  41721. /**
  41722. * Function used to unregister events from window level
  41723. * @param windowElement defines the Window object to use
  41724. * @param events defines the events to unregister
  41725. */
  41726. static UnregisterTopRootEvents(windowElement: Window, events: {
  41727. name: string;
  41728. handler: Nullable<(e: FocusEvent) => any>;
  41729. }[]): void;
  41730. /**
  41731. * @ignore
  41732. */
  41733. static _ScreenshotCanvas: HTMLCanvasElement;
  41734. /**
  41735. * Dumps the current bound framebuffer
  41736. * @param width defines the rendering width
  41737. * @param height defines the rendering height
  41738. * @param engine defines the hosting engine
  41739. * @param successCallback defines the callback triggered once the data are available
  41740. * @param mimeType defines the mime type of the result
  41741. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41742. */
  41743. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41744. /**
  41745. * Converts the canvas data to blob.
  41746. * This acts as a polyfill for browsers not supporting the to blob function.
  41747. * @param canvas Defines the canvas to extract the data from
  41748. * @param successCallback Defines the callback triggered once the data are available
  41749. * @param mimeType Defines the mime type of the result
  41750. */
  41751. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41752. /**
  41753. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41754. * @param successCallback defines the callback triggered once the data are available
  41755. * @param mimeType defines the mime type of the result
  41756. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41757. */
  41758. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41759. /**
  41760. * Downloads a blob in the browser
  41761. * @param blob defines the blob to download
  41762. * @param fileName defines the name of the downloaded file
  41763. */
  41764. static Download(blob: Blob, fileName: string): void;
  41765. /**
  41766. * Will return the right value of the noPreventDefault variable
  41767. * Needed to keep backwards compatibility to the old API.
  41768. *
  41769. * @param args arguments passed to the attachControl function
  41770. * @returns the correct value for noPreventDefault
  41771. */
  41772. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41773. /**
  41774. * Captures a screenshot of the current rendering
  41775. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41776. * @param engine defines the rendering engine
  41777. * @param camera defines the source camera
  41778. * @param size This parameter can be set to a single number or to an object with the
  41779. * following (optional) properties: precision, width, height. If a single number is passed,
  41780. * it will be used for both width and height. If an object is passed, the screenshot size
  41781. * will be derived from the parameters. The precision property is a multiplier allowing
  41782. * rendering at a higher or lower resolution
  41783. * @param successCallback defines the callback receives a single parameter which contains the
  41784. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41785. * src parameter of an <img> to display it
  41786. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41787. * Check your browser for supported MIME types
  41788. */
  41789. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41790. /**
  41791. * Captures a screenshot of the current rendering
  41792. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41793. * @param engine defines the rendering engine
  41794. * @param camera defines the source camera
  41795. * @param size This parameter can be set to a single number or to an object with the
  41796. * following (optional) properties: precision, width, height. If a single number is passed,
  41797. * it will be used for both width and height. If an object is passed, the screenshot size
  41798. * will be derived from the parameters. The precision property is a multiplier allowing
  41799. * rendering at a higher or lower resolution
  41800. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41801. * Check your browser for supported MIME types
  41802. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41803. * to the src parameter of an <img> to display it
  41804. */
  41805. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41806. /**
  41807. * Generates an image screenshot from the specified camera.
  41808. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41809. * @param engine The engine to use for rendering
  41810. * @param camera The camera to use for rendering
  41811. * @param size This parameter can be set to a single number or to an object with the
  41812. * following (optional) properties: precision, width, height. If a single number is passed,
  41813. * it will be used for both width and height. If an object is passed, the screenshot size
  41814. * will be derived from the parameters. The precision property is a multiplier allowing
  41815. * rendering at a higher or lower resolution
  41816. * @param successCallback The callback receives a single parameter which contains the
  41817. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41818. * src parameter of an <img> to display it
  41819. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41820. * Check your browser for supported MIME types
  41821. * @param samples Texture samples (default: 1)
  41822. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41823. * @param fileName A name for for the downloaded file.
  41824. */
  41825. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41826. /**
  41827. * Generates an image screenshot from the specified camera.
  41828. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41829. * @param engine The engine to use for rendering
  41830. * @param camera The camera to use for rendering
  41831. * @param size This parameter can be set to a single number or to an object with the
  41832. * following (optional) properties: precision, width, height. If a single number is passed,
  41833. * it will be used for both width and height. If an object is passed, the screenshot size
  41834. * will be derived from the parameters. The precision property is a multiplier allowing
  41835. * rendering at a higher or lower resolution
  41836. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41837. * Check your browser for supported MIME types
  41838. * @param samples Texture samples (default: 1)
  41839. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41840. * @param fileName A name for for the downloaded file.
  41841. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41842. * to the src parameter of an <img> to display it
  41843. */
  41844. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41845. /**
  41846. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41847. * Be aware Math.random() could cause collisions, but:
  41848. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  41849. * @returns a pseudo random id
  41850. */
  41851. static RandomId(): string;
  41852. /**
  41853. * Test if the given uri is a base64 string
  41854. * @param uri The uri to test
  41855. * @return True if the uri is a base64 string or false otherwise
  41856. */
  41857. static IsBase64(uri: string): boolean;
  41858. /**
  41859. * Decode the given base64 uri.
  41860. * @param uri The uri to decode
  41861. * @return The decoded base64 data.
  41862. */
  41863. static DecodeBase64(uri: string): ArrayBuffer;
  41864. /**
  41865. * Gets the absolute url.
  41866. * @param url the input url
  41867. * @return the absolute url
  41868. */
  41869. static GetAbsoluteUrl(url: string): string;
  41870. /**
  41871. * No log
  41872. */
  41873. static readonly NoneLogLevel: number;
  41874. /**
  41875. * Only message logs
  41876. */
  41877. static readonly MessageLogLevel: number;
  41878. /**
  41879. * Only warning logs
  41880. */
  41881. static readonly WarningLogLevel: number;
  41882. /**
  41883. * Only error logs
  41884. */
  41885. static readonly ErrorLogLevel: number;
  41886. /**
  41887. * All logs
  41888. */
  41889. static readonly AllLogLevel: number;
  41890. /**
  41891. * Gets a value indicating the number of loading errors
  41892. * @ignorenaming
  41893. */
  41894. static get errorsCount(): number;
  41895. /**
  41896. * Callback called when a new log is added
  41897. */
  41898. static OnNewCacheEntry: (entry: string) => void;
  41899. /**
  41900. * Log a message to the console
  41901. * @param message defines the message to log
  41902. */
  41903. static Log(message: string): void;
  41904. /**
  41905. * Write a warning message to the console
  41906. * @param message defines the message to log
  41907. */
  41908. static Warn(message: string): void;
  41909. /**
  41910. * Write an error message to the console
  41911. * @param message defines the message to log
  41912. */
  41913. static Error(message: string): void;
  41914. /**
  41915. * Gets current log cache (list of logs)
  41916. */
  41917. static get LogCache(): string;
  41918. /**
  41919. * Clears the log cache
  41920. */
  41921. static ClearLogCache(): void;
  41922. /**
  41923. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41924. */
  41925. static set LogLevels(level: number);
  41926. /**
  41927. * Checks if the window object exists
  41928. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41929. */
  41930. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41931. /**
  41932. * No performance log
  41933. */
  41934. static readonly PerformanceNoneLogLevel: number;
  41935. /**
  41936. * Use user marks to log performance
  41937. */
  41938. static readonly PerformanceUserMarkLogLevel: number;
  41939. /**
  41940. * Log performance to the console
  41941. */
  41942. static readonly PerformanceConsoleLogLevel: number;
  41943. private static _performance;
  41944. /**
  41945. * Sets the current performance log level
  41946. */
  41947. static set PerformanceLogLevel(level: number);
  41948. private static _StartPerformanceCounterDisabled;
  41949. private static _EndPerformanceCounterDisabled;
  41950. private static _StartUserMark;
  41951. private static _EndUserMark;
  41952. private static _StartPerformanceConsole;
  41953. private static _EndPerformanceConsole;
  41954. /**
  41955. * Starts a performance counter
  41956. */
  41957. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41958. /**
  41959. * Ends a specific performance coutner
  41960. */
  41961. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41962. /**
  41963. * Gets either window.performance.now() if supported or Date.now() else
  41964. */
  41965. static get Now(): number;
  41966. /**
  41967. * This method will return the name of the class used to create the instance of the given object.
  41968. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41969. * @param object the object to get the class name from
  41970. * @param isType defines if the object is actually a type
  41971. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41972. */
  41973. static GetClassName(object: any, isType?: boolean): string;
  41974. /**
  41975. * Gets the first element of an array satisfying a given predicate
  41976. * @param array defines the array to browse
  41977. * @param predicate defines the predicate to use
  41978. * @returns null if not found or the element
  41979. */
  41980. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41981. /**
  41982. * This method will return the name of the full name of the class, including its owning module (if any).
  41983. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  41984. * @param object the object to get the class name from
  41985. * @param isType defines if the object is actually a type
  41986. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  41987. * @ignorenaming
  41988. */
  41989. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41990. /**
  41991. * Returns a promise that resolves after the given amount of time.
  41992. * @param delay Number of milliseconds to delay
  41993. * @returns Promise that resolves after the given amount of time
  41994. */
  41995. static DelayAsync(delay: number): Promise<void>;
  41996. /**
  41997. * Utility function to detect if the current user agent is Safari
  41998. * @returns whether or not the current user agent is safari
  41999. */
  42000. static IsSafari(): boolean;
  42001. }
  42002. /**
  42003. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42004. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42005. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42006. * @param name The name of the class, case should be preserved
  42007. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42008. */
  42009. export function className(name: string, module?: string): (target: Object) => void;
  42010. /**
  42011. * An implementation of a loop for asynchronous functions.
  42012. */
  42013. export class AsyncLoop {
  42014. /**
  42015. * Defines the number of iterations for the loop
  42016. */
  42017. iterations: number;
  42018. /**
  42019. * Defines the current index of the loop.
  42020. */
  42021. index: number;
  42022. private _done;
  42023. private _fn;
  42024. private _successCallback;
  42025. /**
  42026. * Constructor.
  42027. * @param iterations the number of iterations.
  42028. * @param func the function to run each iteration
  42029. * @param successCallback the callback that will be called upon succesful execution
  42030. * @param offset starting offset.
  42031. */
  42032. constructor(
  42033. /**
  42034. * Defines the number of iterations for the loop
  42035. */
  42036. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42037. /**
  42038. * Execute the next iteration. Must be called after the last iteration was finished.
  42039. */
  42040. executeNext(): void;
  42041. /**
  42042. * Break the loop and run the success callback.
  42043. */
  42044. breakLoop(): void;
  42045. /**
  42046. * Create and run an async loop.
  42047. * @param iterations the number of iterations.
  42048. * @param fn the function to run each iteration
  42049. * @param successCallback the callback that will be called upon succesful execution
  42050. * @param offset starting offset.
  42051. * @returns the created async loop object
  42052. */
  42053. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42054. /**
  42055. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42056. * @param iterations total number of iterations
  42057. * @param syncedIterations number of synchronous iterations in each async iteration.
  42058. * @param fn the function to call each iteration.
  42059. * @param callback a success call back that will be called when iterating stops.
  42060. * @param breakFunction a break condition (optional)
  42061. * @param timeout timeout settings for the setTimeout function. default - 0.
  42062. * @returns the created async loop object
  42063. */
  42064. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42065. }
  42066. }
  42067. declare module BABYLON {
  42068. /**
  42069. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42070. * The underlying implementation relies on an associative array to ensure the best performances.
  42071. * The value can be anything including 'null' but except 'undefined'
  42072. */
  42073. export class StringDictionary<T> {
  42074. /**
  42075. * This will clear this dictionary and copy the content from the 'source' one.
  42076. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42077. * @param source the dictionary to take the content from and copy to this dictionary
  42078. */
  42079. copyFrom(source: StringDictionary<T>): void;
  42080. /**
  42081. * Get a value based from its key
  42082. * @param key the given key to get the matching value from
  42083. * @return the value if found, otherwise undefined is returned
  42084. */
  42085. get(key: string): T | undefined;
  42086. /**
  42087. * Get a value from its key or add it if it doesn't exist.
  42088. * This method will ensure you that a given key/data will be present in the dictionary.
  42089. * @param key the given key to get the matching value from
  42090. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42091. * The factory will only be invoked if there's no data for the given key.
  42092. * @return the value corresponding to the key.
  42093. */
  42094. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42095. /**
  42096. * Get a value from its key if present in the dictionary otherwise add it
  42097. * @param key the key to get the value from
  42098. * @param val if there's no such key/value pair in the dictionary add it with this value
  42099. * @return the value corresponding to the key
  42100. */
  42101. getOrAdd(key: string, val: T): T;
  42102. /**
  42103. * Check if there's a given key in the dictionary
  42104. * @param key the key to check for
  42105. * @return true if the key is present, false otherwise
  42106. */
  42107. contains(key: string): boolean;
  42108. /**
  42109. * Add a new key and its corresponding value
  42110. * @param key the key to add
  42111. * @param value the value corresponding to the key
  42112. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  42113. */
  42114. add(key: string, value: T): boolean;
  42115. /**
  42116. * Update a specific value associated to a key
  42117. * @param key defines the key to use
  42118. * @param value defines the value to store
  42119. * @returns true if the value was updated (or false if the key was not found)
  42120. */
  42121. set(key: string, value: T): boolean;
  42122. /**
  42123. * Get the element of the given key and remove it from the dictionary
  42124. * @param key defines the key to search
  42125. * @returns the value associated with the key or null if not found
  42126. */
  42127. getAndRemove(key: string): Nullable<T>;
  42128. /**
  42129. * Remove a key/value from the dictionary.
  42130. * @param key the key to remove
  42131. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42132. */
  42133. remove(key: string): boolean;
  42134. /**
  42135. * Clear the whole content of the dictionary
  42136. */
  42137. clear(): void;
  42138. /**
  42139. * Gets the current count
  42140. */
  42141. get count(): number;
  42142. /**
  42143. * Execute a callback on each key/val of the dictionary.
  42144. * Note that you can remove any element in this dictionary in the callback implementation
  42145. * @param callback the callback to execute on a given key/value pair
  42146. */
  42147. forEach(callback: (key: string, val: T) => void): void;
  42148. /**
  42149. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42150. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42151. * Note that you can remove any element in this dictionary in the callback implementation
  42152. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42153. * @returns the first item
  42154. */
  42155. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42156. private _count;
  42157. private _data;
  42158. }
  42159. }
  42160. declare module BABYLON {
  42161. /** @hidden */
  42162. export interface ICollisionCoordinator {
  42163. createCollider(): Collider;
  42164. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42165. init(scene: Scene): void;
  42166. }
  42167. /** @hidden */
  42168. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42169. private _scene;
  42170. private _scaledPosition;
  42171. private _scaledVelocity;
  42172. private _finalPosition;
  42173. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42174. createCollider(): Collider;
  42175. init(scene: Scene): void;
  42176. private _collideWithWorld;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * Class used to manage all inputs for the scene.
  42182. */
  42183. export class InputManager {
  42184. /** The distance in pixel that you have to move to prevent some events */
  42185. static DragMovementThreshold: number;
  42186. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42187. static LongPressDelay: number;
  42188. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42189. static DoubleClickDelay: number;
  42190. /** If you need to check double click without raising a single click at first click, enable this flag */
  42191. static ExclusiveDoubleClickMode: boolean;
  42192. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  42193. private _alreadyAttached;
  42194. private _alreadyAttachedTo;
  42195. private _wheelEventName;
  42196. private _onPointerMove;
  42197. private _onPointerDown;
  42198. private _onPointerUp;
  42199. private _initClickEvent;
  42200. private _initActionManager;
  42201. private _delayedSimpleClick;
  42202. private _delayedSimpleClickTimeout;
  42203. private _previousDelayedSimpleClickTimeout;
  42204. private _meshPickProceed;
  42205. private _previousButtonPressed;
  42206. private _currentPickResult;
  42207. private _previousPickResult;
  42208. private _totalPointersPressed;
  42209. private _doubleClickOccured;
  42210. private _pointerOverMesh;
  42211. private _pickedDownMesh;
  42212. private _pickedUpMesh;
  42213. private _pointerX;
  42214. private _pointerY;
  42215. private _unTranslatedPointerX;
  42216. private _unTranslatedPointerY;
  42217. private _startingPointerPosition;
  42218. private _previousStartingPointerPosition;
  42219. private _startingPointerTime;
  42220. private _previousStartingPointerTime;
  42221. private _pointerCaptures;
  42222. private _meshUnderPointerId;
  42223. private _onKeyDown;
  42224. private _onKeyUp;
  42225. private _keyboardIsAttached;
  42226. private _onCanvasFocusObserver;
  42227. private _onCanvasBlurObserver;
  42228. private _scene;
  42229. /**
  42230. * Creates a new InputManager
  42231. * @param scene defines the hosting scene
  42232. */
  42233. constructor(scene: Scene);
  42234. /**
  42235. * Gets the mesh that is currently under the pointer
  42236. */
  42237. get meshUnderPointer(): Nullable<AbstractMesh>;
  42238. /**
  42239. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42240. * @param pointerId the pointer id to use
  42241. * @returns The mesh under this pointer id or null if not found
  42242. */
  42243. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42244. /**
  42245. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42246. */
  42247. get unTranslatedPointer(): Vector2;
  42248. /**
  42249. * Gets or sets the current on-screen X position of the pointer
  42250. */
  42251. get pointerX(): number;
  42252. set pointerX(value: number);
  42253. /**
  42254. * Gets or sets the current on-screen Y position of the pointer
  42255. */
  42256. get pointerY(): number;
  42257. set pointerY(value: number);
  42258. private _updatePointerPosition;
  42259. private _processPointerMove;
  42260. private _setRayOnPointerInfo;
  42261. private _checkPrePointerObservable;
  42262. /**
  42263. * Use this method to simulate a pointer move on a mesh
  42264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42267. */
  42268. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42269. /**
  42270. * Use this method to simulate a pointer down on a mesh
  42271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42274. */
  42275. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42276. private _processPointerDown;
  42277. /** @hidden */
  42278. _isPointerSwiping(): boolean;
  42279. /**
  42280. * Use this method to simulate a pointer up on a mesh
  42281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42285. */
  42286. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42287. private _processPointerUp;
  42288. /**
  42289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42291. * @returns true if the pointer was captured
  42292. */
  42293. isPointerCaptured(pointerId?: number): boolean;
  42294. /**
  42295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42296. * @param attachUp defines if you want to attach events to pointerup
  42297. * @param attachDown defines if you want to attach events to pointerdown
  42298. * @param attachMove defines if you want to attach events to pointermove
  42299. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42300. */
  42301. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42302. /**
  42303. * Detaches all event handlers
  42304. */
  42305. detachControl(): void;
  42306. /**
  42307. * Force the value of meshUnderPointer
  42308. * @param mesh defines the mesh to use
  42309. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42310. */
  42311. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42312. /**
  42313. * Gets the mesh under the pointer
  42314. * @returns a Mesh or null if no mesh is under the pointer
  42315. */
  42316. getPointerOverMesh(): Nullable<AbstractMesh>;
  42317. }
  42318. }
  42319. declare module BABYLON {
  42320. /**
  42321. * This class defines the direct association between an animation and a target
  42322. */
  42323. export class TargetedAnimation {
  42324. /**
  42325. * Animation to perform
  42326. */
  42327. animation: Animation;
  42328. /**
  42329. * Target to animate
  42330. */
  42331. target: any;
  42332. /**
  42333. * Returns the string "TargetedAnimation"
  42334. * @returns "TargetedAnimation"
  42335. */
  42336. getClassName(): string;
  42337. /**
  42338. * Serialize the object
  42339. * @returns the JSON object representing the current entity
  42340. */
  42341. serialize(): any;
  42342. }
  42343. /**
  42344. * Use this class to create coordinated animations on multiple targets
  42345. */
  42346. export class AnimationGroup implements IDisposable {
  42347. /** The name of the animation group */
  42348. name: string;
  42349. private _scene;
  42350. private _targetedAnimations;
  42351. private _animatables;
  42352. private _from;
  42353. private _to;
  42354. private _isStarted;
  42355. private _isPaused;
  42356. private _speedRatio;
  42357. private _loopAnimation;
  42358. private _isAdditive;
  42359. /**
  42360. * Gets or sets the unique id of the node
  42361. */
  42362. uniqueId: number;
  42363. /**
  42364. * This observable will notify when one animation have ended
  42365. */
  42366. onAnimationEndObservable: Observable<TargetedAnimation>;
  42367. /**
  42368. * Observer raised when one animation loops
  42369. */
  42370. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42371. /**
  42372. * Observer raised when all animations have looped
  42373. */
  42374. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42375. /**
  42376. * This observable will notify when all animations have ended.
  42377. */
  42378. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42379. /**
  42380. * This observable will notify when all animations have paused.
  42381. */
  42382. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42383. /**
  42384. * This observable will notify when all animations are playing.
  42385. */
  42386. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42387. /**
  42388. * Gets the first frame
  42389. */
  42390. get from(): number;
  42391. /**
  42392. * Gets the last frame
  42393. */
  42394. get to(): number;
  42395. /**
  42396. * Define if the animations are started
  42397. */
  42398. get isStarted(): boolean;
  42399. /**
  42400. * Gets a value indicating that the current group is playing
  42401. */
  42402. get isPlaying(): boolean;
  42403. /**
  42404. * Gets or sets the speed ratio to use for all animations
  42405. */
  42406. get speedRatio(): number;
  42407. /**
  42408. * Gets or sets the speed ratio to use for all animations
  42409. */
  42410. set speedRatio(value: number);
  42411. /**
  42412. * Gets or sets if all animations should loop or not
  42413. */
  42414. get loopAnimation(): boolean;
  42415. set loopAnimation(value: boolean);
  42416. /**
  42417. * Gets or sets if all animations should be evaluated additively
  42418. */
  42419. get isAdditive(): boolean;
  42420. set isAdditive(value: boolean);
  42421. /**
  42422. * Gets the targeted animations for this animation group
  42423. */
  42424. get targetedAnimations(): Array<TargetedAnimation>;
  42425. /**
  42426. * returning the list of animatables controlled by this animation group.
  42427. */
  42428. get animatables(): Array<Animatable>;
  42429. /**
  42430. * Gets the list of target animations
  42431. */
  42432. get children(): TargetedAnimation[];
  42433. /**
  42434. * Instantiates a new Animation Group.
  42435. * This helps managing several animations at once.
  42436. * @see https://doc.babylonjs.com/how_to/group
  42437. * @param name Defines the name of the group
  42438. * @param scene Defines the scene the group belongs to
  42439. */
  42440. constructor(
  42441. /** The name of the animation group */
  42442. name: string, scene?: Nullable<Scene>);
  42443. /**
  42444. * Add an animation (with its target) in the group
  42445. * @param animation defines the animation we want to add
  42446. * @param target defines the target of the animation
  42447. * @returns the TargetedAnimation object
  42448. */
  42449. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42450. /**
  42451. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42452. * It can add constant keys at begin or end
  42453. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42454. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42455. * @returns the animation group
  42456. */
  42457. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42458. private _animationLoopCount;
  42459. private _animationLoopFlags;
  42460. private _processLoop;
  42461. /**
  42462. * Start all animations on given targets
  42463. * @param loop defines if animations must loop
  42464. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42465. * @param from defines the from key (optional)
  42466. * @param to defines the to key (optional)
  42467. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42468. * @returns the current animation group
  42469. */
  42470. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42471. /**
  42472. * Pause all animations
  42473. * @returns the animation group
  42474. */
  42475. pause(): AnimationGroup;
  42476. /**
  42477. * Play all animations to initial state
  42478. * This function will start() the animations if they were not started or will restart() them if they were paused
  42479. * @param loop defines if animations must loop
  42480. * @returns the animation group
  42481. */
  42482. play(loop?: boolean): AnimationGroup;
  42483. /**
  42484. * Reset all animations to initial state
  42485. * @returns the animation group
  42486. */
  42487. reset(): AnimationGroup;
  42488. /**
  42489. * Restart animations from key 0
  42490. * @returns the animation group
  42491. */
  42492. restart(): AnimationGroup;
  42493. /**
  42494. * Stop all animations
  42495. * @returns the animation group
  42496. */
  42497. stop(): AnimationGroup;
  42498. /**
  42499. * Set animation weight for all animatables
  42500. * @param weight defines the weight to use
  42501. * @return the animationGroup
  42502. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42503. */
  42504. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42505. /**
  42506. * Synchronize and normalize all animatables with a source animatable
  42507. * @param root defines the root animatable to synchronize with
  42508. * @return the animationGroup
  42509. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42510. */
  42511. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42512. /**
  42513. * Goes to a specific frame in this animation group
  42514. * @param frame the frame number to go to
  42515. * @return the animationGroup
  42516. */
  42517. goToFrame(frame: number): AnimationGroup;
  42518. /**
  42519. * Dispose all associated resources
  42520. */
  42521. dispose(): void;
  42522. private _checkAnimationGroupEnded;
  42523. /**
  42524. * Clone the current animation group and returns a copy
  42525. * @param newName defines the name of the new group
  42526. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42527. * @returns the new aniamtion group
  42528. */
  42529. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42530. /**
  42531. * Serializes the animationGroup to an object
  42532. * @returns Serialized object
  42533. */
  42534. serialize(): any;
  42535. /**
  42536. * Returns a new AnimationGroup object parsed from the source provided.
  42537. * @param parsedAnimationGroup defines the source
  42538. * @param scene defines the scene that will receive the animationGroup
  42539. * @returns a new AnimationGroup
  42540. */
  42541. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42542. /**
  42543. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42544. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42545. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42546. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42547. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42548. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42549. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42550. */
  42551. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42552. /**
  42553. * Returns the string "AnimationGroup"
  42554. * @returns "AnimationGroup"
  42555. */
  42556. getClassName(): string;
  42557. /**
  42558. * Creates a detailled string about the object
  42559. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42560. * @returns a string representing the object
  42561. */
  42562. toString(fullDetails?: boolean): string;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Define an interface for all classes that will hold resources
  42568. */
  42569. export interface IDisposable {
  42570. /**
  42571. * Releases all held resources
  42572. */
  42573. dispose(): void;
  42574. }
  42575. /** Interface defining initialization parameters for Scene class */
  42576. export interface SceneOptions {
  42577. /**
  42578. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42579. * It will improve performance when the number of geometries becomes important.
  42580. */
  42581. useGeometryUniqueIdsMap?: boolean;
  42582. /**
  42583. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42584. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42585. */
  42586. useMaterialMeshMap?: boolean;
  42587. /**
  42588. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42589. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42590. */
  42591. useClonedMeshMap?: boolean;
  42592. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42593. virtual?: boolean;
  42594. }
  42595. /**
  42596. * Represents a scene to be rendered by the engine.
  42597. * @see https://doc.babylonjs.com/features/scene
  42598. */
  42599. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42600. /** The fog is deactivated */
  42601. static readonly FOGMODE_NONE: number;
  42602. /** The fog density is following an exponential function */
  42603. static readonly FOGMODE_EXP: number;
  42604. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42605. static readonly FOGMODE_EXP2: number;
  42606. /** The fog density is following a linear function. */
  42607. static readonly FOGMODE_LINEAR: number;
  42608. /**
  42609. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42610. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42611. */
  42612. static MinDeltaTime: number;
  42613. /**
  42614. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42615. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42616. */
  42617. static MaxDeltaTime: number;
  42618. /**
  42619. * Factory used to create the default material.
  42620. * @param name The name of the material to create
  42621. * @param scene The scene to create the material for
  42622. * @returns The default material
  42623. */
  42624. static DefaultMaterialFactory(scene: Scene): Material;
  42625. /**
  42626. * Factory used to create the a collision coordinator.
  42627. * @returns The collision coordinator
  42628. */
  42629. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42630. /** @hidden */
  42631. _inputManager: InputManager;
  42632. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42633. cameraToUseForPointers: Nullable<Camera>;
  42634. /** @hidden */
  42635. readonly _isScene: boolean;
  42636. /** @hidden */
  42637. _blockEntityCollection: boolean;
  42638. /**
  42639. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42640. */
  42641. autoClear: boolean;
  42642. /**
  42643. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42644. */
  42645. autoClearDepthAndStencil: boolean;
  42646. /**
  42647. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42648. */
  42649. clearColor: Color4;
  42650. /**
  42651. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42652. */
  42653. ambientColor: Color3;
  42654. /**
  42655. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42656. * It should only be one of the following (if not the default embedded one):
  42657. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42658. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42659. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42660. * The material properties need to be setup according to the type of texture in use.
  42661. */
  42662. environmentBRDFTexture: BaseTexture;
  42663. /**
  42664. * Texture used in all pbr material as the reflection texture.
  42665. * As in the majority of the scene they are the same (exception for multi room and so on),
  42666. * this is easier to reference from here than from all the materials.
  42667. */
  42668. get environmentTexture(): Nullable<BaseTexture>;
  42669. /**
  42670. * Texture used in all pbr material as the reflection texture.
  42671. * As in the majority of the scene they are the same (exception for multi room and so on),
  42672. * this is easier to set here than in all the materials.
  42673. */
  42674. set environmentTexture(value: Nullable<BaseTexture>);
  42675. /** @hidden */
  42676. protected _environmentIntensity: number;
  42677. /**
  42678. * Intensity of the environment in all pbr material.
  42679. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42680. * As in the majority of the scene they are the same (exception for multi room and so on),
  42681. * this is easier to reference from here than from all the materials.
  42682. */
  42683. get environmentIntensity(): number;
  42684. /**
  42685. * Intensity of the environment in all pbr material.
  42686. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42687. * As in the majority of the scene they are the same (exception for multi room and so on),
  42688. * this is easier to set here than in all the materials.
  42689. */
  42690. set environmentIntensity(value: number);
  42691. /** @hidden */
  42692. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42693. /**
  42694. * Default image processing configuration used either in the rendering
  42695. * Forward main pass or through the imageProcessingPostProcess if present.
  42696. * As in the majority of the scene they are the same (exception for multi camera),
  42697. * this is easier to reference from here than from all the materials and post process.
  42698. *
  42699. * No setter as we it is a shared configuration, you can set the values instead.
  42700. */
  42701. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42702. private _forceWireframe;
  42703. /**
  42704. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42705. */
  42706. set forceWireframe(value: boolean);
  42707. get forceWireframe(): boolean;
  42708. private _skipFrustumClipping;
  42709. /**
  42710. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42711. */
  42712. set skipFrustumClipping(value: boolean);
  42713. get skipFrustumClipping(): boolean;
  42714. private _forcePointsCloud;
  42715. /**
  42716. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42717. */
  42718. set forcePointsCloud(value: boolean);
  42719. get forcePointsCloud(): boolean;
  42720. /**
  42721. * Gets or sets the active clipplane 1
  42722. */
  42723. clipPlane: Nullable<Plane>;
  42724. /**
  42725. * Gets or sets the active clipplane 2
  42726. */
  42727. clipPlane2: Nullable<Plane>;
  42728. /**
  42729. * Gets or sets the active clipplane 3
  42730. */
  42731. clipPlane3: Nullable<Plane>;
  42732. /**
  42733. * Gets or sets the active clipplane 4
  42734. */
  42735. clipPlane4: Nullable<Plane>;
  42736. /**
  42737. * Gets or sets the active clipplane 5
  42738. */
  42739. clipPlane5: Nullable<Plane>;
  42740. /**
  42741. * Gets or sets the active clipplane 6
  42742. */
  42743. clipPlane6: Nullable<Plane>;
  42744. /**
  42745. * Gets or sets a boolean indicating if animations are enabled
  42746. */
  42747. animationsEnabled: boolean;
  42748. private _animationPropertiesOverride;
  42749. /**
  42750. * Gets or sets the animation properties override
  42751. */
  42752. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42753. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42754. /**
  42755. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42756. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42757. */
  42758. useConstantAnimationDeltaTime: boolean;
  42759. /**
  42760. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42761. * Please note that it requires to run a ray cast through the scene on every frame
  42762. */
  42763. constantlyUpdateMeshUnderPointer: boolean;
  42764. /**
  42765. * Defines the HTML cursor to use when hovering over interactive elements
  42766. */
  42767. hoverCursor: string;
  42768. /**
  42769. * Defines the HTML default cursor to use (empty by default)
  42770. */
  42771. defaultCursor: string;
  42772. /**
  42773. * Defines whether cursors are handled by the scene.
  42774. */
  42775. doNotHandleCursors: boolean;
  42776. /**
  42777. * This is used to call preventDefault() on pointer down
  42778. * in order to block unwanted artifacts like system double clicks
  42779. */
  42780. preventDefaultOnPointerDown: boolean;
  42781. /**
  42782. * This is used to call preventDefault() on pointer up
  42783. * in order to block unwanted artifacts like system double clicks
  42784. */
  42785. preventDefaultOnPointerUp: boolean;
  42786. /**
  42787. * Gets or sets user defined metadata
  42788. */
  42789. metadata: any;
  42790. /**
  42791. * For internal use only. Please do not use.
  42792. */
  42793. reservedDataStore: any;
  42794. /**
  42795. * Gets the name of the plugin used to load this scene (null by default)
  42796. */
  42797. loadingPluginName: string;
  42798. /**
  42799. * Use this array to add regular expressions used to disable offline support for specific urls
  42800. */
  42801. disableOfflineSupportExceptionRules: RegExp[];
  42802. /**
  42803. * An event triggered when the scene is disposed.
  42804. */
  42805. onDisposeObservable: Observable<Scene>;
  42806. private _onDisposeObserver;
  42807. /** Sets a function to be executed when this scene is disposed. */
  42808. set onDispose(callback: () => void);
  42809. /**
  42810. * An event triggered before rendering the scene (right after animations and physics)
  42811. */
  42812. onBeforeRenderObservable: Observable<Scene>;
  42813. private _onBeforeRenderObserver;
  42814. /** Sets a function to be executed before rendering this scene */
  42815. set beforeRender(callback: Nullable<() => void>);
  42816. /**
  42817. * An event triggered after rendering the scene
  42818. */
  42819. onAfterRenderObservable: Observable<Scene>;
  42820. /**
  42821. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42822. */
  42823. onAfterRenderCameraObservable: Observable<Camera>;
  42824. private _onAfterRenderObserver;
  42825. /** Sets a function to be executed after rendering this scene */
  42826. set afterRender(callback: Nullable<() => void>);
  42827. /**
  42828. * An event triggered before animating the scene
  42829. */
  42830. onBeforeAnimationsObservable: Observable<Scene>;
  42831. /**
  42832. * An event triggered after animations processing
  42833. */
  42834. onAfterAnimationsObservable: Observable<Scene>;
  42835. /**
  42836. * An event triggered before draw calls are ready to be sent
  42837. */
  42838. onBeforeDrawPhaseObservable: Observable<Scene>;
  42839. /**
  42840. * An event triggered after draw calls have been sent
  42841. */
  42842. onAfterDrawPhaseObservable: Observable<Scene>;
  42843. /**
  42844. * An event triggered when the scene is ready
  42845. */
  42846. onReadyObservable: Observable<Scene>;
  42847. /**
  42848. * An event triggered before rendering a camera
  42849. */
  42850. onBeforeCameraRenderObservable: Observable<Camera>;
  42851. private _onBeforeCameraRenderObserver;
  42852. /** Sets a function to be executed before rendering a camera*/
  42853. set beforeCameraRender(callback: () => void);
  42854. /**
  42855. * An event triggered after rendering a camera
  42856. */
  42857. onAfterCameraRenderObservable: Observable<Camera>;
  42858. private _onAfterCameraRenderObserver;
  42859. /** Sets a function to be executed after rendering a camera*/
  42860. set afterCameraRender(callback: () => void);
  42861. /**
  42862. * An event triggered when active meshes evaluation is about to start
  42863. */
  42864. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42865. /**
  42866. * An event triggered when active meshes evaluation is done
  42867. */
  42868. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42869. /**
  42870. * An event triggered when particles rendering is about to start
  42871. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42872. */
  42873. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42874. /**
  42875. * An event triggered when particles rendering is done
  42876. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42877. */
  42878. onAfterParticlesRenderingObservable: Observable<Scene>;
  42879. /**
  42880. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42881. */
  42882. onDataLoadedObservable: Observable<Scene>;
  42883. /**
  42884. * An event triggered when a camera is created
  42885. */
  42886. onNewCameraAddedObservable: Observable<Camera>;
  42887. /**
  42888. * An event triggered when a camera is removed
  42889. */
  42890. onCameraRemovedObservable: Observable<Camera>;
  42891. /**
  42892. * An event triggered when a light is created
  42893. */
  42894. onNewLightAddedObservable: Observable<Light>;
  42895. /**
  42896. * An event triggered when a light is removed
  42897. */
  42898. onLightRemovedObservable: Observable<Light>;
  42899. /**
  42900. * An event triggered when a geometry is created
  42901. */
  42902. onNewGeometryAddedObservable: Observable<Geometry>;
  42903. /**
  42904. * An event triggered when a geometry is removed
  42905. */
  42906. onGeometryRemovedObservable: Observable<Geometry>;
  42907. /**
  42908. * An event triggered when a transform node is created
  42909. */
  42910. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42911. /**
  42912. * An event triggered when a transform node is removed
  42913. */
  42914. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42915. /**
  42916. * An event triggered when a mesh is created
  42917. */
  42918. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42919. /**
  42920. * An event triggered when a mesh is removed
  42921. */
  42922. onMeshRemovedObservable: Observable<AbstractMesh>;
  42923. /**
  42924. * An event triggered when a skeleton is created
  42925. */
  42926. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42927. /**
  42928. * An event triggered when a skeleton is removed
  42929. */
  42930. onSkeletonRemovedObservable: Observable<Skeleton>;
  42931. /**
  42932. * An event triggered when a material is created
  42933. */
  42934. onNewMaterialAddedObservable: Observable<Material>;
  42935. /**
  42936. * An event triggered when a material is removed
  42937. */
  42938. onMaterialRemovedObservable: Observable<Material>;
  42939. /**
  42940. * An event triggered when a texture is created
  42941. */
  42942. onNewTextureAddedObservable: Observable<BaseTexture>;
  42943. /**
  42944. * An event triggered when a texture is removed
  42945. */
  42946. onTextureRemovedObservable: Observable<BaseTexture>;
  42947. /**
  42948. * An event triggered when render targets are about to be rendered
  42949. * Can happen multiple times per frame.
  42950. */
  42951. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42952. /**
  42953. * An event triggered when render targets were rendered.
  42954. * Can happen multiple times per frame.
  42955. */
  42956. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42957. /**
  42958. * An event triggered before calculating deterministic simulation step
  42959. */
  42960. onBeforeStepObservable: Observable<Scene>;
  42961. /**
  42962. * An event triggered after calculating deterministic simulation step
  42963. */
  42964. onAfterStepObservable: Observable<Scene>;
  42965. /**
  42966. * An event triggered when the activeCamera property is updated
  42967. */
  42968. onActiveCameraChanged: Observable<Scene>;
  42969. /**
  42970. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42971. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42972. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  42973. */
  42974. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42975. /**
  42976. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42977. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42978. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  42979. */
  42980. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42981. /**
  42982. * This Observable will when a mesh has been imported into the scene.
  42983. */
  42984. onMeshImportedObservable: Observable<AbstractMesh>;
  42985. /**
  42986. * This Observable will when an animation file has been imported into the scene.
  42987. */
  42988. onAnimationFileImportedObservable: Observable<Scene>;
  42989. /**
  42990. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42991. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42992. */
  42993. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42994. /** @hidden */
  42995. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42996. /**
  42997. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42998. */
  42999. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43000. /**
  43001. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43002. */
  43003. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43004. /**
  43005. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43006. */
  43007. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43008. /** Callback called when a pointer move is detected */
  43009. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43010. /** Callback called when a pointer down is detected */
  43011. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43012. /** Callback called when a pointer up is detected */
  43013. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43014. /** Callback called when a pointer pick is detected */
  43015. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43016. /**
  43017. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  43018. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43019. */
  43020. onPrePointerObservable: Observable<PointerInfoPre>;
  43021. /**
  43022. * Observable event triggered each time an input event is received from the rendering canvas
  43023. */
  43024. onPointerObservable: Observable<PointerInfo>;
  43025. /**
  43026. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43027. */
  43028. get unTranslatedPointer(): Vector2;
  43029. /**
  43030. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43031. */
  43032. static get DragMovementThreshold(): number;
  43033. static set DragMovementThreshold(value: number);
  43034. /**
  43035. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43036. */
  43037. static get LongPressDelay(): number;
  43038. static set LongPressDelay(value: number);
  43039. /**
  43040. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43041. */
  43042. static get DoubleClickDelay(): number;
  43043. static set DoubleClickDelay(value: number);
  43044. /** If you need to check double click without raising a single click at first click, enable this flag */
  43045. static get ExclusiveDoubleClickMode(): boolean;
  43046. static set ExclusiveDoubleClickMode(value: boolean);
  43047. /** @hidden */
  43048. _mirroredCameraPosition: Nullable<Vector3>;
  43049. /**
  43050. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43051. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43052. */
  43053. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43054. /**
  43055. * Observable event triggered each time an keyboard event is received from the hosting window
  43056. */
  43057. onKeyboardObservable: Observable<KeyboardInfo>;
  43058. private _useRightHandedSystem;
  43059. /**
  43060. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43061. */
  43062. set useRightHandedSystem(value: boolean);
  43063. get useRightHandedSystem(): boolean;
  43064. private _timeAccumulator;
  43065. private _currentStepId;
  43066. private _currentInternalStep;
  43067. /**
  43068. * Sets the step Id used by deterministic lock step
  43069. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43070. * @param newStepId defines the step Id
  43071. */
  43072. setStepId(newStepId: number): void;
  43073. /**
  43074. * Gets the step Id used by deterministic lock step
  43075. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43076. * @returns the step Id
  43077. */
  43078. getStepId(): number;
  43079. /**
  43080. * Gets the internal step used by deterministic lock step
  43081. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43082. * @returns the internal step
  43083. */
  43084. getInternalStep(): number;
  43085. private _fogEnabled;
  43086. /**
  43087. * Gets or sets a boolean indicating if fog is enabled on this scene
  43088. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43089. * (Default is true)
  43090. */
  43091. set fogEnabled(value: boolean);
  43092. get fogEnabled(): boolean;
  43093. private _fogMode;
  43094. /**
  43095. * Gets or sets the fog mode to use
  43096. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43097. * | mode | value |
  43098. * | --- | --- |
  43099. * | FOGMODE_NONE | 0 |
  43100. * | FOGMODE_EXP | 1 |
  43101. * | FOGMODE_EXP2 | 2 |
  43102. * | FOGMODE_LINEAR | 3 |
  43103. */
  43104. set fogMode(value: number);
  43105. get fogMode(): number;
  43106. /**
  43107. * Gets or sets the fog color to use
  43108. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43109. * (Default is Color3(0.2, 0.2, 0.3))
  43110. */
  43111. fogColor: Color3;
  43112. /**
  43113. * Gets or sets the fog density to use
  43114. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43115. * (Default is 0.1)
  43116. */
  43117. fogDensity: number;
  43118. /**
  43119. * Gets or sets the fog start distance to use
  43120. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43121. * (Default is 0)
  43122. */
  43123. fogStart: number;
  43124. /**
  43125. * Gets or sets the fog end distance to use
  43126. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43127. * (Default is 1000)
  43128. */
  43129. fogEnd: number;
  43130. /**
  43131. * Flag indicating that the frame buffer binding is handled by another component
  43132. */
  43133. prePass: boolean;
  43134. private _shadowsEnabled;
  43135. /**
  43136. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43137. */
  43138. set shadowsEnabled(value: boolean);
  43139. get shadowsEnabled(): boolean;
  43140. private _lightsEnabled;
  43141. /**
  43142. * Gets or sets a boolean indicating if lights are enabled on this scene
  43143. */
  43144. set lightsEnabled(value: boolean);
  43145. get lightsEnabled(): boolean;
  43146. /** All of the active cameras added to this scene. */
  43147. activeCameras: Camera[];
  43148. /** @hidden */
  43149. _activeCamera: Nullable<Camera>;
  43150. /** Gets or sets the current active camera */
  43151. get activeCamera(): Nullable<Camera>;
  43152. set activeCamera(value: Nullable<Camera>);
  43153. private _defaultMaterial;
  43154. /** The default material used on meshes when no material is affected */
  43155. get defaultMaterial(): Material;
  43156. /** The default material used on meshes when no material is affected */
  43157. set defaultMaterial(value: Material);
  43158. private _texturesEnabled;
  43159. /**
  43160. * Gets or sets a boolean indicating if textures are enabled on this scene
  43161. */
  43162. set texturesEnabled(value: boolean);
  43163. get texturesEnabled(): boolean;
  43164. /**
  43165. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43166. */
  43167. physicsEnabled: boolean;
  43168. /**
  43169. * Gets or sets a boolean indicating if particles are enabled on this scene
  43170. */
  43171. particlesEnabled: boolean;
  43172. /**
  43173. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43174. */
  43175. spritesEnabled: boolean;
  43176. private _skeletonsEnabled;
  43177. /**
  43178. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43179. */
  43180. set skeletonsEnabled(value: boolean);
  43181. get skeletonsEnabled(): boolean;
  43182. /**
  43183. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43184. */
  43185. lensFlaresEnabled: boolean;
  43186. /**
  43187. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43188. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43189. */
  43190. collisionsEnabled: boolean;
  43191. private _collisionCoordinator;
  43192. /** @hidden */
  43193. get collisionCoordinator(): ICollisionCoordinator;
  43194. /**
  43195. * Defines the gravity applied to this scene (used only for collisions)
  43196. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43197. */
  43198. gravity: Vector3;
  43199. /**
  43200. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43201. */
  43202. postProcessesEnabled: boolean;
  43203. /**
  43204. * Gets the current postprocess manager
  43205. */
  43206. postProcessManager: PostProcessManager;
  43207. /**
  43208. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43209. */
  43210. renderTargetsEnabled: boolean;
  43211. /**
  43212. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43213. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43214. */
  43215. dumpNextRenderTargets: boolean;
  43216. /**
  43217. * The list of user defined render targets added to the scene
  43218. */
  43219. customRenderTargets: RenderTargetTexture[];
  43220. /**
  43221. * Defines if texture loading must be delayed
  43222. * If true, textures will only be loaded when they need to be rendered
  43223. */
  43224. useDelayedTextureLoading: boolean;
  43225. /**
  43226. * Gets the list of meshes imported to the scene through SceneLoader
  43227. */
  43228. importedMeshesFiles: String[];
  43229. /**
  43230. * Gets or sets a boolean indicating if probes are enabled on this scene
  43231. */
  43232. probesEnabled: boolean;
  43233. /**
  43234. * Gets or sets the current offline provider to use to store scene data
  43235. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43236. */
  43237. offlineProvider: IOfflineProvider;
  43238. /**
  43239. * Gets or sets the action manager associated with the scene
  43240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43241. */
  43242. actionManager: AbstractActionManager;
  43243. private _meshesForIntersections;
  43244. /**
  43245. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43246. */
  43247. proceduralTexturesEnabled: boolean;
  43248. private _engine;
  43249. private _totalVertices;
  43250. /** @hidden */
  43251. _activeIndices: PerfCounter;
  43252. /** @hidden */
  43253. _activeParticles: PerfCounter;
  43254. /** @hidden */
  43255. _activeBones: PerfCounter;
  43256. private _animationRatio;
  43257. /** @hidden */
  43258. _animationTimeLast: number;
  43259. /** @hidden */
  43260. _animationTime: number;
  43261. /**
  43262. * Gets or sets a general scale for animation speed
  43263. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43264. */
  43265. animationTimeScale: number;
  43266. /** @hidden */
  43267. _cachedMaterial: Nullable<Material>;
  43268. /** @hidden */
  43269. _cachedEffect: Nullable<Effect>;
  43270. /** @hidden */
  43271. _cachedVisibility: Nullable<number>;
  43272. private _renderId;
  43273. private _frameId;
  43274. private _executeWhenReadyTimeoutId;
  43275. private _intermediateRendering;
  43276. private _viewUpdateFlag;
  43277. private _projectionUpdateFlag;
  43278. /** @hidden */
  43279. _toBeDisposed: Nullable<IDisposable>[];
  43280. private _activeRequests;
  43281. /** @hidden */
  43282. _pendingData: any[];
  43283. private _isDisposed;
  43284. /**
  43285. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43286. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43287. */
  43288. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43289. private _activeMeshes;
  43290. private _processedMaterials;
  43291. private _renderTargets;
  43292. /** @hidden */
  43293. _activeParticleSystems: SmartArray<IParticleSystem>;
  43294. private _activeSkeletons;
  43295. private _softwareSkinnedMeshes;
  43296. private _renderingManager;
  43297. /** @hidden */
  43298. _activeAnimatables: Animatable[];
  43299. private _transformMatrix;
  43300. private _sceneUbo;
  43301. /** @hidden */
  43302. _viewMatrix: Matrix;
  43303. private _projectionMatrix;
  43304. /** @hidden */
  43305. _forcedViewPosition: Nullable<Vector3>;
  43306. /** @hidden */
  43307. _frustumPlanes: Plane[];
  43308. /**
  43309. * Gets the list of frustum planes (built from the active camera)
  43310. */
  43311. get frustumPlanes(): Plane[];
  43312. /**
  43313. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43314. * This is useful if there are more lights that the maximum simulteanous authorized
  43315. */
  43316. requireLightSorting: boolean;
  43317. /** @hidden */
  43318. readonly useMaterialMeshMap: boolean;
  43319. /** @hidden */
  43320. readonly useClonedMeshMap: boolean;
  43321. private _externalData;
  43322. private _uid;
  43323. /**
  43324. * @hidden
  43325. * Backing store of defined scene components.
  43326. */
  43327. _components: ISceneComponent[];
  43328. /**
  43329. * @hidden
  43330. * Backing store of defined scene components.
  43331. */
  43332. _serializableComponents: ISceneSerializableComponent[];
  43333. /**
  43334. * List of components to register on the next registration step.
  43335. */
  43336. private _transientComponents;
  43337. /**
  43338. * Registers the transient components if needed.
  43339. */
  43340. private _registerTransientComponents;
  43341. /**
  43342. * @hidden
  43343. * Add a component to the scene.
  43344. * Note that the ccomponent could be registered on th next frame if this is called after
  43345. * the register component stage.
  43346. * @param component Defines the component to add to the scene
  43347. */
  43348. _addComponent(component: ISceneComponent): void;
  43349. /**
  43350. * @hidden
  43351. * Gets a component from the scene.
  43352. * @param name defines the name of the component to retrieve
  43353. * @returns the component or null if not present
  43354. */
  43355. _getComponent(name: string): Nullable<ISceneComponent>;
  43356. /**
  43357. * @hidden
  43358. * Defines the actions happening before camera updates.
  43359. */
  43360. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43361. /**
  43362. * @hidden
  43363. * Defines the actions happening before clear the canvas.
  43364. */
  43365. _beforeClearStage: Stage<SimpleStageAction>;
  43366. /**
  43367. * @hidden
  43368. * Defines the actions when collecting render targets for the frame.
  43369. */
  43370. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43371. /**
  43372. * @hidden
  43373. * Defines the actions happening for one camera in the frame.
  43374. */
  43375. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43376. /**
  43377. * @hidden
  43378. * Defines the actions happening during the per mesh ready checks.
  43379. */
  43380. _isReadyForMeshStage: Stage<MeshStageAction>;
  43381. /**
  43382. * @hidden
  43383. * Defines the actions happening before evaluate active mesh checks.
  43384. */
  43385. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43386. /**
  43387. * @hidden
  43388. * Defines the actions happening during the evaluate sub mesh checks.
  43389. */
  43390. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43391. /**
  43392. * @hidden
  43393. * Defines the actions happening during the active mesh stage.
  43394. */
  43395. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43396. /**
  43397. * @hidden
  43398. * Defines the actions happening during the per camera render target step.
  43399. */
  43400. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43401. /**
  43402. * @hidden
  43403. * Defines the actions happening just before the active camera is drawing.
  43404. */
  43405. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43406. /**
  43407. * @hidden
  43408. * Defines the actions happening just before a render target is drawing.
  43409. */
  43410. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43411. /**
  43412. * @hidden
  43413. * Defines the actions happening just before a rendering group is drawing.
  43414. */
  43415. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43416. /**
  43417. * @hidden
  43418. * Defines the actions happening just before a mesh is drawing.
  43419. */
  43420. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43421. /**
  43422. * @hidden
  43423. * Defines the actions happening just after a mesh has been drawn.
  43424. */
  43425. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43426. /**
  43427. * @hidden
  43428. * Defines the actions happening just after a rendering group has been drawn.
  43429. */
  43430. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43431. /**
  43432. * @hidden
  43433. * Defines the actions happening just after the active camera has been drawn.
  43434. */
  43435. _afterCameraDrawStage: Stage<CameraStageAction>;
  43436. /**
  43437. * @hidden
  43438. * Defines the actions happening just after a render target has been drawn.
  43439. */
  43440. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43441. /**
  43442. * @hidden
  43443. * Defines the actions happening just after rendering all cameras and computing intersections.
  43444. */
  43445. _afterRenderStage: Stage<SimpleStageAction>;
  43446. /**
  43447. * @hidden
  43448. * Defines the actions happening when a pointer move event happens.
  43449. */
  43450. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43451. /**
  43452. * @hidden
  43453. * Defines the actions happening when a pointer down event happens.
  43454. */
  43455. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43456. /**
  43457. * @hidden
  43458. * Defines the actions happening when a pointer up event happens.
  43459. */
  43460. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43461. /**
  43462. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43463. */
  43464. private geometriesByUniqueId;
  43465. /**
  43466. * Creates a new Scene
  43467. * @param engine defines the engine to use to render this scene
  43468. * @param options defines the scene options
  43469. */
  43470. constructor(engine: Engine, options?: SceneOptions);
  43471. /**
  43472. * Gets a string identifying the name of the class
  43473. * @returns "Scene" string
  43474. */
  43475. getClassName(): string;
  43476. private _defaultMeshCandidates;
  43477. /**
  43478. * @hidden
  43479. */
  43480. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43481. private _defaultSubMeshCandidates;
  43482. /**
  43483. * @hidden
  43484. */
  43485. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43486. /**
  43487. * Sets the default candidate providers for the scene.
  43488. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43489. * and getCollidingSubMeshCandidates to their default function
  43490. */
  43491. setDefaultCandidateProviders(): void;
  43492. /**
  43493. * Gets the mesh that is currently under the pointer
  43494. */
  43495. get meshUnderPointer(): Nullable<AbstractMesh>;
  43496. /**
  43497. * Gets or sets the current on-screen X position of the pointer
  43498. */
  43499. get pointerX(): number;
  43500. set pointerX(value: number);
  43501. /**
  43502. * Gets or sets the current on-screen Y position of the pointer
  43503. */
  43504. get pointerY(): number;
  43505. set pointerY(value: number);
  43506. /**
  43507. * Gets the cached material (ie. the latest rendered one)
  43508. * @returns the cached material
  43509. */
  43510. getCachedMaterial(): Nullable<Material>;
  43511. /**
  43512. * Gets the cached effect (ie. the latest rendered one)
  43513. * @returns the cached effect
  43514. */
  43515. getCachedEffect(): Nullable<Effect>;
  43516. /**
  43517. * Gets the cached visibility state (ie. the latest rendered one)
  43518. * @returns the cached visibility state
  43519. */
  43520. getCachedVisibility(): Nullable<number>;
  43521. /**
  43522. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43523. * @param material defines the current material
  43524. * @param effect defines the current effect
  43525. * @param visibility defines the current visibility state
  43526. * @returns true if one parameter is not cached
  43527. */
  43528. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43529. /**
  43530. * Gets the engine associated with the scene
  43531. * @returns an Engine
  43532. */
  43533. getEngine(): Engine;
  43534. /**
  43535. * Gets the total number of vertices rendered per frame
  43536. * @returns the total number of vertices rendered per frame
  43537. */
  43538. getTotalVertices(): number;
  43539. /**
  43540. * Gets the performance counter for total vertices
  43541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43542. */
  43543. get totalVerticesPerfCounter(): PerfCounter;
  43544. /**
  43545. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43546. * @returns the total number of active indices rendered per frame
  43547. */
  43548. getActiveIndices(): number;
  43549. /**
  43550. * Gets the performance counter for active indices
  43551. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43552. */
  43553. get totalActiveIndicesPerfCounter(): PerfCounter;
  43554. /**
  43555. * Gets the total number of active particles rendered per frame
  43556. * @returns the total number of active particles rendered per frame
  43557. */
  43558. getActiveParticles(): number;
  43559. /**
  43560. * Gets the performance counter for active particles
  43561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43562. */
  43563. get activeParticlesPerfCounter(): PerfCounter;
  43564. /**
  43565. * Gets the total number of active bones rendered per frame
  43566. * @returns the total number of active bones rendered per frame
  43567. */
  43568. getActiveBones(): number;
  43569. /**
  43570. * Gets the performance counter for active bones
  43571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43572. */
  43573. get activeBonesPerfCounter(): PerfCounter;
  43574. /**
  43575. * Gets the array of active meshes
  43576. * @returns an array of AbstractMesh
  43577. */
  43578. getActiveMeshes(): SmartArray<AbstractMesh>;
  43579. /**
  43580. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43581. * @returns a number
  43582. */
  43583. getAnimationRatio(): number;
  43584. /**
  43585. * Gets an unique Id for the current render phase
  43586. * @returns a number
  43587. */
  43588. getRenderId(): number;
  43589. /**
  43590. * Gets an unique Id for the current frame
  43591. * @returns a number
  43592. */
  43593. getFrameId(): number;
  43594. /** Call this function if you want to manually increment the render Id*/
  43595. incrementRenderId(): void;
  43596. private _createUbo;
  43597. /**
  43598. * Use this method to simulate a pointer move on a mesh
  43599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43602. * @returns the current scene
  43603. */
  43604. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43605. /**
  43606. * Use this method to simulate a pointer down on a mesh
  43607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43610. * @returns the current scene
  43611. */
  43612. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43613. /**
  43614. * Use this method to simulate a pointer up on a mesh
  43615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43618. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43619. * @returns the current scene
  43620. */
  43621. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43622. /**
  43623. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43624. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43625. * @returns true if the pointer was captured
  43626. */
  43627. isPointerCaptured(pointerId?: number): boolean;
  43628. /**
  43629. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43630. * @param attachUp defines if you want to attach events to pointerup
  43631. * @param attachDown defines if you want to attach events to pointerdown
  43632. * @param attachMove defines if you want to attach events to pointermove
  43633. */
  43634. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43635. /** Detaches all event handlers*/
  43636. detachControl(): void;
  43637. /**
  43638. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43639. * Delay loaded resources are not taking in account
  43640. * @return true if all required resources are ready
  43641. */
  43642. isReady(): boolean;
  43643. /** Resets all cached information relative to material (including effect and visibility) */
  43644. resetCachedMaterial(): void;
  43645. /**
  43646. * Registers a function to be called before every frame render
  43647. * @param func defines the function to register
  43648. */
  43649. registerBeforeRender(func: () => void): void;
  43650. /**
  43651. * Unregisters a function called before every frame render
  43652. * @param func defines the function to unregister
  43653. */
  43654. unregisterBeforeRender(func: () => void): void;
  43655. /**
  43656. * Registers a function to be called after every frame render
  43657. * @param func defines the function to register
  43658. */
  43659. registerAfterRender(func: () => void): void;
  43660. /**
  43661. * Unregisters a function called after every frame render
  43662. * @param func defines the function to unregister
  43663. */
  43664. unregisterAfterRender(func: () => void): void;
  43665. private _executeOnceBeforeRender;
  43666. /**
  43667. * The provided function will run before render once and will be disposed afterwards.
  43668. * A timeout delay can be provided so that the function will be executed in N ms.
  43669. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43670. * @param func The function to be executed.
  43671. * @param timeout optional delay in ms
  43672. */
  43673. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43674. /** @hidden */
  43675. _addPendingData(data: any): void;
  43676. /** @hidden */
  43677. _removePendingData(data: any): void;
  43678. /**
  43679. * Returns the number of items waiting to be loaded
  43680. * @returns the number of items waiting to be loaded
  43681. */
  43682. getWaitingItemsCount(): number;
  43683. /**
  43684. * Returns a boolean indicating if the scene is still loading data
  43685. */
  43686. get isLoading(): boolean;
  43687. /**
  43688. * Registers a function to be executed when the scene is ready
  43689. * @param {Function} func - the function to be executed
  43690. */
  43691. executeWhenReady(func: () => void): void;
  43692. /**
  43693. * Returns a promise that resolves when the scene is ready
  43694. * @returns A promise that resolves when the scene is ready
  43695. */
  43696. whenReadyAsync(): Promise<void>;
  43697. /** @hidden */
  43698. _checkIsReady(): void;
  43699. /**
  43700. * Gets all animatable attached to the scene
  43701. */
  43702. get animatables(): Animatable[];
  43703. /**
  43704. * Resets the last animation time frame.
  43705. * Useful to override when animations start running when loading a scene for the first time.
  43706. */
  43707. resetLastAnimationTimeFrame(): void;
  43708. /**
  43709. * Gets the current view matrix
  43710. * @returns a Matrix
  43711. */
  43712. getViewMatrix(): Matrix;
  43713. /**
  43714. * Gets the current projection matrix
  43715. * @returns a Matrix
  43716. */
  43717. getProjectionMatrix(): Matrix;
  43718. /**
  43719. * Gets the current transform matrix
  43720. * @returns a Matrix made of View * Projection
  43721. */
  43722. getTransformMatrix(): Matrix;
  43723. /**
  43724. * Sets the current transform matrix
  43725. * @param viewL defines the View matrix to use
  43726. * @param projectionL defines the Projection matrix to use
  43727. * @param viewR defines the right View matrix to use (if provided)
  43728. * @param projectionR defines the right Projection matrix to use (if provided)
  43729. */
  43730. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43731. /**
  43732. * Gets the uniform buffer used to store scene data
  43733. * @returns a UniformBuffer
  43734. */
  43735. getSceneUniformBuffer(): UniformBuffer;
  43736. /**
  43737. * Gets an unique (relatively to the current scene) Id
  43738. * @returns an unique number for the scene
  43739. */
  43740. getUniqueId(): number;
  43741. /**
  43742. * Add a mesh to the list of scene's meshes
  43743. * @param newMesh defines the mesh to add
  43744. * @param recursive if all child meshes should also be added to the scene
  43745. */
  43746. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43747. /**
  43748. * Remove a mesh for the list of scene's meshes
  43749. * @param toRemove defines the mesh to remove
  43750. * @param recursive if all child meshes should also be removed from the scene
  43751. * @returns the index where the mesh was in the mesh list
  43752. */
  43753. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43754. /**
  43755. * Add a transform node to the list of scene's transform nodes
  43756. * @param newTransformNode defines the transform node to add
  43757. */
  43758. addTransformNode(newTransformNode: TransformNode): void;
  43759. /**
  43760. * Remove a transform node for the list of scene's transform nodes
  43761. * @param toRemove defines the transform node to remove
  43762. * @returns the index where the transform node was in the transform node list
  43763. */
  43764. removeTransformNode(toRemove: TransformNode): number;
  43765. /**
  43766. * Remove a skeleton for the list of scene's skeletons
  43767. * @param toRemove defines the skeleton to remove
  43768. * @returns the index where the skeleton was in the skeleton list
  43769. */
  43770. removeSkeleton(toRemove: Skeleton): number;
  43771. /**
  43772. * Remove a morph target for the list of scene's morph targets
  43773. * @param toRemove defines the morph target to remove
  43774. * @returns the index where the morph target was in the morph target list
  43775. */
  43776. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43777. /**
  43778. * Remove a light for the list of scene's lights
  43779. * @param toRemove defines the light to remove
  43780. * @returns the index where the light was in the light list
  43781. */
  43782. removeLight(toRemove: Light): number;
  43783. /**
  43784. * Remove a camera for the list of scene's cameras
  43785. * @param toRemove defines the camera to remove
  43786. * @returns the index where the camera was in the camera list
  43787. */
  43788. removeCamera(toRemove: Camera): number;
  43789. /**
  43790. * Remove a particle system for the list of scene's particle systems
  43791. * @param toRemove defines the particle system to remove
  43792. * @returns the index where the particle system was in the particle system list
  43793. */
  43794. removeParticleSystem(toRemove: IParticleSystem): number;
  43795. /**
  43796. * Remove a animation for the list of scene's animations
  43797. * @param toRemove defines the animation to remove
  43798. * @returns the index where the animation was in the animation list
  43799. */
  43800. removeAnimation(toRemove: Animation): number;
  43801. /**
  43802. * Will stop the animation of the given target
  43803. * @param target - the target
  43804. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43805. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  43806. */
  43807. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43808. /**
  43809. * Removes the given animation group from this scene.
  43810. * @param toRemove The animation group to remove
  43811. * @returns The index of the removed animation group
  43812. */
  43813. removeAnimationGroup(toRemove: AnimationGroup): number;
  43814. /**
  43815. * Removes the given multi-material from this scene.
  43816. * @param toRemove The multi-material to remove
  43817. * @returns The index of the removed multi-material
  43818. */
  43819. removeMultiMaterial(toRemove: MultiMaterial): number;
  43820. /**
  43821. * Removes the given material from this scene.
  43822. * @param toRemove The material to remove
  43823. * @returns The index of the removed material
  43824. */
  43825. removeMaterial(toRemove: Material): number;
  43826. /**
  43827. * Removes the given action manager from this scene.
  43828. * @param toRemove The action manager to remove
  43829. * @returns The index of the removed action manager
  43830. */
  43831. removeActionManager(toRemove: AbstractActionManager): number;
  43832. /**
  43833. * Removes the given texture from this scene.
  43834. * @param toRemove The texture to remove
  43835. * @returns The index of the removed texture
  43836. */
  43837. removeTexture(toRemove: BaseTexture): number;
  43838. /**
  43839. * Adds the given light to this scene
  43840. * @param newLight The light to add
  43841. */
  43842. addLight(newLight: Light): void;
  43843. /**
  43844. * Sorts the list list based on light priorities
  43845. */
  43846. sortLightsByPriority(): void;
  43847. /**
  43848. * Adds the given camera to this scene
  43849. * @param newCamera The camera to add
  43850. */
  43851. addCamera(newCamera: Camera): void;
  43852. /**
  43853. * Adds the given skeleton to this scene
  43854. * @param newSkeleton The skeleton to add
  43855. */
  43856. addSkeleton(newSkeleton: Skeleton): void;
  43857. /**
  43858. * Adds the given particle system to this scene
  43859. * @param newParticleSystem The particle system to add
  43860. */
  43861. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43862. /**
  43863. * Adds the given animation to this scene
  43864. * @param newAnimation The animation to add
  43865. */
  43866. addAnimation(newAnimation: Animation): void;
  43867. /**
  43868. * Adds the given animation group to this scene.
  43869. * @param newAnimationGroup The animation group to add
  43870. */
  43871. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43872. /**
  43873. * Adds the given multi-material to this scene
  43874. * @param newMultiMaterial The multi-material to add
  43875. */
  43876. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43877. /**
  43878. * Adds the given material to this scene
  43879. * @param newMaterial The material to add
  43880. */
  43881. addMaterial(newMaterial: Material): void;
  43882. /**
  43883. * Adds the given morph target to this scene
  43884. * @param newMorphTargetManager The morph target to add
  43885. */
  43886. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43887. /**
  43888. * Adds the given geometry to this scene
  43889. * @param newGeometry The geometry to add
  43890. */
  43891. addGeometry(newGeometry: Geometry): void;
  43892. /**
  43893. * Adds the given action manager to this scene
  43894. * @param newActionManager The action manager to add
  43895. */
  43896. addActionManager(newActionManager: AbstractActionManager): void;
  43897. /**
  43898. * Adds the given texture to this scene.
  43899. * @param newTexture The texture to add
  43900. */
  43901. addTexture(newTexture: BaseTexture): void;
  43902. /**
  43903. * Switch active camera
  43904. * @param newCamera defines the new active camera
  43905. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43906. */
  43907. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43908. /**
  43909. * sets the active camera of the scene using its ID
  43910. * @param id defines the camera's ID
  43911. * @return the new active camera or null if none found.
  43912. */
  43913. setActiveCameraByID(id: string): Nullable<Camera>;
  43914. /**
  43915. * sets the active camera of the scene using its name
  43916. * @param name defines the camera's name
  43917. * @returns the new active camera or null if none found.
  43918. */
  43919. setActiveCameraByName(name: string): Nullable<Camera>;
  43920. /**
  43921. * get an animation group using its name
  43922. * @param name defines the material's name
  43923. * @return the animation group or null if none found.
  43924. */
  43925. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43926. /**
  43927. * Get a material using its unique id
  43928. * @param uniqueId defines the material's unique id
  43929. * @return the material or null if none found.
  43930. */
  43931. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43932. /**
  43933. * get a material using its id
  43934. * @param id defines the material's ID
  43935. * @return the material or null if none found.
  43936. */
  43937. getMaterialByID(id: string): Nullable<Material>;
  43938. /**
  43939. * Gets a the last added material using a given id
  43940. * @param id defines the material's ID
  43941. * @return the last material with the given id or null if none found.
  43942. */
  43943. getLastMaterialByID(id: string): Nullable<Material>;
  43944. /**
  43945. * Gets a material using its name
  43946. * @param name defines the material's name
  43947. * @return the material or null if none found.
  43948. */
  43949. getMaterialByName(name: string): Nullable<Material>;
  43950. /**
  43951. * Get a texture using its unique id
  43952. * @param uniqueId defines the texture's unique id
  43953. * @return the texture or null if none found.
  43954. */
  43955. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43956. /**
  43957. * Gets a camera using its id
  43958. * @param id defines the id to look for
  43959. * @returns the camera or null if not found
  43960. */
  43961. getCameraByID(id: string): Nullable<Camera>;
  43962. /**
  43963. * Gets a camera using its unique id
  43964. * @param uniqueId defines the unique id to look for
  43965. * @returns the camera or null if not found
  43966. */
  43967. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43968. /**
  43969. * Gets a camera using its name
  43970. * @param name defines the camera's name
  43971. * @return the camera or null if none found.
  43972. */
  43973. getCameraByName(name: string): Nullable<Camera>;
  43974. /**
  43975. * Gets a bone using its id
  43976. * @param id defines the bone's id
  43977. * @return the bone or null if not found
  43978. */
  43979. getBoneByID(id: string): Nullable<Bone>;
  43980. /**
  43981. * Gets a bone using its id
  43982. * @param name defines the bone's name
  43983. * @return the bone or null if not found
  43984. */
  43985. getBoneByName(name: string): Nullable<Bone>;
  43986. /**
  43987. * Gets a light node using its name
  43988. * @param name defines the the light's name
  43989. * @return the light or null if none found.
  43990. */
  43991. getLightByName(name: string): Nullable<Light>;
  43992. /**
  43993. * Gets a light node using its id
  43994. * @param id defines the light's id
  43995. * @return the light or null if none found.
  43996. */
  43997. getLightByID(id: string): Nullable<Light>;
  43998. /**
  43999. * Gets a light node using its scene-generated unique ID
  44000. * @param uniqueId defines the light's unique id
  44001. * @return the light or null if none found.
  44002. */
  44003. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44004. /**
  44005. * Gets a particle system by id
  44006. * @param id defines the particle system id
  44007. * @return the corresponding system or null if none found
  44008. */
  44009. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44010. /**
  44011. * Gets a geometry using its ID
  44012. * @param id defines the geometry's id
  44013. * @return the geometry or null if none found.
  44014. */
  44015. getGeometryByID(id: string): Nullable<Geometry>;
  44016. private _getGeometryByUniqueID;
  44017. /**
  44018. * Add a new geometry to this scene
  44019. * @param geometry defines the geometry to be added to the scene.
  44020. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44021. * @return a boolean defining if the geometry was added or not
  44022. */
  44023. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44024. /**
  44025. * Removes an existing geometry
  44026. * @param geometry defines the geometry to be removed from the scene
  44027. * @return a boolean defining if the geometry was removed or not
  44028. */
  44029. removeGeometry(geometry: Geometry): boolean;
  44030. /**
  44031. * Gets the list of geometries attached to the scene
  44032. * @returns an array of Geometry
  44033. */
  44034. getGeometries(): Geometry[];
  44035. /**
  44036. * Gets the first added mesh found of a given ID
  44037. * @param id defines the id to search for
  44038. * @return the mesh found or null if not found at all
  44039. */
  44040. getMeshByID(id: string): Nullable<AbstractMesh>;
  44041. /**
  44042. * Gets a list of meshes using their id
  44043. * @param id defines the id to search for
  44044. * @returns a list of meshes
  44045. */
  44046. getMeshesByID(id: string): Array<AbstractMesh>;
  44047. /**
  44048. * Gets the first added transform node found of a given ID
  44049. * @param id defines the id to search for
  44050. * @return the found transform node or null if not found at all.
  44051. */
  44052. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44053. /**
  44054. * Gets a transform node with its auto-generated unique id
  44055. * @param uniqueId efines the unique id to search for
  44056. * @return the found transform node or null if not found at all.
  44057. */
  44058. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44059. /**
  44060. * Gets a list of transform nodes using their id
  44061. * @param id defines the id to search for
  44062. * @returns a list of transform nodes
  44063. */
  44064. getTransformNodesByID(id: string): Array<TransformNode>;
  44065. /**
  44066. * Gets a mesh with its auto-generated unique id
  44067. * @param uniqueId defines the unique id to search for
  44068. * @return the found mesh or null if not found at all.
  44069. */
  44070. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44071. /**
  44072. * Gets a the last added mesh using a given id
  44073. * @param id defines the id to search for
  44074. * @return the found mesh or null if not found at all.
  44075. */
  44076. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44077. /**
  44078. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44079. * @param id defines the id to search for
  44080. * @return the found node or null if not found at all
  44081. */
  44082. getLastEntryByID(id: string): Nullable<Node>;
  44083. /**
  44084. * Gets a node (Mesh, Camera, Light) using a given id
  44085. * @param id defines the id to search for
  44086. * @return the found node or null if not found at all
  44087. */
  44088. getNodeByID(id: string): Nullable<Node>;
  44089. /**
  44090. * Gets a node (Mesh, Camera, Light) using a given name
  44091. * @param name defines the name to search for
  44092. * @return the found node or null if not found at all.
  44093. */
  44094. getNodeByName(name: string): Nullable<Node>;
  44095. /**
  44096. * Gets a mesh using a given name
  44097. * @param name defines the name to search for
  44098. * @return the found mesh or null if not found at all.
  44099. */
  44100. getMeshByName(name: string): Nullable<AbstractMesh>;
  44101. /**
  44102. * Gets a transform node using a given name
  44103. * @param name defines the name to search for
  44104. * @return the found transform node or null if not found at all.
  44105. */
  44106. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44107. /**
  44108. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44109. * @param id defines the id to search for
  44110. * @return the found skeleton or null if not found at all.
  44111. */
  44112. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44113. /**
  44114. * Gets a skeleton using a given auto generated unique id
  44115. * @param uniqueId defines the unique id to search for
  44116. * @return the found skeleton or null if not found at all.
  44117. */
  44118. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44119. /**
  44120. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44121. * @param id defines the id to search for
  44122. * @return the found skeleton or null if not found at all.
  44123. */
  44124. getSkeletonById(id: string): Nullable<Skeleton>;
  44125. /**
  44126. * Gets a skeleton using a given name
  44127. * @param name defines the name to search for
  44128. * @return the found skeleton or null if not found at all.
  44129. */
  44130. getSkeletonByName(name: string): Nullable<Skeleton>;
  44131. /**
  44132. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44133. * @param id defines the id to search for
  44134. * @return the found morph target manager or null if not found at all.
  44135. */
  44136. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44137. /**
  44138. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44139. * @param id defines the id to search for
  44140. * @return the found morph target or null if not found at all.
  44141. */
  44142. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44143. /**
  44144. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44145. * @param name defines the name to search for
  44146. * @return the found morph target or null if not found at all.
  44147. */
  44148. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44149. /**
  44150. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44151. * @param name defines the name to search for
  44152. * @return the found post process or null if not found at all.
  44153. */
  44154. getPostProcessByName(name: string): Nullable<PostProcess>;
  44155. /**
  44156. * Gets a boolean indicating if the given mesh is active
  44157. * @param mesh defines the mesh to look for
  44158. * @returns true if the mesh is in the active list
  44159. */
  44160. isActiveMesh(mesh: AbstractMesh): boolean;
  44161. /**
  44162. * Return a unique id as a string which can serve as an identifier for the scene
  44163. */
  44164. get uid(): string;
  44165. /**
  44166. * Add an externaly attached data from its key.
  44167. * This method call will fail and return false, if such key already exists.
  44168. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44169. * @param key the unique key that identifies the data
  44170. * @param data the data object to associate to the key for this Engine instance
  44171. * @return true if no such key were already present and the data was added successfully, false otherwise
  44172. */
  44173. addExternalData<T>(key: string, data: T): boolean;
  44174. /**
  44175. * Get an externaly attached data from its key
  44176. * @param key the unique key that identifies the data
  44177. * @return the associated data, if present (can be null), or undefined if not present
  44178. */
  44179. getExternalData<T>(key: string): Nullable<T>;
  44180. /**
  44181. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44182. * @param key the unique key that identifies the data
  44183. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44184. * @return the associated data, can be null if the factory returned null.
  44185. */
  44186. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44187. /**
  44188. * Remove an externaly attached data from the Engine instance
  44189. * @param key the unique key that identifies the data
  44190. * @return true if the data was successfully removed, false if it doesn't exist
  44191. */
  44192. removeExternalData(key: string): boolean;
  44193. private _evaluateSubMesh;
  44194. /**
  44195. * Clear the processed materials smart array preventing retention point in material dispose.
  44196. */
  44197. freeProcessedMaterials(): void;
  44198. private _preventFreeActiveMeshesAndRenderingGroups;
  44199. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44200. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44201. * when disposing several meshes in a row or a hierarchy of meshes.
  44202. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44203. */
  44204. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44205. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44206. /**
  44207. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44208. */
  44209. freeActiveMeshes(): void;
  44210. /**
  44211. * Clear the info related to rendering groups preventing retention points during dispose.
  44212. */
  44213. freeRenderingGroups(): void;
  44214. /** @hidden */
  44215. _isInIntermediateRendering(): boolean;
  44216. /**
  44217. * Lambda returning the list of potentially active meshes.
  44218. */
  44219. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44220. /**
  44221. * Lambda returning the list of potentially active sub meshes.
  44222. */
  44223. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44224. /**
  44225. * Lambda returning the list of potentially intersecting sub meshes.
  44226. */
  44227. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44228. /**
  44229. * Lambda returning the list of potentially colliding sub meshes.
  44230. */
  44231. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44232. private _activeMeshesFrozen;
  44233. private _skipEvaluateActiveMeshesCompletely;
  44234. /**
  44235. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44236. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44237. * @param onSuccess optional success callback
  44238. * @param onError optional error callback
  44239. * @returns the current scene
  44240. */
  44241. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44242. /**
  44243. * Use this function to restart evaluating active meshes on every frame
  44244. * @returns the current scene
  44245. */
  44246. unfreezeActiveMeshes(): Scene;
  44247. private _evaluateActiveMeshes;
  44248. private _activeMesh;
  44249. /**
  44250. * Update the transform matrix to update from the current active camera
  44251. * @param force defines a boolean used to force the update even if cache is up to date
  44252. */
  44253. updateTransformMatrix(force?: boolean): void;
  44254. private _bindFrameBuffer;
  44255. /** @hidden */
  44256. _allowPostProcessClearColor: boolean;
  44257. /** @hidden */
  44258. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44259. private _processSubCameras;
  44260. private _checkIntersections;
  44261. /** @hidden */
  44262. _advancePhysicsEngineStep(step: number): void;
  44263. /**
  44264. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44265. */
  44266. getDeterministicFrameTime: () => number;
  44267. /** @hidden */
  44268. _animate(): void;
  44269. /** Execute all animations (for a frame) */
  44270. animate(): void;
  44271. /**
  44272. * Render the scene
  44273. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44274. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44275. */
  44276. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44277. /**
  44278. * Freeze all materials
  44279. * A frozen material will not be updatable but should be faster to render
  44280. */
  44281. freezeMaterials(): void;
  44282. /**
  44283. * Unfreeze all materials
  44284. * A frozen material will not be updatable but should be faster to render
  44285. */
  44286. unfreezeMaterials(): void;
  44287. /**
  44288. * Releases all held ressources
  44289. */
  44290. dispose(): void;
  44291. /**
  44292. * Gets if the scene is already disposed
  44293. */
  44294. get isDisposed(): boolean;
  44295. /**
  44296. * Call this function to reduce memory footprint of the scene.
  44297. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44298. */
  44299. clearCachedVertexData(): void;
  44300. /**
  44301. * This function will remove the local cached buffer data from texture.
  44302. * It will save memory but will prevent the texture from being rebuilt
  44303. */
  44304. cleanCachedTextureBuffer(): void;
  44305. /**
  44306. * Get the world extend vectors with an optional filter
  44307. *
  44308. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44309. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44310. */
  44311. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44312. min: Vector3;
  44313. max: Vector3;
  44314. };
  44315. /**
  44316. * Creates a ray that can be used to pick in the scene
  44317. * @param x defines the x coordinate of the origin (on-screen)
  44318. * @param y defines the y coordinate of the origin (on-screen)
  44319. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44320. * @param camera defines the camera to use for the picking
  44321. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44322. * @returns a Ray
  44323. */
  44324. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44325. /**
  44326. * Creates a ray that can be used to pick in the scene
  44327. * @param x defines the x coordinate of the origin (on-screen)
  44328. * @param y defines the y coordinate of the origin (on-screen)
  44329. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44330. * @param result defines the ray where to store the picking ray
  44331. * @param camera defines the camera to use for the picking
  44332. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44333. * @returns the current scene
  44334. */
  44335. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44336. /**
  44337. * Creates a ray that can be used to pick in the scene
  44338. * @param x defines the x coordinate of the origin (on-screen)
  44339. * @param y defines the y coordinate of the origin (on-screen)
  44340. * @param camera defines the camera to use for the picking
  44341. * @returns a Ray
  44342. */
  44343. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44344. /**
  44345. * Creates a ray that can be used to pick in the scene
  44346. * @param x defines the x coordinate of the origin (on-screen)
  44347. * @param y defines the y coordinate of the origin (on-screen)
  44348. * @param result defines the ray where to store the picking ray
  44349. * @param camera defines the camera to use for the picking
  44350. * @returns the current scene
  44351. */
  44352. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44353. /** Launch a ray to try to pick a mesh in the scene
  44354. * @param x position on screen
  44355. * @param y position on screen
  44356. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44358. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44359. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44360. * @returns a PickingInfo
  44361. */
  44362. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44363. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44364. * @param x position on screen
  44365. * @param y position on screen
  44366. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44367. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44368. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44369. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  44370. */
  44371. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44372. /** Use the given ray to pick a mesh in the scene
  44373. * @param ray The ray to use to pick meshes
  44374. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  44375. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44377. * @returns a PickingInfo
  44378. */
  44379. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44380. /**
  44381. * Launch a ray to try to pick a mesh in the scene
  44382. * @param x X position on screen
  44383. * @param y Y position on screen
  44384. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44385. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44387. * @returns an array of PickingInfo
  44388. */
  44389. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44390. /**
  44391. * Launch a ray to try to pick a mesh in the scene
  44392. * @param ray Ray to use
  44393. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44394. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44395. * @returns an array of PickingInfo
  44396. */
  44397. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44398. /**
  44399. * Force the value of meshUnderPointer
  44400. * @param mesh defines the mesh to use
  44401. * @param pointerId optional pointer id when using more than one pointer
  44402. */
  44403. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44404. /**
  44405. * Gets the mesh under the pointer
  44406. * @returns a Mesh or null if no mesh is under the pointer
  44407. */
  44408. getPointerOverMesh(): Nullable<AbstractMesh>;
  44409. /** @hidden */
  44410. _rebuildGeometries(): void;
  44411. /** @hidden */
  44412. _rebuildTextures(): void;
  44413. private _getByTags;
  44414. /**
  44415. * Get a list of meshes by tags
  44416. * @param tagsQuery defines the tags query to use
  44417. * @param forEach defines a predicate used to filter results
  44418. * @returns an array of Mesh
  44419. */
  44420. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44421. /**
  44422. * Get a list of cameras by tags
  44423. * @param tagsQuery defines the tags query to use
  44424. * @param forEach defines a predicate used to filter results
  44425. * @returns an array of Camera
  44426. */
  44427. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44428. /**
  44429. * Get a list of lights by tags
  44430. * @param tagsQuery defines the tags query to use
  44431. * @param forEach defines a predicate used to filter results
  44432. * @returns an array of Light
  44433. */
  44434. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44435. /**
  44436. * Get a list of materials by tags
  44437. * @param tagsQuery defines the tags query to use
  44438. * @param forEach defines a predicate used to filter results
  44439. * @returns an array of Material
  44440. */
  44441. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44442. /**
  44443. * Get a list of transform nodes by tags
  44444. * @param tagsQuery defines the tags query to use
  44445. * @param forEach defines a predicate used to filter results
  44446. * @returns an array of TransformNode
  44447. */
  44448. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44449. /**
  44450. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44451. * This allowed control for front to back rendering or reversly depending of the special needs.
  44452. *
  44453. * @param renderingGroupId The rendering group id corresponding to its index
  44454. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44455. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44456. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44457. */
  44458. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  44459. /**
  44460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44461. *
  44462. * @param renderingGroupId The rendering group id corresponding to its index
  44463. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44464. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44465. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44466. */
  44467. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44468. /**
  44469. * Gets the current auto clear configuration for one rendering group of the rendering
  44470. * manager.
  44471. * @param index the rendering group index to get the information for
  44472. * @returns The auto clear setup for the requested rendering group
  44473. */
  44474. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44475. private _blockMaterialDirtyMechanism;
  44476. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44477. get blockMaterialDirtyMechanism(): boolean;
  44478. set blockMaterialDirtyMechanism(value: boolean);
  44479. /**
  44480. * Will flag all materials as dirty to trigger new shader compilation
  44481. * @param flag defines the flag used to specify which material part must be marked as dirty
  44482. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44483. */
  44484. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44485. /** @hidden */
  44486. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  44487. /** @hidden */
  44488. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44489. /** @hidden */
  44490. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  44491. /** @hidden */
  44492. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44493. /** @hidden */
  44494. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44495. /** @hidden */
  44496. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44497. }
  44498. }
  44499. declare module BABYLON {
  44500. /**
  44501. * Set of assets to keep when moving a scene into an asset container.
  44502. */
  44503. export class KeepAssets extends AbstractScene {
  44504. }
  44505. /**
  44506. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44507. */
  44508. export class InstantiatedEntries {
  44509. /**
  44510. * List of new root nodes (eg. nodes with no parent)
  44511. */
  44512. rootNodes: TransformNode[];
  44513. /**
  44514. * List of new skeletons
  44515. */
  44516. skeletons: Skeleton[];
  44517. /**
  44518. * List of new animation groups
  44519. */
  44520. animationGroups: AnimationGroup[];
  44521. }
  44522. /**
  44523. * Container with a set of assets that can be added or removed from a scene.
  44524. */
  44525. export class AssetContainer extends AbstractScene {
  44526. private _wasAddedToScene;
  44527. /**
  44528. * The scene the AssetContainer belongs to.
  44529. */
  44530. scene: Scene;
  44531. /**
  44532. * Instantiates an AssetContainer.
  44533. * @param scene The scene the AssetContainer belongs to.
  44534. */
  44535. constructor(scene: Scene);
  44536. /**
  44537. * Instantiate or clone all meshes and add the new ones to the scene.
  44538. * Skeletons and animation groups will all be cloned
  44539. * @param nameFunction defines an optional function used to get new names for clones
  44540. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44541. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44542. */
  44543. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44544. /**
  44545. * Adds all the assets from the container to the scene.
  44546. */
  44547. addAllToScene(): void;
  44548. /**
  44549. * Removes all the assets in the container from the scene
  44550. */
  44551. removeAllFromScene(): void;
  44552. /**
  44553. * Disposes all the assets in the container
  44554. */
  44555. dispose(): void;
  44556. private _moveAssets;
  44557. /**
  44558. * Removes all the assets contained in the scene and adds them to the container.
  44559. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44560. */
  44561. moveAllFromScene(keepAssets?: KeepAssets): void;
  44562. /**
  44563. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  44564. * @returns the root mesh
  44565. */
  44566. createRootMesh(): Mesh;
  44567. /**
  44568. * Merge animations (direct and animation groups) from this asset container into a scene
  44569. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44570. * @param animatables set of animatables to retarget to a node from the scene
  44571. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44572. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44573. */
  44574. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44575. }
  44576. }
  44577. declare module BABYLON {
  44578. /**
  44579. * Defines how the parser contract is defined.
  44580. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44581. */
  44582. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44583. /**
  44584. * Defines how the individual parser contract is defined.
  44585. * These parser can parse an individual asset
  44586. */
  44587. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44588. /**
  44589. * Base class of the scene acting as a container for the different elements composing a scene.
  44590. * This class is dynamically extended by the different components of the scene increasing
  44591. * flexibility and reducing coupling
  44592. */
  44593. export abstract class AbstractScene {
  44594. /**
  44595. * Stores the list of available parsers in the application.
  44596. */
  44597. private static _BabylonFileParsers;
  44598. /**
  44599. * Stores the list of available individual parsers in the application.
  44600. */
  44601. private static _IndividualBabylonFileParsers;
  44602. /**
  44603. * Adds a parser in the list of available ones
  44604. * @param name Defines the name of the parser
  44605. * @param parser Defines the parser to add
  44606. */
  44607. static AddParser(name: string, parser: BabylonFileParser): void;
  44608. /**
  44609. * Gets a general parser from the list of avaialble ones
  44610. * @param name Defines the name of the parser
  44611. * @returns the requested parser or null
  44612. */
  44613. static GetParser(name: string): Nullable<BabylonFileParser>;
  44614. /**
  44615. * Adds n individual parser in the list of available ones
  44616. * @param name Defines the name of the parser
  44617. * @param parser Defines the parser to add
  44618. */
  44619. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44620. /**
  44621. * Gets an individual parser from the list of avaialble ones
  44622. * @param name Defines the name of the parser
  44623. * @returns the requested parser or null
  44624. */
  44625. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44626. /**
  44627. * Parser json data and populate both a scene and its associated container object
  44628. * @param jsonData Defines the data to parse
  44629. * @param scene Defines the scene to parse the data for
  44630. * @param container Defines the container attached to the parsing sequence
  44631. * @param rootUrl Defines the root url of the data
  44632. */
  44633. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44634. /**
  44635. * Gets the list of root nodes (ie. nodes with no parent)
  44636. */
  44637. rootNodes: Node[];
  44638. /** All of the cameras added to this scene
  44639. * @see https://doc.babylonjs.com/babylon101/cameras
  44640. */
  44641. cameras: Camera[];
  44642. /**
  44643. * All of the lights added to this scene
  44644. * @see https://doc.babylonjs.com/babylon101/lights
  44645. */
  44646. lights: Light[];
  44647. /**
  44648. * All of the (abstract) meshes added to this scene
  44649. */
  44650. meshes: AbstractMesh[];
  44651. /**
  44652. * The list of skeletons added to the scene
  44653. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44654. */
  44655. skeletons: Skeleton[];
  44656. /**
  44657. * All of the particle systems added to this scene
  44658. * @see https://doc.babylonjs.com/babylon101/particles
  44659. */
  44660. particleSystems: IParticleSystem[];
  44661. /**
  44662. * Gets a list of Animations associated with the scene
  44663. */
  44664. animations: Animation[];
  44665. /**
  44666. * All of the animation groups added to this scene
  44667. * @see https://doc.babylonjs.com/how_to/group
  44668. */
  44669. animationGroups: AnimationGroup[];
  44670. /**
  44671. * All of the multi-materials added to this scene
  44672. * @see https://doc.babylonjs.com/how_to/multi_materials
  44673. */
  44674. multiMaterials: MultiMaterial[];
  44675. /**
  44676. * All of the materials added to this scene
  44677. * In the context of a Scene, it is not supposed to be modified manually.
  44678. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44679. * Note also that the order of the Material within the array is not significant and might change.
  44680. * @see https://doc.babylonjs.com/babylon101/materials
  44681. */
  44682. materials: Material[];
  44683. /**
  44684. * The list of morph target managers added to the scene
  44685. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44686. */
  44687. morphTargetManagers: MorphTargetManager[];
  44688. /**
  44689. * The list of geometries used in the scene.
  44690. */
  44691. geometries: Geometry[];
  44692. /**
  44693. * All of the tranform nodes added to this scene
  44694. * In the context of a Scene, it is not supposed to be modified manually.
  44695. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44696. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44697. * @see https://doc.babylonjs.com/how_to/transformnode
  44698. */
  44699. transformNodes: TransformNode[];
  44700. /**
  44701. * ActionManagers available on the scene.
  44702. */
  44703. actionManagers: AbstractActionManager[];
  44704. /**
  44705. * Textures to keep.
  44706. */
  44707. textures: BaseTexture[];
  44708. /** @hidden */
  44709. protected _environmentTexture: Nullable<BaseTexture>;
  44710. /**
  44711. * Texture used in all pbr material as the reflection texture.
  44712. * As in the majority of the scene they are the same (exception for multi room and so on),
  44713. * this is easier to reference from here than from all the materials.
  44714. */
  44715. get environmentTexture(): Nullable<BaseTexture>;
  44716. set environmentTexture(value: Nullable<BaseTexture>);
  44717. /**
  44718. * The list of postprocesses added to the scene
  44719. */
  44720. postProcesses: PostProcess[];
  44721. /**
  44722. * @returns all meshes, lights, cameras, transformNodes and bones
  44723. */
  44724. getNodes(): Array<Node>;
  44725. }
  44726. }
  44727. declare module BABYLON {
  44728. /**
  44729. * Interface used to define options for Sound class
  44730. */
  44731. export interface ISoundOptions {
  44732. /**
  44733. * Does the sound autoplay once loaded.
  44734. */
  44735. autoplay?: boolean;
  44736. /**
  44737. * Does the sound loop after it finishes playing once.
  44738. */
  44739. loop?: boolean;
  44740. /**
  44741. * Sound's volume
  44742. */
  44743. volume?: number;
  44744. /**
  44745. * Is it a spatial sound?
  44746. */
  44747. spatialSound?: boolean;
  44748. /**
  44749. * Maximum distance to hear that sound
  44750. */
  44751. maxDistance?: number;
  44752. /**
  44753. * Uses user defined attenuation function
  44754. */
  44755. useCustomAttenuation?: boolean;
  44756. /**
  44757. * Define the roll off factor of spatial sounds.
  44758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44759. */
  44760. rolloffFactor?: number;
  44761. /**
  44762. * Define the reference distance the sound should be heard perfectly.
  44763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44764. */
  44765. refDistance?: number;
  44766. /**
  44767. * Define the distance attenuation model the sound will follow.
  44768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44769. */
  44770. distanceModel?: string;
  44771. /**
  44772. * Defines the playback speed (1 by default)
  44773. */
  44774. playbackRate?: number;
  44775. /**
  44776. * Defines if the sound is from a streaming source
  44777. */
  44778. streaming?: boolean;
  44779. /**
  44780. * Defines an optional length (in seconds) inside the sound file
  44781. */
  44782. length?: number;
  44783. /**
  44784. * Defines an optional offset (in seconds) inside the sound file
  44785. */
  44786. offset?: number;
  44787. /**
  44788. * If true, URLs will not be required to state the audio file codec to use.
  44789. */
  44790. skipCodecCheck?: boolean;
  44791. }
  44792. }
  44793. declare module BABYLON {
  44794. /**
  44795. * Defines a sound that can be played in the application.
  44796. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44798. */
  44799. export class Sound {
  44800. /**
  44801. * The name of the sound in the scene.
  44802. */
  44803. name: string;
  44804. /**
  44805. * Does the sound autoplay once loaded.
  44806. */
  44807. autoplay: boolean;
  44808. /**
  44809. * Does the sound loop after it finishes playing once.
  44810. */
  44811. loop: boolean;
  44812. /**
  44813. * Does the sound use a custom attenuation curve to simulate the falloff
  44814. * happening when the source gets further away from the camera.
  44815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44816. */
  44817. useCustomAttenuation: boolean;
  44818. /**
  44819. * The sound track id this sound belongs to.
  44820. */
  44821. soundTrackId: number;
  44822. /**
  44823. * Is this sound currently played.
  44824. */
  44825. isPlaying: boolean;
  44826. /**
  44827. * Is this sound currently paused.
  44828. */
  44829. isPaused: boolean;
  44830. /**
  44831. * Does this sound enables spatial sound.
  44832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44833. */
  44834. spatialSound: boolean;
  44835. /**
  44836. * Define the reference distance the sound should be heard perfectly.
  44837. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44838. */
  44839. refDistance: number;
  44840. /**
  44841. * Define the roll off factor of spatial sounds.
  44842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44843. */
  44844. rolloffFactor: number;
  44845. /**
  44846. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44848. */
  44849. maxDistance: number;
  44850. /**
  44851. * Define the distance attenuation model the sound will follow.
  44852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44853. */
  44854. distanceModel: string;
  44855. /**
  44856. * @hidden
  44857. * Back Compat
  44858. **/
  44859. onended: () => any;
  44860. /**
  44861. * Gets or sets an object used to store user defined information for the sound.
  44862. */
  44863. metadata: any;
  44864. /**
  44865. * Observable event when the current playing sound finishes.
  44866. */
  44867. onEndedObservable: Observable<Sound>;
  44868. /**
  44869. * Gets the current time for the sound.
  44870. */
  44871. get currentTime(): number;
  44872. private _panningModel;
  44873. private _playbackRate;
  44874. private _streaming;
  44875. private _startTime;
  44876. private _startOffset;
  44877. private _position;
  44878. /** @hidden */
  44879. _positionInEmitterSpace: boolean;
  44880. private _localDirection;
  44881. private _volume;
  44882. private _isReadyToPlay;
  44883. private _isDirectional;
  44884. private _readyToPlayCallback;
  44885. private _audioBuffer;
  44886. private _soundSource;
  44887. private _streamingSource;
  44888. private _soundPanner;
  44889. private _soundGain;
  44890. private _inputAudioNode;
  44891. private _outputAudioNode;
  44892. private _coneInnerAngle;
  44893. private _coneOuterAngle;
  44894. private _coneOuterGain;
  44895. private _scene;
  44896. private _connectedTransformNode;
  44897. private _customAttenuationFunction;
  44898. private _registerFunc;
  44899. private _isOutputConnected;
  44900. private _htmlAudioElement;
  44901. private _urlType;
  44902. private _length?;
  44903. private _offset?;
  44904. /** @hidden */
  44905. static _SceneComponentInitialization: (scene: Scene) => void;
  44906. /**
  44907. * Create a sound and attach it to a scene
  44908. * @param name Name of your sound
  44909. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44910. * @param scene defines the scene the sound belongs to
  44911. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44912. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44913. */
  44914. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44915. /**
  44916. * Release the sound and its associated resources
  44917. */
  44918. dispose(): void;
  44919. /**
  44920. * Gets if the sounds is ready to be played or not.
  44921. * @returns true if ready, otherwise false
  44922. */
  44923. isReady(): boolean;
  44924. private _soundLoaded;
  44925. /**
  44926. * Sets the data of the sound from an audiobuffer
  44927. * @param audioBuffer The audioBuffer containing the data
  44928. */
  44929. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44930. /**
  44931. * Updates the current sounds options such as maxdistance, loop...
  44932. * @param options A JSON object containing values named as the object properties
  44933. */
  44934. updateOptions(options: ISoundOptions): void;
  44935. private _createSpatialParameters;
  44936. private _updateSpatialParameters;
  44937. /**
  44938. * Switch the panning model to HRTF:
  44939. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44940. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44941. */
  44942. switchPanningModelToHRTF(): void;
  44943. /**
  44944. * Switch the panning model to Equal Power:
  44945. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44947. */
  44948. switchPanningModelToEqualPower(): void;
  44949. private _switchPanningModel;
  44950. /**
  44951. * Connect this sound to a sound track audio node like gain...
  44952. * @param soundTrackAudioNode the sound track audio node to connect to
  44953. */
  44954. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44955. /**
  44956. * Transform this sound into a directional source
  44957. * @param coneInnerAngle Size of the inner cone in degree
  44958. * @param coneOuterAngle Size of the outer cone in degree
  44959. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44960. */
  44961. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44962. /**
  44963. * Gets or sets the inner angle for the directional cone.
  44964. */
  44965. get directionalConeInnerAngle(): number;
  44966. /**
  44967. * Gets or sets the inner angle for the directional cone.
  44968. */
  44969. set directionalConeInnerAngle(value: number);
  44970. /**
  44971. * Gets or sets the outer angle for the directional cone.
  44972. */
  44973. get directionalConeOuterAngle(): number;
  44974. /**
  44975. * Gets or sets the outer angle for the directional cone.
  44976. */
  44977. set directionalConeOuterAngle(value: number);
  44978. /**
  44979. * Sets the position of the emitter if spatial sound is enabled
  44980. * @param newPosition Defines the new posisiton
  44981. */
  44982. setPosition(newPosition: Vector3): void;
  44983. /**
  44984. * Sets the local direction of the emitter if spatial sound is enabled
  44985. * @param newLocalDirection Defines the new local direction
  44986. */
  44987. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44988. private _updateDirection;
  44989. /** @hidden */
  44990. updateDistanceFromListener(): void;
  44991. /**
  44992. * Sets a new custom attenuation function for the sound.
  44993. * @param callback Defines the function used for the attenuation
  44994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44995. */
  44996. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44997. /**
  44998. * Play the sound
  44999. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45000. * @param offset (optional) Start the sound at a specific time in seconds
  45001. * @param length (optional) Sound duration (in seconds)
  45002. */
  45003. play(time?: number, offset?: number, length?: number): void;
  45004. private _onended;
  45005. /**
  45006. * Stop the sound
  45007. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45008. */
  45009. stop(time?: number): void;
  45010. /**
  45011. * Put the sound in pause
  45012. */
  45013. pause(): void;
  45014. /**
  45015. * Sets a dedicated volume for this sounds
  45016. * @param newVolume Define the new volume of the sound
  45017. * @param time Define time for gradual change to new volume
  45018. */
  45019. setVolume(newVolume: number, time?: number): void;
  45020. /**
  45021. * Set the sound play back rate
  45022. * @param newPlaybackRate Define the playback rate the sound should be played at
  45023. */
  45024. setPlaybackRate(newPlaybackRate: number): void;
  45025. /**
  45026. * Gets the volume of the sound.
  45027. * @returns the volume of the sound
  45028. */
  45029. getVolume(): number;
  45030. /**
  45031. * Attach the sound to a dedicated mesh
  45032. * @param transformNode The transform node to connect the sound with
  45033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45034. */
  45035. attachToMesh(transformNode: TransformNode): void;
  45036. /**
  45037. * Detach the sound from the previously attached mesh
  45038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45039. */
  45040. detachFromMesh(): void;
  45041. private _onRegisterAfterWorldMatrixUpdate;
  45042. /**
  45043. * Clone the current sound in the scene.
  45044. * @returns the new sound clone
  45045. */
  45046. clone(): Nullable<Sound>;
  45047. /**
  45048. * Gets the current underlying audio buffer containing the data
  45049. * @returns the audio buffer
  45050. */
  45051. getAudioBuffer(): Nullable<AudioBuffer>;
  45052. /**
  45053. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45054. * @returns the source node
  45055. */
  45056. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45057. /**
  45058. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45059. * @returns the gain node
  45060. */
  45061. getSoundGain(): Nullable<GainNode>;
  45062. /**
  45063. * Serializes the Sound in a JSON representation
  45064. * @returns the JSON representation of the sound
  45065. */
  45066. serialize(): any;
  45067. /**
  45068. * Parse a JSON representation of a sound to innstantiate in a given scene
  45069. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45070. * @param scene Define the scene the new parsed sound should be created in
  45071. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45072. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45073. * @returns the newly parsed sound
  45074. */
  45075. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45076. }
  45077. }
  45078. declare module BABYLON {
  45079. /**
  45080. * This defines an action helpful to play a defined sound on a triggered action.
  45081. */
  45082. export class PlaySoundAction extends Action {
  45083. private _sound;
  45084. /**
  45085. * Instantiate the action
  45086. * @param triggerOptions defines the trigger options
  45087. * @param sound defines the sound to play
  45088. * @param condition defines the trigger related conditions
  45089. */
  45090. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45091. /** @hidden */
  45092. _prepare(): void;
  45093. /**
  45094. * Execute the action and play the sound.
  45095. */
  45096. execute(): void;
  45097. /**
  45098. * Serializes the actions and its related information.
  45099. * @param parent defines the object to serialize in
  45100. * @returns the serialized object
  45101. */
  45102. serialize(parent: any): any;
  45103. }
  45104. /**
  45105. * This defines an action helpful to stop a defined sound on a triggered action.
  45106. */
  45107. export class StopSoundAction extends Action {
  45108. private _sound;
  45109. /**
  45110. * Instantiate the action
  45111. * @param triggerOptions defines the trigger options
  45112. * @param sound defines the sound to stop
  45113. * @param condition defines the trigger related conditions
  45114. */
  45115. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45116. /** @hidden */
  45117. _prepare(): void;
  45118. /**
  45119. * Execute the action and stop the sound.
  45120. */
  45121. execute(): void;
  45122. /**
  45123. * Serializes the actions and its related information.
  45124. * @param parent defines the object to serialize in
  45125. * @returns the serialized object
  45126. */
  45127. serialize(parent: any): any;
  45128. }
  45129. }
  45130. declare module BABYLON {
  45131. /**
  45132. * This defines an action responsible to change the value of a property
  45133. * by interpolating between its current value and the newly set one once triggered.
  45134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45135. */
  45136. export class InterpolateValueAction extends Action {
  45137. /**
  45138. * Defines the path of the property where the value should be interpolated
  45139. */
  45140. propertyPath: string;
  45141. /**
  45142. * Defines the target value at the end of the interpolation.
  45143. */
  45144. value: any;
  45145. /**
  45146. * Defines the time it will take for the property to interpolate to the value.
  45147. */
  45148. duration: number;
  45149. /**
  45150. * Defines if the other scene animations should be stopped when the action has been triggered
  45151. */
  45152. stopOtherAnimations?: boolean;
  45153. /**
  45154. * Defines a callback raised once the interpolation animation has been done.
  45155. */
  45156. onInterpolationDone?: () => void;
  45157. /**
  45158. * Observable triggered once the interpolation animation has been done.
  45159. */
  45160. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45161. private _target;
  45162. private _effectiveTarget;
  45163. private _property;
  45164. /**
  45165. * Instantiate the action
  45166. * @param triggerOptions defines the trigger options
  45167. * @param target defines the object containing the value to interpolate
  45168. * @param propertyPath defines the path to the property in the target object
  45169. * @param value defines the target value at the end of the interpolation
  45170. * @param duration deines the time it will take for the property to interpolate to the value.
  45171. * @param condition defines the trigger related conditions
  45172. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45173. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45174. */
  45175. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45176. /** @hidden */
  45177. _prepare(): void;
  45178. /**
  45179. * Execute the action starts the value interpolation.
  45180. */
  45181. execute(): void;
  45182. /**
  45183. * Serializes the actions and its related information.
  45184. * @param parent defines the object to serialize in
  45185. * @returns the serialized object
  45186. */
  45187. serialize(parent: any): any;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. /**
  45192. * This represents the default audio engine used in babylon.
  45193. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45194. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45195. */
  45196. export class AudioEngine implements IAudioEngine {
  45197. private _audioContext;
  45198. private _audioContextInitialized;
  45199. private _muteButton;
  45200. private _hostElement;
  45201. /**
  45202. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45203. */
  45204. canUseWebAudio: boolean;
  45205. /**
  45206. * The master gain node defines the global audio volume of your audio engine.
  45207. */
  45208. masterGain: GainNode;
  45209. /**
  45210. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45211. * @ignoreNaming
  45212. */
  45213. WarnedWebAudioUnsupported: boolean;
  45214. /**
  45215. * Gets whether or not mp3 are supported by your browser.
  45216. */
  45217. isMP3supported: boolean;
  45218. /**
  45219. * Gets whether or not ogg are supported by your browser.
  45220. */
  45221. isOGGsupported: boolean;
  45222. /**
  45223. * Gets whether audio has been unlocked on the device.
  45224. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45225. * a user interaction has happened.
  45226. */
  45227. unlocked: boolean;
  45228. /**
  45229. * Defines if the audio engine relies on a custom unlocked button.
  45230. * In this case, the embedded button will not be displayed.
  45231. */
  45232. useCustomUnlockedButton: boolean;
  45233. /**
  45234. * Event raised when audio has been unlocked on the browser.
  45235. */
  45236. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45237. /**
  45238. * Event raised when audio has been locked on the browser.
  45239. */
  45240. onAudioLockedObservable: Observable<IAudioEngine>;
  45241. /**
  45242. * Gets the current AudioContext if available.
  45243. */
  45244. get audioContext(): Nullable<AudioContext>;
  45245. private _connectedAnalyser;
  45246. /**
  45247. * Instantiates a new audio engine.
  45248. *
  45249. * There should be only one per page as some browsers restrict the number
  45250. * of audio contexts you can create.
  45251. * @param hostElement defines the host element where to display the mute icon if necessary
  45252. */
  45253. constructor(hostElement?: Nullable<HTMLElement>);
  45254. /**
  45255. * Flags the audio engine in Locked state.
  45256. * This happens due to new browser policies preventing audio to autoplay.
  45257. */
  45258. lock(): void;
  45259. /**
  45260. * Unlocks the audio engine once a user action has been done on the dom.
  45261. * This is helpful to resume play once browser policies have been satisfied.
  45262. */
  45263. unlock(): void;
  45264. private _resumeAudioContext;
  45265. private _initializeAudioContext;
  45266. private _tryToRun;
  45267. private _triggerRunningState;
  45268. private _triggerSuspendedState;
  45269. private _displayMuteButton;
  45270. private _moveButtonToTopLeft;
  45271. private _onResize;
  45272. private _hideMuteButton;
  45273. /**
  45274. * Destroy and release the resources associated with the audio ccontext.
  45275. */
  45276. dispose(): void;
  45277. /**
  45278. * Gets the global volume sets on the master gain.
  45279. * @returns the global volume if set or -1 otherwise
  45280. */
  45281. getGlobalVolume(): number;
  45282. /**
  45283. * Sets the global volume of your experience (sets on the master gain).
  45284. * @param newVolume Defines the new global volume of the application
  45285. */
  45286. setGlobalVolume(newVolume: number): void;
  45287. /**
  45288. * Connect the audio engine to an audio analyser allowing some amazing
  45289. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45290. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45291. * @param analyser The analyser to connect to the engine
  45292. */
  45293. connectToAnalyser(analyser: Analyser): void;
  45294. }
  45295. }
  45296. declare module BABYLON {
  45297. /**
  45298. * Options allowed during the creation of a sound track.
  45299. */
  45300. export interface ISoundTrackOptions {
  45301. /**
  45302. * The volume the sound track should take during creation
  45303. */
  45304. volume?: number;
  45305. /**
  45306. * Define if the sound track is the main sound track of the scene
  45307. */
  45308. mainTrack?: boolean;
  45309. }
  45310. /**
  45311. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45312. * It will be also used in a future release to apply effects on a specific track.
  45313. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45314. */
  45315. export class SoundTrack {
  45316. /**
  45317. * The unique identifier of the sound track in the scene.
  45318. */
  45319. id: number;
  45320. /**
  45321. * The list of sounds included in the sound track.
  45322. */
  45323. soundCollection: Array<Sound>;
  45324. private _outputAudioNode;
  45325. private _scene;
  45326. private _connectedAnalyser;
  45327. private _options;
  45328. private _isInitialized;
  45329. /**
  45330. * Creates a new sound track.
  45331. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45332. * @param scene Define the scene the sound track belongs to
  45333. * @param options
  45334. */
  45335. constructor(scene: Scene, options?: ISoundTrackOptions);
  45336. private _initializeSoundTrackAudioGraph;
  45337. /**
  45338. * Release the sound track and its associated resources
  45339. */
  45340. dispose(): void;
  45341. /**
  45342. * Adds a sound to this sound track
  45343. * @param sound define the cound to add
  45344. * @ignoreNaming
  45345. */
  45346. addSound(sound: Sound): void;
  45347. /**
  45348. * Removes a sound to this sound track
  45349. * @param sound define the cound to remove
  45350. * @ignoreNaming
  45351. */
  45352. removeSound(sound: Sound): void;
  45353. /**
  45354. * Set a global volume for the full sound track.
  45355. * @param newVolume Define the new volume of the sound track
  45356. */
  45357. setVolume(newVolume: number): void;
  45358. /**
  45359. * Switch the panning model to HRTF:
  45360. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45362. */
  45363. switchPanningModelToHRTF(): void;
  45364. /**
  45365. * Switch the panning model to Equal Power:
  45366. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45368. */
  45369. switchPanningModelToEqualPower(): void;
  45370. /**
  45371. * Connect the sound track to an audio analyser allowing some amazing
  45372. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45374. * @param analyser The analyser to connect to the engine
  45375. */
  45376. connectToAnalyser(analyser: Analyser): void;
  45377. }
  45378. }
  45379. declare module BABYLON {
  45380. interface AbstractScene {
  45381. /**
  45382. * The list of sounds used in the scene.
  45383. */
  45384. sounds: Nullable<Array<Sound>>;
  45385. }
  45386. interface Scene {
  45387. /**
  45388. * @hidden
  45389. * Backing field
  45390. */
  45391. _mainSoundTrack: SoundTrack;
  45392. /**
  45393. * The main sound track played by the scene.
  45394. * It cotains your primary collection of sounds.
  45395. */
  45396. mainSoundTrack: SoundTrack;
  45397. /**
  45398. * The list of sound tracks added to the scene
  45399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45400. */
  45401. soundTracks: Nullable<Array<SoundTrack>>;
  45402. /**
  45403. * Gets a sound using a given name
  45404. * @param name defines the name to search for
  45405. * @return the found sound or null if not found at all.
  45406. */
  45407. getSoundByName(name: string): Nullable<Sound>;
  45408. /**
  45409. * Gets or sets if audio support is enabled
  45410. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45411. */
  45412. audioEnabled: boolean;
  45413. /**
  45414. * Gets or sets if audio will be output to headphones
  45415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45416. */
  45417. headphone: boolean;
  45418. /**
  45419. * Gets or sets custom audio listener position provider
  45420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45421. */
  45422. audioListenerPositionProvider: Nullable<() => Vector3>;
  45423. /**
  45424. * Gets or sets a refresh rate when using 3D audio positioning
  45425. */
  45426. audioPositioningRefreshRate: number;
  45427. }
  45428. /**
  45429. * Defines the sound scene component responsible to manage any sounds
  45430. * in a given scene.
  45431. */
  45432. export class AudioSceneComponent implements ISceneSerializableComponent {
  45433. private static _CameraDirectionLH;
  45434. private static _CameraDirectionRH;
  45435. /**
  45436. * The component name helpfull to identify the component in the list of scene components.
  45437. */
  45438. readonly name: string;
  45439. /**
  45440. * The scene the component belongs to.
  45441. */
  45442. scene: Scene;
  45443. private _audioEnabled;
  45444. /**
  45445. * Gets whether audio is enabled or not.
  45446. * Please use related enable/disable method to switch state.
  45447. */
  45448. get audioEnabled(): boolean;
  45449. private _headphone;
  45450. /**
  45451. * Gets whether audio is outputing to headphone or not.
  45452. * Please use the according Switch methods to change output.
  45453. */
  45454. get headphone(): boolean;
  45455. /**
  45456. * Gets or sets a refresh rate when using 3D audio positioning
  45457. */
  45458. audioPositioningRefreshRate: number;
  45459. private _audioListenerPositionProvider;
  45460. /**
  45461. * Gets the current audio listener position provider
  45462. */
  45463. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45464. /**
  45465. * Sets a custom listener position for all sounds in the scene
  45466. * By default, this is the position of the first active camera
  45467. */
  45468. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45469. /**
  45470. * Creates a new instance of the component for the given scene
  45471. * @param scene Defines the scene to register the component in
  45472. */
  45473. constructor(scene: Scene);
  45474. /**
  45475. * Registers the component in a given scene
  45476. */
  45477. register(): void;
  45478. /**
  45479. * Rebuilds the elements related to this component in case of
  45480. * context lost for instance.
  45481. */
  45482. rebuild(): void;
  45483. /**
  45484. * Serializes the component data to the specified json object
  45485. * @param serializationObject The object to serialize to
  45486. */
  45487. serialize(serializationObject: any): void;
  45488. /**
  45489. * Adds all the elements from the container to the scene
  45490. * @param container the container holding the elements
  45491. */
  45492. addFromContainer(container: AbstractScene): void;
  45493. /**
  45494. * Removes all the elements in the container from the scene
  45495. * @param container contains the elements to remove
  45496. * @param dispose if the removed element should be disposed (default: false)
  45497. */
  45498. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45499. /**
  45500. * Disposes the component and the associated ressources.
  45501. */
  45502. dispose(): void;
  45503. /**
  45504. * Disables audio in the associated scene.
  45505. */
  45506. disableAudio(): void;
  45507. /**
  45508. * Enables audio in the associated scene.
  45509. */
  45510. enableAudio(): void;
  45511. /**
  45512. * Switch audio to headphone output.
  45513. */
  45514. switchAudioModeForHeadphones(): void;
  45515. /**
  45516. * Switch audio to normal speakers.
  45517. */
  45518. switchAudioModeForNormalSpeakers(): void;
  45519. private _cachedCameraDirection;
  45520. private _cachedCameraPosition;
  45521. private _lastCheck;
  45522. private _afterRender;
  45523. }
  45524. }
  45525. declare module BABYLON {
  45526. /**
  45527. * Wraps one or more Sound objects and selects one with random weight for playback.
  45528. */
  45529. export class WeightedSound {
  45530. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45531. loop: boolean;
  45532. private _coneInnerAngle;
  45533. private _coneOuterAngle;
  45534. private _volume;
  45535. /** A Sound is currently playing. */
  45536. isPlaying: boolean;
  45537. /** A Sound is currently paused. */
  45538. isPaused: boolean;
  45539. private _sounds;
  45540. private _weights;
  45541. private _currentIndex?;
  45542. /**
  45543. * Creates a new WeightedSound from the list of sounds given.
  45544. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45545. * @param sounds Array of Sounds that will be selected from.
  45546. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45547. */
  45548. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45549. /**
  45550. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45551. */
  45552. get directionalConeInnerAngle(): number;
  45553. /**
  45554. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45555. */
  45556. set directionalConeInnerAngle(value: number);
  45557. /**
  45558. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45559. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45560. */
  45561. get directionalConeOuterAngle(): number;
  45562. /**
  45563. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45564. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45565. */
  45566. set directionalConeOuterAngle(value: number);
  45567. /**
  45568. * Playback volume.
  45569. */
  45570. get volume(): number;
  45571. /**
  45572. * Playback volume.
  45573. */
  45574. set volume(value: number);
  45575. private _onended;
  45576. /**
  45577. * Suspend playback
  45578. */
  45579. pause(): void;
  45580. /**
  45581. * Stop playback
  45582. */
  45583. stop(): void;
  45584. /**
  45585. * Start playback.
  45586. * @param startOffset Position the clip head at a specific time in seconds.
  45587. */
  45588. play(startOffset?: number): void;
  45589. }
  45590. }
  45591. declare module BABYLON {
  45592. /**
  45593. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45594. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45595. */
  45596. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45597. /**
  45598. * Gets the name of the behavior.
  45599. */
  45600. get name(): string;
  45601. /**
  45602. * The easing function used by animations
  45603. */
  45604. static EasingFunction: BackEase;
  45605. /**
  45606. * The easing mode used by animations
  45607. */
  45608. static EasingMode: number;
  45609. /**
  45610. * The duration of the animation, in milliseconds
  45611. */
  45612. transitionDuration: number;
  45613. /**
  45614. * Length of the distance animated by the transition when lower radius is reached
  45615. */
  45616. lowerRadiusTransitionRange: number;
  45617. /**
  45618. * Length of the distance animated by the transition when upper radius is reached
  45619. */
  45620. upperRadiusTransitionRange: number;
  45621. private _autoTransitionRange;
  45622. /**
  45623. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45624. */
  45625. get autoTransitionRange(): boolean;
  45626. /**
  45627. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45628. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45629. */
  45630. set autoTransitionRange(value: boolean);
  45631. private _attachedCamera;
  45632. private _onAfterCheckInputsObserver;
  45633. private _onMeshTargetChangedObserver;
  45634. /**
  45635. * Initializes the behavior.
  45636. */
  45637. init(): void;
  45638. /**
  45639. * Attaches the behavior to its arc rotate camera.
  45640. * @param camera Defines the camera to attach the behavior to
  45641. */
  45642. attach(camera: ArcRotateCamera): void;
  45643. /**
  45644. * Detaches the behavior from its current arc rotate camera.
  45645. */
  45646. detach(): void;
  45647. private _radiusIsAnimating;
  45648. private _radiusBounceTransition;
  45649. private _animatables;
  45650. private _cachedWheelPrecision;
  45651. /**
  45652. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45653. * @param radiusLimit The limit to check against.
  45654. * @return Bool to indicate if at limit.
  45655. */
  45656. private _isRadiusAtLimit;
  45657. /**
  45658. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45659. * @param radiusDelta The delta by which to animate to. Can be negative.
  45660. */
  45661. private _applyBoundRadiusAnimation;
  45662. /**
  45663. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45664. */
  45665. protected _clearAnimationLocks(): void;
  45666. /**
  45667. * Stops and removes all animations that have been applied to the camera
  45668. */
  45669. stopAllAnimations(): void;
  45670. }
  45671. }
  45672. declare module BABYLON {
  45673. /**
  45674. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  45675. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45676. */
  45677. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45678. /**
  45679. * Gets the name of the behavior.
  45680. */
  45681. get name(): string;
  45682. private _mode;
  45683. private _radiusScale;
  45684. private _positionScale;
  45685. private _defaultElevation;
  45686. private _elevationReturnTime;
  45687. private _elevationReturnWaitTime;
  45688. private _zoomStopsAnimation;
  45689. private _framingTime;
  45690. /**
  45691. * The easing function used by animations
  45692. */
  45693. static EasingFunction: ExponentialEase;
  45694. /**
  45695. * The easing mode used by animations
  45696. */
  45697. static EasingMode: number;
  45698. /**
  45699. * Sets the current mode used by the behavior
  45700. */
  45701. set mode(mode: number);
  45702. /**
  45703. * Gets current mode used by the behavior.
  45704. */
  45705. get mode(): number;
  45706. /**
  45707. * Sets the scale applied to the radius (1 by default)
  45708. */
  45709. set radiusScale(radius: number);
  45710. /**
  45711. * Gets the scale applied to the radius
  45712. */
  45713. get radiusScale(): number;
  45714. /**
  45715. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45716. */
  45717. set positionScale(scale: number);
  45718. /**
  45719. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45720. */
  45721. get positionScale(): number;
  45722. /**
  45723. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45724. * behaviour is triggered, in radians.
  45725. */
  45726. set defaultElevation(elevation: number);
  45727. /**
  45728. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45729. * behaviour is triggered, in radians.
  45730. */
  45731. get defaultElevation(): number;
  45732. /**
  45733. * Sets the time (in milliseconds) taken to return to the default beta position.
  45734. * Negative value indicates camera should not return to default.
  45735. */
  45736. set elevationReturnTime(speed: number);
  45737. /**
  45738. * Gets the time (in milliseconds) taken to return to the default beta position.
  45739. * Negative value indicates camera should not return to default.
  45740. */
  45741. get elevationReturnTime(): number;
  45742. /**
  45743. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45744. */
  45745. set elevationReturnWaitTime(time: number);
  45746. /**
  45747. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45748. */
  45749. get elevationReturnWaitTime(): number;
  45750. /**
  45751. * Sets the flag that indicates if user zooming should stop animation.
  45752. */
  45753. set zoomStopsAnimation(flag: boolean);
  45754. /**
  45755. * Gets the flag that indicates if user zooming should stop animation.
  45756. */
  45757. get zoomStopsAnimation(): boolean;
  45758. /**
  45759. * Sets the transition time when framing the mesh, in milliseconds
  45760. */
  45761. set framingTime(time: number);
  45762. /**
  45763. * Gets the transition time when framing the mesh, in milliseconds
  45764. */
  45765. get framingTime(): number;
  45766. /**
  45767. * Define if the behavior should automatically change the configured
  45768. * camera limits and sensibilities.
  45769. */
  45770. autoCorrectCameraLimitsAndSensibility: boolean;
  45771. private _onPrePointerObservableObserver;
  45772. private _onAfterCheckInputsObserver;
  45773. private _onMeshTargetChangedObserver;
  45774. private _attachedCamera;
  45775. private _isPointerDown;
  45776. private _lastInteractionTime;
  45777. /**
  45778. * Initializes the behavior.
  45779. */
  45780. init(): void;
  45781. /**
  45782. * Attaches the behavior to its arc rotate camera.
  45783. * @param camera Defines the camera to attach the behavior to
  45784. */
  45785. attach(camera: ArcRotateCamera): void;
  45786. /**
  45787. * Detaches the behavior from its current arc rotate camera.
  45788. */
  45789. detach(): void;
  45790. private _animatables;
  45791. private _betaIsAnimating;
  45792. private _betaTransition;
  45793. private _radiusTransition;
  45794. private _vectorTransition;
  45795. /**
  45796. * Targets the given mesh and updates zoom level accordingly.
  45797. * @param mesh The mesh to target.
  45798. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45799. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45800. */
  45801. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45802. /**
  45803. * Targets the given mesh with its children and updates zoom level accordingly.
  45804. * @param mesh The mesh to target.
  45805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45807. */
  45808. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45809. /**
  45810. * Targets the given meshes with their children and updates zoom level accordingly.
  45811. * @param meshes The mesh to target.
  45812. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45813. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45814. */
  45815. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45816. /**
  45817. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45818. * @param minimumWorld Determines the smaller position of the bounding box extend
  45819. * @param maximumWorld Determines the bigger position of the bounding box extend
  45820. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45821. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45822. */
  45823. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45824. /**
  45825. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45826. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45827. * frustum width.
  45828. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45829. * to fully enclose the mesh in the viewing frustum.
  45830. */
  45831. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45832. /**
  45833. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45834. * is automatically returned to its default position (expected to be above ground plane).
  45835. */
  45836. private _maintainCameraAboveGround;
  45837. /**
  45838. * Returns the frustum slope based on the canvas ratio and camera FOV
  45839. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45840. */
  45841. private _getFrustumSlope;
  45842. /**
  45843. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45844. */
  45845. private _clearAnimationLocks;
  45846. /**
  45847. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45848. */
  45849. private _applyUserInteraction;
  45850. /**
  45851. * Stops and removes all animations that have been applied to the camera
  45852. */
  45853. stopAllAnimations(): void;
  45854. /**
  45855. * Gets a value indicating if the user is moving the camera
  45856. */
  45857. get isUserIsMoving(): boolean;
  45858. /**
  45859. * The camera can move all the way towards the mesh.
  45860. */
  45861. static IgnoreBoundsSizeMode: number;
  45862. /**
  45863. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45864. */
  45865. static FitFrustumSidesMode: number;
  45866. }
  45867. }
  45868. declare module BABYLON {
  45869. /**
  45870. * Base class for Camera Pointer Inputs.
  45871. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45872. * for example usage.
  45873. */
  45874. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45875. /**
  45876. * Defines the camera the input is attached to.
  45877. */
  45878. abstract camera: Camera;
  45879. /**
  45880. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45881. */
  45882. protected _altKey: boolean;
  45883. protected _ctrlKey: boolean;
  45884. protected _metaKey: boolean;
  45885. protected _shiftKey: boolean;
  45886. /**
  45887. * Which mouse buttons were pressed at time of last mouse event.
  45888. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45889. */
  45890. protected _buttonsPressed: number;
  45891. /**
  45892. * Defines the buttons associated with the input to handle camera move.
  45893. */
  45894. buttons: number[];
  45895. /**
  45896. * Attach the input controls to a specific dom element to get the input from.
  45897. * @param element Defines the element the controls should be listened from
  45898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45899. */
  45900. attachControl(noPreventDefault?: boolean): void;
  45901. /**
  45902. * Detach the current controls from the specified dom element.
  45903. */
  45904. detachControl(): void;
  45905. /**
  45906. * Gets the class name of the current input.
  45907. * @returns the class name
  45908. */
  45909. getClassName(): string;
  45910. /**
  45911. * Get the friendly name associated with the input class.
  45912. * @returns the input friendly name
  45913. */
  45914. getSimpleName(): string;
  45915. /**
  45916. * Called on pointer POINTERDOUBLETAP event.
  45917. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45918. */
  45919. protected onDoubleTap(type: string): void;
  45920. /**
  45921. * Called on pointer POINTERMOVE event if only a single touch is active.
  45922. * Override this method to provide functionality.
  45923. */
  45924. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45925. /**
  45926. * Called on pointer POINTERMOVE event if multiple touches are active.
  45927. * Override this method to provide functionality.
  45928. */
  45929. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45930. /**
  45931. * Called on JS contextmenu event.
  45932. * Override this method to provide functionality.
  45933. */
  45934. protected onContextMenu(evt: PointerEvent): void;
  45935. /**
  45936. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45937. * press.
  45938. * Override this method to provide functionality.
  45939. */
  45940. protected onButtonDown(evt: PointerEvent): void;
  45941. /**
  45942. * Called each time a new POINTERUP event occurs. Ie, for each button
  45943. * release.
  45944. * Override this method to provide functionality.
  45945. */
  45946. protected onButtonUp(evt: PointerEvent): void;
  45947. /**
  45948. * Called when window becomes inactive.
  45949. * Override this method to provide functionality.
  45950. */
  45951. protected onLostFocus(): void;
  45952. private _pointerInput;
  45953. private _observer;
  45954. private _onLostFocus;
  45955. private pointA;
  45956. private pointB;
  45957. }
  45958. }
  45959. declare module BABYLON {
  45960. /**
  45961. * Manage the pointers inputs to control an arc rotate camera.
  45962. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45963. */
  45964. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45965. /**
  45966. * Defines the camera the input is attached to.
  45967. */
  45968. camera: ArcRotateCamera;
  45969. /**
  45970. * Gets the class name of the current input.
  45971. * @returns the class name
  45972. */
  45973. getClassName(): string;
  45974. /**
  45975. * Defines the buttons associated with the input to handle camera move.
  45976. */
  45977. buttons: number[];
  45978. /**
  45979. * Defines the pointer angular sensibility along the X axis or how fast is
  45980. * the camera rotating.
  45981. */
  45982. angularSensibilityX: number;
  45983. /**
  45984. * Defines the pointer angular sensibility along the Y axis or how fast is
  45985. * the camera rotating.
  45986. */
  45987. angularSensibilityY: number;
  45988. /**
  45989. * Defines the pointer pinch precision or how fast is the camera zooming.
  45990. */
  45991. pinchPrecision: number;
  45992. /**
  45993. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45994. * from 0.
  45995. * It defines the percentage of current camera.radius to use as delta when
  45996. * pinch zoom is used.
  45997. */
  45998. pinchDeltaPercentage: number;
  45999. /**
  46000. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46001. * that any object in the plane at the camera's target point will scale
  46002. * perfectly with finger motion.
  46003. * Overrides pinchDeltaPercentage and pinchPrecision.
  46004. */
  46005. useNaturalPinchZoom: boolean;
  46006. /**
  46007. * Defines the pointer panning sensibility or how fast is the camera moving.
  46008. */
  46009. panningSensibility: number;
  46010. /**
  46011. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46012. */
  46013. multiTouchPanning: boolean;
  46014. /**
  46015. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46016. * zoom (pinch) through multitouch.
  46017. */
  46018. multiTouchPanAndZoom: boolean;
  46019. /**
  46020. * Revers pinch action direction.
  46021. */
  46022. pinchInwards: boolean;
  46023. private _isPanClick;
  46024. private _twoFingerActivityCount;
  46025. private _isPinching;
  46026. /**
  46027. * Called on pointer POINTERMOVE event if only a single touch is active.
  46028. */
  46029. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46030. /**
  46031. * Called on pointer POINTERDOUBLETAP event.
  46032. */
  46033. protected onDoubleTap(type: string): void;
  46034. /**
  46035. * Called on pointer POINTERMOVE event if multiple touches are active.
  46036. */
  46037. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46038. /**
  46039. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46040. * press.
  46041. */
  46042. protected onButtonDown(evt: PointerEvent): void;
  46043. /**
  46044. * Called each time a new POINTERUP event occurs. Ie, for each button
  46045. * release.
  46046. */
  46047. protected onButtonUp(evt: PointerEvent): void;
  46048. /**
  46049. * Called when window becomes inactive.
  46050. */
  46051. protected onLostFocus(): void;
  46052. }
  46053. }
  46054. declare module BABYLON {
  46055. /**
  46056. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46057. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46058. */
  46059. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46060. /**
  46061. * Defines the camera the input is attached to.
  46062. */
  46063. camera: ArcRotateCamera;
  46064. /**
  46065. * Defines the list of key codes associated with the up action (increase alpha)
  46066. */
  46067. keysUp: number[];
  46068. /**
  46069. * Defines the list of key codes associated with the down action (decrease alpha)
  46070. */
  46071. keysDown: number[];
  46072. /**
  46073. * Defines the list of key codes associated with the left action (increase beta)
  46074. */
  46075. keysLeft: number[];
  46076. /**
  46077. * Defines the list of key codes associated with the right action (decrease beta)
  46078. */
  46079. keysRight: number[];
  46080. /**
  46081. * Defines the list of key codes associated with the reset action.
  46082. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46083. */
  46084. keysReset: number[];
  46085. /**
  46086. * Defines the panning sensibility of the inputs.
  46087. * (How fast is the camera panning)
  46088. */
  46089. panningSensibility: number;
  46090. /**
  46091. * Defines the zooming sensibility of the inputs.
  46092. * (How fast is the camera zooming)
  46093. */
  46094. zoomingSensibility: number;
  46095. /**
  46096. * Defines whether maintaining the alt key down switch the movement mode from
  46097. * orientation to zoom.
  46098. */
  46099. useAltToZoom: boolean;
  46100. /**
  46101. * Rotation speed of the camera
  46102. */
  46103. angularSpeed: number;
  46104. private _keys;
  46105. private _ctrlPressed;
  46106. private _altPressed;
  46107. private _onCanvasBlurObserver;
  46108. private _onKeyboardObserver;
  46109. private _engine;
  46110. private _scene;
  46111. /**
  46112. * Attach the input controls to a specific dom element to get the input from.
  46113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46114. */
  46115. attachControl(noPreventDefault?: boolean): void;
  46116. /**
  46117. * Detach the current controls from the specified dom element.
  46118. */
  46119. detachControl(): void;
  46120. /**
  46121. * Update the current camera state depending on the inputs that have been used this frame.
  46122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46123. */
  46124. checkInputs(): void;
  46125. /**
  46126. * Gets the class name of the current intput.
  46127. * @returns the class name
  46128. */
  46129. getClassName(): string;
  46130. /**
  46131. * Get the friendly name associated with the input class.
  46132. * @returns the input friendly name
  46133. */
  46134. getSimpleName(): string;
  46135. }
  46136. }
  46137. declare module BABYLON {
  46138. /**
  46139. * Manage the mouse wheel inputs to control an arc rotate camera.
  46140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46141. */
  46142. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46143. /**
  46144. * Defines the camera the input is attached to.
  46145. */
  46146. camera: ArcRotateCamera;
  46147. /**
  46148. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46149. */
  46150. wheelPrecision: number;
  46151. /**
  46152. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46153. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46154. */
  46155. wheelDeltaPercentage: number;
  46156. private _wheel;
  46157. private _observer;
  46158. private computeDeltaFromMouseWheelLegacyEvent;
  46159. /**
  46160. * Attach the input controls to a specific dom element to get the input from.
  46161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46162. */
  46163. attachControl(noPreventDefault?: boolean): void;
  46164. /**
  46165. * Detach the current controls from the specified dom element.
  46166. */
  46167. detachControl(): void;
  46168. /**
  46169. * Gets the class name of the current intput.
  46170. * @returns the class name
  46171. */
  46172. getClassName(): string;
  46173. /**
  46174. * Get the friendly name associated with the input class.
  46175. * @returns the input friendly name
  46176. */
  46177. getSimpleName(): string;
  46178. }
  46179. }
  46180. declare module BABYLON {
  46181. /**
  46182. * Default Inputs manager for the ArcRotateCamera.
  46183. * It groups all the default supported inputs for ease of use.
  46184. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46185. */
  46186. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46187. /**
  46188. * Instantiates a new ArcRotateCameraInputsManager.
  46189. * @param camera Defines the camera the inputs belong to
  46190. */
  46191. constructor(camera: ArcRotateCamera);
  46192. /**
  46193. * Add mouse wheel input support to the input manager.
  46194. * @returns the current input manager
  46195. */
  46196. addMouseWheel(): ArcRotateCameraInputsManager;
  46197. /**
  46198. * Add pointers input support to the input manager.
  46199. * @returns the current input manager
  46200. */
  46201. addPointers(): ArcRotateCameraInputsManager;
  46202. /**
  46203. * Add keyboard input support to the input manager.
  46204. * @returns the current input manager
  46205. */
  46206. addKeyboard(): ArcRotateCameraInputsManager;
  46207. }
  46208. }
  46209. declare module BABYLON {
  46210. /**
  46211. * This represents an orbital type of camera.
  46212. *
  46213. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  46214. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  46215. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46216. */
  46217. export class ArcRotateCamera extends TargetCamera {
  46218. /**
  46219. * Defines the rotation angle of the camera along the longitudinal axis.
  46220. */
  46221. alpha: number;
  46222. /**
  46223. * Defines the rotation angle of the camera along the latitudinal axis.
  46224. */
  46225. beta: number;
  46226. /**
  46227. * Defines the radius of the camera from it s target point.
  46228. */
  46229. radius: number;
  46230. protected _target: Vector3;
  46231. protected _targetHost: Nullable<AbstractMesh>;
  46232. /**
  46233. * Defines the target point of the camera.
  46234. * The camera looks towards it form the radius distance.
  46235. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46236. */
  46237. get target(): Vector3;
  46238. set target(value: Vector3);
  46239. /**
  46240. * Define the current local position of the camera in the scene
  46241. */
  46242. get position(): Vector3;
  46243. set position(newPosition: Vector3);
  46244. protected _upToYMatrix: Matrix;
  46245. protected _YToUpMatrix: Matrix;
  46246. /**
  46247. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46248. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46249. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46250. */
  46251. set upVector(vec: Vector3);
  46252. get upVector(): Vector3;
  46253. /**
  46254. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46255. */
  46256. setMatUp(): void;
  46257. /**
  46258. * Current inertia value on the longitudinal axis.
  46259. * The bigger this number the longer it will take for the camera to stop.
  46260. */
  46261. inertialAlphaOffset: number;
  46262. /**
  46263. * Current inertia value on the latitudinal axis.
  46264. * The bigger this number the longer it will take for the camera to stop.
  46265. */
  46266. inertialBetaOffset: number;
  46267. /**
  46268. * Current inertia value on the radius axis.
  46269. * The bigger this number the longer it will take for the camera to stop.
  46270. */
  46271. inertialRadiusOffset: number;
  46272. /**
  46273. * Minimum allowed angle on the longitudinal axis.
  46274. * This can help limiting how the Camera is able to move in the scene.
  46275. */
  46276. lowerAlphaLimit: Nullable<number>;
  46277. /**
  46278. * Maximum allowed angle on the longitudinal axis.
  46279. * This can help limiting how the Camera is able to move in the scene.
  46280. */
  46281. upperAlphaLimit: Nullable<number>;
  46282. /**
  46283. * Minimum allowed angle on the latitudinal axis.
  46284. * This can help limiting how the Camera is able to move in the scene.
  46285. */
  46286. lowerBetaLimit: number;
  46287. /**
  46288. * Maximum allowed angle on the latitudinal axis.
  46289. * This can help limiting how the Camera is able to move in the scene.
  46290. */
  46291. upperBetaLimit: number;
  46292. /**
  46293. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46294. * This can help limiting how the Camera is able to move in the scene.
  46295. */
  46296. lowerRadiusLimit: Nullable<number>;
  46297. /**
  46298. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46299. * This can help limiting how the Camera is able to move in the scene.
  46300. */
  46301. upperRadiusLimit: Nullable<number>;
  46302. /**
  46303. * Defines the current inertia value used during panning of the camera along the X axis.
  46304. */
  46305. inertialPanningX: number;
  46306. /**
  46307. * Defines the current inertia value used during panning of the camera along the Y axis.
  46308. */
  46309. inertialPanningY: number;
  46310. /**
  46311. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46312. * Basically if your fingers moves away from more than this distance you will be considered
  46313. * in pinch mode.
  46314. */
  46315. pinchToPanMaxDistance: number;
  46316. /**
  46317. * Defines the maximum distance the camera can pan.
  46318. * This could help keeping the cammera always in your scene.
  46319. */
  46320. panningDistanceLimit: Nullable<number>;
  46321. /**
  46322. * Defines the target of the camera before paning.
  46323. */
  46324. panningOriginTarget: Vector3;
  46325. /**
  46326. * Defines the value of the inertia used during panning.
  46327. * 0 would mean stop inertia and one would mean no decelleration at all.
  46328. */
  46329. panningInertia: number;
  46330. /**
  46331. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46332. */
  46333. get angularSensibilityX(): number;
  46334. set angularSensibilityX(value: number);
  46335. /**
  46336. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46337. */
  46338. get angularSensibilityY(): number;
  46339. set angularSensibilityY(value: number);
  46340. /**
  46341. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46342. */
  46343. get pinchPrecision(): number;
  46344. set pinchPrecision(value: number);
  46345. /**
  46346. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46347. * It will be used instead of pinchDeltaPrecision if different from 0.
  46348. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46349. */
  46350. get pinchDeltaPercentage(): number;
  46351. set pinchDeltaPercentage(value: number);
  46352. /**
  46353. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46354. * and pinch delta percentage.
  46355. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46356. * that any object in the plane at the camera's target point will scale
  46357. * perfectly with finger motion.
  46358. */
  46359. get useNaturalPinchZoom(): boolean;
  46360. set useNaturalPinchZoom(value: boolean);
  46361. /**
  46362. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46363. */
  46364. get panningSensibility(): number;
  46365. set panningSensibility(value: number);
  46366. /**
  46367. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46368. */
  46369. get keysUp(): number[];
  46370. set keysUp(value: number[]);
  46371. /**
  46372. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46373. */
  46374. get keysDown(): number[];
  46375. set keysDown(value: number[]);
  46376. /**
  46377. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46378. */
  46379. get keysLeft(): number[];
  46380. set keysLeft(value: number[]);
  46381. /**
  46382. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46383. */
  46384. get keysRight(): number[];
  46385. set keysRight(value: number[]);
  46386. /**
  46387. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46388. */
  46389. get wheelPrecision(): number;
  46390. set wheelPrecision(value: number);
  46391. /**
  46392. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46393. * It will be used instead of pinchDeltaPrecision if different from 0.
  46394. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46395. */
  46396. get wheelDeltaPercentage(): number;
  46397. set wheelDeltaPercentage(value: number);
  46398. /**
  46399. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46400. */
  46401. zoomOnFactor: number;
  46402. /**
  46403. * Defines a screen offset for the camera position.
  46404. */
  46405. targetScreenOffset: Vector2;
  46406. /**
  46407. * Allows the camera to be completely reversed.
  46408. * If false the camera can not arrive upside down.
  46409. */
  46410. allowUpsideDown: boolean;
  46411. /**
  46412. * Define if double tap/click is used to restore the previously saved state of the camera.
  46413. */
  46414. useInputToRestoreState: boolean;
  46415. /** @hidden */
  46416. _viewMatrix: Matrix;
  46417. /** @hidden */
  46418. _useCtrlForPanning: boolean;
  46419. /** @hidden */
  46420. _panningMouseButton: number;
  46421. /**
  46422. * Defines the input associated to the camera.
  46423. */
  46424. inputs: ArcRotateCameraInputsManager;
  46425. /** @hidden */
  46426. _reset: () => void;
  46427. /**
  46428. * Defines the allowed panning axis.
  46429. */
  46430. panningAxis: Vector3;
  46431. protected _localDirection: Vector3;
  46432. protected _transformedDirection: Vector3;
  46433. private _bouncingBehavior;
  46434. /**
  46435. * Gets the bouncing behavior of the camera if it has been enabled.
  46436. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46437. */
  46438. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46439. /**
  46440. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46441. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46442. */
  46443. get useBouncingBehavior(): boolean;
  46444. set useBouncingBehavior(value: boolean);
  46445. private _framingBehavior;
  46446. /**
  46447. * Gets the framing behavior of the camera if it has been enabled.
  46448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46449. */
  46450. get framingBehavior(): Nullable<FramingBehavior>;
  46451. /**
  46452. * Defines if the framing behavior of the camera is enabled on the camera.
  46453. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46454. */
  46455. get useFramingBehavior(): boolean;
  46456. set useFramingBehavior(value: boolean);
  46457. private _autoRotationBehavior;
  46458. /**
  46459. * Gets the auto rotation behavior of the camera if it has been enabled.
  46460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46461. */
  46462. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46463. /**
  46464. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46465. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46466. */
  46467. get useAutoRotationBehavior(): boolean;
  46468. set useAutoRotationBehavior(value: boolean);
  46469. /**
  46470. * Observable triggered when the mesh target has been changed on the camera.
  46471. */
  46472. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46473. /**
  46474. * Event raised when the camera is colliding with a mesh.
  46475. */
  46476. onCollide: (collidedMesh: AbstractMesh) => void;
  46477. /**
  46478. * Defines whether the camera should check collision with the objects oh the scene.
  46479. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46480. */
  46481. checkCollisions: boolean;
  46482. /**
  46483. * Defines the collision radius of the camera.
  46484. * This simulates a sphere around the camera.
  46485. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46486. */
  46487. collisionRadius: Vector3;
  46488. protected _collider: Collider;
  46489. protected _previousPosition: Vector3;
  46490. protected _collisionVelocity: Vector3;
  46491. protected _newPosition: Vector3;
  46492. protected _previousAlpha: number;
  46493. protected _previousBeta: number;
  46494. protected _previousRadius: number;
  46495. protected _collisionTriggered: boolean;
  46496. protected _targetBoundingCenter: Nullable<Vector3>;
  46497. private _computationVector;
  46498. /**
  46499. * Instantiates a new ArcRotateCamera in a given scene
  46500. * @param name Defines the name of the camera
  46501. * @param alpha Defines the camera rotation along the logitudinal axis
  46502. * @param beta Defines the camera rotation along the latitudinal axis
  46503. * @param radius Defines the camera distance from its target
  46504. * @param target Defines the camera target
  46505. * @param scene Defines the scene the camera belongs to
  46506. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46507. */
  46508. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46509. /** @hidden */
  46510. _initCache(): void;
  46511. /** @hidden */
  46512. _updateCache(ignoreParentClass?: boolean): void;
  46513. protected _getTargetPosition(): Vector3;
  46514. private _storedAlpha;
  46515. private _storedBeta;
  46516. private _storedRadius;
  46517. private _storedTarget;
  46518. private _storedTargetScreenOffset;
  46519. /**
  46520. * Stores the current state of the camera (alpha, beta, radius and target)
  46521. * @returns the camera itself
  46522. */
  46523. storeState(): Camera;
  46524. /**
  46525. * @hidden
  46526. * Restored camera state. You must call storeState() first
  46527. */
  46528. _restoreStateValues(): boolean;
  46529. /** @hidden */
  46530. _isSynchronizedViewMatrix(): boolean;
  46531. /**
  46532. * Attach the input controls to a specific dom element to get the input from.
  46533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46534. */
  46535. attachControl(noPreventDefault?: boolean): void;
  46536. /**
  46537. * Attach the input controls to a specific dom element to get the input from.
  46538. * @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
  46539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46540. */
  46541. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46542. /**
  46543. * Attached controls to the current camera.
  46544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46545. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46546. */
  46547. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46548. /**
  46549. * Attached controls to the current camera.
  46550. * @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
  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(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46555. /**
  46556. * Attached controls to the current camera.
  46557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46558. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46559. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46560. */
  46561. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46562. /**
  46563. * Detach the current controls from the camera.
  46564. * The camera will stop reacting to inputs.
  46565. */
  46566. detachControl(): void;
  46567. /** @hidden */
  46568. _checkInputs(): void;
  46569. protected _checkLimits(): void;
  46570. /**
  46571. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46572. */
  46573. rebuildAnglesAndRadius(): void;
  46574. /**
  46575. * Use a position to define the current camera related information like alpha, beta and radius
  46576. * @param position Defines the position to set the camera at
  46577. */
  46578. setPosition(position: Vector3): void;
  46579. /**
  46580. * Defines the target the camera should look at.
  46581. * This will automatically adapt alpha beta and radius to fit within the new target.
  46582. * @param target Defines the new target as a Vector or a mesh
  46583. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46584. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46585. */
  46586. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46587. /** @hidden */
  46588. _getViewMatrix(): Matrix;
  46589. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46590. /**
  46591. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46592. * @param meshes Defines the mesh to zoom on
  46593. * @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)
  46594. */
  46595. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46596. /**
  46597. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46598. * The target will be changed but the radius
  46599. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46600. * @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)
  46601. */
  46602. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46603. min: Vector3;
  46604. max: Vector3;
  46605. distance: number;
  46606. }, doNotUpdateMaxZ?: boolean): void;
  46607. /**
  46608. * @override
  46609. * Override Camera.createRigCamera
  46610. */
  46611. createRigCamera(name: string, cameraIndex: number): Camera;
  46612. /**
  46613. * @hidden
  46614. * @override
  46615. * Override Camera._updateRigCameras
  46616. */
  46617. _updateRigCameras(): void;
  46618. /**
  46619. * Destroy the camera and release the current resources hold by it.
  46620. */
  46621. dispose(): void;
  46622. /**
  46623. * Gets the current object class name.
  46624. * @return the class name
  46625. */
  46626. getClassName(): string;
  46627. }
  46628. }
  46629. declare module BABYLON {
  46630. /**
  46631. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46632. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46633. */
  46634. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46635. /**
  46636. * Gets the name of the behavior.
  46637. */
  46638. get name(): string;
  46639. private _zoomStopsAnimation;
  46640. private _idleRotationSpeed;
  46641. private _idleRotationWaitTime;
  46642. private _idleRotationSpinupTime;
  46643. /**
  46644. * Sets the flag that indicates if user zooming should stop animation.
  46645. */
  46646. set zoomStopsAnimation(flag: boolean);
  46647. /**
  46648. * Gets the flag that indicates if user zooming should stop animation.
  46649. */
  46650. get zoomStopsAnimation(): boolean;
  46651. /**
  46652. * Sets the default speed at which the camera rotates around the model.
  46653. */
  46654. set idleRotationSpeed(speed: number);
  46655. /**
  46656. * Gets the default speed at which the camera rotates around the model.
  46657. */
  46658. get idleRotationSpeed(): number;
  46659. /**
  46660. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46661. */
  46662. set idleRotationWaitTime(time: number);
  46663. /**
  46664. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46665. */
  46666. get idleRotationWaitTime(): number;
  46667. /**
  46668. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46669. */
  46670. set idleRotationSpinupTime(time: number);
  46671. /**
  46672. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46673. */
  46674. get idleRotationSpinupTime(): number;
  46675. /**
  46676. * Gets a value indicating if the camera is currently rotating because of this behavior
  46677. */
  46678. get rotationInProgress(): boolean;
  46679. private _onPrePointerObservableObserver;
  46680. private _onAfterCheckInputsObserver;
  46681. private _attachedCamera;
  46682. private _isPointerDown;
  46683. private _lastFrameTime;
  46684. private _lastInteractionTime;
  46685. private _cameraRotationSpeed;
  46686. /**
  46687. * Initializes the behavior.
  46688. */
  46689. init(): void;
  46690. /**
  46691. * Attaches the behavior to its arc rotate camera.
  46692. * @param camera Defines the camera to attach the behavior to
  46693. */
  46694. attach(camera: ArcRotateCamera): void;
  46695. /**
  46696. * Detaches the behavior from its current arc rotate camera.
  46697. */
  46698. detach(): void;
  46699. /**
  46700. * Returns true if user is scrolling.
  46701. * @return true if user is scrolling.
  46702. */
  46703. private _userIsZooming;
  46704. private _lastFrameRadius;
  46705. private _shouldAnimationStopForInteraction;
  46706. /**
  46707. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46708. */
  46709. private _applyUserInteraction;
  46710. private _userIsMoving;
  46711. }
  46712. }
  46713. declare module BABYLON {
  46714. /**
  46715. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46716. */
  46717. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46718. private ui;
  46719. /**
  46720. * The name of the behavior
  46721. */
  46722. name: string;
  46723. /**
  46724. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46725. */
  46726. distanceAwayFromFace: number;
  46727. /**
  46728. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46729. */
  46730. distanceAwayFromBottomOfFace: number;
  46731. private _faceVectors;
  46732. private _target;
  46733. private _scene;
  46734. private _onRenderObserver;
  46735. private _tmpMatrix;
  46736. private _tmpVector;
  46737. /**
  46738. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46739. * @param ui The transform node that should be attched to the mesh
  46740. */
  46741. constructor(ui: TransformNode);
  46742. /**
  46743. * Initializes the behavior
  46744. */
  46745. init(): void;
  46746. private _closestFace;
  46747. private _zeroVector;
  46748. private _lookAtTmpMatrix;
  46749. private _lookAtToRef;
  46750. /**
  46751. * Attaches the AttachToBoxBehavior to the passed in mesh
  46752. * @param target The mesh that the specified node will be attached to
  46753. */
  46754. attach(target: Mesh): void;
  46755. /**
  46756. * Detaches the behavior from the mesh
  46757. */
  46758. detach(): void;
  46759. }
  46760. }
  46761. declare module BABYLON {
  46762. /**
  46763. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46764. */
  46765. export class FadeInOutBehavior implements Behavior<Mesh> {
  46766. /**
  46767. * Time in milliseconds to delay before fading in (Default: 0)
  46768. */
  46769. delay: number;
  46770. /**
  46771. * Time in milliseconds for the mesh to fade in (Default: 300)
  46772. */
  46773. fadeInTime: number;
  46774. private _millisecondsPerFrame;
  46775. private _hovered;
  46776. private _hoverValue;
  46777. private _ownerNode;
  46778. /**
  46779. * Instatiates the FadeInOutBehavior
  46780. */
  46781. constructor();
  46782. /**
  46783. * The name of the behavior
  46784. */
  46785. get name(): string;
  46786. /**
  46787. * Initializes the behavior
  46788. */
  46789. init(): void;
  46790. /**
  46791. * Attaches the fade behavior on the passed in mesh
  46792. * @param ownerNode The mesh that will be faded in/out once attached
  46793. */
  46794. attach(ownerNode: Mesh): void;
  46795. /**
  46796. * Detaches the behavior from the mesh
  46797. */
  46798. detach(): void;
  46799. /**
  46800. * Triggers the mesh to begin fading in or out
  46801. * @param value if the object should fade in or out (true to fade in)
  46802. */
  46803. fadeIn(value: boolean): void;
  46804. private _update;
  46805. private _setAllVisibility;
  46806. }
  46807. }
  46808. declare module BABYLON {
  46809. /**
  46810. * Class containing a set of static utilities functions for managing Pivots
  46811. * @hidden
  46812. */
  46813. export class PivotTools {
  46814. private static _PivotCached;
  46815. private static _OldPivotPoint;
  46816. private static _PivotTranslation;
  46817. private static _PivotTmpVector;
  46818. private static _PivotPostMultiplyPivotMatrix;
  46819. /** @hidden */
  46820. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46821. /** @hidden */
  46822. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46823. }
  46824. }
  46825. declare module BABYLON {
  46826. /**
  46827. * Class containing static functions to help procedurally build meshes
  46828. */
  46829. export class PlaneBuilder {
  46830. /**
  46831. * Creates a plane mesh
  46832. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46833. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46834. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46836. * * 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
  46837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46838. * @param name defines the name of the mesh
  46839. * @param options defines the options used to create the mesh
  46840. * @param scene defines the hosting scene
  46841. * @returns the plane mesh
  46842. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46843. */
  46844. static CreatePlane(name: string, options: {
  46845. size?: number;
  46846. width?: number;
  46847. height?: number;
  46848. sideOrientation?: number;
  46849. frontUVs?: Vector4;
  46850. backUVs?: Vector4;
  46851. updatable?: boolean;
  46852. sourcePlane?: Plane;
  46853. }, scene?: Nullable<Scene>): Mesh;
  46854. }
  46855. }
  46856. declare module BABYLON {
  46857. /**
  46858. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46859. */
  46860. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46861. private static _AnyMouseID;
  46862. /**
  46863. * Abstract mesh the behavior is set on
  46864. */
  46865. attachedNode: AbstractMesh;
  46866. private _dragPlane;
  46867. private _scene;
  46868. private _pointerObserver;
  46869. private _beforeRenderObserver;
  46870. private static _planeScene;
  46871. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46872. /**
  46873. * 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)
  46874. */
  46875. maxDragAngle: number;
  46876. /**
  46877. * @hidden
  46878. */
  46879. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46880. /**
  46881. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46882. */
  46883. currentDraggingPointerID: number;
  46884. /**
  46885. * The last position where the pointer hit the drag plane in world space
  46886. */
  46887. lastDragPosition: Vector3;
  46888. /**
  46889. * If the behavior is currently in a dragging state
  46890. */
  46891. dragging: boolean;
  46892. /**
  46893. * 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)
  46894. */
  46895. dragDeltaRatio: number;
  46896. /**
  46897. * If the drag plane orientation should be updated during the dragging (Default: true)
  46898. */
  46899. updateDragPlane: boolean;
  46900. private _debugMode;
  46901. private _moving;
  46902. /**
  46903. * Fires each time the attached mesh is dragged with the pointer
  46904. * * delta between last drag position and current drag position in world space
  46905. * * dragDistance along the drag axis
  46906. * * dragPlaneNormal normal of the current drag plane used during the drag
  46907. * * dragPlanePoint in world space where the drag intersects the drag plane
  46908. */
  46909. onDragObservable: Observable<{
  46910. delta: Vector3;
  46911. dragPlanePoint: Vector3;
  46912. dragPlaneNormal: Vector3;
  46913. dragDistance: number;
  46914. pointerId: number;
  46915. }>;
  46916. /**
  46917. * Fires each time a drag begins (eg. mouse down on mesh)
  46918. */
  46919. onDragStartObservable: Observable<{
  46920. dragPlanePoint: Vector3;
  46921. pointerId: number;
  46922. }>;
  46923. /**
  46924. * Fires each time a drag ends (eg. mouse release after drag)
  46925. */
  46926. onDragEndObservable: Observable<{
  46927. dragPlanePoint: Vector3;
  46928. pointerId: number;
  46929. }>;
  46930. /**
  46931. * If the attached mesh should be moved when dragged
  46932. */
  46933. moveAttached: boolean;
  46934. /**
  46935. * If the drag behavior will react to drag events (Default: true)
  46936. */
  46937. enabled: boolean;
  46938. /**
  46939. * If pointer events should start and release the drag (Default: true)
  46940. */
  46941. startAndReleaseDragOnPointerEvents: boolean;
  46942. /**
  46943. * If camera controls should be detached during the drag
  46944. */
  46945. detachCameraControls: boolean;
  46946. /**
  46947. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46948. */
  46949. useObjectOrientationForDragging: boolean;
  46950. private _options;
  46951. /**
  46952. * Gets the options used by the behavior
  46953. */
  46954. get options(): {
  46955. dragAxis?: Vector3;
  46956. dragPlaneNormal?: Vector3;
  46957. };
  46958. /**
  46959. * Sets the options used by the behavior
  46960. */
  46961. set options(options: {
  46962. dragAxis?: Vector3;
  46963. dragPlaneNormal?: Vector3;
  46964. });
  46965. /**
  46966. * Creates a pointer drag behavior that can be attached to a mesh
  46967. * @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)
  46968. */
  46969. constructor(options?: {
  46970. dragAxis?: Vector3;
  46971. dragPlaneNormal?: Vector3;
  46972. });
  46973. /**
  46974. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46975. */
  46976. validateDrag: (targetPosition: Vector3) => boolean;
  46977. /**
  46978. * The name of the behavior
  46979. */
  46980. get name(): string;
  46981. /**
  46982. * Initializes the behavior
  46983. */
  46984. init(): void;
  46985. private _tmpVector;
  46986. private _alternatePickedPoint;
  46987. private _worldDragAxis;
  46988. private _targetPosition;
  46989. private _attachedToElement;
  46990. /**
  46991. * Attaches the drag behavior the passed in mesh
  46992. * @param ownerNode The mesh that will be dragged around once attached
  46993. * @param predicate Predicate to use for pick filtering
  46994. */
  46995. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46996. /**
  46997. * Force relase the drag action by code.
  46998. */
  46999. releaseDrag(): void;
  47000. private _startDragRay;
  47001. private _lastPointerRay;
  47002. /**
  47003. * Simulates the start of a pointer drag event on the behavior
  47004. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47005. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47006. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47007. */
  47008. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47009. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47010. private _dragDelta;
  47011. protected _moveDrag(ray: Ray): void;
  47012. private _pickWithRayOnDragPlane;
  47013. private _pointA;
  47014. private _pointC;
  47015. private _localAxis;
  47016. private _lookAt;
  47017. private _updateDragPlanePosition;
  47018. /**
  47019. * Detaches the behavior from the mesh
  47020. */
  47021. detach(): void;
  47022. }
  47023. }
  47024. declare module BABYLON {
  47025. /**
  47026. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47027. */
  47028. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47029. private _dragBehaviorA;
  47030. private _dragBehaviorB;
  47031. private _startDistance;
  47032. private _initialScale;
  47033. private _targetScale;
  47034. private _ownerNode;
  47035. private _sceneRenderObserver;
  47036. /**
  47037. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47038. */
  47039. constructor();
  47040. /**
  47041. * The name of the behavior
  47042. */
  47043. get name(): string;
  47044. /**
  47045. * Initializes the behavior
  47046. */
  47047. init(): void;
  47048. private _getCurrentDistance;
  47049. /**
  47050. * Attaches the scale behavior the passed in mesh
  47051. * @param ownerNode The mesh that will be scaled around once attached
  47052. */
  47053. attach(ownerNode: Mesh): void;
  47054. /**
  47055. * Detaches the behavior from the mesh
  47056. */
  47057. detach(): void;
  47058. }
  47059. }
  47060. declare module BABYLON {
  47061. /**
  47062. * 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
  47063. */
  47064. export class SixDofDragBehavior implements Behavior<Mesh> {
  47065. private static _virtualScene;
  47066. private _ownerNode;
  47067. private _sceneRenderObserver;
  47068. private _scene;
  47069. private _targetPosition;
  47070. private _virtualOriginMesh;
  47071. private _virtualDragMesh;
  47072. private _pointerObserver;
  47073. private _moving;
  47074. private _startingOrientation;
  47075. private _attachedToElement;
  47076. /**
  47077. * 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)
  47078. */
  47079. private zDragFactor;
  47080. /**
  47081. * If the object should rotate to face the drag origin
  47082. */
  47083. rotateDraggedObject: boolean;
  47084. /**
  47085. * If the behavior is currently in a dragging state
  47086. */
  47087. dragging: boolean;
  47088. /**
  47089. * 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)
  47090. */
  47091. dragDeltaRatio: number;
  47092. /**
  47093. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47094. */
  47095. currentDraggingPointerID: number;
  47096. /**
  47097. * If camera controls should be detached during the drag
  47098. */
  47099. detachCameraControls: boolean;
  47100. /**
  47101. * Fires each time a drag starts
  47102. */
  47103. onDragStartObservable: Observable<{}>;
  47104. /**
  47105. * Fires each time a drag ends (eg. mouse release after drag)
  47106. */
  47107. onDragEndObservable: Observable<{}>;
  47108. /**
  47109. * 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
  47110. */
  47111. constructor();
  47112. /**
  47113. * The name of the behavior
  47114. */
  47115. get name(): string;
  47116. /**
  47117. * Initializes the behavior
  47118. */
  47119. init(): void;
  47120. /**
  47121. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47122. */
  47123. private get _pointerCamera();
  47124. /**
  47125. * Attaches the scale behavior the passed in mesh
  47126. * @param ownerNode The mesh that will be scaled around once attached
  47127. */
  47128. attach(ownerNode: Mesh): void;
  47129. /**
  47130. * Detaches the behavior from the mesh
  47131. */
  47132. detach(): void;
  47133. }
  47134. }
  47135. declare module BABYLON {
  47136. /**
  47137. * Class used to apply inverse kinematics to bones
  47138. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47139. */
  47140. export class BoneIKController {
  47141. private static _tmpVecs;
  47142. private static _tmpQuat;
  47143. private static _tmpMats;
  47144. /**
  47145. * Gets or sets the target mesh
  47146. */
  47147. targetMesh: AbstractMesh;
  47148. /** Gets or sets the mesh used as pole */
  47149. poleTargetMesh: AbstractMesh;
  47150. /**
  47151. * Gets or sets the bone used as pole
  47152. */
  47153. poleTargetBone: Nullable<Bone>;
  47154. /**
  47155. * Gets or sets the target position
  47156. */
  47157. targetPosition: Vector3;
  47158. /**
  47159. * Gets or sets the pole target position
  47160. */
  47161. poleTargetPosition: Vector3;
  47162. /**
  47163. * Gets or sets the pole target local offset
  47164. */
  47165. poleTargetLocalOffset: Vector3;
  47166. /**
  47167. * Gets or sets the pole angle
  47168. */
  47169. poleAngle: number;
  47170. /**
  47171. * Gets or sets the mesh associated with the controller
  47172. */
  47173. mesh: AbstractMesh;
  47174. /**
  47175. * 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)
  47176. */
  47177. slerpAmount: number;
  47178. private _bone1Quat;
  47179. private _bone1Mat;
  47180. private _bone2Ang;
  47181. private _bone1;
  47182. private _bone2;
  47183. private _bone1Length;
  47184. private _bone2Length;
  47185. private _maxAngle;
  47186. private _maxReach;
  47187. private _rightHandedSystem;
  47188. private _bendAxis;
  47189. private _slerping;
  47190. private _adjustRoll;
  47191. /**
  47192. * Gets or sets maximum allowed angle
  47193. */
  47194. get maxAngle(): number;
  47195. set maxAngle(value: number);
  47196. /**
  47197. * Creates a new BoneIKController
  47198. * @param mesh defines the mesh to control
  47199. * @param bone defines the bone to control
  47200. * @param options defines options to set up the controller
  47201. */
  47202. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47203. targetMesh?: AbstractMesh;
  47204. poleTargetMesh?: AbstractMesh;
  47205. poleTargetBone?: Bone;
  47206. poleTargetLocalOffset?: Vector3;
  47207. poleAngle?: number;
  47208. bendAxis?: Vector3;
  47209. maxAngle?: number;
  47210. slerpAmount?: number;
  47211. });
  47212. private _setMaxAngle;
  47213. /**
  47214. * Force the controller to update the bones
  47215. */
  47216. update(): void;
  47217. }
  47218. }
  47219. declare module BABYLON {
  47220. /**
  47221. * Class used to make a bone look toward a point in space
  47222. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47223. */
  47224. export class BoneLookController {
  47225. private static _tmpVecs;
  47226. private static _tmpQuat;
  47227. private static _tmpMats;
  47228. /**
  47229. * The target Vector3 that the bone will look at
  47230. */
  47231. target: Vector3;
  47232. /**
  47233. * The mesh that the bone is attached to
  47234. */
  47235. mesh: AbstractMesh;
  47236. /**
  47237. * The bone that will be looking to the target
  47238. */
  47239. bone: Bone;
  47240. /**
  47241. * The up axis of the coordinate system that is used when the bone is rotated
  47242. */
  47243. upAxis: Vector3;
  47244. /**
  47245. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47246. */
  47247. upAxisSpace: Space;
  47248. /**
  47249. * Used to make an adjustment to the yaw of the bone
  47250. */
  47251. adjustYaw: number;
  47252. /**
  47253. * Used to make an adjustment to the pitch of the bone
  47254. */
  47255. adjustPitch: number;
  47256. /**
  47257. * Used to make an adjustment to the roll of the bone
  47258. */
  47259. adjustRoll: number;
  47260. /**
  47261. * 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)
  47262. */
  47263. slerpAmount: number;
  47264. private _minYaw;
  47265. private _maxYaw;
  47266. private _minPitch;
  47267. private _maxPitch;
  47268. private _minYawSin;
  47269. private _minYawCos;
  47270. private _maxYawSin;
  47271. private _maxYawCos;
  47272. private _midYawConstraint;
  47273. private _minPitchTan;
  47274. private _maxPitchTan;
  47275. private _boneQuat;
  47276. private _slerping;
  47277. private _transformYawPitch;
  47278. private _transformYawPitchInv;
  47279. private _firstFrameSkipped;
  47280. private _yawRange;
  47281. private _fowardAxis;
  47282. /**
  47283. * Gets or sets the minimum yaw angle that the bone can look to
  47284. */
  47285. get minYaw(): number;
  47286. set minYaw(value: number);
  47287. /**
  47288. * Gets or sets the maximum yaw angle that the bone can look to
  47289. */
  47290. get maxYaw(): number;
  47291. set maxYaw(value: number);
  47292. /**
  47293. * Gets or sets the minimum pitch angle that the bone can look to
  47294. */
  47295. get minPitch(): number;
  47296. set minPitch(value: number);
  47297. /**
  47298. * Gets or sets the maximum pitch angle that the bone can look to
  47299. */
  47300. get maxPitch(): number;
  47301. set maxPitch(value: number);
  47302. /**
  47303. * Create a BoneLookController
  47304. * @param mesh the mesh that the bone belongs to
  47305. * @param bone the bone that will be looking to the target
  47306. * @param target the target Vector3 to look at
  47307. * @param options optional settings:
  47308. * * maxYaw: the maximum angle the bone will yaw to
  47309. * * minYaw: the minimum angle the bone will yaw to
  47310. * * maxPitch: the maximum angle the bone will pitch to
  47311. * * minPitch: the minimum angle the bone will yaw to
  47312. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47313. * * upAxis: the up axis of the coordinate system
  47314. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47315. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47316. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47317. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47318. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47319. * * adjustRoll: used to make an adjustment to the roll of the bone
  47320. **/
  47321. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47322. maxYaw?: number;
  47323. minYaw?: number;
  47324. maxPitch?: number;
  47325. minPitch?: number;
  47326. slerpAmount?: number;
  47327. upAxis?: Vector3;
  47328. upAxisSpace?: Space;
  47329. yawAxis?: Vector3;
  47330. pitchAxis?: Vector3;
  47331. adjustYaw?: number;
  47332. adjustPitch?: number;
  47333. adjustRoll?: number;
  47334. });
  47335. /**
  47336. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47337. */
  47338. update(): void;
  47339. private _getAngleDiff;
  47340. private _getAngleBetween;
  47341. private _isAngleBetween;
  47342. }
  47343. }
  47344. declare module BABYLON {
  47345. /**
  47346. * Manage the gamepad inputs to control an arc rotate camera.
  47347. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47348. */
  47349. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47350. /**
  47351. * Defines the camera the input is attached to.
  47352. */
  47353. camera: ArcRotateCamera;
  47354. /**
  47355. * Defines the gamepad the input is gathering event from.
  47356. */
  47357. gamepad: Nullable<Gamepad>;
  47358. /**
  47359. * Defines the gamepad rotation sensiblity.
  47360. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47361. */
  47362. gamepadRotationSensibility: number;
  47363. /**
  47364. * Defines the gamepad move sensiblity.
  47365. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47366. */
  47367. gamepadMoveSensibility: number;
  47368. private _yAxisScale;
  47369. /**
  47370. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47371. */
  47372. get invertYAxis(): boolean;
  47373. set invertYAxis(value: boolean);
  47374. private _onGamepadConnectedObserver;
  47375. private _onGamepadDisconnectedObserver;
  47376. /**
  47377. * Attach the input controls to a specific dom element to get the input from.
  47378. */
  47379. attachControl(): void;
  47380. /**
  47381. * Detach the current controls from the specified dom element.
  47382. * @param element Defines the element to stop listening the inputs from
  47383. */
  47384. detachControl(): void;
  47385. /**
  47386. * Update the current camera state depending on the inputs that have been used this frame.
  47387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47388. */
  47389. checkInputs(): void;
  47390. /**
  47391. * Gets the class name of the current intput.
  47392. * @returns the class name
  47393. */
  47394. getClassName(): string;
  47395. /**
  47396. * Get the friendly name associated with the input class.
  47397. * @returns the input friendly name
  47398. */
  47399. getSimpleName(): string;
  47400. }
  47401. }
  47402. declare module BABYLON {
  47403. interface ArcRotateCameraInputsManager {
  47404. /**
  47405. * Add orientation input support to the input manager.
  47406. * @returns the current input manager
  47407. */
  47408. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47409. }
  47410. /**
  47411. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47412. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47413. */
  47414. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47415. /**
  47416. * Defines the camera the input is attached to.
  47417. */
  47418. camera: ArcRotateCamera;
  47419. /**
  47420. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47421. */
  47422. alphaCorrection: number;
  47423. /**
  47424. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47425. */
  47426. gammaCorrection: number;
  47427. private _alpha;
  47428. private _gamma;
  47429. private _dirty;
  47430. private _deviceOrientationHandler;
  47431. /**
  47432. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47433. */
  47434. constructor();
  47435. /**
  47436. * Attach the input controls to a specific dom element to get the input from.
  47437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47438. */
  47439. attachControl(noPreventDefault?: boolean): void;
  47440. /** @hidden */
  47441. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47442. /**
  47443. * Update the current camera state depending on the inputs that have been used this frame.
  47444. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47445. */
  47446. checkInputs(): void;
  47447. /**
  47448. * Detach the current controls from the specified dom element.
  47449. */
  47450. detachControl(): void;
  47451. /**
  47452. * Gets the class name of the current intput.
  47453. * @returns the class name
  47454. */
  47455. getClassName(): string;
  47456. /**
  47457. * Get the friendly name associated with the input class.
  47458. * @returns the input friendly name
  47459. */
  47460. getSimpleName(): string;
  47461. }
  47462. }
  47463. declare module BABYLON {
  47464. /**
  47465. * Listen to mouse events to control the camera.
  47466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47467. */
  47468. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47469. /**
  47470. * Defines the camera the input is attached to.
  47471. */
  47472. camera: FlyCamera;
  47473. /**
  47474. * Defines if touch is enabled. (Default is true.)
  47475. */
  47476. touchEnabled: boolean;
  47477. /**
  47478. * Defines the buttons associated with the input to handle camera rotation.
  47479. */
  47480. buttons: number[];
  47481. /**
  47482. * Assign buttons for Yaw control.
  47483. */
  47484. buttonsYaw: number[];
  47485. /**
  47486. * Assign buttons for Pitch control.
  47487. */
  47488. buttonsPitch: number[];
  47489. /**
  47490. * Assign buttons for Roll control.
  47491. */
  47492. buttonsRoll: number[];
  47493. /**
  47494. * Detect if any button is being pressed while mouse is moved.
  47495. * -1 = Mouse locked.
  47496. * 0 = Left button.
  47497. * 1 = Middle Button.
  47498. * 2 = Right Button.
  47499. */
  47500. activeButton: number;
  47501. /**
  47502. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47503. * Higher values reduce its sensitivity.
  47504. */
  47505. angularSensibility: number;
  47506. private _observer;
  47507. private _rollObserver;
  47508. private previousPosition;
  47509. private noPreventDefault;
  47510. private element;
  47511. /**
  47512. * Listen to mouse events to control the camera.
  47513. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47515. */
  47516. constructor(touchEnabled?: boolean);
  47517. /**
  47518. * Attach the mouse control to the HTML DOM element.
  47519. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47520. */
  47521. attachControl(noPreventDefault?: boolean): void;
  47522. /**
  47523. * Detach the current controls from the specified dom element.
  47524. */
  47525. detachControl(): void;
  47526. /**
  47527. * Gets the class name of the current input.
  47528. * @returns the class name.
  47529. */
  47530. getClassName(): string;
  47531. /**
  47532. * Get the friendly name associated with the input class.
  47533. * @returns the input's friendly name.
  47534. */
  47535. getSimpleName(): string;
  47536. private _pointerInput;
  47537. private _onMouseMove;
  47538. /**
  47539. * Rotate camera by mouse offset.
  47540. */
  47541. private rotateCamera;
  47542. }
  47543. }
  47544. declare module BABYLON {
  47545. /**
  47546. * Default Inputs manager for the FlyCamera.
  47547. * It groups all the default supported inputs for ease of use.
  47548. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47549. */
  47550. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47551. /**
  47552. * Instantiates a new FlyCameraInputsManager.
  47553. * @param camera Defines the camera the inputs belong to.
  47554. */
  47555. constructor(camera: FlyCamera);
  47556. /**
  47557. * Add keyboard input support to the input manager.
  47558. * @returns the new FlyCameraKeyboardMoveInput().
  47559. */
  47560. addKeyboard(): FlyCameraInputsManager;
  47561. /**
  47562. * Add mouse input support to the input manager.
  47563. * @param touchEnabled Enable touch screen support.
  47564. * @returns the new FlyCameraMouseInput().
  47565. */
  47566. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47567. }
  47568. }
  47569. declare module BABYLON {
  47570. /**
  47571. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47572. * such as in a 3D Space Shooter or a Flight Simulator.
  47573. */
  47574. export class FlyCamera extends TargetCamera {
  47575. /**
  47576. * Define the collision ellipsoid of the camera.
  47577. * This is helpful for simulating a camera body, like a player's body.
  47578. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47579. */
  47580. ellipsoid: Vector3;
  47581. /**
  47582. * Define an offset for the position of the ellipsoid around the camera.
  47583. * This can be helpful if the camera is attached away from the player's body center,
  47584. * such as at its head.
  47585. */
  47586. ellipsoidOffset: Vector3;
  47587. /**
  47588. * Enable or disable collisions of the camera with the rest of the scene objects.
  47589. */
  47590. checkCollisions: boolean;
  47591. /**
  47592. * Enable or disable gravity on the camera.
  47593. */
  47594. applyGravity: boolean;
  47595. /**
  47596. * Define the current direction the camera is moving to.
  47597. */
  47598. cameraDirection: Vector3;
  47599. /**
  47600. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47601. * This overrides and empties cameraRotation.
  47602. */
  47603. rotationQuaternion: Quaternion;
  47604. /**
  47605. * Track Roll to maintain the wanted Rolling when looking around.
  47606. */
  47607. _trackRoll: number;
  47608. /**
  47609. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47610. */
  47611. rollCorrect: number;
  47612. /**
  47613. * Mimic a banked turn, Rolling the camera when Yawing.
  47614. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47615. */
  47616. bankedTurn: boolean;
  47617. /**
  47618. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47619. */
  47620. bankedTurnLimit: number;
  47621. /**
  47622. * Value of 0 disables the banked Roll.
  47623. * Value of 1 is equal to the Yaw angle in radians.
  47624. */
  47625. bankedTurnMultiplier: number;
  47626. /**
  47627. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47628. */
  47629. inputs: FlyCameraInputsManager;
  47630. /**
  47631. * Gets the input sensibility for mouse input.
  47632. * Higher values reduce sensitivity.
  47633. */
  47634. get angularSensibility(): number;
  47635. /**
  47636. * Sets the input sensibility for a mouse input.
  47637. * Higher values reduce sensitivity.
  47638. */
  47639. set angularSensibility(value: number);
  47640. /**
  47641. * Get the keys for camera movement forward.
  47642. */
  47643. get keysForward(): number[];
  47644. /**
  47645. * Set the keys for camera movement forward.
  47646. */
  47647. set keysForward(value: number[]);
  47648. /**
  47649. * Get the keys for camera movement backward.
  47650. */
  47651. get keysBackward(): number[];
  47652. set keysBackward(value: number[]);
  47653. /**
  47654. * Get the keys for camera movement up.
  47655. */
  47656. get keysUp(): number[];
  47657. /**
  47658. * Set the keys for camera movement up.
  47659. */
  47660. set keysUp(value: number[]);
  47661. /**
  47662. * Get the keys for camera movement down.
  47663. */
  47664. get keysDown(): number[];
  47665. /**
  47666. * Set the keys for camera movement down.
  47667. */
  47668. set keysDown(value: number[]);
  47669. /**
  47670. * Get the keys for camera movement left.
  47671. */
  47672. get keysLeft(): number[];
  47673. /**
  47674. * Set the keys for camera movement left.
  47675. */
  47676. set keysLeft(value: number[]);
  47677. /**
  47678. * Set the keys for camera movement right.
  47679. */
  47680. get keysRight(): number[];
  47681. /**
  47682. * Set the keys for camera movement right.
  47683. */
  47684. set keysRight(value: number[]);
  47685. /**
  47686. * Event raised when the camera collides with a mesh in the scene.
  47687. */
  47688. onCollide: (collidedMesh: AbstractMesh) => void;
  47689. private _collider;
  47690. private _needMoveForGravity;
  47691. private _oldPosition;
  47692. private _diffPosition;
  47693. private _newPosition;
  47694. /** @hidden */
  47695. _localDirection: Vector3;
  47696. /** @hidden */
  47697. _transformedDirection: Vector3;
  47698. /**
  47699. * Instantiates a FlyCamera.
  47700. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47701. * such as in a 3D Space Shooter or a Flight Simulator.
  47702. * @param name Define the name of the camera in the scene.
  47703. * @param position Define the starting position of the camera in the scene.
  47704. * @param scene Define the scene the camera belongs to.
  47705. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47706. */
  47707. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47708. /**
  47709. * Attach a control to the HTML DOM element.
  47710. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47711. */
  47712. attachControl(noPreventDefault?: boolean): void;
  47713. /**
  47714. * Detach a control from the HTML DOM element.
  47715. * The camera will stop reacting to that input.
  47716. */
  47717. detachControl(): void;
  47718. private _collisionMask;
  47719. /**
  47720. * Get the mask that the camera ignores in collision events.
  47721. */
  47722. get collisionMask(): number;
  47723. /**
  47724. * Set the mask that the camera ignores in collision events.
  47725. */
  47726. set collisionMask(mask: number);
  47727. /** @hidden */
  47728. _collideWithWorld(displacement: Vector3): void;
  47729. /** @hidden */
  47730. private _onCollisionPositionChange;
  47731. /** @hidden */
  47732. _checkInputs(): void;
  47733. /** @hidden */
  47734. _decideIfNeedsToMove(): boolean;
  47735. /** @hidden */
  47736. _updatePosition(): void;
  47737. /**
  47738. * Restore the Roll to its target value at the rate specified.
  47739. * @param rate - Higher means slower restoring.
  47740. * @hidden
  47741. */
  47742. restoreRoll(rate: number): void;
  47743. /**
  47744. * Destroy the camera and release the current resources held by it.
  47745. */
  47746. dispose(): void;
  47747. /**
  47748. * Get the current object class name.
  47749. * @returns the class name.
  47750. */
  47751. getClassName(): string;
  47752. }
  47753. }
  47754. declare module BABYLON {
  47755. /**
  47756. * Listen to keyboard events to control the camera.
  47757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47758. */
  47759. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47760. /**
  47761. * Defines the camera the input is attached to.
  47762. */
  47763. camera: FlyCamera;
  47764. /**
  47765. * The list of keyboard keys used to control the forward move of the camera.
  47766. */
  47767. keysForward: number[];
  47768. /**
  47769. * The list of keyboard keys used to control the backward move of the camera.
  47770. */
  47771. keysBackward: number[];
  47772. /**
  47773. * The list of keyboard keys used to control the forward move of the camera.
  47774. */
  47775. keysUp: number[];
  47776. /**
  47777. * The list of keyboard keys used to control the backward move of the camera.
  47778. */
  47779. keysDown: number[];
  47780. /**
  47781. * The list of keyboard keys used to control the right strafe move of the camera.
  47782. */
  47783. keysRight: number[];
  47784. /**
  47785. * The list of keyboard keys used to control the left strafe move of the camera.
  47786. */
  47787. keysLeft: number[];
  47788. private _keys;
  47789. private _onCanvasBlurObserver;
  47790. private _onKeyboardObserver;
  47791. private _engine;
  47792. private _scene;
  47793. /**
  47794. * Attach the input controls to a specific dom element to get the input from.
  47795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47796. */
  47797. attachControl(noPreventDefault?: boolean): void;
  47798. /**
  47799. * Detach the current controls from the specified dom element.
  47800. */
  47801. detachControl(): void;
  47802. /**
  47803. * Gets the class name of the current intput.
  47804. * @returns the class name
  47805. */
  47806. getClassName(): string;
  47807. /** @hidden */
  47808. _onLostFocus(e: FocusEvent): void;
  47809. /**
  47810. * Get the friendly name associated with the input class.
  47811. * @returns the input friendly name
  47812. */
  47813. getSimpleName(): string;
  47814. /**
  47815. * Update the current camera state depending on the inputs that have been used this frame.
  47816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47817. */
  47818. checkInputs(): void;
  47819. }
  47820. }
  47821. declare module BABYLON {
  47822. /**
  47823. * Manage the mouse wheel inputs to control a follow camera.
  47824. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47825. */
  47826. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47827. /**
  47828. * Defines the camera the input is attached to.
  47829. */
  47830. camera: FollowCamera;
  47831. /**
  47832. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47833. */
  47834. axisControlRadius: boolean;
  47835. /**
  47836. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47837. */
  47838. axisControlHeight: boolean;
  47839. /**
  47840. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47841. */
  47842. axisControlRotation: boolean;
  47843. /**
  47844. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47845. * relation to mouseWheel events.
  47846. */
  47847. wheelPrecision: number;
  47848. /**
  47849. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47850. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47851. */
  47852. wheelDeltaPercentage: number;
  47853. private _wheel;
  47854. private _observer;
  47855. /**
  47856. * Attach the input controls to a specific dom element to get the input from.
  47857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47858. */
  47859. attachControl(noPreventDefault?: boolean): void;
  47860. /**
  47861. * Detach the current controls from the specified dom element.
  47862. */
  47863. detachControl(): void;
  47864. /**
  47865. * Gets the class name of the current intput.
  47866. * @returns the class name
  47867. */
  47868. getClassName(): string;
  47869. /**
  47870. * Get the friendly name associated with the input class.
  47871. * @returns the input friendly name
  47872. */
  47873. getSimpleName(): string;
  47874. }
  47875. }
  47876. declare module BABYLON {
  47877. /**
  47878. * Manage the pointers inputs to control an follow camera.
  47879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47880. */
  47881. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47882. /**
  47883. * Defines the camera the input is attached to.
  47884. */
  47885. camera: FollowCamera;
  47886. /**
  47887. * Gets the class name of the current input.
  47888. * @returns the class name
  47889. */
  47890. getClassName(): string;
  47891. /**
  47892. * Defines the pointer angular sensibility along the X axis or how fast is
  47893. * the camera rotating.
  47894. * A negative number will reverse the axis direction.
  47895. */
  47896. angularSensibilityX: number;
  47897. /**
  47898. * Defines the pointer angular sensibility along the Y axis or how fast is
  47899. * the camera rotating.
  47900. * A negative number will reverse the axis direction.
  47901. */
  47902. angularSensibilityY: number;
  47903. /**
  47904. * Defines the pointer pinch precision or how fast is the camera zooming.
  47905. * A negative number will reverse the axis direction.
  47906. */
  47907. pinchPrecision: number;
  47908. /**
  47909. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47910. * from 0.
  47911. * It defines the percentage of current camera.radius to use as delta when
  47912. * pinch zoom is used.
  47913. */
  47914. pinchDeltaPercentage: number;
  47915. /**
  47916. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47917. */
  47918. axisXControlRadius: boolean;
  47919. /**
  47920. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47921. */
  47922. axisXControlHeight: boolean;
  47923. /**
  47924. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47925. */
  47926. axisXControlRotation: boolean;
  47927. /**
  47928. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47929. */
  47930. axisYControlRadius: boolean;
  47931. /**
  47932. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47933. */
  47934. axisYControlHeight: boolean;
  47935. /**
  47936. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47937. */
  47938. axisYControlRotation: boolean;
  47939. /**
  47940. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47941. */
  47942. axisPinchControlRadius: boolean;
  47943. /**
  47944. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47945. */
  47946. axisPinchControlHeight: boolean;
  47947. /**
  47948. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47949. */
  47950. axisPinchControlRotation: boolean;
  47951. /**
  47952. * Log error messages if basic misconfiguration has occurred.
  47953. */
  47954. warningEnable: boolean;
  47955. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47956. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47957. private _warningCounter;
  47958. private _warning;
  47959. }
  47960. }
  47961. declare module BABYLON {
  47962. /**
  47963. * Default Inputs manager for the FollowCamera.
  47964. * It groups all the default supported inputs for ease of use.
  47965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47966. */
  47967. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47968. /**
  47969. * Instantiates a new FollowCameraInputsManager.
  47970. * @param camera Defines the camera the inputs belong to
  47971. */
  47972. constructor(camera: FollowCamera);
  47973. /**
  47974. * Add keyboard input support to the input manager.
  47975. * @returns the current input manager
  47976. */
  47977. addKeyboard(): FollowCameraInputsManager;
  47978. /**
  47979. * Add mouse wheel input support to the input manager.
  47980. * @returns the current input manager
  47981. */
  47982. addMouseWheel(): FollowCameraInputsManager;
  47983. /**
  47984. * Add pointers input support to the input manager.
  47985. * @returns the current input manager
  47986. */
  47987. addPointers(): FollowCameraInputsManager;
  47988. /**
  47989. * Add orientation input support to the input manager.
  47990. * @returns the current input manager
  47991. */
  47992. addVRDeviceOrientation(): FollowCameraInputsManager;
  47993. }
  47994. }
  47995. declare module BABYLON {
  47996. /**
  47997. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47998. * an arc rotate version arcFollowCamera are available.
  47999. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48000. */
  48001. export class FollowCamera extends TargetCamera {
  48002. /**
  48003. * Distance the follow camera should follow an object at
  48004. */
  48005. radius: number;
  48006. /**
  48007. * Minimum allowed distance of the camera to the axis of rotation
  48008. * (The camera can not get closer).
  48009. * This can help limiting how the Camera is able to move in the scene.
  48010. */
  48011. lowerRadiusLimit: Nullable<number>;
  48012. /**
  48013. * Maximum allowed distance of the camera to the axis of rotation
  48014. * (The camera can not get further).
  48015. * This can help limiting how the Camera is able to move in the scene.
  48016. */
  48017. upperRadiusLimit: Nullable<number>;
  48018. /**
  48019. * Define a rotation offset between the camera and the object it follows
  48020. */
  48021. rotationOffset: number;
  48022. /**
  48023. * Minimum allowed angle to camera position relative to target object.
  48024. * This can help limiting how the Camera is able to move in the scene.
  48025. */
  48026. lowerRotationOffsetLimit: Nullable<number>;
  48027. /**
  48028. * Maximum 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. upperRotationOffsetLimit: Nullable<number>;
  48032. /**
  48033. * Define a height offset between the camera and the object it follows.
  48034. * It can help following an object from the top (like a car chaing a plane)
  48035. */
  48036. heightOffset: number;
  48037. /**
  48038. * Minimum allowed height of camera position relative to target object.
  48039. * This can help limiting how the Camera is able to move in the scene.
  48040. */
  48041. lowerHeightOffsetLimit: Nullable<number>;
  48042. /**
  48043. * Maximum 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. upperHeightOffsetLimit: Nullable<number>;
  48047. /**
  48048. * Define how fast the camera can accelerate to follow it s target.
  48049. */
  48050. cameraAcceleration: number;
  48051. /**
  48052. * Define the speed limit of the camera following an object.
  48053. */
  48054. maxCameraSpeed: number;
  48055. /**
  48056. * Define the target of the camera.
  48057. */
  48058. lockedTarget: Nullable<AbstractMesh>;
  48059. /**
  48060. * Defines the input associated with the camera.
  48061. */
  48062. inputs: FollowCameraInputsManager;
  48063. /**
  48064. * Instantiates the follow camera.
  48065. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48066. * @param name Define the name of the camera in the scene
  48067. * @param position Define the position of the camera
  48068. * @param scene Define the scene the camera belong to
  48069. * @param lockedTarget Define the target of the camera
  48070. */
  48071. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48072. private _follow;
  48073. /**
  48074. * Attached controls to the current camera.
  48075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48076. */
  48077. attachControl(noPreventDefault?: boolean): void;
  48078. /**
  48079. * Detach the current controls from the camera.
  48080. * The camera will stop reacting to inputs.
  48081. */
  48082. detachControl(): void;
  48083. /** @hidden */
  48084. _checkInputs(): void;
  48085. private _checkLimits;
  48086. /**
  48087. * Gets the camera class name.
  48088. * @returns the class name
  48089. */
  48090. getClassName(): string;
  48091. }
  48092. /**
  48093. * Arc Rotate version of the follow camera.
  48094. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48095. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48096. */
  48097. export class ArcFollowCamera extends TargetCamera {
  48098. /** The longitudinal angle of the camera */
  48099. alpha: number;
  48100. /** The latitudinal angle of the camera */
  48101. beta: number;
  48102. /** The radius of the camera from its target */
  48103. radius: number;
  48104. private _cartesianCoordinates;
  48105. /** Define the camera target (the mesh it should follow) */
  48106. private _meshTarget;
  48107. /**
  48108. * Instantiates a new ArcFollowCamera
  48109. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48110. * @param name Define the name of the camera
  48111. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48112. * @param beta Define the rotation angle of the camera around the elevation axis
  48113. * @param radius Define the radius of the camera from its target point
  48114. * @param target Define the target of the camera
  48115. * @param scene Define the scene the camera belongs to
  48116. */
  48117. constructor(name: string,
  48118. /** The longitudinal angle of the camera */
  48119. alpha: number,
  48120. /** The latitudinal angle of the camera */
  48121. beta: number,
  48122. /** The radius of the camera from its target */
  48123. radius: number,
  48124. /** Define the camera target (the mesh it should follow) */
  48125. target: Nullable<AbstractMesh>, scene: Scene);
  48126. private _follow;
  48127. /** @hidden */
  48128. _checkInputs(): void;
  48129. /**
  48130. * Returns the class name of the object.
  48131. * It is mostly used internally for serialization purposes.
  48132. */
  48133. getClassName(): string;
  48134. }
  48135. }
  48136. declare module BABYLON {
  48137. /**
  48138. * Manage the keyboard inputs to control the movement of a follow camera.
  48139. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48140. */
  48141. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48142. /**
  48143. * Defines the camera the input is attached to.
  48144. */
  48145. camera: FollowCamera;
  48146. /**
  48147. * Defines the list of key codes associated with the up action (increase heightOffset)
  48148. */
  48149. keysHeightOffsetIncr: number[];
  48150. /**
  48151. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48152. */
  48153. keysHeightOffsetDecr: number[];
  48154. /**
  48155. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48156. */
  48157. keysHeightOffsetModifierAlt: boolean;
  48158. /**
  48159. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48160. */
  48161. keysHeightOffsetModifierCtrl: boolean;
  48162. /**
  48163. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48164. */
  48165. keysHeightOffsetModifierShift: boolean;
  48166. /**
  48167. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48168. */
  48169. keysRotationOffsetIncr: number[];
  48170. /**
  48171. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48172. */
  48173. keysRotationOffsetDecr: number[];
  48174. /**
  48175. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48176. */
  48177. keysRotationOffsetModifierAlt: boolean;
  48178. /**
  48179. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48180. */
  48181. keysRotationOffsetModifierCtrl: boolean;
  48182. /**
  48183. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48184. */
  48185. keysRotationOffsetModifierShift: boolean;
  48186. /**
  48187. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48188. */
  48189. keysRadiusIncr: number[];
  48190. /**
  48191. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48192. */
  48193. keysRadiusDecr: number[];
  48194. /**
  48195. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48196. */
  48197. keysRadiusModifierAlt: boolean;
  48198. /**
  48199. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48200. */
  48201. keysRadiusModifierCtrl: boolean;
  48202. /**
  48203. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48204. */
  48205. keysRadiusModifierShift: boolean;
  48206. /**
  48207. * Defines the rate of change of heightOffset.
  48208. */
  48209. heightSensibility: number;
  48210. /**
  48211. * Defines the rate of change of rotationOffset.
  48212. */
  48213. rotationSensibility: number;
  48214. /**
  48215. * Defines the rate of change of radius.
  48216. */
  48217. radiusSensibility: number;
  48218. private _keys;
  48219. private _ctrlPressed;
  48220. private _altPressed;
  48221. private _shiftPressed;
  48222. private _onCanvasBlurObserver;
  48223. private _onKeyboardObserver;
  48224. private _engine;
  48225. private _scene;
  48226. /**
  48227. * Attach the input controls to a specific dom element to get the input from.
  48228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48229. */
  48230. attachControl(noPreventDefault?: boolean): void;
  48231. /**
  48232. * Detach the current controls from the specified dom element.
  48233. */
  48234. detachControl(): void;
  48235. /**
  48236. * Update the current camera state depending on the inputs that have been used this frame.
  48237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48238. */
  48239. checkInputs(): void;
  48240. /**
  48241. * Gets the class name of the current input.
  48242. * @returns the class name
  48243. */
  48244. getClassName(): string;
  48245. /**
  48246. * Get the friendly name associated with the input class.
  48247. * @returns the input friendly name
  48248. */
  48249. getSimpleName(): string;
  48250. /**
  48251. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48252. * allow modification of the heightOffset value.
  48253. */
  48254. private _modifierHeightOffset;
  48255. /**
  48256. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48257. * allow modification of the rotationOffset value.
  48258. */
  48259. private _modifierRotationOffset;
  48260. /**
  48261. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48262. * allow modification of the radius value.
  48263. */
  48264. private _modifierRadius;
  48265. }
  48266. }
  48267. declare module BABYLON {
  48268. interface FreeCameraInputsManager {
  48269. /**
  48270. * @hidden
  48271. */
  48272. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48273. /**
  48274. * Add orientation input support to the input manager.
  48275. * @returns the current input manager
  48276. */
  48277. addDeviceOrientation(): FreeCameraInputsManager;
  48278. }
  48279. /**
  48280. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48281. * Screen rotation is taken into account.
  48282. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48283. */
  48284. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48285. private _camera;
  48286. private _screenOrientationAngle;
  48287. private _constantTranform;
  48288. private _screenQuaternion;
  48289. private _alpha;
  48290. private _beta;
  48291. private _gamma;
  48292. /**
  48293. * Can be used to detect if a device orientation sensor is available on a device
  48294. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48295. * @returns a promise that will resolve on orientation change
  48296. */
  48297. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48298. /**
  48299. * @hidden
  48300. */
  48301. _onDeviceOrientationChangedObservable: Observable<void>;
  48302. /**
  48303. * Instantiates a new input
  48304. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48305. */
  48306. constructor();
  48307. /**
  48308. * Define the camera controlled by the input.
  48309. */
  48310. get camera(): FreeCamera;
  48311. set camera(camera: FreeCamera);
  48312. /**
  48313. * Attach the input controls to a specific dom element to get the input from.
  48314. */
  48315. attachControl(): void;
  48316. private _orientationChanged;
  48317. private _deviceOrientation;
  48318. /**
  48319. * Detach the current controls from the specified dom element.
  48320. */
  48321. detachControl(): void;
  48322. /**
  48323. * Update the current camera state depending on the inputs that have been used this frame.
  48324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48325. */
  48326. checkInputs(): void;
  48327. /**
  48328. * Gets the class name of the current intput.
  48329. * @returns the class name
  48330. */
  48331. getClassName(): string;
  48332. /**
  48333. * Get the friendly name associated with the input class.
  48334. * @returns the input friendly name
  48335. */
  48336. getSimpleName(): string;
  48337. }
  48338. }
  48339. declare module BABYLON {
  48340. /**
  48341. * Manage the gamepad inputs to control a free camera.
  48342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48343. */
  48344. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48345. /**
  48346. * Define the camera the input is attached to.
  48347. */
  48348. camera: FreeCamera;
  48349. /**
  48350. * Define the Gamepad controlling the input
  48351. */
  48352. gamepad: Nullable<Gamepad>;
  48353. /**
  48354. * Defines the gamepad rotation sensiblity.
  48355. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48356. */
  48357. gamepadAngularSensibility: number;
  48358. /**
  48359. * Defines the gamepad move sensiblity.
  48360. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48361. */
  48362. gamepadMoveSensibility: number;
  48363. private _yAxisScale;
  48364. /**
  48365. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48366. */
  48367. get invertYAxis(): boolean;
  48368. set invertYAxis(value: boolean);
  48369. private _onGamepadConnectedObserver;
  48370. private _onGamepadDisconnectedObserver;
  48371. private _cameraTransform;
  48372. private _deltaTransform;
  48373. private _vector3;
  48374. private _vector2;
  48375. /**
  48376. * Attach the input controls to a specific dom element to get the input from.
  48377. */
  48378. attachControl(): void;
  48379. /**
  48380. * Detach the current controls from the specified dom element.
  48381. */
  48382. detachControl(): void;
  48383. /**
  48384. * Update the current camera state depending on the inputs that have been used this frame.
  48385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48386. */
  48387. checkInputs(): void;
  48388. /**
  48389. * Gets the class name of the current intput.
  48390. * @returns the class name
  48391. */
  48392. getClassName(): string;
  48393. /**
  48394. * Get the friendly name associated with the input class.
  48395. * @returns the input friendly name
  48396. */
  48397. getSimpleName(): string;
  48398. }
  48399. }
  48400. declare module BABYLON {
  48401. /**
  48402. * Defines the potential axis of a Joystick
  48403. */
  48404. export enum JoystickAxis {
  48405. /** X axis */
  48406. X = 0,
  48407. /** Y axis */
  48408. Y = 1,
  48409. /** Z axis */
  48410. Z = 2
  48411. }
  48412. /**
  48413. * Represents the different customization options available
  48414. * for VirtualJoystick
  48415. */
  48416. interface VirtualJoystickCustomizations {
  48417. /**
  48418. * Size of the joystick's puck
  48419. */
  48420. puckSize: number;
  48421. /**
  48422. * Size of the joystick's container
  48423. */
  48424. containerSize: number;
  48425. /**
  48426. * Color of the joystick && puck
  48427. */
  48428. color: string;
  48429. /**
  48430. * Image URL for the joystick's puck
  48431. */
  48432. puckImage?: string;
  48433. /**
  48434. * Image URL for the joystick's container
  48435. */
  48436. containerImage?: string;
  48437. /**
  48438. * Defines the unmoving position of the joystick container
  48439. */
  48440. position?: {
  48441. x: number;
  48442. y: number;
  48443. };
  48444. /**
  48445. * Defines whether or not the joystick container is always visible
  48446. */
  48447. alwaysVisible: boolean;
  48448. /**
  48449. * Defines whether or not to limit the movement of the puck to the joystick's container
  48450. */
  48451. limitToContainer: boolean;
  48452. }
  48453. /**
  48454. * Class used to define virtual joystick (used in touch mode)
  48455. */
  48456. export class VirtualJoystick {
  48457. /**
  48458. * Gets or sets a boolean indicating that left and right values must be inverted
  48459. */
  48460. reverseLeftRight: boolean;
  48461. /**
  48462. * Gets or sets a boolean indicating that up and down values must be inverted
  48463. */
  48464. reverseUpDown: boolean;
  48465. /**
  48466. * Gets the offset value for the position (ie. the change of the position value)
  48467. */
  48468. deltaPosition: Vector3;
  48469. /**
  48470. * Gets a boolean indicating if the virtual joystick was pressed
  48471. */
  48472. pressed: boolean;
  48473. /**
  48474. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48475. */
  48476. static Canvas: Nullable<HTMLCanvasElement>;
  48477. /**
  48478. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48479. */
  48480. limitToContainer: boolean;
  48481. private static _globalJoystickIndex;
  48482. private static _alwaysVisibleSticks;
  48483. private static vjCanvasContext;
  48484. private static vjCanvasWidth;
  48485. private static vjCanvasHeight;
  48486. private static halfWidth;
  48487. private static _GetDefaultOptions;
  48488. private _action;
  48489. private _axisTargetedByLeftAndRight;
  48490. private _axisTargetedByUpAndDown;
  48491. private _joystickSensibility;
  48492. private _inversedSensibility;
  48493. private _joystickPointerID;
  48494. private _joystickColor;
  48495. private _joystickPointerPos;
  48496. private _joystickPreviousPointerPos;
  48497. private _joystickPointerStartPos;
  48498. private _deltaJoystickVector;
  48499. private _leftJoystick;
  48500. private _touches;
  48501. private _joystickPosition;
  48502. private _alwaysVisible;
  48503. private _puckImage;
  48504. private _containerImage;
  48505. private _joystickPuckSize;
  48506. private _joystickContainerSize;
  48507. private _clearPuckSize;
  48508. private _clearContainerSize;
  48509. private _clearPuckSizeOffset;
  48510. private _clearContainerSizeOffset;
  48511. private _onPointerDownHandlerRef;
  48512. private _onPointerMoveHandlerRef;
  48513. private _onPointerUpHandlerRef;
  48514. private _onResize;
  48515. /**
  48516. * Creates a new virtual joystick
  48517. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48518. * @param customizations Defines the options we want to customize the VirtualJoystick
  48519. */
  48520. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48521. /**
  48522. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48523. * @param newJoystickSensibility defines the new sensibility
  48524. */
  48525. setJoystickSensibility(newJoystickSensibility: number): void;
  48526. private _onPointerDown;
  48527. private _onPointerMove;
  48528. private _onPointerUp;
  48529. /**
  48530. * Change the color of the virtual joystick
  48531. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48532. */
  48533. setJoystickColor(newColor: string): void;
  48534. /**
  48535. * Size of the joystick's container
  48536. */
  48537. set containerSize(newSize: number);
  48538. get containerSize(): number;
  48539. /**
  48540. * Size of the joystick's puck
  48541. */
  48542. set puckSize(newSize: number);
  48543. get puckSize(): number;
  48544. /**
  48545. * Clears the set position of the joystick
  48546. */
  48547. clearPosition(): void;
  48548. /**
  48549. * Defines whether or not the joystick container is always visible
  48550. */
  48551. set alwaysVisible(value: boolean);
  48552. get alwaysVisible(): boolean;
  48553. /**
  48554. * Sets the constant position of the Joystick container
  48555. * @param x X axis coordinate
  48556. * @param y Y axis coordinate
  48557. */
  48558. setPosition(x: number, y: number): void;
  48559. /**
  48560. * Defines a callback to call when the joystick is touched
  48561. * @param action defines the callback
  48562. */
  48563. setActionOnTouch(action: () => any): void;
  48564. /**
  48565. * Defines which axis you'd like to control for left & right
  48566. * @param axis defines the axis to use
  48567. */
  48568. setAxisForLeftRight(axis: JoystickAxis): void;
  48569. /**
  48570. * Defines which axis you'd like to control for up & down
  48571. * @param axis defines the axis to use
  48572. */
  48573. setAxisForUpDown(axis: JoystickAxis): void;
  48574. /**
  48575. * Clears the canvas from the previous puck / container draw
  48576. */
  48577. private _clearPreviousDraw;
  48578. /**
  48579. * Loads `urlPath` to be used for the container's image
  48580. * @param urlPath defines the urlPath of an image to use
  48581. */
  48582. setContainerImage(urlPath: string): void;
  48583. /**
  48584. * Loads `urlPath` to be used for the puck's image
  48585. * @param urlPath defines the urlPath of an image to use
  48586. */
  48587. setPuckImage(urlPath: string): void;
  48588. /**
  48589. * Draws the Virtual Joystick's container
  48590. */
  48591. private _drawContainer;
  48592. /**
  48593. * Draws the Virtual Joystick's puck
  48594. */
  48595. private _drawPuck;
  48596. private _drawVirtualJoystick;
  48597. /**
  48598. * Release internal HTML canvas
  48599. */
  48600. releaseCanvas(): void;
  48601. }
  48602. }
  48603. declare module BABYLON {
  48604. interface FreeCameraInputsManager {
  48605. /**
  48606. * Add virtual joystick input support to the input manager.
  48607. * @returns the current input manager
  48608. */
  48609. addVirtualJoystick(): FreeCameraInputsManager;
  48610. }
  48611. /**
  48612. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48614. */
  48615. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48616. /**
  48617. * Defines the camera the input is attached to.
  48618. */
  48619. camera: FreeCamera;
  48620. private _leftjoystick;
  48621. private _rightjoystick;
  48622. /**
  48623. * Gets the left stick of the virtual joystick.
  48624. * @returns The virtual Joystick
  48625. */
  48626. getLeftJoystick(): VirtualJoystick;
  48627. /**
  48628. * Gets the right stick of the virtual joystick.
  48629. * @returns The virtual Joystick
  48630. */
  48631. getRightJoystick(): VirtualJoystick;
  48632. /**
  48633. * Update the current camera state depending on the inputs that have been used this frame.
  48634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48635. */
  48636. checkInputs(): void;
  48637. /**
  48638. * Attach the input controls to a specific dom element to get the input from.
  48639. */
  48640. attachControl(): void;
  48641. /**
  48642. * Detach the current controls from the specified dom element.
  48643. */
  48644. detachControl(): void;
  48645. /**
  48646. * Gets the class name of the current intput.
  48647. * @returns the class name
  48648. */
  48649. getClassName(): string;
  48650. /**
  48651. * Get the friendly name associated with the input class.
  48652. * @returns the input friendly name
  48653. */
  48654. getSimpleName(): string;
  48655. }
  48656. }
  48657. declare module BABYLON {
  48658. /**
  48659. * This represents a FPS type of camera controlled by touch.
  48660. * This is like a universal camera minus the Gamepad controls.
  48661. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48662. */
  48663. export class TouchCamera extends FreeCamera {
  48664. /**
  48665. * Defines the touch sensibility for rotation.
  48666. * The higher the faster.
  48667. */
  48668. get touchAngularSensibility(): number;
  48669. set touchAngularSensibility(value: number);
  48670. /**
  48671. * Defines the touch sensibility for move.
  48672. * The higher the faster.
  48673. */
  48674. get touchMoveSensibility(): number;
  48675. set touchMoveSensibility(value: number);
  48676. /**
  48677. * Instantiates a new touch camera.
  48678. * This represents a FPS type of camera controlled by touch.
  48679. * This is like a universal camera minus the Gamepad controls.
  48680. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48681. * @param name Define the name of the camera in the scene
  48682. * @param position Define the start position of the camera in the scene
  48683. * @param scene Define the scene the camera belongs to
  48684. */
  48685. constructor(name: string, position: Vector3, scene: Scene);
  48686. /**
  48687. * Gets the current object class name.
  48688. * @return the class name
  48689. */
  48690. getClassName(): string;
  48691. /** @hidden */
  48692. _setupInputs(): void;
  48693. }
  48694. }
  48695. declare module BABYLON {
  48696. /**
  48697. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48698. * being tilted forward or back and left or right.
  48699. */
  48700. export class DeviceOrientationCamera extends FreeCamera {
  48701. private _initialQuaternion;
  48702. private _quaternionCache;
  48703. private _tmpDragQuaternion;
  48704. private _disablePointerInputWhenUsingDeviceOrientation;
  48705. /**
  48706. * Creates a new device orientation camera
  48707. * @param name The name of the camera
  48708. * @param position The start position camera
  48709. * @param scene The scene the camera belongs to
  48710. */
  48711. constructor(name: string, position: Vector3, scene: Scene);
  48712. /**
  48713. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48714. */
  48715. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48716. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48717. private _dragFactor;
  48718. /**
  48719. * Enabled turning on the y axis when the orientation sensor is active
  48720. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48721. */
  48722. enableHorizontalDragging(dragFactor?: number): void;
  48723. /**
  48724. * Gets the current instance class name ("DeviceOrientationCamera").
  48725. * This helps avoiding instanceof at run time.
  48726. * @returns the class name
  48727. */
  48728. getClassName(): string;
  48729. /**
  48730. * @hidden
  48731. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48732. */
  48733. _checkInputs(): void;
  48734. /**
  48735. * Reset the camera to its default orientation on the specified axis only.
  48736. * @param axis The axis to reset
  48737. */
  48738. resetToCurrentRotation(axis?: Axis): void;
  48739. }
  48740. }
  48741. declare module BABYLON {
  48742. /**
  48743. * Defines supported buttons for XBox360 compatible gamepads
  48744. */
  48745. export enum Xbox360Button {
  48746. /** A */
  48747. A = 0,
  48748. /** B */
  48749. B = 1,
  48750. /** X */
  48751. X = 2,
  48752. /** Y */
  48753. Y = 3,
  48754. /** Left button */
  48755. LB = 4,
  48756. /** Right button */
  48757. RB = 5,
  48758. /** Back */
  48759. Back = 8,
  48760. /** Start */
  48761. Start = 9,
  48762. /** Left stick */
  48763. LeftStick = 10,
  48764. /** Right stick */
  48765. RightStick = 11
  48766. }
  48767. /** Defines values for XBox360 DPad */
  48768. export enum Xbox360Dpad {
  48769. /** Up */
  48770. Up = 12,
  48771. /** Down */
  48772. Down = 13,
  48773. /** Left */
  48774. Left = 14,
  48775. /** Right */
  48776. Right = 15
  48777. }
  48778. /**
  48779. * Defines a XBox360 gamepad
  48780. */
  48781. export class Xbox360Pad extends Gamepad {
  48782. private _leftTrigger;
  48783. private _rightTrigger;
  48784. private _onlefttriggerchanged;
  48785. private _onrighttriggerchanged;
  48786. private _onbuttondown;
  48787. private _onbuttonup;
  48788. private _ondpaddown;
  48789. private _ondpadup;
  48790. /** Observable raised when a button is pressed */
  48791. onButtonDownObservable: Observable<Xbox360Button>;
  48792. /** Observable raised when a button is released */
  48793. onButtonUpObservable: Observable<Xbox360Button>;
  48794. /** Observable raised when a pad is pressed */
  48795. onPadDownObservable: Observable<Xbox360Dpad>;
  48796. /** Observable raised when a pad is released */
  48797. onPadUpObservable: Observable<Xbox360Dpad>;
  48798. private _buttonA;
  48799. private _buttonB;
  48800. private _buttonX;
  48801. private _buttonY;
  48802. private _buttonBack;
  48803. private _buttonStart;
  48804. private _buttonLB;
  48805. private _buttonRB;
  48806. private _buttonLeftStick;
  48807. private _buttonRightStick;
  48808. private _dPadUp;
  48809. private _dPadDown;
  48810. private _dPadLeft;
  48811. private _dPadRight;
  48812. private _isXboxOnePad;
  48813. /**
  48814. * Creates a new XBox360 gamepad object
  48815. * @param id defines the id of this gamepad
  48816. * @param index defines its index
  48817. * @param gamepad defines the internal HTML gamepad object
  48818. * @param xboxOne defines if it is a XBox One gamepad
  48819. */
  48820. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48821. /**
  48822. * Defines the callback to call when left trigger is pressed
  48823. * @param callback defines the callback to use
  48824. */
  48825. onlefttriggerchanged(callback: (value: number) => void): void;
  48826. /**
  48827. * Defines the callback to call when right trigger is pressed
  48828. * @param callback defines the callback to use
  48829. */
  48830. onrighttriggerchanged(callback: (value: number) => void): void;
  48831. /**
  48832. * Gets the left trigger value
  48833. */
  48834. get leftTrigger(): number;
  48835. /**
  48836. * Sets the left trigger value
  48837. */
  48838. set leftTrigger(newValue: number);
  48839. /**
  48840. * Gets the right trigger value
  48841. */
  48842. get rightTrigger(): number;
  48843. /**
  48844. * Sets the right trigger value
  48845. */
  48846. set rightTrigger(newValue: number);
  48847. /**
  48848. * Defines the callback to call when a button is pressed
  48849. * @param callback defines the callback to use
  48850. */
  48851. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48852. /**
  48853. * Defines the callback to call when a button is released
  48854. * @param callback defines the callback to use
  48855. */
  48856. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48857. /**
  48858. * Defines the callback to call when a pad is pressed
  48859. * @param callback defines the callback to use
  48860. */
  48861. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48862. /**
  48863. * Defines the callback to call when a pad is released
  48864. * @param callback defines the callback to use
  48865. */
  48866. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48867. private _setButtonValue;
  48868. private _setDPadValue;
  48869. /**
  48870. * Gets the value of the `A` button
  48871. */
  48872. get buttonA(): number;
  48873. /**
  48874. * Sets the value of the `A` button
  48875. */
  48876. set buttonA(value: number);
  48877. /**
  48878. * Gets the value of the `B` button
  48879. */
  48880. get buttonB(): number;
  48881. /**
  48882. * Sets the value of the `B` button
  48883. */
  48884. set buttonB(value: number);
  48885. /**
  48886. * Gets the value of the `X` button
  48887. */
  48888. get buttonX(): number;
  48889. /**
  48890. * Sets the value of the `X` button
  48891. */
  48892. set buttonX(value: number);
  48893. /**
  48894. * Gets the value of the `Y` button
  48895. */
  48896. get buttonY(): number;
  48897. /**
  48898. * Sets the value of the `Y` button
  48899. */
  48900. set buttonY(value: number);
  48901. /**
  48902. * Gets the value of the `Start` button
  48903. */
  48904. get buttonStart(): number;
  48905. /**
  48906. * Sets the value of the `Start` button
  48907. */
  48908. set buttonStart(value: number);
  48909. /**
  48910. * Gets the value of the `Back` button
  48911. */
  48912. get buttonBack(): number;
  48913. /**
  48914. * Sets the value of the `Back` button
  48915. */
  48916. set buttonBack(value: number);
  48917. /**
  48918. * Gets the value of the `Left` button
  48919. */
  48920. get buttonLB(): number;
  48921. /**
  48922. * Sets the value of the `Left` button
  48923. */
  48924. set buttonLB(value: number);
  48925. /**
  48926. * Gets the value of the `Right` button
  48927. */
  48928. get buttonRB(): number;
  48929. /**
  48930. * Sets the value of the `Right` button
  48931. */
  48932. set buttonRB(value: number);
  48933. /**
  48934. * Gets the value of the Left joystick
  48935. */
  48936. get buttonLeftStick(): number;
  48937. /**
  48938. * Sets the value of the Left joystick
  48939. */
  48940. set buttonLeftStick(value: number);
  48941. /**
  48942. * Gets the value of the Right joystick
  48943. */
  48944. get buttonRightStick(): number;
  48945. /**
  48946. * Sets the value of the Right joystick
  48947. */
  48948. set buttonRightStick(value: number);
  48949. /**
  48950. * Gets the value of D-pad up
  48951. */
  48952. get dPadUp(): number;
  48953. /**
  48954. * Sets the value of D-pad up
  48955. */
  48956. set dPadUp(value: number);
  48957. /**
  48958. * Gets the value of D-pad down
  48959. */
  48960. get dPadDown(): number;
  48961. /**
  48962. * Sets the value of D-pad down
  48963. */
  48964. set dPadDown(value: number);
  48965. /**
  48966. * Gets the value of D-pad left
  48967. */
  48968. get dPadLeft(): number;
  48969. /**
  48970. * Sets the value of D-pad left
  48971. */
  48972. set dPadLeft(value: number);
  48973. /**
  48974. * Gets the value of D-pad right
  48975. */
  48976. get dPadRight(): number;
  48977. /**
  48978. * Sets the value of D-pad right
  48979. */
  48980. set dPadRight(value: number);
  48981. /**
  48982. * Force the gamepad to synchronize with device values
  48983. */
  48984. update(): void;
  48985. /**
  48986. * Disposes the gamepad
  48987. */
  48988. dispose(): void;
  48989. }
  48990. }
  48991. declare module BABYLON {
  48992. /**
  48993. * Defines supported buttons for DualShock compatible gamepads
  48994. */
  48995. export enum DualShockButton {
  48996. /** Cross */
  48997. Cross = 0,
  48998. /** Circle */
  48999. Circle = 1,
  49000. /** Square */
  49001. Square = 2,
  49002. /** Triangle */
  49003. Triangle = 3,
  49004. /** L1 */
  49005. L1 = 4,
  49006. /** R1 */
  49007. R1 = 5,
  49008. /** Share */
  49009. Share = 8,
  49010. /** Options */
  49011. Options = 9,
  49012. /** Left stick */
  49013. LeftStick = 10,
  49014. /** Right stick */
  49015. RightStick = 11
  49016. }
  49017. /** Defines values for DualShock DPad */
  49018. export enum DualShockDpad {
  49019. /** Up */
  49020. Up = 12,
  49021. /** Down */
  49022. Down = 13,
  49023. /** Left */
  49024. Left = 14,
  49025. /** Right */
  49026. Right = 15
  49027. }
  49028. /**
  49029. * Defines a DualShock gamepad
  49030. */
  49031. export class DualShockPad extends Gamepad {
  49032. private _leftTrigger;
  49033. private _rightTrigger;
  49034. private _onlefttriggerchanged;
  49035. private _onrighttriggerchanged;
  49036. private _onbuttondown;
  49037. private _onbuttonup;
  49038. private _ondpaddown;
  49039. private _ondpadup;
  49040. /** Observable raised when a button is pressed */
  49041. onButtonDownObservable: Observable<DualShockButton>;
  49042. /** Observable raised when a button is released */
  49043. onButtonUpObservable: Observable<DualShockButton>;
  49044. /** Observable raised when a pad is pressed */
  49045. onPadDownObservable: Observable<DualShockDpad>;
  49046. /** Observable raised when a pad is released */
  49047. onPadUpObservable: Observable<DualShockDpad>;
  49048. private _buttonCross;
  49049. private _buttonCircle;
  49050. private _buttonSquare;
  49051. private _buttonTriangle;
  49052. private _buttonShare;
  49053. private _buttonOptions;
  49054. private _buttonL1;
  49055. private _buttonR1;
  49056. private _buttonLeftStick;
  49057. private _buttonRightStick;
  49058. private _dPadUp;
  49059. private _dPadDown;
  49060. private _dPadLeft;
  49061. private _dPadRight;
  49062. /**
  49063. * Creates a new DualShock gamepad object
  49064. * @param id defines the id of this gamepad
  49065. * @param index defines its index
  49066. * @param gamepad defines the internal HTML gamepad object
  49067. */
  49068. constructor(id: string, index: number, gamepad: any);
  49069. /**
  49070. * Defines the callback to call when left trigger is pressed
  49071. * @param callback defines the callback to use
  49072. */
  49073. onlefttriggerchanged(callback: (value: number) => void): void;
  49074. /**
  49075. * Defines the callback to call when right trigger is pressed
  49076. * @param callback defines the callback to use
  49077. */
  49078. onrighttriggerchanged(callback: (value: number) => void): void;
  49079. /**
  49080. * Gets the left trigger value
  49081. */
  49082. get leftTrigger(): number;
  49083. /**
  49084. * Sets the left trigger value
  49085. */
  49086. set leftTrigger(newValue: number);
  49087. /**
  49088. * Gets the right trigger value
  49089. */
  49090. get rightTrigger(): number;
  49091. /**
  49092. * Sets the right trigger value
  49093. */
  49094. set rightTrigger(newValue: number);
  49095. /**
  49096. * Defines the callback to call when a button is pressed
  49097. * @param callback defines the callback to use
  49098. */
  49099. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49100. /**
  49101. * Defines the callback to call when a button is released
  49102. * @param callback defines the callback to use
  49103. */
  49104. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49105. /**
  49106. * Defines the callback to call when a pad is pressed
  49107. * @param callback defines the callback to use
  49108. */
  49109. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49110. /**
  49111. * Defines the callback to call when a pad is released
  49112. * @param callback defines the callback to use
  49113. */
  49114. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49115. private _setButtonValue;
  49116. private _setDPadValue;
  49117. /**
  49118. * Gets the value of the `Cross` button
  49119. */
  49120. get buttonCross(): number;
  49121. /**
  49122. * Sets the value of the `Cross` button
  49123. */
  49124. set buttonCross(value: number);
  49125. /**
  49126. * Gets the value of the `Circle` button
  49127. */
  49128. get buttonCircle(): number;
  49129. /**
  49130. * Sets the value of the `Circle` button
  49131. */
  49132. set buttonCircle(value: number);
  49133. /**
  49134. * Gets the value of the `Square` button
  49135. */
  49136. get buttonSquare(): number;
  49137. /**
  49138. * Sets the value of the `Square` button
  49139. */
  49140. set buttonSquare(value: number);
  49141. /**
  49142. * Gets the value of the `Triangle` button
  49143. */
  49144. get buttonTriangle(): number;
  49145. /**
  49146. * Sets the value of the `Triangle` button
  49147. */
  49148. set buttonTriangle(value: number);
  49149. /**
  49150. * Gets the value of the `Options` button
  49151. */
  49152. get buttonOptions(): number;
  49153. /**
  49154. * Sets the value of the `Options` button
  49155. */
  49156. set buttonOptions(value: number);
  49157. /**
  49158. * Gets the value of the `Share` button
  49159. */
  49160. get buttonShare(): number;
  49161. /**
  49162. * Sets the value of the `Share` button
  49163. */
  49164. set buttonShare(value: number);
  49165. /**
  49166. * Gets the value of the `L1` button
  49167. */
  49168. get buttonL1(): number;
  49169. /**
  49170. * Sets the value of the `L1` button
  49171. */
  49172. set buttonL1(value: number);
  49173. /**
  49174. * Gets the value of the `R1` button
  49175. */
  49176. get buttonR1(): number;
  49177. /**
  49178. * Sets the value of the `R1` button
  49179. */
  49180. set buttonR1(value: number);
  49181. /**
  49182. * Gets the value of the Left joystick
  49183. */
  49184. get buttonLeftStick(): number;
  49185. /**
  49186. * Sets the value of the Left joystick
  49187. */
  49188. set buttonLeftStick(value: number);
  49189. /**
  49190. * Gets the value of the Right joystick
  49191. */
  49192. get buttonRightStick(): number;
  49193. /**
  49194. * Sets the value of the Right joystick
  49195. */
  49196. set buttonRightStick(value: number);
  49197. /**
  49198. * Gets the value of D-pad up
  49199. */
  49200. get dPadUp(): number;
  49201. /**
  49202. * Sets the value of D-pad up
  49203. */
  49204. set dPadUp(value: number);
  49205. /**
  49206. * Gets the value of D-pad down
  49207. */
  49208. get dPadDown(): number;
  49209. /**
  49210. * Sets the value of D-pad down
  49211. */
  49212. set dPadDown(value: number);
  49213. /**
  49214. * Gets the value of D-pad left
  49215. */
  49216. get dPadLeft(): number;
  49217. /**
  49218. * Sets the value of D-pad left
  49219. */
  49220. set dPadLeft(value: number);
  49221. /**
  49222. * Gets the value of D-pad right
  49223. */
  49224. get dPadRight(): number;
  49225. /**
  49226. * Sets the value of D-pad right
  49227. */
  49228. set dPadRight(value: number);
  49229. /**
  49230. * Force the gamepad to synchronize with device values
  49231. */
  49232. update(): void;
  49233. /**
  49234. * Disposes the gamepad
  49235. */
  49236. dispose(): void;
  49237. }
  49238. }
  49239. declare module BABYLON {
  49240. /**
  49241. * Manager for handling gamepads
  49242. */
  49243. export class GamepadManager {
  49244. private _scene?;
  49245. private _babylonGamepads;
  49246. private _oneGamepadConnected;
  49247. /** @hidden */
  49248. _isMonitoring: boolean;
  49249. private _gamepadEventSupported;
  49250. private _gamepadSupport?;
  49251. /**
  49252. * observable to be triggered when the gamepad controller has been connected
  49253. */
  49254. onGamepadConnectedObservable: Observable<Gamepad>;
  49255. /**
  49256. * observable to be triggered when the gamepad controller has been disconnected
  49257. */
  49258. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49259. private _onGamepadConnectedEvent;
  49260. private _onGamepadDisconnectedEvent;
  49261. /**
  49262. * Initializes the gamepad manager
  49263. * @param _scene BabylonJS scene
  49264. */
  49265. constructor(_scene?: Scene | undefined);
  49266. /**
  49267. * The gamepads in the game pad manager
  49268. */
  49269. get gamepads(): Gamepad[];
  49270. /**
  49271. * Get the gamepad controllers based on type
  49272. * @param type The type of gamepad controller
  49273. * @returns Nullable gamepad
  49274. */
  49275. getGamepadByType(type?: number): Nullable<Gamepad>;
  49276. /**
  49277. * Disposes the gamepad manager
  49278. */
  49279. dispose(): void;
  49280. private _addNewGamepad;
  49281. private _startMonitoringGamepads;
  49282. private _stopMonitoringGamepads;
  49283. /** @hidden */
  49284. _checkGamepadsStatus(): void;
  49285. private _updateGamepadObjects;
  49286. }
  49287. }
  49288. declare module BABYLON {
  49289. interface Scene {
  49290. /** @hidden */
  49291. _gamepadManager: Nullable<GamepadManager>;
  49292. /**
  49293. * Gets the gamepad manager associated with the scene
  49294. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49295. */
  49296. gamepadManager: GamepadManager;
  49297. }
  49298. /**
  49299. * Interface representing a free camera inputs manager
  49300. */
  49301. interface FreeCameraInputsManager {
  49302. /**
  49303. * Adds gamepad input support to the FreeCameraInputsManager.
  49304. * @returns the FreeCameraInputsManager
  49305. */
  49306. addGamepad(): FreeCameraInputsManager;
  49307. }
  49308. /**
  49309. * Interface representing an arc rotate camera inputs manager
  49310. */
  49311. interface ArcRotateCameraInputsManager {
  49312. /**
  49313. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49314. * @returns the camera inputs manager
  49315. */
  49316. addGamepad(): ArcRotateCameraInputsManager;
  49317. }
  49318. /**
  49319. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49320. */
  49321. export class GamepadSystemSceneComponent implements ISceneComponent {
  49322. /**
  49323. * The component name helpfull to identify the component in the list of scene components.
  49324. */
  49325. readonly name: string;
  49326. /**
  49327. * The scene the component belongs to.
  49328. */
  49329. scene: Scene;
  49330. /**
  49331. * Creates a new instance of the component for the given scene
  49332. * @param scene Defines the scene to register the component in
  49333. */
  49334. constructor(scene: Scene);
  49335. /**
  49336. * Registers the component in a given scene
  49337. */
  49338. register(): void;
  49339. /**
  49340. * Rebuilds the elements related to this component in case of
  49341. * context lost for instance.
  49342. */
  49343. rebuild(): void;
  49344. /**
  49345. * Disposes the component and the associated ressources
  49346. */
  49347. dispose(): void;
  49348. private _beforeCameraUpdate;
  49349. }
  49350. }
  49351. declare module BABYLON {
  49352. /**
  49353. * 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,
  49354. * which still works and will still be found in many Playgrounds.
  49355. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49356. */
  49357. export class UniversalCamera extends TouchCamera {
  49358. /**
  49359. * Defines the gamepad rotation sensiblity.
  49360. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49361. */
  49362. get gamepadAngularSensibility(): number;
  49363. set gamepadAngularSensibility(value: number);
  49364. /**
  49365. * Defines the gamepad move sensiblity.
  49366. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49367. */
  49368. get gamepadMoveSensibility(): number;
  49369. set gamepadMoveSensibility(value: number);
  49370. /**
  49371. * 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,
  49372. * which still works and will still be found in many Playgrounds.
  49373. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49374. * @param name Define the name of the camera in the scene
  49375. * @param position Define the start position of the camera in the scene
  49376. * @param scene Define the scene the camera belongs to
  49377. */
  49378. constructor(name: string, position: Vector3, scene: Scene);
  49379. /**
  49380. * Gets the current object class name.
  49381. * @return the class name
  49382. */
  49383. getClassName(): string;
  49384. }
  49385. }
  49386. declare module BABYLON {
  49387. /**
  49388. * This represents a FPS type of camera. This is only here for back compat purpose.
  49389. * Please use the UniversalCamera instead as both are identical.
  49390. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49391. */
  49392. export class GamepadCamera extends UniversalCamera {
  49393. /**
  49394. * Instantiates a new Gamepad Camera
  49395. * This represents a FPS type of camera. This is only here for back compat purpose.
  49396. * Please use the UniversalCamera instead as both are identical.
  49397. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49398. * @param name Define the name of the camera in the scene
  49399. * @param position Define the start position of the camera in the scene
  49400. * @param scene Define the scene the camera belongs to
  49401. */
  49402. constructor(name: string, position: Vector3, scene: Scene);
  49403. /**
  49404. * Gets the current object class name.
  49405. * @return the class name
  49406. */
  49407. getClassName(): string;
  49408. }
  49409. }
  49410. declare module BABYLON {
  49411. /** @hidden */
  49412. export var passPixelShader: {
  49413. name: string;
  49414. shader: string;
  49415. };
  49416. }
  49417. declare module BABYLON {
  49418. /** @hidden */
  49419. export var passCubePixelShader: {
  49420. name: string;
  49421. shader: string;
  49422. };
  49423. }
  49424. declare module BABYLON {
  49425. /**
  49426. * PassPostProcess which produces an output the same as it's input
  49427. */
  49428. export class PassPostProcess extends PostProcess {
  49429. /**
  49430. * Gets a string identifying the name of the class
  49431. * @returns "PassPostProcess" string
  49432. */
  49433. getClassName(): string;
  49434. /**
  49435. * Creates the PassPostProcess
  49436. * @param name The name of the effect.
  49437. * @param options The required width/height ratio to downsize to before computing the render pass.
  49438. * @param camera The camera to apply the render pass to.
  49439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49440. * @param engine The engine which the post process will be applied. (default: current engine)
  49441. * @param reusable If the post process can be reused on the same frame. (default: false)
  49442. * @param textureType The type of texture to be used when performing the post processing.
  49443. * @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)
  49444. */
  49445. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49446. /** @hidden */
  49447. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49448. }
  49449. /**
  49450. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49451. */
  49452. export class PassCubePostProcess extends PostProcess {
  49453. private _face;
  49454. /**
  49455. * Gets or sets the cube face to display.
  49456. * * 0 is +X
  49457. * * 1 is -X
  49458. * * 2 is +Y
  49459. * * 3 is -Y
  49460. * * 4 is +Z
  49461. * * 5 is -Z
  49462. */
  49463. get face(): number;
  49464. set face(value: number);
  49465. /**
  49466. * Gets a string identifying the name of the class
  49467. * @returns "PassCubePostProcess" string
  49468. */
  49469. getClassName(): string;
  49470. /**
  49471. * Creates the PassCubePostProcess
  49472. * @param name The name of the effect.
  49473. * @param options The required width/height ratio to downsize to before computing the render pass.
  49474. * @param camera The camera to apply the render pass to.
  49475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49476. * @param engine The engine which the post process will be applied. (default: current engine)
  49477. * @param reusable If the post process can be reused on the same frame. (default: false)
  49478. * @param textureType The type of texture to be used when performing the post processing.
  49479. * @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)
  49480. */
  49481. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49482. /** @hidden */
  49483. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. /** @hidden */
  49488. export var anaglyphPixelShader: {
  49489. name: string;
  49490. shader: string;
  49491. };
  49492. }
  49493. declare module BABYLON {
  49494. /**
  49495. * Postprocess used to generate anaglyphic rendering
  49496. */
  49497. export class AnaglyphPostProcess extends PostProcess {
  49498. private _passedProcess;
  49499. /**
  49500. * Gets a string identifying the name of the class
  49501. * @returns "AnaglyphPostProcess" string
  49502. */
  49503. getClassName(): string;
  49504. /**
  49505. * Creates a new AnaglyphPostProcess
  49506. * @param name defines postprocess name
  49507. * @param options defines creation options or target ratio scale
  49508. * @param rigCameras defines cameras using this postprocess
  49509. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49510. * @param engine defines hosting engine
  49511. * @param reusable defines if the postprocess will be reused multiple times per frame
  49512. */
  49513. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49519. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49520. */
  49521. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49522. /**
  49523. * Creates a new AnaglyphArcRotateCamera
  49524. * @param name defines camera name
  49525. * @param alpha defines alpha angle (in radians)
  49526. * @param beta defines beta angle (in radians)
  49527. * @param radius defines radius
  49528. * @param target defines camera target
  49529. * @param interaxialDistance defines distance between each color axis
  49530. * @param scene defines the hosting scene
  49531. */
  49532. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49533. /**
  49534. * Gets camera class name
  49535. * @returns AnaglyphArcRotateCamera
  49536. */
  49537. getClassName(): string;
  49538. }
  49539. }
  49540. declare module BABYLON {
  49541. /**
  49542. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49543. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49544. */
  49545. export class AnaglyphFreeCamera extends FreeCamera {
  49546. /**
  49547. * Creates a new AnaglyphFreeCamera
  49548. * @param name defines camera name
  49549. * @param position defines initial position
  49550. * @param interaxialDistance defines distance between each color axis
  49551. * @param scene defines the hosting scene
  49552. */
  49553. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49554. /**
  49555. * Gets camera class name
  49556. * @returns AnaglyphFreeCamera
  49557. */
  49558. getClassName(): string;
  49559. }
  49560. }
  49561. declare module BABYLON {
  49562. /**
  49563. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49564. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49565. */
  49566. export class AnaglyphGamepadCamera extends GamepadCamera {
  49567. /**
  49568. * Creates a new AnaglyphGamepadCamera
  49569. * @param name defines camera name
  49570. * @param position defines initial position
  49571. * @param interaxialDistance defines distance between each color axis
  49572. * @param scene defines the hosting scene
  49573. */
  49574. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49575. /**
  49576. * Gets camera class name
  49577. * @returns AnaglyphGamepadCamera
  49578. */
  49579. getClassName(): string;
  49580. }
  49581. }
  49582. declare module BABYLON {
  49583. /**
  49584. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49585. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49586. */
  49587. export class AnaglyphUniversalCamera extends UniversalCamera {
  49588. /**
  49589. * Creates a new AnaglyphUniversalCamera
  49590. * @param name defines camera name
  49591. * @param position defines initial position
  49592. * @param interaxialDistance defines distance between each color axis
  49593. * @param scene defines the hosting scene
  49594. */
  49595. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49596. /**
  49597. * Gets camera class name
  49598. * @returns AnaglyphUniversalCamera
  49599. */
  49600. getClassName(): string;
  49601. }
  49602. }
  49603. declare module BABYLON {
  49604. /**
  49605. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49606. * @see https://doc.babylonjs.com/features/cameras
  49607. */
  49608. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49609. /**
  49610. * Creates a new StereoscopicArcRotateCamera
  49611. * @param name defines camera name
  49612. * @param alpha defines alpha angle (in radians)
  49613. * @param beta defines beta angle (in radians)
  49614. * @param radius defines radius
  49615. * @param target defines camera target
  49616. * @param interaxialDistance defines distance between each color axis
  49617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49618. * @param scene defines the hosting scene
  49619. */
  49620. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49621. /**
  49622. * Gets camera class name
  49623. * @returns StereoscopicArcRotateCamera
  49624. */
  49625. getClassName(): string;
  49626. }
  49627. }
  49628. declare module BABYLON {
  49629. /**
  49630. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49631. * @see https://doc.babylonjs.com/features/cameras
  49632. */
  49633. export class StereoscopicFreeCamera extends FreeCamera {
  49634. /**
  49635. * Creates a new StereoscopicFreeCamera
  49636. * @param name defines camera name
  49637. * @param position defines initial position
  49638. * @param interaxialDistance defines distance between each color axis
  49639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49640. * @param scene defines the hosting scene
  49641. */
  49642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49643. /**
  49644. * Gets camera class name
  49645. * @returns StereoscopicFreeCamera
  49646. */
  49647. getClassName(): string;
  49648. }
  49649. }
  49650. declare module BABYLON {
  49651. /**
  49652. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49653. * @see https://doc.babylonjs.com/features/cameras
  49654. */
  49655. export class StereoscopicGamepadCamera extends GamepadCamera {
  49656. /**
  49657. * Creates a new StereoscopicGamepadCamera
  49658. * @param name defines camera name
  49659. * @param position defines initial position
  49660. * @param interaxialDistance defines distance between each color axis
  49661. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49662. * @param scene defines the hosting scene
  49663. */
  49664. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49665. /**
  49666. * Gets camera class name
  49667. * @returns StereoscopicGamepadCamera
  49668. */
  49669. getClassName(): string;
  49670. }
  49671. }
  49672. declare module BABYLON {
  49673. /**
  49674. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49675. * @see https://doc.babylonjs.com/features/cameras
  49676. */
  49677. export class StereoscopicUniversalCamera extends UniversalCamera {
  49678. /**
  49679. * Creates a new StereoscopicUniversalCamera
  49680. * @param name defines camera name
  49681. * @param position defines initial position
  49682. * @param interaxialDistance defines distance between each color axis
  49683. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49684. * @param scene defines the hosting scene
  49685. */
  49686. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49687. /**
  49688. * Gets camera class name
  49689. * @returns StereoscopicUniversalCamera
  49690. */
  49691. getClassName(): string;
  49692. }
  49693. }
  49694. declare module BABYLON {
  49695. /**
  49696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49697. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49698. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49699. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49700. */
  49701. export class VirtualJoysticksCamera extends FreeCamera {
  49702. /**
  49703. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49704. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49705. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49706. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49707. * @param name Define the name of the camera in the scene
  49708. * @param position Define the start position of the camera in the scene
  49709. * @param scene Define the scene the camera belongs to
  49710. */
  49711. constructor(name: string, position: Vector3, scene: Scene);
  49712. /**
  49713. * Gets the current object class name.
  49714. * @return the class name
  49715. */
  49716. getClassName(): string;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * This represents all the required metrics to create a VR camera.
  49722. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49723. */
  49724. export class VRCameraMetrics {
  49725. /**
  49726. * Define the horizontal resolution off the screen.
  49727. */
  49728. hResolution: number;
  49729. /**
  49730. * Define the vertical resolution off the screen.
  49731. */
  49732. vResolution: number;
  49733. /**
  49734. * Define the horizontal screen size.
  49735. */
  49736. hScreenSize: number;
  49737. /**
  49738. * Define the vertical screen size.
  49739. */
  49740. vScreenSize: number;
  49741. /**
  49742. * Define the vertical screen center position.
  49743. */
  49744. vScreenCenter: number;
  49745. /**
  49746. * Define the distance of the eyes to the screen.
  49747. */
  49748. eyeToScreenDistance: number;
  49749. /**
  49750. * Define the distance between both lenses
  49751. */
  49752. lensSeparationDistance: number;
  49753. /**
  49754. * Define the distance between both viewer's eyes.
  49755. */
  49756. interpupillaryDistance: number;
  49757. /**
  49758. * Define the distortion factor of the VR postprocess.
  49759. * Please, touch with care.
  49760. */
  49761. distortionK: number[];
  49762. /**
  49763. * Define the chromatic aberration correction factors for the VR post process.
  49764. */
  49765. chromaAbCorrection: number[];
  49766. /**
  49767. * Define the scale factor of the post process.
  49768. * The smaller the better but the slower.
  49769. */
  49770. postProcessScaleFactor: number;
  49771. /**
  49772. * Define an offset for the lens center.
  49773. */
  49774. lensCenterOffset: number;
  49775. /**
  49776. * Define if the current vr camera should compensate the distortion of the lense or not.
  49777. */
  49778. compensateDistortion: boolean;
  49779. /**
  49780. * Defines if multiview should be enabled when rendering (Default: false)
  49781. */
  49782. multiviewEnabled: boolean;
  49783. /**
  49784. * Gets the rendering aspect ratio based on the provided resolutions.
  49785. */
  49786. get aspectRatio(): number;
  49787. /**
  49788. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49789. */
  49790. get aspectRatioFov(): number;
  49791. /**
  49792. * @hidden
  49793. */
  49794. get leftHMatrix(): Matrix;
  49795. /**
  49796. * @hidden
  49797. */
  49798. get rightHMatrix(): Matrix;
  49799. /**
  49800. * @hidden
  49801. */
  49802. get leftPreViewMatrix(): Matrix;
  49803. /**
  49804. * @hidden
  49805. */
  49806. get rightPreViewMatrix(): Matrix;
  49807. /**
  49808. * Get the default VRMetrics based on the most generic setup.
  49809. * @returns the default vr metrics
  49810. */
  49811. static GetDefault(): VRCameraMetrics;
  49812. }
  49813. }
  49814. declare module BABYLON {
  49815. /** @hidden */
  49816. export var vrDistortionCorrectionPixelShader: {
  49817. name: string;
  49818. shader: string;
  49819. };
  49820. }
  49821. declare module BABYLON {
  49822. /**
  49823. * VRDistortionCorrectionPostProcess used for mobile VR
  49824. */
  49825. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49826. private _isRightEye;
  49827. private _distortionFactors;
  49828. private _postProcessScaleFactor;
  49829. private _lensCenterOffset;
  49830. private _scaleIn;
  49831. private _scaleFactor;
  49832. private _lensCenter;
  49833. /**
  49834. * Gets a string identifying the name of the class
  49835. * @returns "VRDistortionCorrectionPostProcess" string
  49836. */
  49837. getClassName(): string;
  49838. /**
  49839. * Initializes the VRDistortionCorrectionPostProcess
  49840. * @param name The name of the effect.
  49841. * @param camera The camera to apply the render pass to.
  49842. * @param isRightEye If this is for the right eye distortion
  49843. * @param vrMetrics All the required metrics for the VR camera
  49844. */
  49845. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49846. }
  49847. }
  49848. declare module BABYLON {
  49849. /**
  49850. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49851. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49852. */
  49853. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49854. /**
  49855. * Creates a new VRDeviceOrientationArcRotateCamera
  49856. * @param name defines camera name
  49857. * @param alpha defines the camera rotation along the logitudinal axis
  49858. * @param beta defines the camera rotation along the latitudinal axis
  49859. * @param radius defines the camera distance from its target
  49860. * @param target defines the camera target
  49861. * @param scene defines the scene the camera belongs to
  49862. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49863. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49864. */
  49865. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49866. /**
  49867. * Gets camera class name
  49868. * @returns VRDeviceOrientationArcRotateCamera
  49869. */
  49870. getClassName(): string;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Camera used to simulate VR rendering (based on FreeCamera)
  49876. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49877. */
  49878. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49879. /**
  49880. * Creates a new VRDeviceOrientationFreeCamera
  49881. * @param name defines camera name
  49882. * @param position defines the start position of the camera
  49883. * @param scene defines the scene the camera belongs to
  49884. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49885. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49886. */
  49887. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49888. /**
  49889. * Gets camera class name
  49890. * @returns VRDeviceOrientationFreeCamera
  49891. */
  49892. getClassName(): string;
  49893. }
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49898. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49899. */
  49900. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49901. /**
  49902. * Creates a new VRDeviceOrientationGamepadCamera
  49903. * @param name defines camera name
  49904. * @param position defines the start position of the camera
  49905. * @param scene defines the scene the camera belongs to
  49906. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49907. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49908. */
  49909. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49910. /**
  49911. * Gets camera class name
  49912. * @returns VRDeviceOrientationGamepadCamera
  49913. */
  49914. getClassName(): string;
  49915. }
  49916. }
  49917. declare module BABYLON {
  49918. /**
  49919. * A class extending Texture allowing drawing on a texture
  49920. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49921. */
  49922. export class DynamicTexture extends Texture {
  49923. private _generateMipMaps;
  49924. private _canvas;
  49925. private _context;
  49926. /**
  49927. * Creates a DynamicTexture
  49928. * @param name defines the name of the texture
  49929. * @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
  49930. * @param scene defines the scene where you want the texture
  49931. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49932. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49933. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49934. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49935. */
  49936. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49937. /**
  49938. * Get the current class name of the texture useful for serialization or dynamic coding.
  49939. * @returns "DynamicTexture"
  49940. */
  49941. getClassName(): string;
  49942. /**
  49943. * Gets the current state of canRescale
  49944. */
  49945. get canRescale(): boolean;
  49946. private _recreate;
  49947. /**
  49948. * Scales the texture
  49949. * @param ratio the scale factor to apply to both width and height
  49950. */
  49951. scale(ratio: number): void;
  49952. /**
  49953. * Resizes the texture
  49954. * @param width the new width
  49955. * @param height the new height
  49956. */
  49957. scaleTo(width: number, height: number): void;
  49958. /**
  49959. * Gets the context of the canvas used by the texture
  49960. * @returns the canvas context of the dynamic texture
  49961. */
  49962. getContext(): CanvasRenderingContext2D;
  49963. /**
  49964. * Clears the texture
  49965. */
  49966. clear(): void;
  49967. /**
  49968. * Updates the texture
  49969. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49970. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49971. */
  49972. update(invertY?: boolean, premulAlpha?: boolean): void;
  49973. /**
  49974. * Draws text onto the texture
  49975. * @param text defines the text to be drawn
  49976. * @param x defines the placement of the text from the left
  49977. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49978. * @param font defines the font to be used with font-style, font-size, font-name
  49979. * @param color defines the color used for the text
  49980. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49981. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49982. * @param update defines whether texture is immediately update (default is true)
  49983. */
  49984. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49985. /**
  49986. * Clones the texture
  49987. * @returns the clone of the texture.
  49988. */
  49989. clone(): DynamicTexture;
  49990. /**
  49991. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49992. * @returns a serialized dynamic texture object
  49993. */
  49994. serialize(): any;
  49995. private _IsCanvasElement;
  49996. /** @hidden */
  49997. _rebuild(): void;
  49998. }
  49999. }
  50000. declare module BABYLON {
  50001. /**
  50002. * Class containing static functions to help procedurally build meshes
  50003. */
  50004. export class GroundBuilder {
  50005. /**
  50006. * Creates a ground mesh
  50007. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50008. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50010. * @param name defines the name of the mesh
  50011. * @param options defines the options used to create the mesh
  50012. * @param scene defines the hosting scene
  50013. * @returns the ground mesh
  50014. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50015. */
  50016. static CreateGround(name: string, options: {
  50017. width?: number;
  50018. height?: number;
  50019. subdivisions?: number;
  50020. subdivisionsX?: number;
  50021. subdivisionsY?: number;
  50022. updatable?: boolean;
  50023. }, scene: any): Mesh;
  50024. /**
  50025. * Creates a tiled ground mesh
  50026. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50027. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50028. * * 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
  50029. * * 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
  50030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50031. * @param name defines the name of the mesh
  50032. * @param options defines the options used to create the mesh
  50033. * @param scene defines the hosting scene
  50034. * @returns the tiled ground mesh
  50035. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50036. */
  50037. static CreateTiledGround(name: string, options: {
  50038. xmin: number;
  50039. zmin: number;
  50040. xmax: number;
  50041. zmax: number;
  50042. subdivisions?: {
  50043. w: number;
  50044. h: number;
  50045. };
  50046. precision?: {
  50047. w: number;
  50048. h: number;
  50049. };
  50050. updatable?: boolean;
  50051. }, scene?: Nullable<Scene>): Mesh;
  50052. /**
  50053. * Creates a ground mesh from a height map
  50054. * * The parameter `url` sets the URL of the height map image resource.
  50055. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50056. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50057. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50058. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50059. * * 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.
  50060. * * 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).
  50061. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50063. * @param name defines the name of the mesh
  50064. * @param url defines the url to the height map
  50065. * @param options defines the options used to create the mesh
  50066. * @param scene defines the hosting scene
  50067. * @returns the ground mesh
  50068. * @see https://doc.babylonjs.com/babylon101/height_map
  50069. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50070. */
  50071. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50072. width?: number;
  50073. height?: number;
  50074. subdivisions?: number;
  50075. minHeight?: number;
  50076. maxHeight?: number;
  50077. colorFilter?: Color3;
  50078. alphaFilter?: number;
  50079. updatable?: boolean;
  50080. onReady?: (mesh: GroundMesh) => void;
  50081. }, scene?: Nullable<Scene>): GroundMesh;
  50082. }
  50083. }
  50084. declare module BABYLON {
  50085. /**
  50086. * Class containing static functions to help procedurally build meshes
  50087. */
  50088. export class TorusBuilder {
  50089. /**
  50090. * Creates a torus mesh
  50091. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50092. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50093. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50095. * * 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
  50096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50097. * @param name defines the name of the mesh
  50098. * @param options defines the options used to create the mesh
  50099. * @param scene defines the hosting scene
  50100. * @returns the torus mesh
  50101. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50102. */
  50103. static CreateTorus(name: string, options: {
  50104. diameter?: number;
  50105. thickness?: number;
  50106. tessellation?: number;
  50107. updatable?: boolean;
  50108. sideOrientation?: number;
  50109. frontUVs?: Vector4;
  50110. backUVs?: Vector4;
  50111. }, scene: any): Mesh;
  50112. }
  50113. }
  50114. declare module BABYLON {
  50115. /**
  50116. * Class containing static functions to help procedurally build meshes
  50117. */
  50118. export class CylinderBuilder {
  50119. /**
  50120. * Creates a cylinder or a cone mesh
  50121. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50122. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50123. * * 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.
  50124. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50125. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50126. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50127. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50128. * * 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).
  50129. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50130. * * 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).
  50131. * * 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
  50132. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50133. * * 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
  50134. * * 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.
  50135. * * If `enclose` is false, a ring surface is one element.
  50136. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50137. * * 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
  50138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50139. * * 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
  50140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50141. * @param name defines the name of the mesh
  50142. * @param options defines the options used to create the mesh
  50143. * @param scene defines the hosting scene
  50144. * @returns the cylinder mesh
  50145. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50146. */
  50147. static CreateCylinder(name: string, options: {
  50148. height?: number;
  50149. diameterTop?: number;
  50150. diameterBottom?: number;
  50151. diameter?: number;
  50152. tessellation?: number;
  50153. subdivisions?: number;
  50154. arc?: number;
  50155. faceColors?: Color4[];
  50156. faceUV?: Vector4[];
  50157. updatable?: boolean;
  50158. hasRings?: boolean;
  50159. enclose?: boolean;
  50160. cap?: number;
  50161. sideOrientation?: number;
  50162. frontUVs?: Vector4;
  50163. backUVs?: Vector4;
  50164. }, scene: any): Mesh;
  50165. }
  50166. }
  50167. declare module BABYLON {
  50168. /**
  50169. * States of the webXR experience
  50170. */
  50171. export enum WebXRState {
  50172. /**
  50173. * Transitioning to being in XR mode
  50174. */
  50175. ENTERING_XR = 0,
  50176. /**
  50177. * Transitioning to non XR mode
  50178. */
  50179. EXITING_XR = 1,
  50180. /**
  50181. * In XR mode and presenting
  50182. */
  50183. IN_XR = 2,
  50184. /**
  50185. * Not entered XR mode
  50186. */
  50187. NOT_IN_XR = 3
  50188. }
  50189. /**
  50190. * The state of the XR camera's tracking
  50191. */
  50192. export enum WebXRTrackingState {
  50193. /**
  50194. * No transformation received, device is not being tracked
  50195. */
  50196. NOT_TRACKING = 0,
  50197. /**
  50198. * Tracking lost - using emulated position
  50199. */
  50200. TRACKING_LOST = 1,
  50201. /**
  50202. * Transformation tracking works normally
  50203. */
  50204. TRACKING = 2
  50205. }
  50206. /**
  50207. * Abstraction of the XR render target
  50208. */
  50209. export interface WebXRRenderTarget extends IDisposable {
  50210. /**
  50211. * xrpresent context of the canvas which can be used to display/mirror xr content
  50212. */
  50213. canvasContext: WebGLRenderingContext;
  50214. /**
  50215. * xr layer for the canvas
  50216. */
  50217. xrLayer: Nullable<XRWebGLLayer>;
  50218. /**
  50219. * Initializes the xr layer for the session
  50220. * @param xrSession xr session
  50221. * @returns a promise that will resolve once the XR Layer has been created
  50222. */
  50223. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50224. }
  50225. }
  50226. declare module BABYLON {
  50227. /**
  50228. * COnfiguration object for WebXR output canvas
  50229. */
  50230. export class WebXRManagedOutputCanvasOptions {
  50231. /**
  50232. * An optional canvas in case you wish to create it yourself and provide it here.
  50233. * If not provided, a new canvas will be created
  50234. */
  50235. canvasElement?: HTMLCanvasElement;
  50236. /**
  50237. * Options for this XR Layer output
  50238. */
  50239. canvasOptions?: XRWebGLLayerInit;
  50240. /**
  50241. * CSS styling for a newly created canvas (if not provided)
  50242. */
  50243. newCanvasCssStyle?: string;
  50244. /**
  50245. * Get the default values of the configuration object
  50246. * @param engine defines the engine to use (can be null)
  50247. * @returns default values of this configuration object
  50248. */
  50249. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50250. }
  50251. /**
  50252. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50253. */
  50254. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50255. private _options;
  50256. private _canvas;
  50257. private _engine;
  50258. private _originalCanvasSize;
  50259. /**
  50260. * Rendering context of the canvas which can be used to display/mirror xr content
  50261. */
  50262. canvasContext: WebGLRenderingContext;
  50263. /**
  50264. * xr layer for the canvas
  50265. */
  50266. xrLayer: Nullable<XRWebGLLayer>;
  50267. /**
  50268. * Obseervers registered here will be triggered when the xr layer was initialized
  50269. */
  50270. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50271. /**
  50272. * Initializes the canvas to be added/removed upon entering/exiting xr
  50273. * @param _xrSessionManager The XR Session manager
  50274. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50275. */
  50276. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50277. /**
  50278. * Disposes of the object
  50279. */
  50280. dispose(): void;
  50281. /**
  50282. * Initializes the xr layer for the session
  50283. * @param xrSession xr session
  50284. * @returns a promise that will resolve once the XR Layer has been created
  50285. */
  50286. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50287. private _addCanvas;
  50288. private _removeCanvas;
  50289. private _setCanvasSize;
  50290. private _setManagedOutputCanvas;
  50291. }
  50292. }
  50293. declare module BABYLON {
  50294. /**
  50295. * Manages an XRSession to work with Babylon's engine
  50296. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50297. */
  50298. export class WebXRSessionManager implements IDisposable {
  50299. /** The scene which the session should be created for */
  50300. scene: Scene;
  50301. private _referenceSpace;
  50302. private _rttProvider;
  50303. private _sessionEnded;
  50304. private _xrNavigator;
  50305. private baseLayer;
  50306. /**
  50307. * The base reference space from which the session started. good if you want to reset your
  50308. * reference space
  50309. */
  50310. baseReferenceSpace: XRReferenceSpace;
  50311. /**
  50312. * Current XR frame
  50313. */
  50314. currentFrame: Nullable<XRFrame>;
  50315. /** WebXR timestamp updated every frame */
  50316. currentTimestamp: number;
  50317. /**
  50318. * Used just in case of a failure to initialize an immersive session.
  50319. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50320. */
  50321. defaultHeightCompensation: number;
  50322. /**
  50323. * Fires every time a new xrFrame arrives which can be used to update the camera
  50324. */
  50325. onXRFrameObservable: Observable<XRFrame>;
  50326. /**
  50327. * Fires when the reference space changed
  50328. */
  50329. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50330. /**
  50331. * Fires when the xr session is ended either by the device or manually done
  50332. */
  50333. onXRSessionEnded: Observable<any>;
  50334. /**
  50335. * Fires when the xr session is ended either by the device or manually done
  50336. */
  50337. onXRSessionInit: Observable<XRSession>;
  50338. /**
  50339. * Underlying xr session
  50340. */
  50341. session: XRSession;
  50342. /**
  50343. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50344. * or get the offset the player is currently at.
  50345. */
  50346. viewerReferenceSpace: XRReferenceSpace;
  50347. /**
  50348. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50349. * @param scene The scene which the session should be created for
  50350. */
  50351. constructor(
  50352. /** The scene which the session should be created for */
  50353. scene: Scene);
  50354. /**
  50355. * The current reference space used in this session. This reference space can constantly change!
  50356. * It is mainly used to offset the camera's position.
  50357. */
  50358. get referenceSpace(): XRReferenceSpace;
  50359. /**
  50360. * Set a new reference space and triggers the observable
  50361. */
  50362. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50363. /**
  50364. * Disposes of the session manager
  50365. */
  50366. dispose(): void;
  50367. /**
  50368. * Stops the xrSession and restores the render loop
  50369. * @returns Promise which resolves after it exits XR
  50370. */
  50371. exitXRAsync(): Promise<void>;
  50372. /**
  50373. * Gets the correct render target texture to be rendered this frame for this eye
  50374. * @param eye the eye for which to get the render target
  50375. * @returns the render target for the specified eye
  50376. */
  50377. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50378. /**
  50379. * Creates a WebXRRenderTarget object for the XR session
  50380. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50381. * @param options optional options to provide when creating a new render target
  50382. * @returns a WebXR render target to which the session can render
  50383. */
  50384. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50385. /**
  50386. * Initializes the manager
  50387. * After initialization enterXR can be called to start an XR session
  50388. * @returns Promise which resolves after it is initialized
  50389. */
  50390. initializeAsync(): Promise<void>;
  50391. /**
  50392. * Initializes an xr session
  50393. * @param xrSessionMode mode to initialize
  50394. * @param xrSessionInit defines optional and required values to pass to the session builder
  50395. * @returns a promise which will resolve once the session has been initialized
  50396. */
  50397. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50398. /**
  50399. * Checks if a session would be supported for the creation options specified
  50400. * @param sessionMode session mode to check if supported eg. immersive-vr
  50401. * @returns A Promise that resolves to true if supported and false if not
  50402. */
  50403. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50404. /**
  50405. * Resets the reference space to the one started the session
  50406. */
  50407. resetReferenceSpace(): void;
  50408. /**
  50409. * Starts rendering to the xr layer
  50410. */
  50411. runXRRenderLoop(): void;
  50412. /**
  50413. * Sets the reference space on the xr session
  50414. * @param referenceSpaceType space to set
  50415. * @returns a promise that will resolve once the reference space has been set
  50416. */
  50417. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50418. /**
  50419. * Updates the render state of the session
  50420. * @param state state to set
  50421. * @returns a promise that resolves once the render state has been updated
  50422. */
  50423. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50424. /**
  50425. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50426. * @param sessionMode defines the session to test
  50427. * @returns a promise with boolean as final value
  50428. */
  50429. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50430. private _createRenderTargetTexture;
  50431. }
  50432. }
  50433. declare module BABYLON {
  50434. /**
  50435. * WebXR Camera which holds the views for the xrSession
  50436. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50437. */
  50438. export class WebXRCamera extends FreeCamera {
  50439. private _xrSessionManager;
  50440. private _firstFrame;
  50441. private _referenceQuaternion;
  50442. private _referencedPosition;
  50443. private _xrInvPositionCache;
  50444. private _xrInvQuaternionCache;
  50445. private _trackingState;
  50446. /**
  50447. * Observable raised before camera teleportation
  50448. */
  50449. onBeforeCameraTeleport: Observable<Vector3>;
  50450. /**
  50451. * Observable raised after camera teleportation
  50452. */
  50453. onAfterCameraTeleport: Observable<Vector3>;
  50454. /**
  50455. * Notifies when the camera's tracking state has changed.
  50456. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50457. */
  50458. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50459. /**
  50460. * Should position compensation execute on first frame.
  50461. * This is used when copying the position from a native (non XR) camera
  50462. */
  50463. compensateOnFirstFrame: boolean;
  50464. /**
  50465. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50466. * @param name the name of the camera
  50467. * @param scene the scene to add the camera to
  50468. * @param _xrSessionManager a constructed xr session manager
  50469. */
  50470. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50471. /**
  50472. * Get the current XR tracking state of the camera
  50473. */
  50474. get trackingState(): WebXRTrackingState;
  50475. private _setTrackingState;
  50476. /**
  50477. * Return the user's height, unrelated to the current ground.
  50478. * This will be the y position of this camera, when ground level is 0.
  50479. */
  50480. get realWorldHeight(): number;
  50481. /** @hidden */
  50482. _updateForDualEyeDebugging(): void;
  50483. /**
  50484. * Sets this camera's transformation based on a non-vr camera
  50485. * @param otherCamera the non-vr camera to copy the transformation from
  50486. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50487. */
  50488. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50489. /**
  50490. * Gets the current instance class name ("WebXRCamera").
  50491. * @returns the class name
  50492. */
  50493. getClassName(): string;
  50494. private _rotate180;
  50495. private _updateFromXRSession;
  50496. private _updateNumberOfRigCameras;
  50497. private _updateReferenceSpace;
  50498. private _updateReferenceSpaceOffset;
  50499. }
  50500. }
  50501. declare module BABYLON {
  50502. /**
  50503. * Defining the interface required for a (webxr) feature
  50504. */
  50505. export interface IWebXRFeature extends IDisposable {
  50506. /**
  50507. * Is this feature attached
  50508. */
  50509. attached: boolean;
  50510. /**
  50511. * Should auto-attach be disabled?
  50512. */
  50513. disableAutoAttach: boolean;
  50514. /**
  50515. * Attach the feature to the session
  50516. * Will usually be called by the features manager
  50517. *
  50518. * @param force should attachment be forced (even when already attached)
  50519. * @returns true if successful.
  50520. */
  50521. attach(force?: boolean): boolean;
  50522. /**
  50523. * Detach the feature from the session
  50524. * Will usually be called by the features manager
  50525. *
  50526. * @returns true if successful.
  50527. */
  50528. detach(): boolean;
  50529. /**
  50530. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50531. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50532. *
  50533. * @returns whether or not the feature is compatible in this environment
  50534. */
  50535. isCompatible(): boolean;
  50536. /**
  50537. * Was this feature disposed;
  50538. */
  50539. isDisposed: boolean;
  50540. /**
  50541. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50542. */
  50543. xrNativeFeatureName?: string;
  50544. /**
  50545. * A list of (Babylon WebXR) features this feature depends on
  50546. */
  50547. dependsOn?: string[];
  50548. }
  50549. /**
  50550. * A list of the currently available features without referencing them
  50551. */
  50552. export class WebXRFeatureName {
  50553. /**
  50554. * The name of the anchor system feature
  50555. */
  50556. static readonly ANCHOR_SYSTEM: string;
  50557. /**
  50558. * The name of the background remover feature
  50559. */
  50560. static readonly BACKGROUND_REMOVER: string;
  50561. /**
  50562. * The name of the hit test feature
  50563. */
  50564. static readonly HIT_TEST: string;
  50565. /**
  50566. * physics impostors for xr controllers feature
  50567. */
  50568. static readonly PHYSICS_CONTROLLERS: string;
  50569. /**
  50570. * The name of the plane detection feature
  50571. */
  50572. static readonly PLANE_DETECTION: string;
  50573. /**
  50574. * The name of the pointer selection feature
  50575. */
  50576. static readonly POINTER_SELECTION: string;
  50577. /**
  50578. * The name of the teleportation feature
  50579. */
  50580. static readonly TELEPORTATION: string;
  50581. /**
  50582. * The name of the feature points feature.
  50583. */
  50584. static readonly FEATURE_POINTS: string;
  50585. /**
  50586. * The name of the hand tracking feature.
  50587. */
  50588. static readonly HAND_TRACKING: string;
  50589. }
  50590. /**
  50591. * Defining the constructor of a feature. Used to register the modules.
  50592. */
  50593. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50594. /**
  50595. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50596. * It is mainly used in AR sessions.
  50597. *
  50598. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50599. */
  50600. export class WebXRFeaturesManager implements IDisposable {
  50601. private _xrSessionManager;
  50602. private static readonly _AvailableFeatures;
  50603. private _features;
  50604. /**
  50605. * constructs a new features manages.
  50606. *
  50607. * @param _xrSessionManager an instance of WebXRSessionManager
  50608. */
  50609. constructor(_xrSessionManager: WebXRSessionManager);
  50610. /**
  50611. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50612. * Mainly used internally.
  50613. *
  50614. * @param featureName the name of the feature to register
  50615. * @param constructorFunction the function used to construct the module
  50616. * @param version the (babylon) version of the module
  50617. * @param stable is that a stable version of this module
  50618. */
  50619. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50620. /**
  50621. * Returns a constructor of a specific feature.
  50622. *
  50623. * @param featureName the name of the feature to construct
  50624. * @param version the version of the feature to load
  50625. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50626. * @param options optional options provided to the module.
  50627. * @returns a function that, when called, will return a new instance of this feature
  50628. */
  50629. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50630. /**
  50631. * Can be used to return the list of features currently registered
  50632. *
  50633. * @returns an Array of available features
  50634. */
  50635. static GetAvailableFeatures(): string[];
  50636. /**
  50637. * Gets the versions available for a specific feature
  50638. * @param featureName the name of the feature
  50639. * @returns an array with the available versions
  50640. */
  50641. static GetAvailableVersions(featureName: string): string[];
  50642. /**
  50643. * Return the latest unstable version of this feature
  50644. * @param featureName the name of the feature to search
  50645. * @returns the version number. if not found will return -1
  50646. */
  50647. static GetLatestVersionOfFeature(featureName: string): number;
  50648. /**
  50649. * Return the latest stable version of this feature
  50650. * @param featureName the name of the feature to search
  50651. * @returns the version number. if not found will return -1
  50652. */
  50653. static GetStableVersionOfFeature(featureName: string): number;
  50654. /**
  50655. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50656. * Can be used during a session to start a feature
  50657. * @param featureName the name of feature to attach
  50658. */
  50659. attachFeature(featureName: string): void;
  50660. /**
  50661. * Can be used inside a session or when the session ends to detach a specific feature
  50662. * @param featureName the name of the feature to detach
  50663. */
  50664. detachFeature(featureName: string): void;
  50665. /**
  50666. * Used to disable an already-enabled feature
  50667. * The feature will be disposed and will be recreated once enabled.
  50668. * @param featureName the feature to disable
  50669. * @returns true if disable was successful
  50670. */
  50671. disableFeature(featureName: string | {
  50672. Name: string;
  50673. }): boolean;
  50674. /**
  50675. * dispose this features manager
  50676. */
  50677. dispose(): void;
  50678. /**
  50679. * 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.
  50680. * 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.
  50681. *
  50682. * @param featureName the name of the feature to load or the class of the feature
  50683. * @param version optional version to load. if not provided the latest version will be enabled
  50684. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50685. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50686. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50687. * @returns a new constructed feature or throws an error if feature not found.
  50688. */
  50689. enableFeature(featureName: string | {
  50690. Name: string;
  50691. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50692. /**
  50693. * get the implementation of an enabled feature.
  50694. * @param featureName the name of the feature to load
  50695. * @returns the feature class, if found
  50696. */
  50697. getEnabledFeature(featureName: string): IWebXRFeature;
  50698. /**
  50699. * Get the list of enabled features
  50700. * @returns an array of enabled features
  50701. */
  50702. getEnabledFeatures(): string[];
  50703. /**
  50704. * This function will exten the session creation configuration object with enabled features.
  50705. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50706. * according to the defined "required" variable, provided during enableFeature call
  50707. * @param xrSessionInit the xr Session init object to extend
  50708. *
  50709. * @returns an extended XRSessionInit object
  50710. */
  50711. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. /**
  50716. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50717. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50718. */
  50719. export class WebXRExperienceHelper implements IDisposable {
  50720. private scene;
  50721. private _nonVRCamera;
  50722. private _originalSceneAutoClear;
  50723. private _supported;
  50724. /**
  50725. * Camera used to render xr content
  50726. */
  50727. camera: WebXRCamera;
  50728. /** A features manager for this xr session */
  50729. featuresManager: WebXRFeaturesManager;
  50730. /**
  50731. * Observers registered here will be triggered after the camera's initial transformation is set
  50732. * This can be used to set a different ground level or an extra rotation.
  50733. *
  50734. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50735. * to the position set after this observable is done executing.
  50736. */
  50737. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50738. /**
  50739. * Fires when the state of the experience helper has changed
  50740. */
  50741. onStateChangedObservable: Observable<WebXRState>;
  50742. /** Session manager used to keep track of xr session */
  50743. sessionManager: WebXRSessionManager;
  50744. /**
  50745. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50746. */
  50747. state: WebXRState;
  50748. /**
  50749. * Creates a WebXRExperienceHelper
  50750. * @param scene The scene the helper should be created in
  50751. */
  50752. private constructor();
  50753. /**
  50754. * Creates the experience helper
  50755. * @param scene the scene to attach the experience helper to
  50756. * @returns a promise for the experience helper
  50757. */
  50758. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50759. /**
  50760. * Disposes of the experience helper
  50761. */
  50762. dispose(): void;
  50763. /**
  50764. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50765. * @param sessionMode options for the XR session
  50766. * @param referenceSpaceType frame of reference of the XR session
  50767. * @param renderTarget the output canvas that will be used to enter XR mode
  50768. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50769. * @returns promise that resolves after xr mode has entered
  50770. */
  50771. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50772. /**
  50773. * Exits XR mode and returns the scene to its original state
  50774. * @returns promise that resolves after xr mode has exited
  50775. */
  50776. exitXRAsync(): Promise<void>;
  50777. private _nonXRToXRCamera;
  50778. private _setState;
  50779. }
  50780. }
  50781. declare module BABYLON {
  50782. /**
  50783. * X-Y values for axes in WebXR
  50784. */
  50785. export interface IWebXRMotionControllerAxesValue {
  50786. /**
  50787. * The value of the x axis
  50788. */
  50789. x: number;
  50790. /**
  50791. * The value of the y-axis
  50792. */
  50793. y: number;
  50794. }
  50795. /**
  50796. * changed / previous values for the values of this component
  50797. */
  50798. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50799. /**
  50800. * current (this frame) value
  50801. */
  50802. current: T;
  50803. /**
  50804. * previous (last change) value
  50805. */
  50806. previous: T;
  50807. }
  50808. /**
  50809. * Represents changes in the component between current frame and last values recorded
  50810. */
  50811. export interface IWebXRMotionControllerComponentChanges {
  50812. /**
  50813. * will be populated with previous and current values if axes changed
  50814. */
  50815. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50816. /**
  50817. * will be populated with previous and current values if pressed changed
  50818. */
  50819. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50820. /**
  50821. * will be populated with previous and current values if touched changed
  50822. */
  50823. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50824. /**
  50825. * will be populated with previous and current values if value changed
  50826. */
  50827. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50828. }
  50829. /**
  50830. * This class represents a single component (for example button or thumbstick) of a motion controller
  50831. */
  50832. export class WebXRControllerComponent implements IDisposable {
  50833. /**
  50834. * the id of this component
  50835. */
  50836. id: string;
  50837. /**
  50838. * the type of the component
  50839. */
  50840. type: MotionControllerComponentType;
  50841. private _buttonIndex;
  50842. private _axesIndices;
  50843. private _axes;
  50844. private _changes;
  50845. private _currentValue;
  50846. private _hasChanges;
  50847. private _pressed;
  50848. private _touched;
  50849. /**
  50850. * button component type
  50851. */
  50852. static BUTTON_TYPE: MotionControllerComponentType;
  50853. /**
  50854. * squeeze component type
  50855. */
  50856. static SQUEEZE_TYPE: MotionControllerComponentType;
  50857. /**
  50858. * Thumbstick component type
  50859. */
  50860. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50861. /**
  50862. * Touchpad component type
  50863. */
  50864. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50865. /**
  50866. * trigger component type
  50867. */
  50868. static TRIGGER_TYPE: MotionControllerComponentType;
  50869. /**
  50870. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50871. * the axes data changes
  50872. */
  50873. onAxisValueChangedObservable: Observable<{
  50874. x: number;
  50875. y: number;
  50876. }>;
  50877. /**
  50878. * Observers registered here will be triggered when the state of a button changes
  50879. * State change is either pressed / touched / value
  50880. */
  50881. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50882. /**
  50883. * Creates a new component for a motion controller.
  50884. * It is created by the motion controller itself
  50885. *
  50886. * @param id the id of this component
  50887. * @param type the type of the component
  50888. * @param _buttonIndex index in the buttons array of the gamepad
  50889. * @param _axesIndices indices of the values in the axes array of the gamepad
  50890. */
  50891. constructor(
  50892. /**
  50893. * the id of this component
  50894. */
  50895. id: string,
  50896. /**
  50897. * the type of the component
  50898. */
  50899. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50900. /**
  50901. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50902. */
  50903. get axes(): IWebXRMotionControllerAxesValue;
  50904. /**
  50905. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50906. */
  50907. get changes(): IWebXRMotionControllerComponentChanges;
  50908. /**
  50909. * Return whether or not the component changed the last frame
  50910. */
  50911. get hasChanges(): boolean;
  50912. /**
  50913. * is the button currently pressed
  50914. */
  50915. get pressed(): boolean;
  50916. /**
  50917. * is the button currently touched
  50918. */
  50919. get touched(): boolean;
  50920. /**
  50921. * Get the current value of this component
  50922. */
  50923. get value(): number;
  50924. /**
  50925. * Dispose this component
  50926. */
  50927. dispose(): void;
  50928. /**
  50929. * Are there axes correlating to this component
  50930. * @return true is axes data is available
  50931. */
  50932. isAxes(): boolean;
  50933. /**
  50934. * Is this component a button (hence - pressable)
  50935. * @returns true if can be pressed
  50936. */
  50937. isButton(): boolean;
  50938. /**
  50939. * update this component using the gamepad object it is in. Called on every frame
  50940. * @param nativeController the native gamepad controller object
  50941. */
  50942. update(nativeController: IMinimalMotionControllerObject): void;
  50943. }
  50944. }
  50945. declare module BABYLON {
  50946. /**
  50947. * Interface used to represent data loading progression
  50948. */
  50949. export interface ISceneLoaderProgressEvent {
  50950. /**
  50951. * Defines if data length to load can be evaluated
  50952. */
  50953. readonly lengthComputable: boolean;
  50954. /**
  50955. * Defines the loaded data length
  50956. */
  50957. readonly loaded: number;
  50958. /**
  50959. * Defines the data length to load
  50960. */
  50961. readonly total: number;
  50962. }
  50963. /**
  50964. * Interface used by SceneLoader plugins to define supported file extensions
  50965. */
  50966. export interface ISceneLoaderPluginExtensions {
  50967. /**
  50968. * Defines the list of supported extensions
  50969. */
  50970. [extension: string]: {
  50971. isBinary: boolean;
  50972. };
  50973. }
  50974. /**
  50975. * Interface used by SceneLoader plugin factory
  50976. */
  50977. export interface ISceneLoaderPluginFactory {
  50978. /**
  50979. * Defines the name of the factory
  50980. */
  50981. name: string;
  50982. /**
  50983. * Function called to create a new plugin
  50984. * @return the new plugin
  50985. */
  50986. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50987. /**
  50988. * The callback that returns true if the data can be directly loaded.
  50989. * @param data string containing the file data
  50990. * @returns if the data can be loaded directly
  50991. */
  50992. canDirectLoad?(data: string): boolean;
  50993. }
  50994. /**
  50995. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50996. */
  50997. export interface ISceneLoaderPluginBase {
  50998. /**
  50999. * The friendly name of this plugin.
  51000. */
  51001. name: string;
  51002. /**
  51003. * The file extensions supported by this plugin.
  51004. */
  51005. extensions: string | ISceneLoaderPluginExtensions;
  51006. /**
  51007. * The callback called when loading from a url.
  51008. * @param scene scene loading this url
  51009. * @param url url to load
  51010. * @param onSuccess callback called when the file successfully loads
  51011. * @param onProgress callback called while file is loading (if the server supports this mode)
  51012. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51013. * @param onError callback called when the file fails to load
  51014. * @returns a file request object
  51015. */
  51016. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51017. /**
  51018. * The callback called when loading from a file object.
  51019. * @param scene scene loading this file
  51020. * @param file defines the file to load
  51021. * @param onSuccess defines the callback to call when data is loaded
  51022. * @param onProgress defines the callback to call during loading process
  51023. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51024. * @param onError defines the callback to call when an error occurs
  51025. * @returns a file request object
  51026. */
  51027. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51028. /**
  51029. * The callback that returns true if the data can be directly loaded.
  51030. * @param data string containing the file data
  51031. * @returns if the data can be loaded directly
  51032. */
  51033. canDirectLoad?(data: string): boolean;
  51034. /**
  51035. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51036. * @param scene scene loading this data
  51037. * @param data string containing the data
  51038. * @returns data to pass to the plugin
  51039. */
  51040. directLoad?(scene: Scene, data: string): any;
  51041. /**
  51042. * The callback that allows custom handling of the root url based on the response url.
  51043. * @param rootUrl the original root url
  51044. * @param responseURL the response url if available
  51045. * @returns the new root url
  51046. */
  51047. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51048. }
  51049. /**
  51050. * Interface used to define a SceneLoader plugin
  51051. */
  51052. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51053. /**
  51054. * Import meshes into a scene.
  51055. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51056. * @param scene The scene to import into
  51057. * @param data The data to import
  51058. * @param rootUrl The root url for scene and resources
  51059. * @param meshes The meshes array to import into
  51060. * @param particleSystems The particle systems array to import into
  51061. * @param skeletons The skeletons array to import into
  51062. * @param onError The callback when import fails
  51063. * @returns True if successful or false otherwise
  51064. */
  51065. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51066. /**
  51067. * Load into a scene.
  51068. * @param scene The scene to load into
  51069. * @param data The data to import
  51070. * @param rootUrl The root url for scene and resources
  51071. * @param onError The callback when import fails
  51072. * @returns True if successful or false otherwise
  51073. */
  51074. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51075. /**
  51076. * Load into an asset container.
  51077. * @param scene The scene to load into
  51078. * @param data The data to import
  51079. * @param rootUrl The root url for scene and resources
  51080. * @param onError The callback when import fails
  51081. * @returns The loaded asset container
  51082. */
  51083. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51084. }
  51085. /**
  51086. * Interface used to define an async SceneLoader plugin
  51087. */
  51088. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51089. /**
  51090. * Import meshes into a scene.
  51091. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51092. * @param scene The scene to import into
  51093. * @param data The data to import
  51094. * @param rootUrl The root url for scene and resources
  51095. * @param onProgress The callback when the load progresses
  51096. * @param fileName Defines the name of the file to load
  51097. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51098. */
  51099. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51100. meshes: AbstractMesh[];
  51101. particleSystems: IParticleSystem[];
  51102. skeletons: Skeleton[];
  51103. animationGroups: AnimationGroup[];
  51104. }>;
  51105. /**
  51106. * Load into a scene.
  51107. * @param scene The scene to load into
  51108. * @param data The data to import
  51109. * @param rootUrl The root url for scene and resources
  51110. * @param onProgress The callback when the load progresses
  51111. * @param fileName Defines the name of the file to load
  51112. * @returns Nothing
  51113. */
  51114. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51115. /**
  51116. * Load into an asset container.
  51117. * @param scene The scene to load into
  51118. * @param data The data to import
  51119. * @param rootUrl The root url for scene and resources
  51120. * @param onProgress The callback when the load progresses
  51121. * @param fileName Defines the name of the file to load
  51122. * @returns The loaded asset container
  51123. */
  51124. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51125. }
  51126. /**
  51127. * Mode that determines how to handle old animation groups before loading new ones.
  51128. */
  51129. export enum SceneLoaderAnimationGroupLoadingMode {
  51130. /**
  51131. * Reset all old animations to initial state then dispose them.
  51132. */
  51133. Clean = 0,
  51134. /**
  51135. * Stop all old animations.
  51136. */
  51137. Stop = 1,
  51138. /**
  51139. * Restart old animations from first frame.
  51140. */
  51141. Sync = 2,
  51142. /**
  51143. * Old animations remains untouched.
  51144. */
  51145. NoSync = 3
  51146. }
  51147. /**
  51148. * Defines a plugin registered by the SceneLoader
  51149. */
  51150. interface IRegisteredPlugin {
  51151. /**
  51152. * Defines the plugin to use
  51153. */
  51154. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51155. /**
  51156. * Defines if the plugin supports binary data
  51157. */
  51158. isBinary: boolean;
  51159. }
  51160. /**
  51161. * Class used to load scene from various file formats using registered plugins
  51162. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51163. */
  51164. export class SceneLoader {
  51165. /**
  51166. * No logging while loading
  51167. */
  51168. static readonly NO_LOGGING: number;
  51169. /**
  51170. * Minimal logging while loading
  51171. */
  51172. static readonly MINIMAL_LOGGING: number;
  51173. /**
  51174. * Summary logging while loading
  51175. */
  51176. static readonly SUMMARY_LOGGING: number;
  51177. /**
  51178. * Detailled logging while loading
  51179. */
  51180. static readonly DETAILED_LOGGING: number;
  51181. /**
  51182. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51183. */
  51184. static get ForceFullSceneLoadingForIncremental(): boolean;
  51185. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51186. /**
  51187. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51188. */
  51189. static get ShowLoadingScreen(): boolean;
  51190. static set ShowLoadingScreen(value: boolean);
  51191. /**
  51192. * Defines the current logging level (while loading the scene)
  51193. * @ignorenaming
  51194. */
  51195. static get loggingLevel(): number;
  51196. static set loggingLevel(value: number);
  51197. /**
  51198. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51199. */
  51200. static get CleanBoneMatrixWeights(): boolean;
  51201. static set CleanBoneMatrixWeights(value: boolean);
  51202. /**
  51203. * Event raised when a plugin is used to load a scene
  51204. */
  51205. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51206. private static _registeredPlugins;
  51207. private static _showingLoadingScreen;
  51208. /**
  51209. * Gets the default plugin (used to load Babylon files)
  51210. * @returns the .babylon plugin
  51211. */
  51212. static GetDefaultPlugin(): IRegisteredPlugin;
  51213. private static _GetPluginForExtension;
  51214. private static _GetPluginForDirectLoad;
  51215. private static _GetPluginForFilename;
  51216. private static _GetDirectLoad;
  51217. private static _LoadData;
  51218. private static _GetFileInfo;
  51219. /**
  51220. * Gets a plugin that can load the given extension
  51221. * @param extension defines the extension to load
  51222. * @returns a plugin or null if none works
  51223. */
  51224. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51225. /**
  51226. * Gets a boolean indicating that the given extension can be loaded
  51227. * @param extension defines the extension to load
  51228. * @returns true if the extension is supported
  51229. */
  51230. static IsPluginForExtensionAvailable(extension: string): boolean;
  51231. /**
  51232. * Adds a new plugin to the list of registered plugins
  51233. * @param plugin defines the plugin to add
  51234. */
  51235. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51236. /**
  51237. * Import meshes into a scene
  51238. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51239. * @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)
  51240. * @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)
  51241. * @param scene the instance of BABYLON.Scene to append to
  51242. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51243. * @param onProgress a callback with a progress event for each file being loaded
  51244. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51245. * @param pluginExtension the extension used to determine the plugin
  51246. * @returns The loaded plugin
  51247. */
  51248. 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>;
  51249. /**
  51250. * Import meshes into a scene
  51251. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51252. * @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)
  51253. * @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)
  51254. * @param scene the instance of BABYLON.Scene to append to
  51255. * @param onProgress a callback with a progress event for each file being loaded
  51256. * @param pluginExtension the extension used to determine the plugin
  51257. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51258. */
  51259. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51260. meshes: AbstractMesh[];
  51261. particleSystems: IParticleSystem[];
  51262. skeletons: Skeleton[];
  51263. animationGroups: AnimationGroup[];
  51264. }>;
  51265. /**
  51266. * Load a scene
  51267. * @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)
  51268. * @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)
  51269. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51270. * @param onSuccess a callback with the scene when import succeeds
  51271. * @param onProgress a callback with a progress event for each file being loaded
  51272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51273. * @param pluginExtension the extension used to determine the plugin
  51274. * @returns The loaded plugin
  51275. */
  51276. 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>;
  51277. /**
  51278. * Load a scene
  51279. * @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)
  51280. * @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)
  51281. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51282. * @param onProgress a callback with a progress event for each file being loaded
  51283. * @param pluginExtension the extension used to determine the plugin
  51284. * @returns The loaded scene
  51285. */
  51286. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51287. /**
  51288. * Append a scene
  51289. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51290. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51291. * @param scene is the instance of BABYLON.Scene to append to
  51292. * @param onSuccess a callback with the scene when import succeeds
  51293. * @param onProgress a callback with a progress event for each file being loaded
  51294. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51295. * @param pluginExtension the extension used to determine the plugin
  51296. * @returns The loaded plugin
  51297. */
  51298. 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>;
  51299. /**
  51300. * Append a scene
  51301. * @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)
  51302. * @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)
  51303. * @param scene is the instance of BABYLON.Scene to append to
  51304. * @param onProgress a callback with a progress event for each file being loaded
  51305. * @param pluginExtension the extension used to determine the plugin
  51306. * @returns The given scene
  51307. */
  51308. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51309. /**
  51310. * Load a scene into an asset container
  51311. * @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)
  51312. * @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)
  51313. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51314. * @param onSuccess a callback with the scene when import succeeds
  51315. * @param onProgress a callback with a progress event for each file being loaded
  51316. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51317. * @param pluginExtension the extension used to determine the plugin
  51318. * @returns The loaded plugin
  51319. */
  51320. 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>;
  51321. /**
  51322. * Load a scene into an asset container
  51323. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51324. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  51325. * @param scene is the instance of Scene to append to
  51326. * @param onProgress a callback with a progress event for each file being loaded
  51327. * @param pluginExtension the extension used to determine the plugin
  51328. * @returns The loaded asset container
  51329. */
  51330. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51331. /**
  51332. * Import animations from a file into a scene
  51333. * @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)
  51334. * @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)
  51335. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51336. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51337. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51338. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51339. * @param onSuccess a callback with the scene when import succeeds
  51340. * @param onProgress a callback with a progress event for each file being loaded
  51341. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51342. * @param pluginExtension the extension used to determine the plugin
  51343. */
  51344. 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;
  51345. /**
  51346. * Import animations from a file into a scene
  51347. * @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)
  51348. * @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)
  51349. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51350. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51351. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51352. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51353. * @param onSuccess a callback with the scene when import succeeds
  51354. * @param onProgress a callback with a progress event for each file being loaded
  51355. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51356. * @param pluginExtension the extension used to determine the plugin
  51357. * @returns the updated scene with imported animations
  51358. */
  51359. 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>;
  51360. }
  51361. }
  51362. declare module BABYLON {
  51363. /**
  51364. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51365. */
  51366. export type MotionControllerHandedness = "none" | "left" | "right";
  51367. /**
  51368. * The type of components available in motion controllers.
  51369. * This is not the name of the component.
  51370. */
  51371. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51372. /**
  51373. * The state of a controller component
  51374. */
  51375. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51376. /**
  51377. * The schema of motion controller layout.
  51378. * No object will be initialized using this interface
  51379. * This is used just to define the profile.
  51380. */
  51381. export interface IMotionControllerLayout {
  51382. /**
  51383. * Path to load the assets. Usually relative to the base path
  51384. */
  51385. assetPath: string;
  51386. /**
  51387. * Available components (unsorted)
  51388. */
  51389. components: {
  51390. /**
  51391. * A map of component Ids
  51392. */
  51393. [componentId: string]: {
  51394. /**
  51395. * The type of input the component outputs
  51396. */
  51397. type: MotionControllerComponentType;
  51398. /**
  51399. * The indices of this component in the gamepad object
  51400. */
  51401. gamepadIndices: {
  51402. /**
  51403. * Index of button
  51404. */
  51405. button?: number;
  51406. /**
  51407. * If available, index of x-axis
  51408. */
  51409. xAxis?: number;
  51410. /**
  51411. * If available, index of y-axis
  51412. */
  51413. yAxis?: number;
  51414. };
  51415. /**
  51416. * The mesh's root node name
  51417. */
  51418. rootNodeName: string;
  51419. /**
  51420. * Animation definitions for this model
  51421. */
  51422. visualResponses: {
  51423. [stateKey: string]: {
  51424. /**
  51425. * What property will be animated
  51426. */
  51427. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51428. /**
  51429. * What states influence this visual response
  51430. */
  51431. states: MotionControllerComponentStateType[];
  51432. /**
  51433. * Type of animation - movement or visibility
  51434. */
  51435. valueNodeProperty: "transform" | "visibility";
  51436. /**
  51437. * Base node name to move. Its position will be calculated according to the min and max nodes
  51438. */
  51439. valueNodeName?: string;
  51440. /**
  51441. * Minimum movement node
  51442. */
  51443. minNodeName?: string;
  51444. /**
  51445. * Max movement node
  51446. */
  51447. maxNodeName?: string;
  51448. };
  51449. };
  51450. /**
  51451. * If touch enabled, what is the name of node to display user feedback
  51452. */
  51453. touchPointNodeName?: string;
  51454. };
  51455. };
  51456. /**
  51457. * Is it xr standard mapping or not
  51458. */
  51459. gamepadMapping: "" | "xr-standard";
  51460. /**
  51461. * Base root node of this entire model
  51462. */
  51463. rootNodeName: string;
  51464. /**
  51465. * Defines the main button component id
  51466. */
  51467. selectComponentId: string;
  51468. }
  51469. /**
  51470. * A definition for the layout map in the input profile
  51471. */
  51472. export interface IMotionControllerLayoutMap {
  51473. /**
  51474. * Layouts with handedness type as a key
  51475. */
  51476. [handedness: string]: IMotionControllerLayout;
  51477. }
  51478. /**
  51479. * The XR Input profile schema
  51480. * Profiles can be found here:
  51481. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51482. */
  51483. export interface IMotionControllerProfile {
  51484. /**
  51485. * fallback profiles for this profileId
  51486. */
  51487. fallbackProfileIds: string[];
  51488. /**
  51489. * The layout map, with handedness as key
  51490. */
  51491. layouts: IMotionControllerLayoutMap;
  51492. /**
  51493. * The id of this profile
  51494. * correlates to the profile(s) in the xrInput.profiles array
  51495. */
  51496. profileId: string;
  51497. }
  51498. /**
  51499. * A helper-interface for the 3 meshes needed for controller button animation
  51500. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51501. */
  51502. export interface IMotionControllerButtonMeshMap {
  51503. /**
  51504. * the mesh that defines the pressed value mesh position.
  51505. * This is used to find the max-position of this button
  51506. */
  51507. pressedMesh: AbstractMesh;
  51508. /**
  51509. * the mesh that defines the unpressed value mesh position.
  51510. * This is used to find the min (or initial) position of this button
  51511. */
  51512. unpressedMesh: AbstractMesh;
  51513. /**
  51514. * The mesh that will be changed when value changes
  51515. */
  51516. valueMesh: AbstractMesh;
  51517. }
  51518. /**
  51519. * A helper-interface for the 3 meshes needed for controller axis animation.
  51520. * This will be expanded when touchpad animations are fully supported
  51521. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51522. */
  51523. export interface IMotionControllerMeshMap {
  51524. /**
  51525. * the mesh that defines the maximum value mesh position.
  51526. */
  51527. maxMesh?: AbstractMesh;
  51528. /**
  51529. * the mesh that defines the minimum value mesh position.
  51530. */
  51531. minMesh?: AbstractMesh;
  51532. /**
  51533. * The mesh that will be changed when axis value changes
  51534. */
  51535. valueMesh?: AbstractMesh;
  51536. }
  51537. /**
  51538. * The elements needed for change-detection of the gamepad objects in motion controllers
  51539. */
  51540. export interface IMinimalMotionControllerObject {
  51541. /**
  51542. * Available axes of this controller
  51543. */
  51544. axes: number[];
  51545. /**
  51546. * An array of available buttons
  51547. */
  51548. buttons: Array<{
  51549. /**
  51550. * Value of the button/trigger
  51551. */
  51552. value: number;
  51553. /**
  51554. * If the button/trigger is currently touched
  51555. */
  51556. touched: boolean;
  51557. /**
  51558. * If the button/trigger is currently pressed
  51559. */
  51560. pressed: boolean;
  51561. }>;
  51562. /**
  51563. * EXPERIMENTAL haptic support.
  51564. */
  51565. hapticActuators?: Array<{
  51566. pulse: (value: number, duration: number) => Promise<boolean>;
  51567. }>;
  51568. }
  51569. /**
  51570. * An Abstract Motion controller
  51571. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51572. * Each component has an observable to check for changes in value and state
  51573. */
  51574. export abstract class WebXRAbstractMotionController implements IDisposable {
  51575. protected scene: Scene;
  51576. protected layout: IMotionControllerLayout;
  51577. /**
  51578. * The gamepad object correlating to this controller
  51579. */
  51580. gamepadObject: IMinimalMotionControllerObject;
  51581. /**
  51582. * handedness (left/right/none) of this controller
  51583. */
  51584. handedness: MotionControllerHandedness;
  51585. private _initComponent;
  51586. private _modelReady;
  51587. /**
  51588. * A map of components (WebXRControllerComponent) in this motion controller
  51589. * Components have a ComponentType and can also have both button and axis definitions
  51590. */
  51591. readonly components: {
  51592. [id: string]: WebXRControllerComponent;
  51593. };
  51594. /**
  51595. * Disable the model's animation. Can be set at any time.
  51596. */
  51597. disableAnimation: boolean;
  51598. /**
  51599. * Observers registered here will be triggered when the model of this controller is done loading
  51600. */
  51601. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51602. /**
  51603. * The profile id of this motion controller
  51604. */
  51605. abstract profileId: string;
  51606. /**
  51607. * The root mesh of the model. It is null if the model was not yet initialized
  51608. */
  51609. rootMesh: Nullable<AbstractMesh>;
  51610. /**
  51611. * constructs a new abstract motion controller
  51612. * @param scene the scene to which the model of the controller will be added
  51613. * @param layout The profile layout to load
  51614. * @param gamepadObject The gamepad object correlating to this controller
  51615. * @param handedness handedness (left/right/none) of this controller
  51616. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51617. */
  51618. constructor(scene: Scene, layout: IMotionControllerLayout,
  51619. /**
  51620. * The gamepad object correlating to this controller
  51621. */
  51622. gamepadObject: IMinimalMotionControllerObject,
  51623. /**
  51624. * handedness (left/right/none) of this controller
  51625. */
  51626. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51627. /**
  51628. * Dispose this controller, the model mesh and all its components
  51629. */
  51630. dispose(): void;
  51631. /**
  51632. * Returns all components of specific type
  51633. * @param type the type to search for
  51634. * @return an array of components with this type
  51635. */
  51636. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51637. /**
  51638. * get a component based an its component id as defined in layout.components
  51639. * @param id the id of the component
  51640. * @returns the component correlates to the id or undefined if not found
  51641. */
  51642. getComponent(id: string): WebXRControllerComponent;
  51643. /**
  51644. * Get the list of components available in this motion controller
  51645. * @returns an array of strings correlating to available components
  51646. */
  51647. getComponentIds(): string[];
  51648. /**
  51649. * Get the first component of specific type
  51650. * @param type type of component to find
  51651. * @return a controller component or null if not found
  51652. */
  51653. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51654. /**
  51655. * Get the main (Select) component of this controller as defined in the layout
  51656. * @returns the main component of this controller
  51657. */
  51658. getMainComponent(): WebXRControllerComponent;
  51659. /**
  51660. * Loads the model correlating to this controller
  51661. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51662. * @returns A promise fulfilled with the result of the model loading
  51663. */
  51664. loadModel(): Promise<boolean>;
  51665. /**
  51666. * Update this model using the current XRFrame
  51667. * @param xrFrame the current xr frame to use and update the model
  51668. */
  51669. updateFromXRFrame(xrFrame: XRFrame): void;
  51670. /**
  51671. * Backwards compatibility due to a deeply-integrated typo
  51672. */
  51673. get handness(): XREye;
  51674. /**
  51675. * Pulse (vibrate) this controller
  51676. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51677. * Consecutive calls to this function will cancel the last pulse call
  51678. *
  51679. * @param value the strength of the pulse in 0.0...1.0 range
  51680. * @param duration Duration of the pulse in milliseconds
  51681. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51682. * @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
  51683. */
  51684. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51685. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51686. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51687. /**
  51688. * Moves the axis on the controller mesh based on its current state
  51689. * @param axis the index of the axis
  51690. * @param axisValue the value of the axis which determines the meshes new position
  51691. * @hidden
  51692. */
  51693. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51694. /**
  51695. * Update the model itself with the current frame data
  51696. * @param xrFrame the frame to use for updating the model mesh
  51697. */
  51698. protected updateModel(xrFrame: XRFrame): void;
  51699. /**
  51700. * Get the filename and path for this controller's model
  51701. * @returns a map of filename and path
  51702. */
  51703. protected abstract _getFilenameAndPath(): {
  51704. filename: string;
  51705. path: string;
  51706. };
  51707. /**
  51708. * This function is called before the mesh is loaded. It checks for loading constraints.
  51709. * For example, this function can check if the GLB loader is available
  51710. * If this function returns false, the generic controller will be loaded instead
  51711. * @returns Is the client ready to load the mesh
  51712. */
  51713. protected abstract _getModelLoadingConstraints(): boolean;
  51714. /**
  51715. * This function will be called after the model was successfully loaded and can be used
  51716. * for mesh transformations before it is available for the user
  51717. * @param meshes the loaded meshes
  51718. */
  51719. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51720. /**
  51721. * Set the root mesh for this controller. Important for the WebXR controller class
  51722. * @param meshes the loaded meshes
  51723. */
  51724. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51725. /**
  51726. * A function executed each frame that updates the mesh (if needed)
  51727. * @param xrFrame the current xrFrame
  51728. */
  51729. protected abstract _updateModel(xrFrame: XRFrame): void;
  51730. private _getGenericFilenameAndPath;
  51731. private _getGenericParentMesh;
  51732. }
  51733. }
  51734. declare module BABYLON {
  51735. /**
  51736. * A generic trigger-only motion controller for WebXR
  51737. */
  51738. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51739. /**
  51740. * Static version of the profile id of this controller
  51741. */
  51742. static ProfileId: string;
  51743. profileId: string;
  51744. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51745. protected _getFilenameAndPath(): {
  51746. filename: string;
  51747. path: string;
  51748. };
  51749. protected _getModelLoadingConstraints(): boolean;
  51750. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51751. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51752. protected _updateModel(): void;
  51753. }
  51754. }
  51755. declare module BABYLON {
  51756. /**
  51757. * Class containing static functions to help procedurally build meshes
  51758. */
  51759. export class SphereBuilder {
  51760. /**
  51761. * Creates a sphere mesh
  51762. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51763. * * 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`)
  51764. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51765. * * 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
  51766. * * 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)
  51767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51768. * * 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
  51769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51770. * @param name defines the name of the mesh
  51771. * @param options defines the options used to create the mesh
  51772. * @param scene defines the hosting scene
  51773. * @returns the sphere mesh
  51774. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51775. */
  51776. static CreateSphere(name: string, options: {
  51777. segments?: number;
  51778. diameter?: number;
  51779. diameterX?: number;
  51780. diameterY?: number;
  51781. diameterZ?: number;
  51782. arc?: number;
  51783. slice?: number;
  51784. sideOrientation?: number;
  51785. frontUVs?: Vector4;
  51786. backUVs?: Vector4;
  51787. updatable?: boolean;
  51788. }, scene?: Nullable<Scene>): Mesh;
  51789. }
  51790. }
  51791. declare module BABYLON {
  51792. /**
  51793. * A profiled motion controller has its profile loaded from an online repository.
  51794. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51795. */
  51796. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51797. private _repositoryUrl;
  51798. private _buttonMeshMapping;
  51799. private _touchDots;
  51800. /**
  51801. * The profile ID of this controller. Will be populated when the controller initializes.
  51802. */
  51803. profileId: string;
  51804. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51805. dispose(): void;
  51806. protected _getFilenameAndPath(): {
  51807. filename: string;
  51808. path: string;
  51809. };
  51810. protected _getModelLoadingConstraints(): boolean;
  51811. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51812. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51813. protected _updateModel(_xrFrame: XRFrame): void;
  51814. }
  51815. }
  51816. declare module BABYLON {
  51817. /**
  51818. * A construction function type to create a new controller based on an xrInput object
  51819. */
  51820. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51821. /**
  51822. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51823. *
  51824. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51825. * it should be replaced with auto-loaded controllers.
  51826. *
  51827. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51828. */
  51829. export class WebXRMotionControllerManager {
  51830. private static _AvailableControllers;
  51831. private static _Fallbacks;
  51832. private static _ProfileLoadingPromises;
  51833. private static _ProfilesList;
  51834. /**
  51835. * The base URL of the online controller repository. Can be changed at any time.
  51836. */
  51837. static BaseRepositoryUrl: string;
  51838. /**
  51839. * Which repository gets priority - local or online
  51840. */
  51841. static PrioritizeOnlineRepository: boolean;
  51842. /**
  51843. * Use the online repository, or use only locally-defined controllers
  51844. */
  51845. static UseOnlineRepository: boolean;
  51846. /**
  51847. * Clear the cache used for profile loading and reload when requested again
  51848. */
  51849. static ClearProfilesCache(): void;
  51850. /**
  51851. * Register the default fallbacks.
  51852. * This function is called automatically when this file is imported.
  51853. */
  51854. static DefaultFallbacks(): void;
  51855. /**
  51856. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51857. * @param profileId the profile to which a fallback needs to be found
  51858. * @return an array with corresponding fallback profiles
  51859. */
  51860. static FindFallbackWithProfileId(profileId: string): string[];
  51861. /**
  51862. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51863. * The order of search:
  51864. *
  51865. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51866. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51867. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51868. * 4) return the generic trigger controller if none were found
  51869. *
  51870. * @param xrInput the xrInput to which a new controller is initialized
  51871. * @param scene the scene to which the model will be added
  51872. * @param forceProfile force a certain profile for this controller
  51873. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51874. */
  51875. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51876. /**
  51877. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51878. *
  51879. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51880. *
  51881. * @param type the profile type to register
  51882. * @param constructFunction the function to be called when loading this profile
  51883. */
  51884. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51885. /**
  51886. * Register a fallback to a specific profile.
  51887. * @param profileId the profileId that will receive the fallbacks
  51888. * @param fallbacks A list of fallback profiles
  51889. */
  51890. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51891. /**
  51892. * Will update the list of profiles available in the repository
  51893. * @return a promise that resolves to a map of profiles available online
  51894. */
  51895. static UpdateProfilesList(): Promise<{
  51896. [profile: string]: string;
  51897. }>;
  51898. private static _LoadProfileFromRepository;
  51899. private static _LoadProfilesFromAvailableControllers;
  51900. }
  51901. }
  51902. declare module BABYLON {
  51903. /**
  51904. * Configuration options for the WebXR controller creation
  51905. */
  51906. export interface IWebXRControllerOptions {
  51907. /**
  51908. * Should the controller mesh be animated when a user interacts with it
  51909. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51910. */
  51911. disableMotionControllerAnimation?: boolean;
  51912. /**
  51913. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51914. */
  51915. doNotLoadControllerMesh?: boolean;
  51916. /**
  51917. * Force a specific controller type for this controller.
  51918. * This can be used when creating your own profile or when testing different controllers
  51919. */
  51920. forceControllerProfile?: string;
  51921. /**
  51922. * Defines a rendering group ID for meshes that will be loaded.
  51923. * This is for the default controllers only.
  51924. */
  51925. renderingGroupId?: number;
  51926. }
  51927. /**
  51928. * Represents an XR controller
  51929. */
  51930. export class WebXRInputSource {
  51931. private _scene;
  51932. /** The underlying input source for the controller */
  51933. inputSource: XRInputSource;
  51934. private _options;
  51935. private _tmpVector;
  51936. private _uniqueId;
  51937. private _disposed;
  51938. /**
  51939. * 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
  51940. */
  51941. grip?: AbstractMesh;
  51942. /**
  51943. * If available, this is the gamepad object related to this controller.
  51944. * Using this object it is possible to get click events and trackpad changes of the
  51945. * webxr controller that is currently being used.
  51946. */
  51947. motionController?: WebXRAbstractMotionController;
  51948. /**
  51949. * Event that fires when the controller is removed/disposed.
  51950. * The object provided as event data is this controller, after associated assets were disposed.
  51951. * uniqueId is still available.
  51952. */
  51953. onDisposeObservable: Observable<WebXRInputSource>;
  51954. /**
  51955. * Will be triggered when the mesh associated with the motion controller is done loading.
  51956. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51957. * A shortened version of controller -> motion controller -> on mesh loaded.
  51958. */
  51959. onMeshLoadedObservable: Observable<AbstractMesh>;
  51960. /**
  51961. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51962. */
  51963. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51964. /**
  51965. * Pointer which can be used to select objects or attach a visible laser to
  51966. */
  51967. pointer: AbstractMesh;
  51968. /**
  51969. * Creates the input source object
  51970. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51971. * @param _scene the scene which the controller should be associated to
  51972. * @param inputSource the underlying input source for the controller
  51973. * @param _options options for this controller creation
  51974. */
  51975. constructor(_scene: Scene,
  51976. /** The underlying input source for the controller */
  51977. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51978. /**
  51979. * Get this controllers unique id
  51980. */
  51981. get uniqueId(): string;
  51982. /**
  51983. * Disposes of the object
  51984. */
  51985. dispose(): void;
  51986. /**
  51987. * Gets a world space ray coming from the pointer or grip
  51988. * @param result the resulting ray
  51989. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51990. */
  51991. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51992. /**
  51993. * Updates the controller pose based on the given XRFrame
  51994. * @param xrFrame xr frame to update the pose with
  51995. * @param referenceSpace reference space to use
  51996. */
  51997. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51998. }
  51999. }
  52000. declare module BABYLON {
  52001. /**
  52002. * The schema for initialization options of the XR Input class
  52003. */
  52004. export interface IWebXRInputOptions {
  52005. /**
  52006. * If set to true no model will be automatically loaded
  52007. */
  52008. doNotLoadControllerMeshes?: boolean;
  52009. /**
  52010. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52011. * If not found, the xr input profile data will be used.
  52012. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52013. */
  52014. forceInputProfile?: string;
  52015. /**
  52016. * Do not send a request to the controller repository to load the profile.
  52017. *
  52018. * Instead, use the controllers available in babylon itself.
  52019. */
  52020. disableOnlineControllerRepository?: boolean;
  52021. /**
  52022. * A custom URL for the controllers repository
  52023. */
  52024. customControllersRepositoryURL?: string;
  52025. /**
  52026. * Should the controller model's components not move according to the user input
  52027. */
  52028. disableControllerAnimation?: boolean;
  52029. /**
  52030. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52031. */
  52032. controllerOptions?: IWebXRControllerOptions;
  52033. }
  52034. /**
  52035. * XR input used to track XR inputs such as controllers/rays
  52036. */
  52037. export class WebXRInput implements IDisposable {
  52038. /**
  52039. * the xr session manager for this session
  52040. */
  52041. xrSessionManager: WebXRSessionManager;
  52042. /**
  52043. * the WebXR camera for this session. Mainly used for teleportation
  52044. */
  52045. xrCamera: WebXRCamera;
  52046. private readonly options;
  52047. /**
  52048. * XR controllers being tracked
  52049. */
  52050. controllers: Array<WebXRInputSource>;
  52051. private _frameObserver;
  52052. private _sessionEndedObserver;
  52053. private _sessionInitObserver;
  52054. /**
  52055. * Event when a controller has been connected/added
  52056. */
  52057. onControllerAddedObservable: Observable<WebXRInputSource>;
  52058. /**
  52059. * Event when a controller has been removed/disconnected
  52060. */
  52061. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52062. /**
  52063. * Initializes the WebXRInput
  52064. * @param xrSessionManager the xr session manager for this session
  52065. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52066. * @param options = initialization options for this xr input
  52067. */
  52068. constructor(
  52069. /**
  52070. * the xr session manager for this session
  52071. */
  52072. xrSessionManager: WebXRSessionManager,
  52073. /**
  52074. * the WebXR camera for this session. Mainly used for teleportation
  52075. */
  52076. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52077. private _onInputSourcesChange;
  52078. private _addAndRemoveControllers;
  52079. /**
  52080. * Disposes of the object
  52081. */
  52082. dispose(): void;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * This is the base class for all WebXR features.
  52088. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52089. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52090. */
  52091. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52092. protected _xrSessionManager: WebXRSessionManager;
  52093. private _attached;
  52094. private _removeOnDetach;
  52095. /**
  52096. * Is this feature disposed?
  52097. */
  52098. isDisposed: boolean;
  52099. /**
  52100. * Should auto-attach be disabled?
  52101. */
  52102. disableAutoAttach: boolean;
  52103. /**
  52104. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52105. */
  52106. xrNativeFeatureName: string;
  52107. /**
  52108. * Construct a new (abstract) WebXR feature
  52109. * @param _xrSessionManager the xr session manager for this feature
  52110. */
  52111. constructor(_xrSessionManager: WebXRSessionManager);
  52112. /**
  52113. * Is this feature attached
  52114. */
  52115. get attached(): boolean;
  52116. /**
  52117. * attach this feature
  52118. *
  52119. * @param force should attachment be forced (even when already attached)
  52120. * @returns true if successful, false is failed or already attached
  52121. */
  52122. attach(force?: boolean): boolean;
  52123. /**
  52124. * detach this feature.
  52125. *
  52126. * @returns true if successful, false if failed or already detached
  52127. */
  52128. detach(): boolean;
  52129. /**
  52130. * Dispose this feature and all of the resources attached
  52131. */
  52132. dispose(): void;
  52133. /**
  52134. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52135. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52136. *
  52137. * @returns whether or not the feature is compatible in this environment
  52138. */
  52139. isCompatible(): boolean;
  52140. /**
  52141. * This is used to register callbacks that will automatically be removed when detach is called.
  52142. * @param observable the observable to which the observer will be attached
  52143. * @param callback the callback to register
  52144. */
  52145. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52146. /**
  52147. * Code in this function will be executed on each xrFrame received from the browser.
  52148. * This function will not execute after the feature is detached.
  52149. * @param _xrFrame the current frame
  52150. */
  52151. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52152. }
  52153. }
  52154. declare module BABYLON {
  52155. /**
  52156. * Renders a layer on top of an existing scene
  52157. */
  52158. export class UtilityLayerRenderer implements IDisposable {
  52159. /** the original scene that will be rendered on top of */
  52160. originalScene: Scene;
  52161. private _pointerCaptures;
  52162. private _lastPointerEvents;
  52163. private static _DefaultUtilityLayer;
  52164. private static _DefaultKeepDepthUtilityLayer;
  52165. private _sharedGizmoLight;
  52166. private _renderCamera;
  52167. /**
  52168. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52169. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52170. * @returns the camera that is used when rendering the utility layer
  52171. */
  52172. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52173. /**
  52174. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52175. * @param cam the camera that should be used when rendering the utility layer
  52176. */
  52177. setRenderCamera(cam: Nullable<Camera>): void;
  52178. /**
  52179. * @hidden
  52180. * Light which used by gizmos to get light shading
  52181. */
  52182. _getSharedGizmoLight(): HemisphericLight;
  52183. /**
  52184. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52185. */
  52186. pickUtilitySceneFirst: boolean;
  52187. /**
  52188. * 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)
  52189. */
  52190. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52191. /**
  52192. * 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)
  52193. */
  52194. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52195. /**
  52196. * The scene that is rendered on top of the original scene
  52197. */
  52198. utilityLayerScene: Scene;
  52199. /**
  52200. * If the utility layer should automatically be rendered on top of existing scene
  52201. */
  52202. shouldRender: boolean;
  52203. /**
  52204. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52205. */
  52206. onlyCheckPointerDownEvents: boolean;
  52207. /**
  52208. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52209. */
  52210. processAllEvents: boolean;
  52211. /**
  52212. * Observable raised when the pointer move from the utility layer scene to the main scene
  52213. */
  52214. onPointerOutObservable: Observable<number>;
  52215. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52216. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52217. private _afterRenderObserver;
  52218. private _sceneDisposeObserver;
  52219. private _originalPointerObserver;
  52220. /**
  52221. * Instantiates a UtilityLayerRenderer
  52222. * @param originalScene the original scene that will be rendered on top of
  52223. * @param handleEvents boolean indicating if the utility layer should handle events
  52224. */
  52225. constructor(
  52226. /** the original scene that will be rendered on top of */
  52227. originalScene: Scene, handleEvents?: boolean);
  52228. private _notifyObservers;
  52229. /**
  52230. * Renders the utility layers scene on top of the original scene
  52231. */
  52232. render(): void;
  52233. /**
  52234. * Disposes of the renderer
  52235. */
  52236. dispose(): void;
  52237. private _updateCamera;
  52238. }
  52239. }
  52240. declare module BABYLON {
  52241. /**
  52242. * Options interface for the pointer selection module
  52243. */
  52244. export interface IWebXRControllerPointerSelectionOptions {
  52245. /**
  52246. * if provided, this scene will be used to render meshes.
  52247. */
  52248. customUtilityLayerScene?: Scene;
  52249. /**
  52250. * 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)
  52251. * If not disabled, the last picked point will be used to execute a pointer up event
  52252. * If disabled, pointer up event will be triggered right after the pointer down event.
  52253. * Used in screen and gaze target ray mode only
  52254. */
  52255. disablePointerUpOnTouchOut: boolean;
  52256. /**
  52257. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52258. */
  52259. forceGazeMode: boolean;
  52260. /**
  52261. * 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
  52262. * to start a new countdown to the pointer down event.
  52263. * Defaults to 1.
  52264. */
  52265. gazeModePointerMovedFactor?: number;
  52266. /**
  52267. * Different button type to use instead of the main component
  52268. */
  52269. overrideButtonId?: string;
  52270. /**
  52271. * use this rendering group id for the meshes (optional)
  52272. */
  52273. renderingGroupId?: number;
  52274. /**
  52275. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52276. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52277. * 3000 means 3 seconds between pointing at something and selecting it
  52278. */
  52279. timeToSelect?: number;
  52280. /**
  52281. * Should meshes created here be added to a utility layer or the main scene
  52282. */
  52283. useUtilityLayer?: boolean;
  52284. /**
  52285. * Optional WebXR camera to be used for gaze selection
  52286. */
  52287. gazeCamera?: WebXRCamera;
  52288. /**
  52289. * the xr input to use with this pointer selection
  52290. */
  52291. xrInput: WebXRInput;
  52292. /**
  52293. * Should the scene pointerX and pointerY update be disabled
  52294. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52295. * Disable in VR, if not needed.
  52296. * The first rig camera (left eye) will be used to calculate the projection
  52297. */
  52298. disableScenePointerVectorUpdate: boolean;
  52299. /**
  52300. * Enable pointer selection on all controllers instead of switching between them
  52301. */
  52302. enablePointerSelectionOnAllControllers?: boolean;
  52303. /**
  52304. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52305. * If switch is enabled, it will still allow the user to switch between the different controllers
  52306. */
  52307. preferredHandedness?: XRHandedness;
  52308. /**
  52309. * Disable switching the pointer selection from one controller to the other.
  52310. * 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
  52311. */
  52312. disableSwitchOnClick?: boolean;
  52313. /**
  52314. * The maximum distance of the pointer selection feature. Defaults to 100.
  52315. */
  52316. maxPointerDistance?: number;
  52317. }
  52318. /**
  52319. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52320. */
  52321. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52322. private readonly _options;
  52323. private static _idCounter;
  52324. private _attachController;
  52325. private _controllers;
  52326. private _scene;
  52327. private _tmpVectorForPickCompare;
  52328. private _attachedController;
  52329. /**
  52330. * The module's name
  52331. */
  52332. static readonly Name: string;
  52333. /**
  52334. * The (Babylon) version of this module.
  52335. * This is an integer representing the implementation version.
  52336. * This number does not correspond to the WebXR specs version
  52337. */
  52338. static readonly Version: number;
  52339. /**
  52340. * Disable lighting on the laser pointer (so it will always be visible)
  52341. */
  52342. disablePointerLighting: boolean;
  52343. /**
  52344. * Disable lighting on the selection mesh (so it will always be visible)
  52345. */
  52346. disableSelectionMeshLighting: boolean;
  52347. /**
  52348. * Should the laser pointer be displayed
  52349. */
  52350. displayLaserPointer: boolean;
  52351. /**
  52352. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52353. */
  52354. displaySelectionMesh: boolean;
  52355. /**
  52356. * This color will be set to the laser pointer when selection is triggered
  52357. */
  52358. laserPointerPickedColor: Color3;
  52359. /**
  52360. * Default color of the laser pointer
  52361. */
  52362. laserPointerDefaultColor: Color3;
  52363. /**
  52364. * default color of the selection ring
  52365. */
  52366. selectionMeshDefaultColor: Color3;
  52367. /**
  52368. * This color will be applied to the selection ring when selection is triggered
  52369. */
  52370. selectionMeshPickedColor: Color3;
  52371. /**
  52372. * Optional filter to be used for ray selection. This predicate shares behavior with
  52373. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52374. */
  52375. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52376. /**
  52377. * constructs a new background remover module
  52378. * @param _xrSessionManager the session manager for this module
  52379. * @param _options read-only options to be used in this module
  52380. */
  52381. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52382. /**
  52383. * attach this feature
  52384. * Will usually be called by the features manager
  52385. *
  52386. * @returns true if successful.
  52387. */
  52388. attach(): boolean;
  52389. /**
  52390. * detach this feature.
  52391. * Will usually be called by the features manager
  52392. *
  52393. * @returns true if successful.
  52394. */
  52395. detach(): boolean;
  52396. /**
  52397. * Will get the mesh under a specific pointer.
  52398. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52399. * @param controllerId the controllerId to check
  52400. * @returns The mesh under pointer or null if no mesh is under the pointer
  52401. */
  52402. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52403. /**
  52404. * Get the xr controller that correlates to the pointer id in the pointer event
  52405. *
  52406. * @param id the pointer id to search for
  52407. * @returns the controller that correlates to this id or null if not found
  52408. */
  52409. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52410. private _identityMatrix;
  52411. private _screenCoordinatesRef;
  52412. private _viewportRef;
  52413. protected _onXRFrame(_xrFrame: XRFrame): void;
  52414. private _attachGazeMode;
  52415. private _attachScreenRayMode;
  52416. private _attachTrackedPointerRayMode;
  52417. private _convertNormalToDirectionOfRay;
  52418. private _detachController;
  52419. private _generateNewMeshPair;
  52420. private _pickingMoved;
  52421. private _updatePointerDistance;
  52422. /** @hidden */
  52423. get lasterPointerDefaultColor(): Color3;
  52424. }
  52425. }
  52426. declare module BABYLON {
  52427. /**
  52428. * Button which can be used to enter a different mode of XR
  52429. */
  52430. export class WebXREnterExitUIButton {
  52431. /** button element */
  52432. element: HTMLElement;
  52433. /** XR initialization options for the button */
  52434. sessionMode: XRSessionMode;
  52435. /** Reference space type */
  52436. referenceSpaceType: XRReferenceSpaceType;
  52437. /**
  52438. * Creates a WebXREnterExitUIButton
  52439. * @param element button element
  52440. * @param sessionMode XR initialization session mode
  52441. * @param referenceSpaceType the type of reference space to be used
  52442. */
  52443. constructor(
  52444. /** button element */
  52445. element: HTMLElement,
  52446. /** XR initialization options for the button */
  52447. sessionMode: XRSessionMode,
  52448. /** Reference space type */
  52449. referenceSpaceType: XRReferenceSpaceType);
  52450. /**
  52451. * Extendable function which can be used to update the button's visuals when the state changes
  52452. * @param activeButton the current active button in the UI
  52453. */
  52454. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52455. }
  52456. /**
  52457. * Options to create the webXR UI
  52458. */
  52459. export class WebXREnterExitUIOptions {
  52460. /**
  52461. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52462. */
  52463. customButtons?: Array<WebXREnterExitUIButton>;
  52464. /**
  52465. * A reference space type to use when creating the default button.
  52466. * Default is local-floor
  52467. */
  52468. referenceSpaceType?: XRReferenceSpaceType;
  52469. /**
  52470. * Context to enter xr with
  52471. */
  52472. renderTarget?: Nullable<WebXRRenderTarget>;
  52473. /**
  52474. * A session mode to use when creating the default button.
  52475. * Default is immersive-vr
  52476. */
  52477. sessionMode?: XRSessionMode;
  52478. /**
  52479. * A list of optional features to init the session with
  52480. */
  52481. optionalFeatures?: string[];
  52482. /**
  52483. * A list of optional features to init the session with
  52484. */
  52485. requiredFeatures?: string[];
  52486. /**
  52487. * If defined, this function will be executed if the UI encounters an error when entering XR
  52488. */
  52489. onError?: (error: any) => void;
  52490. }
  52491. /**
  52492. * UI to allow the user to enter/exit XR mode
  52493. */
  52494. export class WebXREnterExitUI implements IDisposable {
  52495. private scene;
  52496. /** version of the options passed to this UI */
  52497. options: WebXREnterExitUIOptions;
  52498. private _activeButton;
  52499. private _buttons;
  52500. /**
  52501. * The HTML Div Element to which buttons are added.
  52502. */
  52503. readonly overlay: HTMLDivElement;
  52504. /**
  52505. * Fired every time the active button is changed.
  52506. *
  52507. * When xr is entered via a button that launches xr that button will be the callback parameter
  52508. *
  52509. * When exiting xr the callback parameter will be null)
  52510. */
  52511. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52512. /**
  52513. *
  52514. * @param scene babylon scene object to use
  52515. * @param options (read-only) version of the options passed to this UI
  52516. */
  52517. private constructor();
  52518. /**
  52519. * Creates UI to allow the user to enter/exit XR mode
  52520. * @param scene the scene to add the ui to
  52521. * @param helper the xr experience helper to enter/exit xr with
  52522. * @param options options to configure the UI
  52523. * @returns the created ui
  52524. */
  52525. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52526. /**
  52527. * Disposes of the XR UI component
  52528. */
  52529. dispose(): void;
  52530. private _updateButtons;
  52531. }
  52532. }
  52533. declare module BABYLON {
  52534. /**
  52535. * Class containing static functions to help procedurally build meshes
  52536. */
  52537. export class LinesBuilder {
  52538. /**
  52539. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52540. * * 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
  52541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52542. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52543. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52544. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52545. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52546. * * 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
  52547. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52550. * @param name defines the name of the new line system
  52551. * @param options defines the options used to create the line system
  52552. * @param scene defines the hosting scene
  52553. * @returns a new line system mesh
  52554. */
  52555. static CreateLineSystem(name: string, options: {
  52556. lines: Vector3[][];
  52557. updatable?: boolean;
  52558. instance?: Nullable<LinesMesh>;
  52559. colors?: Nullable<Color4[][]>;
  52560. useVertexAlpha?: boolean;
  52561. }, scene: Nullable<Scene>): LinesMesh;
  52562. /**
  52563. * Creates a line mesh
  52564. * 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
  52565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52566. * * The parameter `points` is an array successive Vector3
  52567. * * 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
  52568. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52569. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52570. * * When updating an instance, remember that only point positions can change, not the number of points
  52571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52573. * @param name defines the name of the new line system
  52574. * @param options defines the options used to create the line system
  52575. * @param scene defines the hosting scene
  52576. * @returns a new line mesh
  52577. */
  52578. static CreateLines(name: string, options: {
  52579. points: Vector3[];
  52580. updatable?: boolean;
  52581. instance?: Nullable<LinesMesh>;
  52582. colors?: Color4[];
  52583. useVertexAlpha?: boolean;
  52584. }, scene?: Nullable<Scene>): LinesMesh;
  52585. /**
  52586. * Creates a dashed line mesh
  52587. * * 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
  52588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52589. * * The parameter `points` is an array successive Vector3
  52590. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52591. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52592. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52593. * * 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
  52594. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52595. * * When updating an instance, remember that only point positions can change, not the number of points
  52596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52597. * @param name defines the name of the mesh
  52598. * @param options defines the options used to create the mesh
  52599. * @param scene defines the hosting scene
  52600. * @returns the dashed line mesh
  52601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52602. */
  52603. static CreateDashedLines(name: string, options: {
  52604. points: Vector3[];
  52605. dashSize?: number;
  52606. gapSize?: number;
  52607. dashNb?: number;
  52608. updatable?: boolean;
  52609. instance?: LinesMesh;
  52610. useVertexAlpha?: boolean;
  52611. }, scene?: Nullable<Scene>): LinesMesh;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Construction options for a timer
  52617. */
  52618. export interface ITimerOptions<T> {
  52619. /**
  52620. * Time-to-end
  52621. */
  52622. timeout: number;
  52623. /**
  52624. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52625. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52626. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52627. */
  52628. contextObservable: Observable<T>;
  52629. /**
  52630. * Optional parameters when adding an observer to the observable
  52631. */
  52632. observableParameters?: {
  52633. mask?: number;
  52634. insertFirst?: boolean;
  52635. scope?: any;
  52636. };
  52637. /**
  52638. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52639. */
  52640. breakCondition?: (data?: ITimerData<T>) => boolean;
  52641. /**
  52642. * Will be triggered when the time condition has met
  52643. */
  52644. onEnded?: (data: ITimerData<any>) => void;
  52645. /**
  52646. * Will be triggered when the break condition has met (prematurely ended)
  52647. */
  52648. onAborted?: (data: ITimerData<any>) => void;
  52649. /**
  52650. * Optional function to execute on each tick (or count)
  52651. */
  52652. onTick?: (data: ITimerData<any>) => void;
  52653. }
  52654. /**
  52655. * An interface defining the data sent by the timer
  52656. */
  52657. export interface ITimerData<T> {
  52658. /**
  52659. * When did it start
  52660. */
  52661. startTime: number;
  52662. /**
  52663. * Time now
  52664. */
  52665. currentTime: number;
  52666. /**
  52667. * Time passed since started
  52668. */
  52669. deltaTime: number;
  52670. /**
  52671. * How much is completed, in [0.0...1.0].
  52672. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52673. */
  52674. completeRate: number;
  52675. /**
  52676. * What the registered observable sent in the last count
  52677. */
  52678. payload: T;
  52679. }
  52680. /**
  52681. * The current state of the timer
  52682. */
  52683. export enum TimerState {
  52684. /**
  52685. * Timer initialized, not yet started
  52686. */
  52687. INIT = 0,
  52688. /**
  52689. * Timer started and counting
  52690. */
  52691. STARTED = 1,
  52692. /**
  52693. * Timer ended (whether aborted or time reached)
  52694. */
  52695. ENDED = 2
  52696. }
  52697. /**
  52698. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52699. *
  52700. * @param options options with which to initialize this timer
  52701. */
  52702. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52703. /**
  52704. * An advanced implementation of a timer class
  52705. */
  52706. export class AdvancedTimer<T = any> implements IDisposable {
  52707. /**
  52708. * Will notify each time the timer calculates the remaining time
  52709. */
  52710. onEachCountObservable: Observable<ITimerData<T>>;
  52711. /**
  52712. * Will trigger when the timer was aborted due to the break condition
  52713. */
  52714. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52715. /**
  52716. * Will trigger when the timer ended successfully
  52717. */
  52718. onTimerEndedObservable: Observable<ITimerData<T>>;
  52719. /**
  52720. * Will trigger when the timer state has changed
  52721. */
  52722. onStateChangedObservable: Observable<TimerState>;
  52723. private _observer;
  52724. private _contextObservable;
  52725. private _observableParameters;
  52726. private _startTime;
  52727. private _timer;
  52728. private _state;
  52729. private _breakCondition;
  52730. private _timeToEnd;
  52731. private _breakOnNextTick;
  52732. /**
  52733. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52734. * @param options construction options for this advanced timer
  52735. */
  52736. constructor(options: ITimerOptions<T>);
  52737. /**
  52738. * set a breaking condition for this timer. Default is to never break during count
  52739. * @param predicate the new break condition. Returns true to break, false otherwise
  52740. */
  52741. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52742. /**
  52743. * Reset ALL associated observables in this advanced timer
  52744. */
  52745. clearObservables(): void;
  52746. /**
  52747. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52748. *
  52749. * @param timeToEnd how much time to measure until timer ended
  52750. */
  52751. start(timeToEnd?: number): void;
  52752. /**
  52753. * Will force a stop on the next tick.
  52754. */
  52755. stop(): void;
  52756. /**
  52757. * Dispose this timer, clearing all resources
  52758. */
  52759. dispose(): void;
  52760. private _setState;
  52761. private _tick;
  52762. private _stop;
  52763. }
  52764. }
  52765. declare module BABYLON {
  52766. /**
  52767. * The options container for the teleportation module
  52768. */
  52769. export interface IWebXRTeleportationOptions {
  52770. /**
  52771. * if provided, this scene will be used to render meshes.
  52772. */
  52773. customUtilityLayerScene?: Scene;
  52774. /**
  52775. * Values to configure the default target mesh
  52776. */
  52777. defaultTargetMeshOptions?: {
  52778. /**
  52779. * Fill color of the teleportation area
  52780. */
  52781. teleportationFillColor?: string;
  52782. /**
  52783. * Border color for the teleportation area
  52784. */
  52785. teleportationBorderColor?: string;
  52786. /**
  52787. * Disable the mesh's animation sequence
  52788. */
  52789. disableAnimation?: boolean;
  52790. /**
  52791. * Disable lighting on the material or the ring and arrow
  52792. */
  52793. disableLighting?: boolean;
  52794. /**
  52795. * Override the default material of the torus and arrow
  52796. */
  52797. torusArrowMaterial?: Material;
  52798. };
  52799. /**
  52800. * A list of meshes to use as floor meshes.
  52801. * Meshes can be added and removed after initializing the feature using the
  52802. * addFloorMesh and removeFloorMesh functions
  52803. * If empty, rotation will still work
  52804. */
  52805. floorMeshes?: AbstractMesh[];
  52806. /**
  52807. * use this rendering group id for the meshes (optional)
  52808. */
  52809. renderingGroupId?: number;
  52810. /**
  52811. * Should teleportation move only to snap points
  52812. */
  52813. snapPointsOnly?: boolean;
  52814. /**
  52815. * An array of points to which the teleportation will snap to.
  52816. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52817. */
  52818. snapPositions?: Vector3[];
  52819. /**
  52820. * How close should the teleportation ray be in order to snap to position.
  52821. * Default to 0.8 units (meters)
  52822. */
  52823. snapToPositionRadius?: number;
  52824. /**
  52825. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52826. * If you want to support rotation, make sure your mesh has a direction indicator.
  52827. *
  52828. * When left untouched, the default mesh will be initialized.
  52829. */
  52830. teleportationTargetMesh?: AbstractMesh;
  52831. /**
  52832. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52833. */
  52834. timeToTeleport?: number;
  52835. /**
  52836. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52837. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52838. */
  52839. useMainComponentOnly?: boolean;
  52840. /**
  52841. * Should meshes created here be added to a utility layer or the main scene
  52842. */
  52843. useUtilityLayer?: boolean;
  52844. /**
  52845. * Babylon XR Input class for controller
  52846. */
  52847. xrInput: WebXRInput;
  52848. /**
  52849. * Meshes that the teleportation ray cannot go through
  52850. */
  52851. pickBlockerMeshes?: AbstractMesh[];
  52852. }
  52853. /**
  52854. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52855. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52856. * the input of the attached controllers.
  52857. */
  52858. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52859. private _options;
  52860. private _controllers;
  52861. private _currentTeleportationControllerId;
  52862. private _floorMeshes;
  52863. private _quadraticBezierCurve;
  52864. private _selectionFeature;
  52865. private _snapToPositions;
  52866. private _snappedToPoint;
  52867. private _teleportationRingMaterial?;
  52868. private _tmpRay;
  52869. private _tmpVector;
  52870. private _tmpQuaternion;
  52871. /**
  52872. * The module's name
  52873. */
  52874. static readonly Name: string;
  52875. /**
  52876. * The (Babylon) version of this module.
  52877. * This is an integer representing the implementation version.
  52878. * This number does not correspond to the webxr specs version
  52879. */
  52880. static readonly Version: number;
  52881. /**
  52882. * Is movement backwards enabled
  52883. */
  52884. backwardsMovementEnabled: boolean;
  52885. /**
  52886. * Distance to travel when moving backwards
  52887. */
  52888. backwardsTeleportationDistance: number;
  52889. /**
  52890. * The distance from the user to the inspection point in the direction of the controller
  52891. * A higher number will allow the user to move further
  52892. * defaults to 5 (meters, in xr units)
  52893. */
  52894. parabolicCheckRadius: number;
  52895. /**
  52896. * Should the module support parabolic ray on top of direct ray
  52897. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52898. * Very helpful when moving between floors / different heights
  52899. */
  52900. parabolicRayEnabled: boolean;
  52901. /**
  52902. * How much rotation should be applied when rotating right and left
  52903. */
  52904. rotationAngle: number;
  52905. /**
  52906. * Is rotation enabled when moving forward?
  52907. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52908. */
  52909. rotationEnabled: boolean;
  52910. /**
  52911. * constructs a new anchor system
  52912. * @param _xrSessionManager an instance of WebXRSessionManager
  52913. * @param _options configuration object for this feature
  52914. */
  52915. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52916. /**
  52917. * Get the snapPointsOnly flag
  52918. */
  52919. get snapPointsOnly(): boolean;
  52920. /**
  52921. * Sets the snapPointsOnly flag
  52922. * @param snapToPoints should teleportation be exclusively to snap points
  52923. */
  52924. set snapPointsOnly(snapToPoints: boolean);
  52925. /**
  52926. * Add a new mesh to the floor meshes array
  52927. * @param mesh the mesh to use as floor mesh
  52928. */
  52929. addFloorMesh(mesh: AbstractMesh): void;
  52930. /**
  52931. * Add a new snap-to point to fix teleportation to this position
  52932. * @param newSnapPoint The new Snap-To point
  52933. */
  52934. addSnapPoint(newSnapPoint: Vector3): void;
  52935. attach(): boolean;
  52936. detach(): boolean;
  52937. dispose(): void;
  52938. /**
  52939. * Remove a mesh from the floor meshes array
  52940. * @param mesh the mesh to remove
  52941. */
  52942. removeFloorMesh(mesh: AbstractMesh): void;
  52943. /**
  52944. * Remove a mesh from the floor meshes array using its name
  52945. * @param name the mesh name to remove
  52946. */
  52947. removeFloorMeshByName(name: string): void;
  52948. /**
  52949. * 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
  52950. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52951. * @returns was the point found and removed or not
  52952. */
  52953. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52954. /**
  52955. * This function sets a selection feature that will be disabled when
  52956. * the forward ray is shown and will be reattached when hidden.
  52957. * This is used to remove the selection rays when moving.
  52958. * @param selectionFeature the feature to disable when forward movement is enabled
  52959. */
  52960. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52961. protected _onXRFrame(_xrFrame: XRFrame): void;
  52962. private _attachController;
  52963. private _createDefaultTargetMesh;
  52964. private _detachController;
  52965. private _findClosestSnapPointWithRadius;
  52966. private _setTargetMeshPosition;
  52967. private _setTargetMeshVisibility;
  52968. private _showParabolicPath;
  52969. private _teleportForward;
  52970. }
  52971. }
  52972. declare module BABYLON {
  52973. /**
  52974. * Options for the default xr helper
  52975. */
  52976. export class WebXRDefaultExperienceOptions {
  52977. /**
  52978. * Enable or disable default UI to enter XR
  52979. */
  52980. disableDefaultUI?: boolean;
  52981. /**
  52982. * Should teleportation not initialize. defaults to false.
  52983. */
  52984. disableTeleportation?: boolean;
  52985. /**
  52986. * Floor meshes that will be used for teleport
  52987. */
  52988. floorMeshes?: Array<AbstractMesh>;
  52989. /**
  52990. * If set to true, the first frame will not be used to reset position
  52991. * The first frame is mainly used when copying transformation from the old camera
  52992. * Mainly used in AR
  52993. */
  52994. ignoreNativeCameraTransformation?: boolean;
  52995. /**
  52996. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52997. */
  52998. inputOptions?: IWebXRInputOptions;
  52999. /**
  53000. * optional configuration for the output canvas
  53001. */
  53002. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53003. /**
  53004. * optional UI options. This can be used among other to change session mode and reference space type
  53005. */
  53006. uiOptions?: WebXREnterExitUIOptions;
  53007. /**
  53008. * When loading teleportation and pointer select, use stable versions instead of latest.
  53009. */
  53010. useStablePlugins?: boolean;
  53011. /**
  53012. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53013. */
  53014. renderingGroupId?: number;
  53015. /**
  53016. * A list of optional features to init the session with
  53017. * If set to true, all features we support will be added
  53018. */
  53019. optionalFeatures?: boolean | string[];
  53020. }
  53021. /**
  53022. * Default experience which provides a similar setup to the previous webVRExperience
  53023. */
  53024. export class WebXRDefaultExperience {
  53025. /**
  53026. * Base experience
  53027. */
  53028. baseExperience: WebXRExperienceHelper;
  53029. /**
  53030. * Enables ui for entering/exiting xr
  53031. */
  53032. enterExitUI: WebXREnterExitUI;
  53033. /**
  53034. * Input experience extension
  53035. */
  53036. input: WebXRInput;
  53037. /**
  53038. * Enables laser pointer and selection
  53039. */
  53040. pointerSelection: WebXRControllerPointerSelection;
  53041. /**
  53042. * Default target xr should render to
  53043. */
  53044. renderTarget: WebXRRenderTarget;
  53045. /**
  53046. * Enables teleportation
  53047. */
  53048. teleportation: WebXRMotionControllerTeleportation;
  53049. private constructor();
  53050. /**
  53051. * Creates the default xr experience
  53052. * @param scene scene
  53053. * @param options options for basic configuration
  53054. * @returns resulting WebXRDefaultExperience
  53055. */
  53056. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53057. /**
  53058. * DIsposes of the experience helper
  53059. */
  53060. dispose(): void;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /**
  53065. * Options to modify the vr teleportation behavior.
  53066. */
  53067. export interface VRTeleportationOptions {
  53068. /**
  53069. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53070. */
  53071. floorMeshName?: string;
  53072. /**
  53073. * A list of meshes to be used as the teleportation floor. (default: empty)
  53074. */
  53075. floorMeshes?: Mesh[];
  53076. /**
  53077. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53078. */
  53079. teleportationMode?: number;
  53080. /**
  53081. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53082. */
  53083. teleportationTime?: number;
  53084. /**
  53085. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53086. */
  53087. teleportationSpeed?: number;
  53088. /**
  53089. * The easing function used in the animation or null for Linear. (default CircleEase)
  53090. */
  53091. easingFunction?: EasingFunction;
  53092. }
  53093. /**
  53094. * Options to modify the vr experience helper's behavior.
  53095. */
  53096. export interface VRExperienceHelperOptions extends WebVROptions {
  53097. /**
  53098. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53099. */
  53100. createDeviceOrientationCamera?: boolean;
  53101. /**
  53102. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53103. */
  53104. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53105. /**
  53106. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53107. */
  53108. laserToggle?: boolean;
  53109. /**
  53110. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53111. */
  53112. floorMeshes?: Mesh[];
  53113. /**
  53114. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53115. */
  53116. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53117. /**
  53118. * Defines if WebXR should be used instead of WebVR (if available)
  53119. */
  53120. useXR?: boolean;
  53121. }
  53122. /**
  53123. * Event containing information after VR has been entered
  53124. */
  53125. export class OnAfterEnteringVRObservableEvent {
  53126. /**
  53127. * If entering vr was successful
  53128. */
  53129. success: boolean;
  53130. }
  53131. /**
  53132. * Helps to quickly add VR support to an existing scene.
  53133. * See https://doc.babylonjs.com/how_to/webvr_helper
  53134. */
  53135. export class VRExperienceHelper {
  53136. /** Options to modify the vr experience helper's behavior. */
  53137. webVROptions: VRExperienceHelperOptions;
  53138. private _scene;
  53139. private _position;
  53140. private _btnVR;
  53141. private _btnVRDisplayed;
  53142. private _webVRsupported;
  53143. private _webVRready;
  53144. private _webVRrequesting;
  53145. private _webVRpresenting;
  53146. private _hasEnteredVR;
  53147. private _fullscreenVRpresenting;
  53148. private _inputElement;
  53149. private _webVRCamera;
  53150. private _vrDeviceOrientationCamera;
  53151. private _deviceOrientationCamera;
  53152. private _existingCamera;
  53153. private _onKeyDown;
  53154. private _onVrDisplayPresentChange;
  53155. private _onVRDisplayChanged;
  53156. private _onVRRequestPresentStart;
  53157. private _onVRRequestPresentComplete;
  53158. /**
  53159. * 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)
  53160. */
  53161. enableGazeEvenWhenNoPointerLock: boolean;
  53162. /**
  53163. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53164. */
  53165. exitVROnDoubleTap: boolean;
  53166. /**
  53167. * Observable raised right before entering VR.
  53168. */
  53169. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53170. /**
  53171. * Observable raised when entering VR has completed.
  53172. */
  53173. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53174. /**
  53175. * Observable raised when exiting VR.
  53176. */
  53177. onExitingVRObservable: Observable<VRExperienceHelper>;
  53178. /**
  53179. * Observable raised when controller mesh is loaded.
  53180. */
  53181. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53182. /** Return this.onEnteringVRObservable
  53183. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53184. */
  53185. get onEnteringVR(): Observable<VRExperienceHelper>;
  53186. /** Return this.onExitingVRObservable
  53187. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53188. */
  53189. get onExitingVR(): Observable<VRExperienceHelper>;
  53190. /** Return this.onControllerMeshLoadedObservable
  53191. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53192. */
  53193. get onControllerMeshLoaded(): Observable<WebVRController>;
  53194. private _rayLength;
  53195. private _useCustomVRButton;
  53196. private _teleportationRequested;
  53197. private _teleportActive;
  53198. private _floorMeshName;
  53199. private _floorMeshesCollection;
  53200. private _teleportationMode;
  53201. private _teleportationTime;
  53202. private _teleportationSpeed;
  53203. private _teleportationEasing;
  53204. private _rotationAllowed;
  53205. private _teleportBackwardsVector;
  53206. private _teleportationTarget;
  53207. private _isDefaultTeleportationTarget;
  53208. private _postProcessMove;
  53209. private _teleportationFillColor;
  53210. private _teleportationBorderColor;
  53211. private _rotationAngle;
  53212. private _haloCenter;
  53213. private _cameraGazer;
  53214. private _padSensibilityUp;
  53215. private _padSensibilityDown;
  53216. private _leftController;
  53217. private _rightController;
  53218. private _gazeColor;
  53219. private _laserColor;
  53220. private _pickedLaserColor;
  53221. private _pickedGazeColor;
  53222. /**
  53223. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53224. */
  53225. onNewMeshSelected: Observable<AbstractMesh>;
  53226. /**
  53227. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53228. * This observable will provide the mesh and the controller used to select the mesh
  53229. */
  53230. onMeshSelectedWithController: Observable<{
  53231. mesh: AbstractMesh;
  53232. controller: WebVRController;
  53233. }>;
  53234. /**
  53235. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53236. */
  53237. onNewMeshPicked: Observable<PickingInfo>;
  53238. private _circleEase;
  53239. /**
  53240. * Observable raised before camera teleportation
  53241. */
  53242. onBeforeCameraTeleport: Observable<Vector3>;
  53243. /**
  53244. * Observable raised after camera teleportation
  53245. */
  53246. onAfterCameraTeleport: Observable<Vector3>;
  53247. /**
  53248. * Observable raised when current selected mesh gets unselected
  53249. */
  53250. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53251. private _raySelectionPredicate;
  53252. /**
  53253. * To be optionaly changed by user to define custom ray selection
  53254. */
  53255. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53256. /**
  53257. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53258. */
  53259. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53260. /**
  53261. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53262. */
  53263. teleportationEnabled: boolean;
  53264. private _defaultHeight;
  53265. private _teleportationInitialized;
  53266. private _interactionsEnabled;
  53267. private _interactionsRequested;
  53268. private _displayGaze;
  53269. private _displayLaserPointer;
  53270. /**
  53271. * The mesh used to display where the user is going to teleport.
  53272. */
  53273. get teleportationTarget(): Mesh;
  53274. /**
  53275. * Sets the mesh to be used to display where the user is going to teleport.
  53276. */
  53277. set teleportationTarget(value: Mesh);
  53278. /**
  53279. * 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
  53280. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53281. * See https://doc.babylonjs.com/resources/baking_transformations
  53282. */
  53283. get gazeTrackerMesh(): Mesh;
  53284. set gazeTrackerMesh(value: Mesh);
  53285. /**
  53286. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53287. */
  53288. updateGazeTrackerScale: boolean;
  53289. /**
  53290. * If the gaze trackers color should be updated when selecting meshes
  53291. */
  53292. updateGazeTrackerColor: boolean;
  53293. /**
  53294. * If the controller laser color should be updated when selecting meshes
  53295. */
  53296. updateControllerLaserColor: boolean;
  53297. /**
  53298. * The gaze tracking mesh corresponding to the left controller
  53299. */
  53300. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53301. /**
  53302. * The gaze tracking mesh corresponding to the right controller
  53303. */
  53304. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53305. /**
  53306. * If the ray of the gaze should be displayed.
  53307. */
  53308. get displayGaze(): boolean;
  53309. /**
  53310. * Sets if the ray of the gaze should be displayed.
  53311. */
  53312. set displayGaze(value: boolean);
  53313. /**
  53314. * If the ray of the LaserPointer should be displayed.
  53315. */
  53316. get displayLaserPointer(): boolean;
  53317. /**
  53318. * Sets if the ray of the LaserPointer should be displayed.
  53319. */
  53320. set displayLaserPointer(value: boolean);
  53321. /**
  53322. * The deviceOrientationCamera used as the camera when not in VR.
  53323. */
  53324. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53325. /**
  53326. * Based on the current WebVR support, returns the current VR camera used.
  53327. */
  53328. get currentVRCamera(): Nullable<Camera>;
  53329. /**
  53330. * The webVRCamera which is used when in VR.
  53331. */
  53332. get webVRCamera(): WebVRFreeCamera;
  53333. /**
  53334. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53335. */
  53336. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53337. /**
  53338. * The html button that is used to trigger entering into VR.
  53339. */
  53340. get vrButton(): Nullable<HTMLButtonElement>;
  53341. private get _teleportationRequestInitiated();
  53342. /**
  53343. * Defines whether or not Pointer lock should be requested when switching to
  53344. * full screen.
  53345. */
  53346. requestPointerLockOnFullScreen: boolean;
  53347. /**
  53348. * If asking to force XR, this will be populated with the default xr experience
  53349. */
  53350. xr: WebXRDefaultExperience;
  53351. /**
  53352. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53353. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53354. */
  53355. xrTestDone: boolean;
  53356. /**
  53357. * Instantiates a VRExperienceHelper.
  53358. * Helps to quickly add VR support to an existing scene.
  53359. * @param scene The scene the VRExperienceHelper belongs to.
  53360. * @param webVROptions Options to modify the vr experience helper's behavior.
  53361. */
  53362. constructor(scene: Scene,
  53363. /** Options to modify the vr experience helper's behavior. */
  53364. webVROptions?: VRExperienceHelperOptions);
  53365. private completeVRInit;
  53366. private _onDefaultMeshLoaded;
  53367. private _onResize;
  53368. private _onFullscreenChange;
  53369. /**
  53370. * Gets a value indicating if we are currently in VR mode.
  53371. */
  53372. get isInVRMode(): boolean;
  53373. private onVrDisplayPresentChange;
  53374. private onVRDisplayChanged;
  53375. private moveButtonToBottomRight;
  53376. private displayVRButton;
  53377. private updateButtonVisibility;
  53378. private _cachedAngularSensibility;
  53379. /**
  53380. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53381. * Otherwise, will use the fullscreen API.
  53382. */
  53383. enterVR(): void;
  53384. /**
  53385. * Attempt to exit VR, or fullscreen.
  53386. */
  53387. exitVR(): void;
  53388. /**
  53389. * The position of the vr experience helper.
  53390. */
  53391. get position(): Vector3;
  53392. /**
  53393. * Sets the position of the vr experience helper.
  53394. */
  53395. set position(value: Vector3);
  53396. /**
  53397. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53398. */
  53399. enableInteractions(): void;
  53400. private get _noControllerIsActive();
  53401. private beforeRender;
  53402. private _isTeleportationFloor;
  53403. /**
  53404. * Adds a floor mesh to be used for teleportation.
  53405. * @param floorMesh the mesh to be used for teleportation.
  53406. */
  53407. addFloorMesh(floorMesh: Mesh): void;
  53408. /**
  53409. * Removes a floor mesh from being used for teleportation.
  53410. * @param floorMesh the mesh to be removed.
  53411. */
  53412. removeFloorMesh(floorMesh: Mesh): void;
  53413. /**
  53414. * Enables interactions and teleportation using the VR controllers and gaze.
  53415. * @param vrTeleportationOptions options to modify teleportation behavior.
  53416. */
  53417. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53418. private _onNewGamepadConnected;
  53419. private _tryEnableInteractionOnController;
  53420. private _onNewGamepadDisconnected;
  53421. private _enableInteractionOnController;
  53422. private _checkTeleportWithRay;
  53423. private _checkRotate;
  53424. private _checkTeleportBackwards;
  53425. private _enableTeleportationOnController;
  53426. private _createTeleportationCircles;
  53427. private _displayTeleportationTarget;
  53428. private _hideTeleportationTarget;
  53429. private _rotateCamera;
  53430. private _moveTeleportationSelectorTo;
  53431. private _workingVector;
  53432. private _workingQuaternion;
  53433. private _workingMatrix;
  53434. /**
  53435. * Time Constant Teleportation Mode
  53436. */
  53437. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53438. /**
  53439. * Speed Constant Teleportation Mode
  53440. */
  53441. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53442. /**
  53443. * Teleports the users feet to the desired location
  53444. * @param location The location where the user's feet should be placed
  53445. */
  53446. teleportCamera(location: Vector3): void;
  53447. private _convertNormalToDirectionOfRay;
  53448. private _castRayAndSelectObject;
  53449. private _notifySelectedMeshUnselected;
  53450. /**
  53451. * Permanently set new colors for the laser pointer
  53452. * @param color the new laser color
  53453. * @param pickedColor the new laser color when picked mesh detected
  53454. */
  53455. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53456. /**
  53457. * Set lighting enabled / disabled on the laser pointer of both controllers
  53458. * @param enabled should the lighting be enabled on the laser pointer
  53459. */
  53460. setLaserLightingState(enabled?: boolean): void;
  53461. /**
  53462. * Permanently set new colors for the gaze pointer
  53463. * @param color the new gaze color
  53464. * @param pickedColor the new gaze color when picked mesh detected
  53465. */
  53466. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53467. /**
  53468. * Sets the color of the laser ray from the vr controllers.
  53469. * @param color new color for the ray.
  53470. */
  53471. changeLaserColor(color: Color3): void;
  53472. /**
  53473. * Sets the color of the ray from the vr headsets gaze.
  53474. * @param color new color for the ray.
  53475. */
  53476. changeGazeColor(color: Color3): void;
  53477. /**
  53478. * Exits VR and disposes of the vr experience helper
  53479. */
  53480. dispose(): void;
  53481. /**
  53482. * Gets the name of the VRExperienceHelper class
  53483. * @returns "VRExperienceHelper"
  53484. */
  53485. getClassName(): string;
  53486. }
  53487. }
  53488. declare module BABYLON {
  53489. /**
  53490. * Contains an array of blocks representing the octree
  53491. */
  53492. export interface IOctreeContainer<T> {
  53493. /**
  53494. * Blocks within the octree
  53495. */
  53496. blocks: Array<OctreeBlock<T>>;
  53497. }
  53498. /**
  53499. * Class used to store a cell in an octree
  53500. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53501. */
  53502. export class OctreeBlock<T> {
  53503. /**
  53504. * Gets the content of the current block
  53505. */
  53506. entries: T[];
  53507. /**
  53508. * Gets the list of block children
  53509. */
  53510. blocks: Array<OctreeBlock<T>>;
  53511. private _depth;
  53512. private _maxDepth;
  53513. private _capacity;
  53514. private _minPoint;
  53515. private _maxPoint;
  53516. private _boundingVectors;
  53517. private _creationFunc;
  53518. /**
  53519. * Creates a new block
  53520. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53521. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53522. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53523. * @param depth defines the current depth of this block in the octree
  53524. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53525. * @param creationFunc defines a callback to call when an element is added to the block
  53526. */
  53527. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53528. /**
  53529. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53530. */
  53531. get capacity(): number;
  53532. /**
  53533. * Gets the minimum vector (in world space) of the block's bounding box
  53534. */
  53535. get minPoint(): Vector3;
  53536. /**
  53537. * Gets the maximum vector (in world space) of the block's bounding box
  53538. */
  53539. get maxPoint(): Vector3;
  53540. /**
  53541. * Add a new element to this block
  53542. * @param entry defines the element to add
  53543. */
  53544. addEntry(entry: T): void;
  53545. /**
  53546. * Remove an element from this block
  53547. * @param entry defines the element to remove
  53548. */
  53549. removeEntry(entry: T): void;
  53550. /**
  53551. * Add an array of elements to this block
  53552. * @param entries defines the array of elements to add
  53553. */
  53554. addEntries(entries: T[]): void;
  53555. /**
  53556. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53557. * @param frustumPlanes defines the frustum planes to test
  53558. * @param selection defines the array to store current content if selection is positive
  53559. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53560. */
  53561. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53562. /**
  53563. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53564. * @param sphereCenter defines the bounding sphere center
  53565. * @param sphereRadius defines the bounding sphere radius
  53566. * @param selection defines the array to store current content if selection is positive
  53567. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53568. */
  53569. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53570. /**
  53571. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53572. * @param ray defines the ray to test with
  53573. * @param selection defines the array to store current content if selection is positive
  53574. */
  53575. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53576. /**
  53577. * Subdivide the content into child blocks (this block will then be empty)
  53578. */
  53579. createInnerBlocks(): void;
  53580. /**
  53581. * @hidden
  53582. */
  53583. 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;
  53584. }
  53585. }
  53586. declare module BABYLON {
  53587. /**
  53588. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53590. */
  53591. export class Octree<T> {
  53592. /** 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.) */
  53593. maxDepth: number;
  53594. /**
  53595. * Blocks within the octree containing objects
  53596. */
  53597. blocks: Array<OctreeBlock<T>>;
  53598. /**
  53599. * Content stored in the octree
  53600. */
  53601. dynamicContent: T[];
  53602. private _maxBlockCapacity;
  53603. private _selectionContent;
  53604. private _creationFunc;
  53605. /**
  53606. * Creates a octree
  53607. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53608. * @param creationFunc function to be used to instatiate the octree
  53609. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53610. * @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.)
  53611. */
  53612. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53613. /** 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.) */
  53614. maxDepth?: number);
  53615. /**
  53616. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53617. * @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);
  53618. * @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);
  53619. * @param entries meshes to be added to the octree blocks
  53620. */
  53621. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53622. /**
  53623. * Adds a mesh to the octree
  53624. * @param entry Mesh to add to the octree
  53625. */
  53626. addMesh(entry: T): void;
  53627. /**
  53628. * Remove an element from the octree
  53629. * @param entry defines the element to remove
  53630. */
  53631. removeMesh(entry: T): void;
  53632. /**
  53633. * Selects an array of meshes within the frustum
  53634. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53635. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53636. * @returns array of meshes within the frustum
  53637. */
  53638. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53639. /**
  53640. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53641. * @param sphereCenter defines the bounding sphere center
  53642. * @param sphereRadius defines the bounding sphere radius
  53643. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53644. * @returns an array of objects that intersect the sphere
  53645. */
  53646. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53647. /**
  53648. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53649. * @param ray defines the ray to test with
  53650. * @returns array of intersected objects
  53651. */
  53652. intersectsRay(ray: Ray): SmartArray<T>;
  53653. /**
  53654. * Adds a mesh into the octree block if it intersects the block
  53655. */
  53656. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53657. /**
  53658. * Adds a submesh into the octree block if it intersects the block
  53659. */
  53660. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53661. }
  53662. }
  53663. declare module BABYLON {
  53664. interface Scene {
  53665. /**
  53666. * @hidden
  53667. * Backing Filed
  53668. */
  53669. _selectionOctree: Octree<AbstractMesh>;
  53670. /**
  53671. * Gets the octree used to boost mesh selection (picking)
  53672. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53673. */
  53674. selectionOctree: Octree<AbstractMesh>;
  53675. /**
  53676. * Creates or updates the octree used to boost selection (picking)
  53677. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53678. * @param maxCapacity defines the maximum capacity per leaf
  53679. * @param maxDepth defines the maximum depth of the octree
  53680. * @returns an octree of AbstractMesh
  53681. */
  53682. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53683. }
  53684. interface AbstractMesh {
  53685. /**
  53686. * @hidden
  53687. * Backing Field
  53688. */
  53689. _submeshesOctree: Octree<SubMesh>;
  53690. /**
  53691. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53692. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53693. * @param maxCapacity defines the maximum size of each block (64 by default)
  53694. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53695. * @returns the new octree
  53696. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53698. */
  53699. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53700. }
  53701. /**
  53702. * Defines the octree scene component responsible to manage any octrees
  53703. * in a given scene.
  53704. */
  53705. export class OctreeSceneComponent {
  53706. /**
  53707. * The component name help to identify the component in the list of scene components.
  53708. */
  53709. readonly name: string;
  53710. /**
  53711. * The scene the component belongs to.
  53712. */
  53713. scene: Scene;
  53714. /**
  53715. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53716. */
  53717. readonly checksIsEnabled: boolean;
  53718. /**
  53719. * Creates a new instance of the component for the given scene
  53720. * @param scene Defines the scene to register the component in
  53721. */
  53722. constructor(scene: Scene);
  53723. /**
  53724. * Registers the component in a given scene
  53725. */
  53726. register(): void;
  53727. /**
  53728. * Return the list of active meshes
  53729. * @returns the list of active meshes
  53730. */
  53731. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53732. /**
  53733. * Return the list of active sub meshes
  53734. * @param mesh The mesh to get the candidates sub meshes from
  53735. * @returns the list of active sub meshes
  53736. */
  53737. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53738. private _tempRay;
  53739. /**
  53740. * Return the list of sub meshes intersecting with a given local ray
  53741. * @param mesh defines the mesh to find the submesh for
  53742. * @param localRay defines the ray in local space
  53743. * @returns the list of intersecting sub meshes
  53744. */
  53745. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53746. /**
  53747. * Return the list of sub meshes colliding with a collider
  53748. * @param mesh defines the mesh to find the submesh for
  53749. * @param collider defines the collider to evaluate the collision against
  53750. * @returns the list of colliding sub meshes
  53751. */
  53752. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53753. /**
  53754. * Rebuilds the elements related to this component in case of
  53755. * context lost for instance.
  53756. */
  53757. rebuild(): void;
  53758. /**
  53759. * Disposes the component and the associated ressources.
  53760. */
  53761. dispose(): void;
  53762. }
  53763. }
  53764. declare module BABYLON {
  53765. /**
  53766. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53767. */
  53768. export class Gizmo implements IDisposable {
  53769. /** The utility layer the gizmo will be added to */
  53770. gizmoLayer: UtilityLayerRenderer;
  53771. /**
  53772. * The root mesh of the gizmo
  53773. */
  53774. _rootMesh: Mesh;
  53775. private _attachedMesh;
  53776. private _attachedNode;
  53777. /**
  53778. * Ratio for the scale of the gizmo (Default: 1)
  53779. */
  53780. protected _scaleRatio: number;
  53781. /**
  53782. * boolean updated by pointermove when a gizmo mesh is hovered
  53783. */
  53784. protected _isHovered: boolean;
  53785. /**
  53786. * Ratio for the scale of the gizmo (Default: 1)
  53787. */
  53788. set scaleRatio(value: number);
  53789. get scaleRatio(): number;
  53790. /**
  53791. * True when the mouse pointer is hovered a gizmo mesh
  53792. */
  53793. get isHovered(): boolean;
  53794. /**
  53795. * If a custom mesh has been set (Default: false)
  53796. */
  53797. protected _customMeshSet: boolean;
  53798. /**
  53799. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53800. * * When set, interactions will be enabled
  53801. */
  53802. get attachedMesh(): Nullable<AbstractMesh>;
  53803. set attachedMesh(value: Nullable<AbstractMesh>);
  53804. /**
  53805. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53806. * * When set, interactions will be enabled
  53807. */
  53808. get attachedNode(): Nullable<Node>;
  53809. set attachedNode(value: Nullable<Node>);
  53810. /**
  53811. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53812. * @param mesh The mesh to replace the default mesh of the gizmo
  53813. */
  53814. setCustomMesh(mesh: Mesh): void;
  53815. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53816. /**
  53817. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53818. */
  53819. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53820. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53821. /**
  53822. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53823. */
  53824. updateGizmoPositionToMatchAttachedMesh: boolean;
  53825. /**
  53826. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53827. */
  53828. updateScale: boolean;
  53829. protected _interactionsEnabled: boolean;
  53830. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53831. private _beforeRenderObserver;
  53832. private _tempQuaternion;
  53833. private _tempVector;
  53834. private _tempVector2;
  53835. private _tempMatrix1;
  53836. private _tempMatrix2;
  53837. private _rightHandtoLeftHandMatrix;
  53838. /**
  53839. * Creates a gizmo
  53840. * @param gizmoLayer The utility layer the gizmo will be added to
  53841. */
  53842. constructor(
  53843. /** The utility layer the gizmo will be added to */
  53844. gizmoLayer?: UtilityLayerRenderer);
  53845. /**
  53846. * Updates the gizmo to match the attached mesh's position/rotation
  53847. */
  53848. protected _update(): void;
  53849. /**
  53850. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53851. * @param value Node, TransformNode or mesh
  53852. */
  53853. protected _matrixChanged(): void;
  53854. /**
  53855. * Disposes of the gizmo
  53856. */
  53857. dispose(): void;
  53858. }
  53859. }
  53860. declare module BABYLON {
  53861. /**
  53862. * Single plane drag gizmo
  53863. */
  53864. export class PlaneDragGizmo extends Gizmo {
  53865. /**
  53866. * Drag behavior responsible for the gizmos dragging interactions
  53867. */
  53868. dragBehavior: PointerDragBehavior;
  53869. private _pointerObserver;
  53870. /**
  53871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53872. */
  53873. snapDistance: number;
  53874. /**
  53875. * Event that fires each time the gizmo snaps to a new location.
  53876. * * snapDistance is the the change in distance
  53877. */
  53878. onSnapObservable: Observable<{
  53879. snapDistance: number;
  53880. }>;
  53881. private _plane;
  53882. private _coloredMaterial;
  53883. private _hoverMaterial;
  53884. private _isEnabled;
  53885. private _parent;
  53886. /** @hidden */
  53887. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53888. /** @hidden */
  53889. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53890. /**
  53891. * Creates a PlaneDragGizmo
  53892. * @param gizmoLayer The utility layer the gizmo will be added to
  53893. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53894. * @param color The color of the gizmo
  53895. */
  53896. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53897. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53898. /**
  53899. * If the gizmo is enabled
  53900. */
  53901. set isEnabled(value: boolean);
  53902. get isEnabled(): boolean;
  53903. /**
  53904. * Disposes of the gizmo
  53905. */
  53906. dispose(): void;
  53907. }
  53908. }
  53909. declare module BABYLON {
  53910. /**
  53911. * Gizmo that enables dragging a mesh along 3 axis
  53912. */
  53913. export class PositionGizmo extends Gizmo {
  53914. /**
  53915. * Internal gizmo used for interactions on the x axis
  53916. */
  53917. xGizmo: AxisDragGizmo;
  53918. /**
  53919. * Internal gizmo used for interactions on the y axis
  53920. */
  53921. yGizmo: AxisDragGizmo;
  53922. /**
  53923. * Internal gizmo used for interactions on the z axis
  53924. */
  53925. zGizmo: AxisDragGizmo;
  53926. /**
  53927. * Internal gizmo used for interactions on the yz plane
  53928. */
  53929. xPlaneGizmo: PlaneDragGizmo;
  53930. /**
  53931. * Internal gizmo used for interactions on the xz plane
  53932. */
  53933. yPlaneGizmo: PlaneDragGizmo;
  53934. /**
  53935. * Internal gizmo used for interactions on the xy plane
  53936. */
  53937. zPlaneGizmo: PlaneDragGizmo;
  53938. /**
  53939. * private variables
  53940. */
  53941. private _meshAttached;
  53942. private _nodeAttached;
  53943. private _snapDistance;
  53944. /** Fires an event when any of it's sub gizmos are dragged */
  53945. onDragStartObservable: Observable<unknown>;
  53946. /** Fires an event when any of it's sub gizmos are released from dragging */
  53947. onDragEndObservable: Observable<unknown>;
  53948. /**
  53949. * If set to true, planar drag is enabled
  53950. */
  53951. private _planarGizmoEnabled;
  53952. get attachedMesh(): Nullable<AbstractMesh>;
  53953. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53954. get attachedNode(): Nullable<Node>;
  53955. set attachedNode(node: Nullable<Node>);
  53956. /**
  53957. * True when the mouse pointer is hovering a gizmo mesh
  53958. */
  53959. get isHovered(): boolean;
  53960. /**
  53961. * Creates a PositionGizmo
  53962. * @param gizmoLayer The utility layer the gizmo will be added to
  53963. @param thickness display gizmo axis thickness
  53964. */
  53965. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53966. /**
  53967. * If the planar drag gizmo is enabled
  53968. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53969. */
  53970. set planarGizmoEnabled(value: boolean);
  53971. get planarGizmoEnabled(): boolean;
  53972. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53973. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53974. /**
  53975. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53976. */
  53977. set snapDistance(value: number);
  53978. get snapDistance(): number;
  53979. /**
  53980. * Ratio for the scale of the gizmo (Default: 1)
  53981. */
  53982. set scaleRatio(value: number);
  53983. get scaleRatio(): number;
  53984. /**
  53985. * Disposes of the gizmo
  53986. */
  53987. dispose(): void;
  53988. /**
  53989. * CustomMeshes are not supported by this gizmo
  53990. * @param mesh The mesh to replace the default mesh of the gizmo
  53991. */
  53992. setCustomMesh(mesh: Mesh): void;
  53993. }
  53994. }
  53995. declare module BABYLON {
  53996. /**
  53997. * Single axis drag gizmo
  53998. */
  53999. export class AxisDragGizmo extends Gizmo {
  54000. /**
  54001. * Drag behavior responsible for the gizmos dragging interactions
  54002. */
  54003. dragBehavior: PointerDragBehavior;
  54004. private _pointerObserver;
  54005. /**
  54006. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54007. */
  54008. snapDistance: number;
  54009. /**
  54010. * Event that fires each time the gizmo snaps to a new location.
  54011. * * snapDistance is the the change in distance
  54012. */
  54013. onSnapObservable: Observable<{
  54014. snapDistance: number;
  54015. }>;
  54016. private _isEnabled;
  54017. private _parent;
  54018. private _arrow;
  54019. private _coloredMaterial;
  54020. private _hoverMaterial;
  54021. /** @hidden */
  54022. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  54023. /** @hidden */
  54024. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54025. /**
  54026. * Creates an AxisDragGizmo
  54027. * @param gizmoLayer The utility layer the gizmo will be added to
  54028. * @param dragAxis The axis which the gizmo will be able to drag on
  54029. * @param color The color of the gizmo
  54030. * @param thickness display gizmo axis thickness
  54031. */
  54032. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54033. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54034. /**
  54035. * If the gizmo is enabled
  54036. */
  54037. set isEnabled(value: boolean);
  54038. get isEnabled(): boolean;
  54039. /**
  54040. * Disposes of the gizmo
  54041. */
  54042. dispose(): void;
  54043. }
  54044. }
  54045. declare module BABYLON.Debug {
  54046. /**
  54047. * The Axes viewer will show 3 axes in a specific point in space
  54048. */
  54049. export class AxesViewer {
  54050. private _xAxis;
  54051. private _yAxis;
  54052. private _zAxis;
  54053. private _scaleLinesFactor;
  54054. private _instanced;
  54055. /**
  54056. * Gets the hosting scene
  54057. */
  54058. scene: Nullable<Scene>;
  54059. /**
  54060. * Gets or sets a number used to scale line length
  54061. */
  54062. scaleLines: number;
  54063. /** Gets the node hierarchy used to render x-axis */
  54064. get xAxis(): TransformNode;
  54065. /** Gets the node hierarchy used to render y-axis */
  54066. get yAxis(): TransformNode;
  54067. /** Gets the node hierarchy used to render z-axis */
  54068. get zAxis(): TransformNode;
  54069. /**
  54070. * Creates a new AxesViewer
  54071. * @param scene defines the hosting scene
  54072. * @param scaleLines defines a number used to scale line length (1 by default)
  54073. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54074. * @param xAxis defines the node hierarchy used to render the x-axis
  54075. * @param yAxis defines the node hierarchy used to render the y-axis
  54076. * @param zAxis defines the node hierarchy used to render the z-axis
  54077. */
  54078. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54079. /**
  54080. * Force the viewer to update
  54081. * @param position defines the position of the viewer
  54082. * @param xaxis defines the x axis of the viewer
  54083. * @param yaxis defines the y axis of the viewer
  54084. * @param zaxis defines the z axis of the viewer
  54085. */
  54086. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54087. /**
  54088. * Creates an instance of this axes viewer.
  54089. * @returns a new axes viewer with instanced meshes
  54090. */
  54091. createInstance(): AxesViewer;
  54092. /** Releases resources */
  54093. dispose(): void;
  54094. private static _SetRenderingGroupId;
  54095. }
  54096. }
  54097. declare module BABYLON.Debug {
  54098. /**
  54099. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54100. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54101. */
  54102. export class BoneAxesViewer extends AxesViewer {
  54103. /**
  54104. * Gets or sets the target mesh where to display the axes viewer
  54105. */
  54106. mesh: Nullable<Mesh>;
  54107. /**
  54108. * Gets or sets the target bone where to display the axes viewer
  54109. */
  54110. bone: Nullable<Bone>;
  54111. /** Gets current position */
  54112. pos: Vector3;
  54113. /** Gets direction of X axis */
  54114. xaxis: Vector3;
  54115. /** Gets direction of Y axis */
  54116. yaxis: Vector3;
  54117. /** Gets direction of Z axis */
  54118. zaxis: Vector3;
  54119. /**
  54120. * Creates a new BoneAxesViewer
  54121. * @param scene defines the hosting scene
  54122. * @param bone defines the target bone
  54123. * @param mesh defines the target mesh
  54124. * @param scaleLines defines a scaling factor for line length (1 by default)
  54125. */
  54126. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54127. /**
  54128. * Force the viewer to update
  54129. */
  54130. update(): void;
  54131. /** Releases resources */
  54132. dispose(): void;
  54133. }
  54134. }
  54135. declare module BABYLON {
  54136. /**
  54137. * Interface used to define scene explorer extensibility option
  54138. */
  54139. export interface IExplorerExtensibilityOption {
  54140. /**
  54141. * Define the option label
  54142. */
  54143. label: string;
  54144. /**
  54145. * Defines the action to execute on click
  54146. */
  54147. action: (entity: any) => void;
  54148. }
  54149. /**
  54150. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54151. */
  54152. export interface IExplorerExtensibilityGroup {
  54153. /**
  54154. * Defines a predicate to test if a given type mut be extended
  54155. */
  54156. predicate: (entity: any) => boolean;
  54157. /**
  54158. * Gets the list of options added to a type
  54159. */
  54160. entries: IExplorerExtensibilityOption[];
  54161. }
  54162. /**
  54163. * Interface used to define the options to use to create the Inspector
  54164. */
  54165. export interface IInspectorOptions {
  54166. /**
  54167. * Display in overlay mode (default: false)
  54168. */
  54169. overlay?: boolean;
  54170. /**
  54171. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54172. */
  54173. globalRoot?: HTMLElement;
  54174. /**
  54175. * Display the Scene explorer
  54176. */
  54177. showExplorer?: boolean;
  54178. /**
  54179. * Display the property inspector
  54180. */
  54181. showInspector?: boolean;
  54182. /**
  54183. * Display in embed mode (both panes on the right)
  54184. */
  54185. embedMode?: boolean;
  54186. /**
  54187. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54188. */
  54189. handleResize?: boolean;
  54190. /**
  54191. * Allow the panes to popup (default: true)
  54192. */
  54193. enablePopup?: boolean;
  54194. /**
  54195. * Allow the panes to be closed by users (default: true)
  54196. */
  54197. enableClose?: boolean;
  54198. /**
  54199. * Optional list of extensibility entries
  54200. */
  54201. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54202. /**
  54203. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54204. */
  54205. inspectorURL?: string;
  54206. /**
  54207. * Optional initial tab (default to DebugLayerTab.Properties)
  54208. */
  54209. initialTab?: DebugLayerTab;
  54210. }
  54211. interface Scene {
  54212. /**
  54213. * @hidden
  54214. * Backing field
  54215. */
  54216. _debugLayer: DebugLayer;
  54217. /**
  54218. * Gets the debug layer (aka Inspector) associated with the scene
  54219. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54220. */
  54221. debugLayer: DebugLayer;
  54222. }
  54223. /**
  54224. * Enum of inspector action tab
  54225. */
  54226. export enum DebugLayerTab {
  54227. /**
  54228. * Properties tag (default)
  54229. */
  54230. Properties = 0,
  54231. /**
  54232. * Debug tab
  54233. */
  54234. Debug = 1,
  54235. /**
  54236. * Statistics tab
  54237. */
  54238. Statistics = 2,
  54239. /**
  54240. * Tools tab
  54241. */
  54242. Tools = 3,
  54243. /**
  54244. * Settings tab
  54245. */
  54246. Settings = 4
  54247. }
  54248. /**
  54249. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54250. * what is happening in your scene
  54251. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54252. */
  54253. export class DebugLayer {
  54254. /**
  54255. * Define the url to get the inspector script from.
  54256. * By default it uses the babylonjs CDN.
  54257. * @ignoreNaming
  54258. */
  54259. static InspectorURL: string;
  54260. private _scene;
  54261. private BJSINSPECTOR;
  54262. private _onPropertyChangedObservable?;
  54263. /**
  54264. * Observable triggered when a property is changed through the inspector.
  54265. */
  54266. get onPropertyChangedObservable(): any;
  54267. /**
  54268. * Instantiates a new debug layer.
  54269. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54270. * what is happening in your scene
  54271. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54272. * @param scene Defines the scene to inspect
  54273. */
  54274. constructor(scene: Scene);
  54275. /** Creates the inspector window. */
  54276. private _createInspector;
  54277. /**
  54278. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54279. * @param entity defines the entity to select
  54280. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54281. */
  54282. select(entity: any, lineContainerTitles?: string | string[]): void;
  54283. /** Get the inspector from bundle or global */
  54284. private _getGlobalInspector;
  54285. /**
  54286. * Get if the inspector is visible or not.
  54287. * @returns true if visible otherwise, false
  54288. */
  54289. isVisible(): boolean;
  54290. /**
  54291. * Hide the inspector and close its window.
  54292. */
  54293. hide(): void;
  54294. /**
  54295. * Update the scene in the inspector
  54296. */
  54297. setAsActiveScene(): void;
  54298. /**
  54299. * Launch the debugLayer.
  54300. * @param config Define the configuration of the inspector
  54301. * @return a promise fulfilled when the debug layer is visible
  54302. */
  54303. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54304. }
  54305. }
  54306. declare module BABYLON {
  54307. /**
  54308. * Class containing static functions to help procedurally build meshes
  54309. */
  54310. export class BoxBuilder {
  54311. /**
  54312. * Creates a box mesh
  54313. * * The parameter `size` sets the size (float) of each box side (default 1)
  54314. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54315. * * 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)
  54316. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54318. * * 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
  54319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54320. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54321. * @param name defines the name of the mesh
  54322. * @param options defines the options used to create the mesh
  54323. * @param scene defines the hosting scene
  54324. * @returns the box mesh
  54325. */
  54326. static CreateBox(name: string, options: {
  54327. size?: number;
  54328. width?: number;
  54329. height?: number;
  54330. depth?: number;
  54331. faceUV?: Vector4[];
  54332. faceColors?: Color4[];
  54333. sideOrientation?: number;
  54334. frontUVs?: Vector4;
  54335. backUVs?: Vector4;
  54336. wrap?: boolean;
  54337. topBaseAt?: number;
  54338. bottomBaseAt?: number;
  54339. updatable?: boolean;
  54340. }, scene?: Nullable<Scene>): Mesh;
  54341. }
  54342. }
  54343. declare module BABYLON.Debug {
  54344. /**
  54345. * Used to show the physics impostor around the specific mesh
  54346. */
  54347. export class PhysicsViewer {
  54348. /** @hidden */
  54349. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54350. /** @hidden */
  54351. protected _meshes: Array<Nullable<AbstractMesh>>;
  54352. /** @hidden */
  54353. protected _scene: Nullable<Scene>;
  54354. /** @hidden */
  54355. protected _numMeshes: number;
  54356. /** @hidden */
  54357. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54358. private _renderFunction;
  54359. private _utilityLayer;
  54360. private _debugBoxMesh;
  54361. private _debugSphereMesh;
  54362. private _debugCylinderMesh;
  54363. private _debugMaterial;
  54364. private _debugMeshMeshes;
  54365. /**
  54366. * Creates a new PhysicsViewer
  54367. * @param scene defines the hosting scene
  54368. */
  54369. constructor(scene: Scene);
  54370. /** @hidden */
  54371. protected _updateDebugMeshes(): void;
  54372. /**
  54373. * Renders a specified physic impostor
  54374. * @param impostor defines the impostor to render
  54375. * @param targetMesh defines the mesh represented by the impostor
  54376. * @returns the new debug mesh used to render the impostor
  54377. */
  54378. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54379. /**
  54380. * Hides a specified physic impostor
  54381. * @param impostor defines the impostor to hide
  54382. */
  54383. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54384. private _getDebugMaterial;
  54385. private _getDebugBoxMesh;
  54386. private _getDebugSphereMesh;
  54387. private _getDebugCylinderMesh;
  54388. private _getDebugMeshMesh;
  54389. private _getDebugMesh;
  54390. /** Releases all resources */
  54391. dispose(): void;
  54392. }
  54393. }
  54394. declare module BABYLON {
  54395. /**
  54396. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54397. * in order to better appreciate the issue one might have.
  54398. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54399. */
  54400. export class RayHelper {
  54401. /**
  54402. * Defines the ray we are currently tryin to visualize.
  54403. */
  54404. ray: Nullable<Ray>;
  54405. private _renderPoints;
  54406. private _renderLine;
  54407. private _renderFunction;
  54408. private _scene;
  54409. private _onAfterRenderObserver;
  54410. private _onAfterStepObserver;
  54411. private _attachedToMesh;
  54412. private _meshSpaceDirection;
  54413. private _meshSpaceOrigin;
  54414. /**
  54415. * Helper function to create a colored helper in a scene in one line.
  54416. * @param ray Defines the ray we are currently tryin to visualize
  54417. * @param scene Defines the scene the ray is used in
  54418. * @param color Defines the color we want to see the ray in
  54419. * @returns The newly created ray helper.
  54420. */
  54421. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54422. /**
  54423. * Instantiate a new ray helper.
  54424. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54425. * in order to better appreciate the issue one might have.
  54426. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54427. * @param ray Defines the ray we are currently tryin to visualize
  54428. */
  54429. constructor(ray: Ray);
  54430. /**
  54431. * Shows the ray we are willing to debug.
  54432. * @param scene Defines the scene the ray needs to be rendered in
  54433. * @param color Defines the color the ray needs to be rendered in
  54434. */
  54435. show(scene: Scene, color?: Color3): void;
  54436. /**
  54437. * Hides the ray we are debugging.
  54438. */
  54439. hide(): void;
  54440. private _render;
  54441. /**
  54442. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54443. * @param mesh Defines the mesh we want the helper attached to
  54444. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54445. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54446. * @param length Defines the length of the ray
  54447. */
  54448. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54449. /**
  54450. * Detach the ray helper from the mesh it has previously been attached to.
  54451. */
  54452. detachFromMesh(): void;
  54453. private _updateToMesh;
  54454. /**
  54455. * Dispose the helper and release its associated resources.
  54456. */
  54457. dispose(): void;
  54458. }
  54459. }
  54460. declare module BABYLON {
  54461. /**
  54462. * Defines the options associated with the creation of a SkeletonViewer.
  54463. */
  54464. export interface ISkeletonViewerOptions {
  54465. /** Should the system pause animations before building the Viewer? */
  54466. pauseAnimations: boolean;
  54467. /** Should the system return the skeleton to rest before building? */
  54468. returnToRest: boolean;
  54469. /** public Display Mode of the Viewer */
  54470. displayMode: number;
  54471. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54472. displayOptions: ISkeletonViewerDisplayOptions;
  54473. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54474. computeBonesUsingShaders: boolean;
  54475. /** Flag ignore non weighted bones */
  54476. useAllBones: boolean;
  54477. }
  54478. /**
  54479. * Defines how to display the various bone meshes for the viewer.
  54480. */
  54481. export interface ISkeletonViewerDisplayOptions {
  54482. /** How far down to start tapering the bone spurs */
  54483. midStep?: number;
  54484. /** How big is the midStep? */
  54485. midStepFactor?: number;
  54486. /** Base for the Sphere Size */
  54487. sphereBaseSize?: number;
  54488. /** The ratio of the sphere to the longest bone in units */
  54489. sphereScaleUnit?: number;
  54490. /** Ratio for the Sphere Size */
  54491. sphereFactor?: number;
  54492. /** Whether a spur should attach its far end to the child bone position */
  54493. spurFollowsChild?: boolean;
  54494. /** Whether to show local axes or not */
  54495. showLocalAxes?: boolean;
  54496. /** Length of each local axis */
  54497. localAxesSize?: number;
  54498. }
  54499. /**
  54500. * Defines the constructor options for the BoneWeight Shader.
  54501. */
  54502. export interface IBoneWeightShaderOptions {
  54503. /** Skeleton to Map */
  54504. skeleton: Skeleton;
  54505. /** Colors for Uninfluenced bones */
  54506. colorBase?: Color3;
  54507. /** Colors for 0.0-0.25 Weight bones */
  54508. colorZero?: Color3;
  54509. /** Color for 0.25-0.5 Weight Influence */
  54510. colorQuarter?: Color3;
  54511. /** Color for 0.5-0.75 Weight Influence */
  54512. colorHalf?: Color3;
  54513. /** Color for 0.75-1 Weight Influence */
  54514. colorFull?: Color3;
  54515. /** Color for Zero Weight Influence */
  54516. targetBoneIndex?: number;
  54517. }
  54518. /**
  54519. * Simple structure of the gradient steps for the Color Map.
  54520. */
  54521. export interface ISkeletonMapShaderColorMapKnot {
  54522. /** Color of the Knot */
  54523. color: Color3;
  54524. /** Location of the Knot */
  54525. location: number;
  54526. }
  54527. /**
  54528. * Defines the constructor options for the SkeletonMap Shader.
  54529. */
  54530. export interface ISkeletonMapShaderOptions {
  54531. /** Skeleton to Map */
  54532. skeleton: Skeleton;
  54533. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54534. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54535. }
  54536. }
  54537. declare module BABYLON {
  54538. /**
  54539. * Class containing static functions to help procedurally build meshes
  54540. */
  54541. export class RibbonBuilder {
  54542. /**
  54543. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54544. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54545. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54546. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54547. * * 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
  54548. * * 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
  54549. * * 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
  54550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54551. * * 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
  54552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54553. * * 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
  54554. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54555. * * 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
  54556. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54558. * @param name defines the name of the mesh
  54559. * @param options defines the options used to create the mesh
  54560. * @param scene defines the hosting scene
  54561. * @returns the ribbon mesh
  54562. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54564. */
  54565. static CreateRibbon(name: string, options: {
  54566. pathArray: Vector3[][];
  54567. closeArray?: boolean;
  54568. closePath?: boolean;
  54569. offset?: number;
  54570. updatable?: boolean;
  54571. sideOrientation?: number;
  54572. frontUVs?: Vector4;
  54573. backUVs?: Vector4;
  54574. instance?: Mesh;
  54575. invertUV?: boolean;
  54576. uvs?: Vector2[];
  54577. colors?: Color4[];
  54578. }, scene?: Nullable<Scene>): Mesh;
  54579. }
  54580. }
  54581. declare module BABYLON {
  54582. /**
  54583. * Class containing static functions to help procedurally build meshes
  54584. */
  54585. export class ShapeBuilder {
  54586. /**
  54587. * 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.
  54588. * * 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.
  54589. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54590. * * 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.
  54591. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54592. * * 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
  54593. * * 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
  54594. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54596. * * 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
  54597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54599. * @param name defines the name of the mesh
  54600. * @param options defines the options used to create the mesh
  54601. * @param scene defines the hosting scene
  54602. * @returns the extruded shape mesh
  54603. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54605. */
  54606. static ExtrudeShape(name: string, options: {
  54607. shape: Vector3[];
  54608. path: Vector3[];
  54609. scale?: number;
  54610. rotation?: number;
  54611. cap?: number;
  54612. updatable?: boolean;
  54613. sideOrientation?: number;
  54614. frontUVs?: Vector4;
  54615. backUVs?: Vector4;
  54616. instance?: Mesh;
  54617. invertUV?: boolean;
  54618. }, scene?: Nullable<Scene>): Mesh;
  54619. /**
  54620. * Creates an custom extruded shape mesh.
  54621. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54622. * * 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.
  54623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54624. * * 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
  54625. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54626. * * 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
  54627. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54628. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54629. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54630. * * 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
  54631. * * 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
  54632. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54634. * * 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
  54635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54637. * @param name defines the name of the mesh
  54638. * @param options defines the options used to create the mesh
  54639. * @param scene defines the hosting scene
  54640. * @returns the custom extruded shape mesh
  54641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54642. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54644. */
  54645. static ExtrudeShapeCustom(name: string, options: {
  54646. shape: Vector3[];
  54647. path: Vector3[];
  54648. scaleFunction?: any;
  54649. rotationFunction?: any;
  54650. ribbonCloseArray?: boolean;
  54651. ribbonClosePath?: boolean;
  54652. cap?: number;
  54653. updatable?: boolean;
  54654. sideOrientation?: number;
  54655. frontUVs?: Vector4;
  54656. backUVs?: Vector4;
  54657. instance?: Mesh;
  54658. invertUV?: boolean;
  54659. }, scene?: Nullable<Scene>): Mesh;
  54660. private static _ExtrudeShapeGeneric;
  54661. }
  54662. }
  54663. declare module BABYLON.Debug {
  54664. /**
  54665. * Class used to render a debug view of a given skeleton
  54666. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54667. */
  54668. export class SkeletonViewer {
  54669. /** defines the skeleton to render */
  54670. skeleton: Skeleton;
  54671. /** defines the mesh attached to the skeleton */
  54672. mesh: AbstractMesh;
  54673. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54674. autoUpdateBonesMatrices: boolean;
  54675. /** defines the rendering group id to use with the viewer */
  54676. renderingGroupId: number;
  54677. /** is the options for the viewer */
  54678. options: Partial<ISkeletonViewerOptions>;
  54679. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54680. static readonly DISPLAY_LINES: number;
  54681. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54682. static readonly DISPLAY_SPHERES: number;
  54683. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54684. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54685. /** public static method to create a BoneWeight Shader
  54686. * @param options The constructor options
  54687. * @param scene The scene that the shader is scoped to
  54688. * @returns The created ShaderMaterial
  54689. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54690. */
  54691. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54692. /** public static method to create a BoneWeight Shader
  54693. * @param options The constructor options
  54694. * @param scene The scene that the shader is scoped to
  54695. * @returns The created ShaderMaterial
  54696. */
  54697. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54698. /** private static method to create a BoneWeight Shader
  54699. * @param size The size of the buffer to create (usually the bone count)
  54700. * @param colorMap The gradient data to generate
  54701. * @param scene The scene that the shader is scoped to
  54702. * @returns an Array of floats from the color gradient values
  54703. */
  54704. private static _CreateBoneMapColorBuffer;
  54705. /** If SkeletonViewer scene scope. */
  54706. private _scene;
  54707. /** Gets or sets the color used to render the skeleton */
  54708. color: Color3;
  54709. /** Array of the points of the skeleton fo the line view. */
  54710. private _debugLines;
  54711. /** The SkeletonViewers Mesh. */
  54712. private _debugMesh;
  54713. /** The local axes Meshes. */
  54714. private _localAxes;
  54715. /** If SkeletonViewer is enabled. */
  54716. private _isEnabled;
  54717. /** If SkeletonViewer is ready. */
  54718. private _ready;
  54719. /** SkeletonViewer render observable. */
  54720. private _obs;
  54721. /** The Utility Layer to render the gizmos in. */
  54722. private _utilityLayer;
  54723. private _boneIndices;
  54724. /** Gets the Scene. */
  54725. get scene(): Scene;
  54726. /** Gets the utilityLayer. */
  54727. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54728. /** Checks Ready Status. */
  54729. get isReady(): Boolean;
  54730. /** Sets Ready Status. */
  54731. set ready(value: boolean);
  54732. /** Gets the debugMesh */
  54733. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54734. /** Sets the debugMesh */
  54735. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54736. /** Gets the displayMode */
  54737. get displayMode(): number;
  54738. /** Sets the displayMode */
  54739. set displayMode(value: number);
  54740. /**
  54741. * Creates a new SkeletonViewer
  54742. * @param skeleton defines the skeleton to render
  54743. * @param mesh defines the mesh attached to the skeleton
  54744. * @param scene defines the hosting scene
  54745. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54746. * @param renderingGroupId defines the rendering group id to use with the viewer
  54747. * @param options All of the extra constructor options for the SkeletonViewer
  54748. */
  54749. constructor(
  54750. /** defines the skeleton to render */
  54751. skeleton: Skeleton,
  54752. /** defines the mesh attached to the skeleton */
  54753. mesh: AbstractMesh,
  54754. /** The Scene scope*/
  54755. scene: Scene,
  54756. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54757. autoUpdateBonesMatrices?: boolean,
  54758. /** defines the rendering group id to use with the viewer */
  54759. renderingGroupId?: number,
  54760. /** is the options for the viewer */
  54761. options?: Partial<ISkeletonViewerOptions>);
  54762. /** The Dynamic bindings for the update functions */
  54763. private _bindObs;
  54764. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54765. update(): void;
  54766. /** Gets or sets a boolean indicating if the viewer is enabled */
  54767. set isEnabled(value: boolean);
  54768. get isEnabled(): boolean;
  54769. private _getBonePosition;
  54770. private _getLinesForBonesWithLength;
  54771. private _getLinesForBonesNoLength;
  54772. /** function to revert the mesh and scene back to the initial state. */
  54773. private _revert;
  54774. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54775. private _getAbsoluteBindPoseToRef;
  54776. /** function to build and bind sphere joint points and spur bone representations. */
  54777. private _buildSpheresAndSpurs;
  54778. private _buildLocalAxes;
  54779. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54780. private _displayLinesUpdate;
  54781. /** Changes the displayMode of the skeleton viewer
  54782. * @param mode The displayMode numerical value
  54783. */
  54784. changeDisplayMode(mode: number): void;
  54785. /** Sets a display option of the skeleton viewer
  54786. *
  54787. * | Option | Type | Default | Description |
  54788. * | ---------------- | ------- | ------- | ----------- |
  54789. * | 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`. |
  54790. * | 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`. |
  54791. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54792. * | 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`. |
  54793. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54794. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54795. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54796. *
  54797. * @param option String of the option name
  54798. * @param value The numerical option value
  54799. */
  54800. changeDisplayOptions(option: string, value: number): void;
  54801. /** Release associated resources */
  54802. dispose(): void;
  54803. }
  54804. }
  54805. declare module BABYLON {
  54806. /**
  54807. * Enum for Device Types
  54808. */
  54809. export enum DeviceType {
  54810. /** Generic */
  54811. Generic = 0,
  54812. /** Keyboard */
  54813. Keyboard = 1,
  54814. /** Mouse */
  54815. Mouse = 2,
  54816. /** Touch Pointers */
  54817. Touch = 3,
  54818. /** PS4 Dual Shock */
  54819. DualShock = 4,
  54820. /** Xbox */
  54821. Xbox = 5,
  54822. /** Switch Controller */
  54823. Switch = 6
  54824. }
  54825. /**
  54826. * Enum for All Pointers (Touch/Mouse)
  54827. */
  54828. export enum PointerInput {
  54829. /** Horizontal Axis */
  54830. Horizontal = 0,
  54831. /** Vertical Axis */
  54832. Vertical = 1,
  54833. /** Left Click or Touch */
  54834. LeftClick = 2,
  54835. /** Middle Click */
  54836. MiddleClick = 3,
  54837. /** Right Click */
  54838. RightClick = 4,
  54839. /** Browser Back */
  54840. BrowserBack = 5,
  54841. /** Browser Forward */
  54842. BrowserForward = 6
  54843. }
  54844. /**
  54845. * Enum for Dual Shock Gamepad
  54846. */
  54847. export enum DualShockInput {
  54848. /** Cross */
  54849. Cross = 0,
  54850. /** Circle */
  54851. Circle = 1,
  54852. /** Square */
  54853. Square = 2,
  54854. /** Triangle */
  54855. Triangle = 3,
  54856. /** L1 */
  54857. L1 = 4,
  54858. /** R1 */
  54859. R1 = 5,
  54860. /** L2 */
  54861. L2 = 6,
  54862. /** R2 */
  54863. R2 = 7,
  54864. /** Share */
  54865. Share = 8,
  54866. /** Options */
  54867. Options = 9,
  54868. /** L3 */
  54869. L3 = 10,
  54870. /** R3 */
  54871. R3 = 11,
  54872. /** DPadUp */
  54873. DPadUp = 12,
  54874. /** DPadDown */
  54875. DPadDown = 13,
  54876. /** DPadLeft */
  54877. DPadLeft = 14,
  54878. /** DRight */
  54879. DPadRight = 15,
  54880. /** Home */
  54881. Home = 16,
  54882. /** TouchPad */
  54883. TouchPad = 17,
  54884. /** LStickXAxis */
  54885. LStickXAxis = 18,
  54886. /** LStickYAxis */
  54887. LStickYAxis = 19,
  54888. /** RStickXAxis */
  54889. RStickXAxis = 20,
  54890. /** RStickYAxis */
  54891. RStickYAxis = 21
  54892. }
  54893. /**
  54894. * Enum for Xbox Gamepad
  54895. */
  54896. export enum XboxInput {
  54897. /** A */
  54898. A = 0,
  54899. /** B */
  54900. B = 1,
  54901. /** X */
  54902. X = 2,
  54903. /** Y */
  54904. Y = 3,
  54905. /** LB */
  54906. LB = 4,
  54907. /** RB */
  54908. RB = 5,
  54909. /** LT */
  54910. LT = 6,
  54911. /** RT */
  54912. RT = 7,
  54913. /** Back */
  54914. Back = 8,
  54915. /** Start */
  54916. Start = 9,
  54917. /** LS */
  54918. LS = 10,
  54919. /** RS */
  54920. RS = 11,
  54921. /** DPadUp */
  54922. DPadUp = 12,
  54923. /** DPadDown */
  54924. DPadDown = 13,
  54925. /** DPadLeft */
  54926. DPadLeft = 14,
  54927. /** DRight */
  54928. DPadRight = 15,
  54929. /** Home */
  54930. Home = 16,
  54931. /** LStickXAxis */
  54932. LStickXAxis = 17,
  54933. /** LStickYAxis */
  54934. LStickYAxis = 18,
  54935. /** RStickXAxis */
  54936. RStickXAxis = 19,
  54937. /** RStickYAxis */
  54938. RStickYAxis = 20
  54939. }
  54940. /**
  54941. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54942. */
  54943. export enum SwitchInput {
  54944. /** B */
  54945. B = 0,
  54946. /** A */
  54947. A = 1,
  54948. /** Y */
  54949. Y = 2,
  54950. /** X */
  54951. X = 3,
  54952. /** L */
  54953. L = 4,
  54954. /** R */
  54955. R = 5,
  54956. /** ZL */
  54957. ZL = 6,
  54958. /** ZR */
  54959. ZR = 7,
  54960. /** Minus */
  54961. Minus = 8,
  54962. /** Plus */
  54963. Plus = 9,
  54964. /** LS */
  54965. LS = 10,
  54966. /** RS */
  54967. RS = 11,
  54968. /** DPadUp */
  54969. DPadUp = 12,
  54970. /** DPadDown */
  54971. DPadDown = 13,
  54972. /** DPadLeft */
  54973. DPadLeft = 14,
  54974. /** DRight */
  54975. DPadRight = 15,
  54976. /** Home */
  54977. Home = 16,
  54978. /** Capture */
  54979. Capture = 17,
  54980. /** LStickXAxis */
  54981. LStickXAxis = 18,
  54982. /** LStickYAxis */
  54983. LStickYAxis = 19,
  54984. /** RStickXAxis */
  54985. RStickXAxis = 20,
  54986. /** RStickYAxis */
  54987. RStickYAxis = 21
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * This class will take all inputs from Keyboard, Pointer, and
  54993. * any Gamepads and provide a polling system that all devices
  54994. * will use. This class assumes that there will only be one
  54995. * pointer device and one keyboard.
  54996. */
  54997. export class DeviceInputSystem implements IDisposable {
  54998. /**
  54999. * Returns onDeviceConnected callback property
  55000. * @returns Callback with function to execute when a device is connected
  55001. */
  55002. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55003. /**
  55004. * Sets callback function when a device is connected and executes against all connected devices
  55005. * @param callback Function to execute when a device is connected
  55006. */
  55007. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55008. /**
  55009. * Callback to be triggered when a device is disconnected
  55010. */
  55011. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55012. /**
  55013. * Callback to be triggered when event driven input is updated
  55014. */
  55015. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55016. private _inputs;
  55017. private _gamepads;
  55018. private _keyboardActive;
  55019. private _pointerActive;
  55020. private _elementToAttachTo;
  55021. private _keyboardDownEvent;
  55022. private _keyboardUpEvent;
  55023. private _pointerMoveEvent;
  55024. private _pointerDownEvent;
  55025. private _pointerUpEvent;
  55026. private _gamepadConnectedEvent;
  55027. private _gamepadDisconnectedEvent;
  55028. private _onDeviceConnected;
  55029. private static _MAX_KEYCODES;
  55030. private static _MAX_POINTER_INPUTS;
  55031. private constructor();
  55032. /**
  55033. * Creates a new DeviceInputSystem instance
  55034. * @param engine Engine to pull input element from
  55035. * @returns The new instance
  55036. */
  55037. static Create(engine: Engine): DeviceInputSystem;
  55038. /**
  55039. * Checks for current device input value, given an id and input index
  55040. * @param deviceName Id of connected device
  55041. * @param inputIndex Index of device input
  55042. * @returns Current value of input
  55043. */
  55044. /**
  55045. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55046. * @param deviceType Enum specifiying device type
  55047. * @param deviceSlot "Slot" or index that device is referenced in
  55048. * @param inputIndex Id of input to be checked
  55049. * @returns Current value of input
  55050. */
  55051. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55052. /**
  55053. * Dispose of all the eventlisteners
  55054. */
  55055. dispose(): void;
  55056. /**
  55057. * Checks for existing connections to devices and register them, if necessary
  55058. * Currently handles gamepads and mouse
  55059. */
  55060. private _checkForConnectedDevices;
  55061. /**
  55062. * Add a gamepad to the DeviceInputSystem
  55063. * @param gamepad A single DOM Gamepad object
  55064. */
  55065. private _addGamePad;
  55066. /**
  55067. * Add pointer device to DeviceInputSystem
  55068. * @param deviceType Type of Pointer to add
  55069. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55070. * @param currentX Current X at point of adding
  55071. * @param currentY Current Y at point of adding
  55072. */
  55073. private _addPointerDevice;
  55074. /**
  55075. * Add device and inputs to device array
  55076. * @param deviceType Enum specifiying device type
  55077. * @param deviceSlot "Slot" or index that device is referenced in
  55078. * @param numberOfInputs Number of input entries to create for given device
  55079. */
  55080. private _registerDevice;
  55081. /**
  55082. * Given a specific device name, remove that device from the device map
  55083. * @param deviceType Enum specifiying device type
  55084. * @param deviceSlot "Slot" or index that device is referenced in
  55085. */
  55086. private _unregisterDevice;
  55087. /**
  55088. * Handle all actions that come from keyboard interaction
  55089. */
  55090. private _handleKeyActions;
  55091. /**
  55092. * Handle all actions that come from pointer interaction
  55093. */
  55094. private _handlePointerActions;
  55095. /**
  55096. * Handle all actions that come from gamepad interaction
  55097. */
  55098. private _handleGamepadActions;
  55099. /**
  55100. * Update all non-event based devices with each frame
  55101. * @param deviceType Enum specifiying device type
  55102. * @param deviceSlot "Slot" or index that device is referenced in
  55103. * @param inputIndex Id of input to be checked
  55104. */
  55105. private _updateDevice;
  55106. /**
  55107. * Gets DeviceType from the device name
  55108. * @param deviceName Name of Device from DeviceInputSystem
  55109. * @returns DeviceType enum value
  55110. */
  55111. private _getGamepadDeviceType;
  55112. }
  55113. }
  55114. declare module BABYLON {
  55115. /**
  55116. * Type to handle enforcement of inputs
  55117. */
  55118. 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;
  55119. }
  55120. declare module BABYLON {
  55121. /**
  55122. * Class that handles all input for a specific device
  55123. */
  55124. export class DeviceSource<T extends DeviceType> {
  55125. /** Type of device */
  55126. readonly deviceType: DeviceType;
  55127. /** "Slot" or index that device is referenced in */
  55128. readonly deviceSlot: number;
  55129. /**
  55130. * Observable to handle device input changes per device
  55131. */
  55132. readonly onInputChangedObservable: Observable<{
  55133. inputIndex: DeviceInput<T>;
  55134. previousState: Nullable<number>;
  55135. currentState: Nullable<number>;
  55136. }>;
  55137. private readonly _deviceInputSystem;
  55138. /**
  55139. * Default Constructor
  55140. * @param deviceInputSystem Reference to DeviceInputSystem
  55141. * @param deviceType Type of device
  55142. * @param deviceSlot "Slot" or index that device is referenced in
  55143. */
  55144. constructor(deviceInputSystem: DeviceInputSystem,
  55145. /** Type of device */
  55146. deviceType: DeviceType,
  55147. /** "Slot" or index that device is referenced in */
  55148. deviceSlot?: number);
  55149. /**
  55150. * Get input for specific input
  55151. * @param inputIndex index of specific input on device
  55152. * @returns Input value from DeviceInputSystem
  55153. */
  55154. getInput(inputIndex: DeviceInput<T>): number;
  55155. }
  55156. /**
  55157. * Class to keep track of devices
  55158. */
  55159. export class DeviceSourceManager implements IDisposable {
  55160. /**
  55161. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55162. */
  55163. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55164. /**
  55165. * Observable to be triggered when after a device is disconnected
  55166. */
  55167. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55168. private readonly _devices;
  55169. private readonly _firstDevice;
  55170. private readonly _deviceInputSystem;
  55171. /**
  55172. * Default Constructor
  55173. * @param engine engine to pull input element from
  55174. */
  55175. constructor(engine: Engine);
  55176. /**
  55177. * Gets a DeviceSource, given a type and slot
  55178. * @param deviceType Enum specifying device type
  55179. * @param deviceSlot "Slot" or index that device is referenced in
  55180. * @returns DeviceSource object
  55181. */
  55182. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55183. /**
  55184. * Gets an array of DeviceSource objects for a given device type
  55185. * @param deviceType Enum specifying device type
  55186. * @returns Array of DeviceSource objects
  55187. */
  55188. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55189. /**
  55190. * Returns a read-only list of all available devices
  55191. * @returns Read-only array with active devices
  55192. */
  55193. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55194. /**
  55195. * Dispose of DeviceInputSystem and other parts
  55196. */
  55197. dispose(): void;
  55198. /**
  55199. * Function to add device name to device list
  55200. * @param deviceType Enum specifying device type
  55201. * @param deviceSlot "Slot" or index that device is referenced in
  55202. */
  55203. private _addDevice;
  55204. /**
  55205. * Function to remove device name to device list
  55206. * @param deviceType Enum specifying device type
  55207. * @param deviceSlot "Slot" or index that device is referenced in
  55208. */
  55209. private _removeDevice;
  55210. /**
  55211. * Updates array storing first connected device of each type
  55212. * @param type Type of Device
  55213. */
  55214. private _updateFirstDevices;
  55215. }
  55216. }
  55217. declare module BABYLON {
  55218. /**
  55219. * Options to create the null engine
  55220. */
  55221. export class NullEngineOptions {
  55222. /**
  55223. * Render width (Default: 512)
  55224. */
  55225. renderWidth: number;
  55226. /**
  55227. * Render height (Default: 256)
  55228. */
  55229. renderHeight: number;
  55230. /**
  55231. * Texture size (Default: 512)
  55232. */
  55233. textureSize: number;
  55234. /**
  55235. * If delta time between frames should be constant
  55236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55237. */
  55238. deterministicLockstep: boolean;
  55239. /**
  55240. * Maximum about of steps between frames (Default: 4)
  55241. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55242. */
  55243. lockstepMaxSteps: number;
  55244. /**
  55245. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55246. */
  55247. useHighPrecisionMatrix?: boolean;
  55248. }
  55249. /**
  55250. * The null engine class provides support for headless version of babylon.js.
  55251. * This can be used in server side scenario or for testing purposes
  55252. */
  55253. export class NullEngine extends Engine {
  55254. private _options;
  55255. /**
  55256. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55257. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55258. * @returns true if engine is in deterministic lock step mode
  55259. */
  55260. isDeterministicLockStep(): boolean;
  55261. /**
  55262. * Gets the max steps when engine is running in deterministic lock step
  55263. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55264. * @returns the max steps
  55265. */
  55266. getLockstepMaxSteps(): number;
  55267. /**
  55268. * Gets the current hardware scaling level.
  55269. * By default the hardware scaling level is computed from the window device ratio.
  55270. * 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.
  55271. * @returns a number indicating the current hardware scaling level
  55272. */
  55273. getHardwareScalingLevel(): number;
  55274. constructor(options?: NullEngineOptions);
  55275. /**
  55276. * Creates a vertex buffer
  55277. * @param vertices the data for the vertex buffer
  55278. * @returns the new WebGL static buffer
  55279. */
  55280. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55281. /**
  55282. * Creates a new index buffer
  55283. * @param indices defines the content of the index buffer
  55284. * @param updatable defines if the index buffer must be updatable
  55285. * @returns a new webGL buffer
  55286. */
  55287. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55288. /**
  55289. * Clear the current render buffer or the current render target (if any is set up)
  55290. * @param color defines the color to use
  55291. * @param backBuffer defines if the back buffer must be cleared
  55292. * @param depth defines if the depth buffer must be cleared
  55293. * @param stencil defines if the stencil buffer must be cleared
  55294. */
  55295. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55296. /**
  55297. * Gets the current render width
  55298. * @param useScreen defines if screen size must be used (or the current render target if any)
  55299. * @returns a number defining the current render width
  55300. */
  55301. getRenderWidth(useScreen?: boolean): number;
  55302. /**
  55303. * Gets the current render height
  55304. * @param useScreen defines if screen size must be used (or the current render target if any)
  55305. * @returns a number defining the current render height
  55306. */
  55307. getRenderHeight(useScreen?: boolean): number;
  55308. /**
  55309. * Set the WebGL's viewport
  55310. * @param viewport defines the viewport element to be used
  55311. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55312. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55313. */
  55314. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55315. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55316. /**
  55317. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55318. * @param pipelineContext defines the pipeline context to use
  55319. * @param uniformsNames defines the list of uniform names
  55320. * @returns an array of webGL uniform locations
  55321. */
  55322. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55323. /**
  55324. * Gets the lsit of active attributes for a given webGL program
  55325. * @param pipelineContext defines the pipeline context to use
  55326. * @param attributesNames defines the list of attribute names to get
  55327. * @returns an array of indices indicating the offset of each attribute
  55328. */
  55329. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55330. /**
  55331. * Binds an effect to the webGL context
  55332. * @param effect defines the effect to bind
  55333. */
  55334. bindSamplers(effect: Effect): void;
  55335. /**
  55336. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55337. * @param effect defines the effect to activate
  55338. */
  55339. enableEffect(effect: Effect): void;
  55340. /**
  55341. * Set various states to the webGL context
  55342. * @param culling defines backface culling state
  55343. * @param zOffset defines the value to apply to zOffset (0 by default)
  55344. * @param force defines if states must be applied even if cache is up to date
  55345. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55346. */
  55347. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55348. /**
  55349. * Set the value of an uniform to an array of int32
  55350. * @param uniform defines the webGL uniform location where to store the value
  55351. * @param array defines the array of int32 to store
  55352. * @returns true if value was set
  55353. */
  55354. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55355. /**
  55356. * Set the value of an uniform to an array of int32 (stored as vec2)
  55357. * @param uniform defines the webGL uniform location where to store the value
  55358. * @param array defines the array of int32 to store
  55359. * @returns true if value was set
  55360. */
  55361. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55362. /**
  55363. * Set the value of an uniform to an array of int32 (stored as vec3)
  55364. * @param uniform defines the webGL uniform location where to store the value
  55365. * @param array defines the array of int32 to store
  55366. * @returns true if value was set
  55367. */
  55368. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55369. /**
  55370. * Set the value of an uniform to an array of int32 (stored as vec4)
  55371. * @param uniform defines the webGL uniform location where to store the value
  55372. * @param array defines the array of int32 to store
  55373. * @returns true if value was set
  55374. */
  55375. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55376. /**
  55377. * Set the value of an uniform to an array of float32
  55378. * @param uniform defines the webGL uniform location where to store the value
  55379. * @param array defines the array of float32 to store
  55380. * @returns true if value was set
  55381. */
  55382. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55383. /**
  55384. * Set the value of an uniform to an array of float32 (stored as vec2)
  55385. * @param uniform defines the webGL uniform location where to store the value
  55386. * @param array defines the array of float32 to store
  55387. * @returns true if value was set
  55388. */
  55389. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55390. /**
  55391. * Set the value of an uniform to an array of float32 (stored as vec3)
  55392. * @param uniform defines the webGL uniform location where to store the value
  55393. * @param array defines the array of float32 to store
  55394. * @returns true if value was set
  55395. */
  55396. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55397. /**
  55398. * Set the value of an uniform to an array of float32 (stored as vec4)
  55399. * @param uniform defines the webGL uniform location where to store the value
  55400. * @param array defines the array of float32 to store
  55401. * @returns true if value was set
  55402. */
  55403. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55404. /**
  55405. * Set the value of an uniform to an array of number
  55406. * @param uniform defines the webGL uniform location where to store the value
  55407. * @param array defines the array of number to store
  55408. * @returns true if value was set
  55409. */
  55410. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55411. /**
  55412. * Set the value of an uniform to an array of number (stored as vec2)
  55413. * @param uniform defines the webGL uniform location where to store the value
  55414. * @param array defines the array of number to store
  55415. * @returns true if value was set
  55416. */
  55417. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55418. /**
  55419. * Set the value of an uniform to an array of number (stored as vec3)
  55420. * @param uniform defines the webGL uniform location where to store the value
  55421. * @param array defines the array of number to store
  55422. * @returns true if value was set
  55423. */
  55424. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55425. /**
  55426. * Set the value of an uniform to an array of number (stored as vec4)
  55427. * @param uniform defines the webGL uniform location where to store the value
  55428. * @param array defines the array of number to store
  55429. * @returns true if value was set
  55430. */
  55431. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55432. /**
  55433. * Set the value of an uniform to an array of float32 (stored as matrices)
  55434. * @param uniform defines the webGL uniform location where to store the value
  55435. * @param matrices defines the array of float32 to store
  55436. * @returns true if value was set
  55437. */
  55438. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55439. /**
  55440. * Set the value of an uniform to a matrix (3x3)
  55441. * @param uniform defines the webGL uniform location where to store the value
  55442. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55443. * @returns true if value was set
  55444. */
  55445. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55446. /**
  55447. * Set the value of an uniform to a matrix (2x2)
  55448. * @param uniform defines the webGL uniform location where to store the value
  55449. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55450. * @returns true if value was set
  55451. */
  55452. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55453. /**
  55454. * Set the value of an uniform to a number (float)
  55455. * @param uniform defines the webGL uniform location where to store the value
  55456. * @param value defines the float number to store
  55457. * @returns true if value was set
  55458. */
  55459. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55460. /**
  55461. * Set the value of an uniform to a vec2
  55462. * @param uniform defines the webGL uniform location where to store the value
  55463. * @param x defines the 1st component of the value
  55464. * @param y defines the 2nd component of the value
  55465. * @returns true if value was set
  55466. */
  55467. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55468. /**
  55469. * Set the value of an uniform to a vec3
  55470. * @param uniform defines the webGL uniform location where to store the value
  55471. * @param x defines the 1st component of the value
  55472. * @param y defines the 2nd component of the value
  55473. * @param z defines the 3rd component of the value
  55474. * @returns true if value was set
  55475. */
  55476. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55477. /**
  55478. * Set the value of an uniform to a boolean
  55479. * @param uniform defines the webGL uniform location where to store the value
  55480. * @param bool defines the boolean to store
  55481. * @returns true if value was set
  55482. */
  55483. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55484. /**
  55485. * Set the value of an uniform to a vec4
  55486. * @param uniform defines the webGL uniform location where to store the value
  55487. * @param x defines the 1st component of the value
  55488. * @param y defines the 2nd component of the value
  55489. * @param z defines the 3rd component of the value
  55490. * @param w defines the 4th component of the value
  55491. * @returns true if value was set
  55492. */
  55493. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55494. /**
  55495. * Sets the current alpha mode
  55496. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55497. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55498. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55499. */
  55500. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55501. /**
  55502. * Bind webGl buffers directly to the webGL context
  55503. * @param vertexBuffers defines the vertex buffer to bind
  55504. * @param indexBuffer defines the index buffer to bind
  55505. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55506. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55507. * @param effect defines the effect associated with the vertex buffer
  55508. */
  55509. bindBuffers(vertexBuffers: {
  55510. [key: string]: VertexBuffer;
  55511. }, indexBuffer: DataBuffer, effect: Effect): void;
  55512. /**
  55513. * Force the entire cache to be cleared
  55514. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55515. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55516. */
  55517. wipeCaches(bruteForce?: boolean): void;
  55518. /**
  55519. * Send a draw order
  55520. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55521. * @param indexStart defines the starting index
  55522. * @param indexCount defines the number of index to draw
  55523. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55524. */
  55525. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55526. /**
  55527. * Draw a list of indexed primitives
  55528. * @param fillMode defines the primitive to use
  55529. * @param indexStart defines the starting index
  55530. * @param indexCount defines the number of index to draw
  55531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55532. */
  55533. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55534. /**
  55535. * Draw a list of unindexed primitives
  55536. * @param fillMode defines the primitive to use
  55537. * @param verticesStart defines the index of first vertex to draw
  55538. * @param verticesCount defines the count of vertices to draw
  55539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55540. */
  55541. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55542. /** @hidden */
  55543. _createTexture(): WebGLTexture;
  55544. /** @hidden */
  55545. _releaseTexture(texture: InternalTexture): void;
  55546. /**
  55547. * Usually called from Texture.ts.
  55548. * Passed information to create a WebGLTexture
  55549. * @param urlArg defines a value which contains one of the following:
  55550. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55551. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55552. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55553. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55554. * @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)
  55555. * @param scene needed for loading to the correct scene
  55556. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55557. * @param onLoad optional callback to be called upon successful completion
  55558. * @param onError optional callback to be called upon failure
  55559. * @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
  55560. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55561. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55562. * @param forcedExtension defines the extension to use to pick the right loader
  55563. * @param mimeType defines an optional mime type
  55564. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55565. */
  55566. 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;
  55567. /**
  55568. * Creates a new render target texture
  55569. * @param size defines the size of the texture
  55570. * @param options defines the options used to create the texture
  55571. * @returns a new render target texture stored in an InternalTexture
  55572. */
  55573. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55574. /**
  55575. * Update the sampling mode of a given texture
  55576. * @param samplingMode defines the required sampling mode
  55577. * @param texture defines the texture to update
  55578. */
  55579. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55580. /**
  55581. * Binds the frame buffer to the specified texture.
  55582. * @param texture The texture to render to or null for the default canvas
  55583. * @param faceIndex The face of the texture to render to in case of cube texture
  55584. * @param requiredWidth The width of the target to render to
  55585. * @param requiredHeight The height of the target to render to
  55586. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55587. * @param lodLevel defines le lod level to bind to the frame buffer
  55588. */
  55589. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55590. /**
  55591. * Unbind the current render target texture from the webGL context
  55592. * @param texture defines the render target texture to unbind
  55593. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55594. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55595. */
  55596. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55597. /**
  55598. * Creates a dynamic vertex buffer
  55599. * @param vertices the data for the dynamic vertex buffer
  55600. * @returns the new WebGL dynamic buffer
  55601. */
  55602. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55603. /**
  55604. * Update the content of a dynamic texture
  55605. * @param texture defines the texture to update
  55606. * @param canvas defines the canvas containing the source
  55607. * @param invertY defines if data must be stored with Y axis inverted
  55608. * @param premulAlpha defines if alpha is stored as premultiplied
  55609. * @param format defines the format of the data
  55610. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55611. */
  55612. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55613. /**
  55614. * Gets a boolean indicating if all created effects are ready
  55615. * @returns true if all effects are ready
  55616. */
  55617. areAllEffectsReady(): boolean;
  55618. /**
  55619. * @hidden
  55620. * Get the current error code of the webGL context
  55621. * @returns the error code
  55622. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55623. */
  55624. getError(): number;
  55625. /** @hidden */
  55626. _getUnpackAlignement(): number;
  55627. /** @hidden */
  55628. _unpackFlipY(value: boolean): void;
  55629. /**
  55630. * Update a dynamic index buffer
  55631. * @param indexBuffer defines the target index buffer
  55632. * @param indices defines the data to update
  55633. * @param offset defines the offset in the target index buffer where update should start
  55634. */
  55635. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55636. /**
  55637. * Updates a dynamic vertex buffer.
  55638. * @param vertexBuffer the vertex buffer to update
  55639. * @param vertices the data used to update the vertex buffer
  55640. * @param byteOffset the byte offset of the data (optional)
  55641. * @param byteLength the byte length of the data (optional)
  55642. */
  55643. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55644. /** @hidden */
  55645. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55646. /** @hidden */
  55647. _bindTexture(channel: number, texture: InternalTexture): void;
  55648. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55649. /**
  55650. * 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
  55651. */
  55652. releaseEffects(): void;
  55653. displayLoadingUI(): void;
  55654. hideLoadingUI(): void;
  55655. /** @hidden */
  55656. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55657. /** @hidden */
  55658. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55659. /** @hidden */
  55660. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55661. /** @hidden */
  55662. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55663. }
  55664. }
  55665. declare module BABYLON {
  55666. /**
  55667. * @hidden
  55668. **/
  55669. export class _TimeToken {
  55670. _startTimeQuery: Nullable<WebGLQuery>;
  55671. _endTimeQuery: Nullable<WebGLQuery>;
  55672. _timeElapsedQuery: Nullable<WebGLQuery>;
  55673. _timeElapsedQueryEnded: boolean;
  55674. }
  55675. }
  55676. declare module BABYLON {
  55677. /** @hidden */
  55678. export class _OcclusionDataStorage {
  55679. /** @hidden */
  55680. occlusionInternalRetryCounter: number;
  55681. /** @hidden */
  55682. isOcclusionQueryInProgress: boolean;
  55683. /** @hidden */
  55684. isOccluded: boolean;
  55685. /** @hidden */
  55686. occlusionRetryCount: number;
  55687. /** @hidden */
  55688. occlusionType: number;
  55689. /** @hidden */
  55690. occlusionQueryAlgorithmType: number;
  55691. }
  55692. interface Engine {
  55693. /**
  55694. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55695. * @return the new query
  55696. */
  55697. createQuery(): WebGLQuery;
  55698. /**
  55699. * Delete and release a webGL query
  55700. * @param query defines the query to delete
  55701. * @return the current engine
  55702. */
  55703. deleteQuery(query: WebGLQuery): Engine;
  55704. /**
  55705. * Check if a given query has resolved and got its value
  55706. * @param query defines the query to check
  55707. * @returns true if the query got its value
  55708. */
  55709. isQueryResultAvailable(query: WebGLQuery): boolean;
  55710. /**
  55711. * Gets the value of a given query
  55712. * @param query defines the query to check
  55713. * @returns the value of the query
  55714. */
  55715. getQueryResult(query: WebGLQuery): number;
  55716. /**
  55717. * Initiates an occlusion query
  55718. * @param algorithmType defines the algorithm to use
  55719. * @param query defines the query to use
  55720. * @returns the current engine
  55721. * @see https://doc.babylonjs.com/features/occlusionquery
  55722. */
  55723. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55724. /**
  55725. * Ends an occlusion query
  55726. * @see https://doc.babylonjs.com/features/occlusionquery
  55727. * @param algorithmType defines the algorithm to use
  55728. * @returns the current engine
  55729. */
  55730. endOcclusionQuery(algorithmType: number): Engine;
  55731. /**
  55732. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55733. * Please note that only one query can be issued at a time
  55734. * @returns a time token used to track the time span
  55735. */
  55736. startTimeQuery(): Nullable<_TimeToken>;
  55737. /**
  55738. * Ends a time query
  55739. * @param token defines the token used to measure the time span
  55740. * @returns the time spent (in ns)
  55741. */
  55742. endTimeQuery(token: _TimeToken): int;
  55743. /** @hidden */
  55744. _currentNonTimestampToken: Nullable<_TimeToken>;
  55745. /** @hidden */
  55746. _createTimeQuery(): WebGLQuery;
  55747. /** @hidden */
  55748. _deleteTimeQuery(query: WebGLQuery): void;
  55749. /** @hidden */
  55750. _getGlAlgorithmType(algorithmType: number): number;
  55751. /** @hidden */
  55752. _getTimeQueryResult(query: WebGLQuery): any;
  55753. /** @hidden */
  55754. _getTimeQueryAvailability(query: WebGLQuery): any;
  55755. }
  55756. interface AbstractMesh {
  55757. /**
  55758. * Backing filed
  55759. * @hidden
  55760. */
  55761. __occlusionDataStorage: _OcclusionDataStorage;
  55762. /**
  55763. * Access property
  55764. * @hidden
  55765. */
  55766. _occlusionDataStorage: _OcclusionDataStorage;
  55767. /**
  55768. * 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.
  55769. * The default value is -1 which means don't break the query and wait till the result
  55770. * @see https://doc.babylonjs.com/features/occlusionquery
  55771. */
  55772. occlusionRetryCount: number;
  55773. /**
  55774. * 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:
  55775. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55776. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55777. * * 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.
  55778. * @see https://doc.babylonjs.com/features/occlusionquery
  55779. */
  55780. occlusionType: number;
  55781. /**
  55782. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55783. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55784. * * 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.
  55785. * @see https://doc.babylonjs.com/features/occlusionquery
  55786. */
  55787. occlusionQueryAlgorithmType: number;
  55788. /**
  55789. * 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
  55790. * @see https://doc.babylonjs.com/features/occlusionquery
  55791. */
  55792. isOccluded: boolean;
  55793. /**
  55794. * Flag to check the progress status of the query
  55795. * @see https://doc.babylonjs.com/features/occlusionquery
  55796. */
  55797. isOcclusionQueryInProgress: boolean;
  55798. }
  55799. }
  55800. declare module BABYLON {
  55801. /** @hidden */
  55802. export var _forceTransformFeedbackToBundle: boolean;
  55803. interface Engine {
  55804. /**
  55805. * Creates a webGL transform feedback object
  55806. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55807. * @returns the webGL transform feedback object
  55808. */
  55809. createTransformFeedback(): WebGLTransformFeedback;
  55810. /**
  55811. * Delete a webGL transform feedback object
  55812. * @param value defines the webGL transform feedback object to delete
  55813. */
  55814. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55815. /**
  55816. * Bind a webGL transform feedback object to the webgl context
  55817. * @param value defines the webGL transform feedback object to bind
  55818. */
  55819. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55820. /**
  55821. * Begins a transform feedback operation
  55822. * @param usePoints defines if points or triangles must be used
  55823. */
  55824. beginTransformFeedback(usePoints: boolean): void;
  55825. /**
  55826. * Ends a transform feedback operation
  55827. */
  55828. endTransformFeedback(): void;
  55829. /**
  55830. * Specify the varyings to use with transform feedback
  55831. * @param program defines the associated webGL program
  55832. * @param value defines the list of strings representing the varying names
  55833. */
  55834. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55835. /**
  55836. * Bind a webGL buffer for a transform feedback operation
  55837. * @param value defines the webGL buffer to bind
  55838. */
  55839. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55840. }
  55841. }
  55842. declare module BABYLON {
  55843. /**
  55844. * Class used to define an additional view for the engine
  55845. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55846. */
  55847. export class EngineView {
  55848. /** Defines the canvas where to render the view */
  55849. target: HTMLCanvasElement;
  55850. /** Defines an optional camera used to render the view (will use active camera else) */
  55851. camera?: Camera;
  55852. }
  55853. interface Engine {
  55854. /**
  55855. * Gets or sets the HTML element to use for attaching events
  55856. */
  55857. inputElement: Nullable<HTMLElement>;
  55858. /**
  55859. * Gets the current engine view
  55860. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55861. */
  55862. activeView: Nullable<EngineView>;
  55863. /** Gets or sets the list of views */
  55864. views: EngineView[];
  55865. /**
  55866. * Register a new child canvas
  55867. * @param canvas defines the canvas to register
  55868. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55869. * @returns the associated view
  55870. */
  55871. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55872. /**
  55873. * Remove a registered child canvas
  55874. * @param canvas defines the canvas to remove
  55875. * @returns the current engine
  55876. */
  55877. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55878. }
  55879. }
  55880. declare module BABYLON {
  55881. interface Engine {
  55882. /** @hidden */
  55883. _excludedCompressedTextures: string[];
  55884. /** @hidden */
  55885. _textureFormatInUse: string;
  55886. /**
  55887. * Gets the list of texture formats supported
  55888. */
  55889. readonly texturesSupported: Array<string>;
  55890. /**
  55891. * Gets the texture format in use
  55892. */
  55893. readonly textureFormatInUse: Nullable<string>;
  55894. /**
  55895. * Set the compressed texture extensions or file names to skip.
  55896. *
  55897. * @param skippedFiles defines the list of those texture files you want to skip
  55898. * Example: [".dds", ".env", "myfile.png"]
  55899. */
  55900. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55901. /**
  55902. * Set the compressed texture format to use, based on the formats you have, and the formats
  55903. * supported by the hardware / browser.
  55904. *
  55905. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55906. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55907. * to API arguments needed to compressed textures. This puts the burden on the container
  55908. * generator to house the arcane code for determining these for current & future formats.
  55909. *
  55910. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55911. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55912. *
  55913. * Note: The result of this call is not taken into account when a texture is base64.
  55914. *
  55915. * @param formatsAvailable defines the list of those format families you have created
  55916. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55917. *
  55918. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55919. * @returns The extension selected.
  55920. */
  55921. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55922. }
  55923. }
  55924. declare module BABYLON {
  55925. /** @hidden */
  55926. export var rgbdEncodePixelShader: {
  55927. name: string;
  55928. shader: string;
  55929. };
  55930. }
  55931. declare module BABYLON {
  55932. /**
  55933. * Raw texture data and descriptor sufficient for WebGL texture upload
  55934. */
  55935. export interface EnvironmentTextureInfo {
  55936. /**
  55937. * Version of the environment map
  55938. */
  55939. version: number;
  55940. /**
  55941. * Width of image
  55942. */
  55943. width: number;
  55944. /**
  55945. * Irradiance information stored in the file.
  55946. */
  55947. irradiance: any;
  55948. /**
  55949. * Specular information stored in the file.
  55950. */
  55951. specular: any;
  55952. }
  55953. /**
  55954. * Defines One Image in the file. It requires only the position in the file
  55955. * as well as the length.
  55956. */
  55957. interface BufferImageData {
  55958. /**
  55959. * Length of the image data.
  55960. */
  55961. length: number;
  55962. /**
  55963. * Position of the data from the null terminator delimiting the end of the JSON.
  55964. */
  55965. position: number;
  55966. }
  55967. /**
  55968. * Defines the specular data enclosed in the file.
  55969. * This corresponds to the version 1 of the data.
  55970. */
  55971. export interface EnvironmentTextureSpecularInfoV1 {
  55972. /**
  55973. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55974. */
  55975. specularDataPosition?: number;
  55976. /**
  55977. * This contains all the images data needed to reconstruct the cubemap.
  55978. */
  55979. mipmaps: Array<BufferImageData>;
  55980. /**
  55981. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55982. */
  55983. lodGenerationScale: number;
  55984. }
  55985. /**
  55986. * Sets of helpers addressing the serialization and deserialization of environment texture
  55987. * stored in a BabylonJS env file.
  55988. * Those files are usually stored as .env files.
  55989. */
  55990. export class EnvironmentTextureTools {
  55991. /**
  55992. * Magic number identifying the env file.
  55993. */
  55994. private static _MagicBytes;
  55995. /**
  55996. * Gets the environment info from an env file.
  55997. * @param data The array buffer containing the .env bytes.
  55998. * @returns the environment file info (the json header) if successfully parsed.
  55999. */
  56000. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56001. /**
  56002. * Creates an environment texture from a loaded cube texture.
  56003. * @param texture defines the cube texture to convert in env file
  56004. * @return a promise containing the environment data if succesfull.
  56005. */
  56006. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56007. /**
  56008. * Creates a JSON representation of the spherical data.
  56009. * @param texture defines the texture containing the polynomials
  56010. * @return the JSON representation of the spherical info
  56011. */
  56012. private static _CreateEnvTextureIrradiance;
  56013. /**
  56014. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56015. * @param data the image data
  56016. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56017. * @return the views described by info providing access to the underlying buffer
  56018. */
  56019. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56020. /**
  56021. * Uploads the texture info contained in the env file to the GPU.
  56022. * @param texture defines the internal texture to upload to
  56023. * @param data defines the data to load
  56024. * @param info defines the texture info retrieved through the GetEnvInfo method
  56025. * @returns a promise
  56026. */
  56027. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56028. private static _OnImageReadyAsync;
  56029. /**
  56030. * Uploads the levels of image data to the GPU.
  56031. * @param texture defines the internal texture to upload to
  56032. * @param imageData defines the array buffer views of image data [mipmap][face]
  56033. * @returns a promise
  56034. */
  56035. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56036. /**
  56037. * Uploads spherical polynomials information to the texture.
  56038. * @param texture defines the texture we are trying to upload the information to
  56039. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56040. */
  56041. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56042. /** @hidden */
  56043. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56044. }
  56045. }
  56046. declare module BABYLON {
  56047. /**
  56048. * Class used to inline functions in shader code
  56049. */
  56050. export class ShaderCodeInliner {
  56051. private static readonly _RegexpFindFunctionNameAndType;
  56052. private _sourceCode;
  56053. private _functionDescr;
  56054. private _numMaxIterations;
  56055. /** Gets or sets the token used to mark the functions to inline */
  56056. inlineToken: string;
  56057. /** Gets or sets the debug mode */
  56058. debug: boolean;
  56059. /** Gets the code after the inlining process */
  56060. get code(): string;
  56061. /**
  56062. * Initializes the inliner
  56063. * @param sourceCode shader code source to inline
  56064. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56065. */
  56066. constructor(sourceCode: string, numMaxIterations?: number);
  56067. /**
  56068. * Start the processing of the shader code
  56069. */
  56070. processCode(): void;
  56071. private _collectFunctions;
  56072. private _processInlining;
  56073. private _extractBetweenMarkers;
  56074. private _skipWhitespaces;
  56075. private _removeComments;
  56076. private _replaceFunctionCallsByCode;
  56077. private _findBackward;
  56078. private _escapeRegExp;
  56079. private _replaceNames;
  56080. }
  56081. }
  56082. declare module BABYLON {
  56083. /**
  56084. * Container for accessors for natively-stored mesh data buffers.
  56085. */
  56086. class NativeDataBuffer extends DataBuffer {
  56087. /**
  56088. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56089. */
  56090. nativeIndexBuffer?: any;
  56091. /**
  56092. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56093. */
  56094. nativeVertexBuffer?: any;
  56095. }
  56096. /** @hidden */
  56097. class NativeTexture extends InternalTexture {
  56098. getInternalTexture(): InternalTexture;
  56099. getViewCount(): number;
  56100. }
  56101. /** @hidden */
  56102. export class NativeEngine extends Engine {
  56103. private readonly _native;
  56104. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56105. private readonly INVALID_HANDLE;
  56106. private _boundBuffersVertexArray;
  56107. private _currentDepthTest;
  56108. getHardwareScalingLevel(): number;
  56109. constructor();
  56110. dispose(): void;
  56111. /**
  56112. * Can be used to override the current requestAnimationFrame requester.
  56113. * @hidden
  56114. */
  56115. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56116. /**
  56117. * Override default engine behavior.
  56118. * @param color
  56119. * @param backBuffer
  56120. * @param depth
  56121. * @param stencil
  56122. */
  56123. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56124. /**
  56125. * Gets host document
  56126. * @returns the host document object
  56127. */
  56128. getHostDocument(): Nullable<Document>;
  56129. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56130. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56131. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56132. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56133. [key: string]: VertexBuffer;
  56134. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56135. bindBuffers(vertexBuffers: {
  56136. [key: string]: VertexBuffer;
  56137. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56138. recordVertexArrayObject(vertexBuffers: {
  56139. [key: string]: VertexBuffer;
  56140. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56141. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56142. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56143. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56144. /**
  56145. * Draw a list of indexed primitives
  56146. * @param fillMode defines the primitive to use
  56147. * @param indexStart defines the starting index
  56148. * @param indexCount defines the number of index to draw
  56149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56150. */
  56151. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56152. /**
  56153. * Draw a list of unindexed primitives
  56154. * @param fillMode defines the primitive to use
  56155. * @param verticesStart defines the index of first vertex to draw
  56156. * @param verticesCount defines the count of vertices to draw
  56157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56158. */
  56159. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56160. createPipelineContext(): IPipelineContext;
  56161. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56162. /** @hidden */
  56163. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56164. /** @hidden */
  56165. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56166. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56167. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56168. protected _setProgram(program: WebGLProgram): void;
  56169. _releaseEffect(effect: Effect): void;
  56170. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56171. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56172. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56173. bindSamplers(effect: Effect): void;
  56174. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56175. getRenderWidth(useScreen?: boolean): number;
  56176. getRenderHeight(useScreen?: boolean): number;
  56177. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56178. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56179. /**
  56180. * Set the z offset to apply to current rendering
  56181. * @param value defines the offset to apply
  56182. */
  56183. setZOffset(value: number): void;
  56184. /**
  56185. * Gets the current value of the zOffset
  56186. * @returns the current zOffset state
  56187. */
  56188. getZOffset(): number;
  56189. /**
  56190. * Enable or disable depth buffering
  56191. * @param enable defines the state to set
  56192. */
  56193. setDepthBuffer(enable: boolean): void;
  56194. /**
  56195. * Gets a boolean indicating if depth writing is enabled
  56196. * @returns the current depth writing state
  56197. */
  56198. getDepthWrite(): boolean;
  56199. setDepthFunctionToGreater(): void;
  56200. setDepthFunctionToGreaterOrEqual(): void;
  56201. setDepthFunctionToLess(): void;
  56202. setDepthFunctionToLessOrEqual(): void;
  56203. /**
  56204. * Enable or disable depth writing
  56205. * @param enable defines the state to set
  56206. */
  56207. setDepthWrite(enable: boolean): void;
  56208. /**
  56209. * Enable or disable color writing
  56210. * @param enable defines the state to set
  56211. */
  56212. setColorWrite(enable: boolean): void;
  56213. /**
  56214. * Gets a boolean indicating if color writing is enabled
  56215. * @returns the current color writing state
  56216. */
  56217. getColorWrite(): boolean;
  56218. /**
  56219. * Sets alpha constants used by some alpha blending modes
  56220. * @param r defines the red component
  56221. * @param g defines the green component
  56222. * @param b defines the blue component
  56223. * @param a defines the alpha component
  56224. */
  56225. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56226. /**
  56227. * Sets the current alpha mode
  56228. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56229. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56230. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56231. */
  56232. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56233. /**
  56234. * Gets the current alpha mode
  56235. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56236. * @returns the current alpha mode
  56237. */
  56238. getAlphaMode(): number;
  56239. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56240. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56241. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56242. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56243. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56244. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56245. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56246. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56247. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56248. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56249. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56250. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56251. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56252. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56253. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56254. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56255. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56256. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56257. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56258. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56259. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56260. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56261. wipeCaches(bruteForce?: boolean): void;
  56262. _createTexture(): WebGLTexture;
  56263. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56264. /**
  56265. * Update the content of a dynamic texture
  56266. * @param texture defines the texture to update
  56267. * @param canvas defines the canvas containing the source
  56268. * @param invertY defines if data must be stored with Y axis inverted
  56269. * @param premulAlpha defines if alpha is stored as premultiplied
  56270. * @param format defines the format of the data
  56271. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56272. */
  56273. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56274. /**
  56275. * Usually called from Texture.ts.
  56276. * Passed information to create a WebGLTexture
  56277. * @param url defines a value which contains one of the following:
  56278. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56279. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56280. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56281. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56282. * @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)
  56283. * @param scene needed for loading to the correct scene
  56284. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56285. * @param onLoad optional callback to be called upon successful completion
  56286. * @param onError optional callback to be called upon failure
  56287. * @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
  56288. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56289. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56290. * @param forcedExtension defines the extension to use to pick the right loader
  56291. * @param mimeType defines an optional mime type
  56292. * @param loaderOptions options to be passed to the loader
  56293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56294. */
  56295. 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;
  56296. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56297. _releaseFramebufferObjects(texture: InternalTexture): void;
  56298. /**
  56299. * Creates a cube texture
  56300. * @param rootUrl defines the url where the files to load is located
  56301. * @param scene defines the current scene
  56302. * @param files defines the list of files to load (1 per face)
  56303. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56304. * @param onLoad defines an optional callback raised when the texture is loaded
  56305. * @param onError defines an optional callback raised if there is an issue to load the texture
  56306. * @param format defines the format of the data
  56307. * @param forcedExtension defines the extension to use to pick the right loader
  56308. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56309. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56310. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56311. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56312. * @returns the cube texture as an InternalTexture
  56313. */
  56314. 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;
  56315. createRenderTargetTexture(size: number | {
  56316. width: number;
  56317. height: number;
  56318. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56319. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56320. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56321. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56322. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56323. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56324. /**
  56325. * Updates a dynamic vertex buffer.
  56326. * @param vertexBuffer the vertex buffer to update
  56327. * @param data the data used to update the vertex buffer
  56328. * @param byteOffset the byte offset of the data (optional)
  56329. * @param byteLength the byte length of the data (optional)
  56330. */
  56331. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56332. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56333. private _updateAnisotropicLevel;
  56334. private _getAddressMode;
  56335. /** @hidden */
  56336. _bindTexture(channel: number, texture: InternalTexture): void;
  56337. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56338. releaseEffects(): void;
  56339. /** @hidden */
  56340. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56341. /** @hidden */
  56342. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56343. /** @hidden */
  56344. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56345. /** @hidden */
  56346. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56347. private _getNativeSamplingMode;
  56348. private _getNativeTextureFormat;
  56349. private _getNativeAlphaMode;
  56350. private _getNativeAttribType;
  56351. }
  56352. }
  56353. declare module BABYLON {
  56354. /**
  56355. * Gather the list of clipboard event types as constants.
  56356. */
  56357. export class ClipboardEventTypes {
  56358. /**
  56359. * The clipboard event is fired when a copy command is active (pressed).
  56360. */
  56361. static readonly COPY: number;
  56362. /**
  56363. * The clipboard event is fired when a cut command is active (pressed).
  56364. */
  56365. static readonly CUT: number;
  56366. /**
  56367. * The clipboard event is fired when a paste command is active (pressed).
  56368. */
  56369. static readonly PASTE: number;
  56370. }
  56371. /**
  56372. * This class is used to store clipboard related info for the onClipboardObservable event.
  56373. */
  56374. export class ClipboardInfo {
  56375. /**
  56376. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56377. */
  56378. type: number;
  56379. /**
  56380. * Defines the related dom event
  56381. */
  56382. event: ClipboardEvent;
  56383. /**
  56384. *Creates an instance of ClipboardInfo.
  56385. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56386. * @param event Defines the related dom event
  56387. */
  56388. constructor(
  56389. /**
  56390. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56391. */
  56392. type: number,
  56393. /**
  56394. * Defines the related dom event
  56395. */
  56396. event: ClipboardEvent);
  56397. /**
  56398. * Get the clipboard event's type from the keycode.
  56399. * @param keyCode Defines the keyCode for the current keyboard event.
  56400. * @return {number}
  56401. */
  56402. static GetTypeFromCharacter(keyCode: number): number;
  56403. }
  56404. }
  56405. declare module BABYLON {
  56406. /**
  56407. * Google Daydream controller
  56408. */
  56409. export class DaydreamController extends WebVRController {
  56410. /**
  56411. * Base Url for the controller model.
  56412. */
  56413. static MODEL_BASE_URL: string;
  56414. /**
  56415. * File name for the controller model.
  56416. */
  56417. static MODEL_FILENAME: string;
  56418. /**
  56419. * Gamepad Id prefix used to identify Daydream Controller.
  56420. */
  56421. static readonly GAMEPAD_ID_PREFIX: string;
  56422. /**
  56423. * Creates a new DaydreamController from a gamepad
  56424. * @param vrGamepad the gamepad that the controller should be created from
  56425. */
  56426. constructor(vrGamepad: any);
  56427. /**
  56428. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56429. * @param scene scene in which to add meshes
  56430. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56431. */
  56432. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56433. /**
  56434. * Called once for each button that changed state since the last frame
  56435. * @param buttonIdx Which button index changed
  56436. * @param state New state of the button
  56437. * @param changes Which properties on the state changed since last frame
  56438. */
  56439. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56440. }
  56441. }
  56442. declare module BABYLON {
  56443. /**
  56444. * Gear VR Controller
  56445. */
  56446. export class GearVRController extends WebVRController {
  56447. /**
  56448. * Base Url for the controller model.
  56449. */
  56450. static MODEL_BASE_URL: string;
  56451. /**
  56452. * File name for the controller model.
  56453. */
  56454. static MODEL_FILENAME: string;
  56455. /**
  56456. * Gamepad Id prefix used to identify this controller.
  56457. */
  56458. static readonly GAMEPAD_ID_PREFIX: string;
  56459. private readonly _buttonIndexToObservableNameMap;
  56460. /**
  56461. * Creates a new GearVRController from a gamepad
  56462. * @param vrGamepad the gamepad that the controller should be created from
  56463. */
  56464. constructor(vrGamepad: any);
  56465. /**
  56466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56467. * @param scene scene in which to add meshes
  56468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56469. */
  56470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56471. /**
  56472. * Called once for each button that changed state since the last frame
  56473. * @param buttonIdx Which button index changed
  56474. * @param state New state of the button
  56475. * @param changes Which properties on the state changed since last frame
  56476. */
  56477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56478. }
  56479. }
  56480. declare module BABYLON {
  56481. /**
  56482. * Generic Controller
  56483. */
  56484. export class GenericController extends WebVRController {
  56485. /**
  56486. * Base Url for the controller model.
  56487. */
  56488. static readonly MODEL_BASE_URL: string;
  56489. /**
  56490. * File name for the controller model.
  56491. */
  56492. static readonly MODEL_FILENAME: string;
  56493. /**
  56494. * Creates a new GenericController from a gamepad
  56495. * @param vrGamepad the gamepad that the controller should be created from
  56496. */
  56497. constructor(vrGamepad: any);
  56498. /**
  56499. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56500. * @param scene scene in which to add meshes
  56501. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56502. */
  56503. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56504. /**
  56505. * Called once for each button that changed state since the last frame
  56506. * @param buttonIdx Which button index changed
  56507. * @param state New state of the button
  56508. * @param changes Which properties on the state changed since last frame
  56509. */
  56510. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56511. }
  56512. }
  56513. declare module BABYLON {
  56514. /**
  56515. * Oculus Touch Controller
  56516. */
  56517. export class OculusTouchController extends WebVRController {
  56518. /**
  56519. * Base Url for the controller model.
  56520. */
  56521. static MODEL_BASE_URL: string;
  56522. /**
  56523. * File name for the left controller model.
  56524. */
  56525. static MODEL_LEFT_FILENAME: string;
  56526. /**
  56527. * File name for the right controller model.
  56528. */
  56529. static MODEL_RIGHT_FILENAME: string;
  56530. /**
  56531. * Base Url for the Quest controller model.
  56532. */
  56533. static QUEST_MODEL_BASE_URL: string;
  56534. /**
  56535. * @hidden
  56536. * If the controllers are running on a device that needs the updated Quest controller models
  56537. */
  56538. static _IsQuest: boolean;
  56539. /**
  56540. * Fired when the secondary trigger on this controller is modified
  56541. */
  56542. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56543. /**
  56544. * Fired when the thumb rest on this controller is modified
  56545. */
  56546. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56547. /**
  56548. * Creates a new OculusTouchController from a gamepad
  56549. * @param vrGamepad the gamepad that the controller should be created from
  56550. */
  56551. constructor(vrGamepad: any);
  56552. /**
  56553. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56554. * @param scene scene in which to add meshes
  56555. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56556. */
  56557. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56558. /**
  56559. * Fired when the A button on this controller is modified
  56560. */
  56561. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56562. /**
  56563. * Fired when the B button on this controller is modified
  56564. */
  56565. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56566. /**
  56567. * Fired when the X button on this controller is modified
  56568. */
  56569. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56570. /**
  56571. * Fired when the Y button on this controller is modified
  56572. */
  56573. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56574. /**
  56575. * Called once for each button that changed state since the last frame
  56576. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56577. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56578. * 2) secondary trigger (same)
  56579. * 3) A (right) X (left), touch, pressed = value
  56580. * 4) B / Y
  56581. * 5) thumb rest
  56582. * @param buttonIdx Which button index changed
  56583. * @param state New state of the button
  56584. * @param changes Which properties on the state changed since last frame
  56585. */
  56586. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56587. }
  56588. }
  56589. declare module BABYLON {
  56590. /**
  56591. * Vive Controller
  56592. */
  56593. export class ViveController extends WebVRController {
  56594. /**
  56595. * Base Url for the controller model.
  56596. */
  56597. static MODEL_BASE_URL: string;
  56598. /**
  56599. * File name for the controller model.
  56600. */
  56601. static MODEL_FILENAME: string;
  56602. /**
  56603. * Creates a new ViveController from a gamepad
  56604. * @param vrGamepad the gamepad that the controller should be created from
  56605. */
  56606. constructor(vrGamepad: any);
  56607. /**
  56608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56609. * @param scene scene in which to add meshes
  56610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56611. */
  56612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56613. /**
  56614. * Fired when the left button on this controller is modified
  56615. */
  56616. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56617. /**
  56618. * Fired when the right button on this controller is modified
  56619. */
  56620. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56621. /**
  56622. * Fired when the menu button on this controller is modified
  56623. */
  56624. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56625. /**
  56626. * Called once for each button that changed state since the last frame
  56627. * Vive mapping:
  56628. * 0: touchpad
  56629. * 1: trigger
  56630. * 2: left AND right buttons
  56631. * 3: menu button
  56632. * @param buttonIdx Which button index changed
  56633. * @param state New state of the button
  56634. * @param changes Which properties on the state changed since last frame
  56635. */
  56636. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56637. }
  56638. }
  56639. declare module BABYLON {
  56640. /**
  56641. * Defines the WindowsMotionController object that the state of the windows motion controller
  56642. */
  56643. export class WindowsMotionController extends WebVRController {
  56644. /**
  56645. * The base url used to load the left and right controller models
  56646. */
  56647. static MODEL_BASE_URL: string;
  56648. /**
  56649. * The name of the left controller model file
  56650. */
  56651. static MODEL_LEFT_FILENAME: string;
  56652. /**
  56653. * The name of the right controller model file
  56654. */
  56655. static MODEL_RIGHT_FILENAME: string;
  56656. /**
  56657. * The controller name prefix for this controller type
  56658. */
  56659. static readonly GAMEPAD_ID_PREFIX: string;
  56660. /**
  56661. * The controller id pattern for this controller type
  56662. */
  56663. private static readonly GAMEPAD_ID_PATTERN;
  56664. private _loadedMeshInfo;
  56665. protected readonly _mapping: {
  56666. buttons: string[];
  56667. buttonMeshNames: {
  56668. trigger: string;
  56669. menu: string;
  56670. grip: string;
  56671. thumbstick: string;
  56672. trackpad: string;
  56673. };
  56674. buttonObservableNames: {
  56675. trigger: string;
  56676. menu: string;
  56677. grip: string;
  56678. thumbstick: string;
  56679. trackpad: string;
  56680. };
  56681. axisMeshNames: string[];
  56682. pointingPoseMeshName: string;
  56683. };
  56684. /**
  56685. * Fired when the trackpad on this controller is clicked
  56686. */
  56687. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56688. /**
  56689. * Fired when the trackpad on this controller is modified
  56690. */
  56691. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56692. /**
  56693. * The current x and y values of this controller's trackpad
  56694. */
  56695. trackpad: StickValues;
  56696. /**
  56697. * Creates a new WindowsMotionController from a gamepad
  56698. * @param vrGamepad the gamepad that the controller should be created from
  56699. */
  56700. constructor(vrGamepad: any);
  56701. /**
  56702. * Fired when the trigger on this controller is modified
  56703. */
  56704. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56705. /**
  56706. * Fired when the menu button on this controller is modified
  56707. */
  56708. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56709. /**
  56710. * Fired when the grip button on this controller is modified
  56711. */
  56712. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56713. /**
  56714. * Fired when the thumbstick button on this controller is modified
  56715. */
  56716. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56717. /**
  56718. * Fired when the touchpad button on this controller is modified
  56719. */
  56720. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56721. /**
  56722. * Fired when the touchpad values on this controller are modified
  56723. */
  56724. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56725. protected _updateTrackpad(): void;
  56726. /**
  56727. * Called once per frame by the engine.
  56728. */
  56729. update(): void;
  56730. /**
  56731. * Called once for each button that changed state since the last frame
  56732. * @param buttonIdx Which button index changed
  56733. * @param state New state of the button
  56734. * @param changes Which properties on the state changed since last frame
  56735. */
  56736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56737. /**
  56738. * Moves the buttons on the controller mesh based on their current state
  56739. * @param buttonName the name of the button to move
  56740. * @param buttonValue the value of the button which determines the buttons new position
  56741. */
  56742. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56743. /**
  56744. * Moves the axis on the controller mesh based on its current state
  56745. * @param axis the index of the axis
  56746. * @param axisValue the value of the axis which determines the meshes new position
  56747. * @hidden
  56748. */
  56749. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56750. /**
  56751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56752. * @param scene scene in which to add meshes
  56753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56754. */
  56755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56756. /**
  56757. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56758. * can be transformed by button presses and axes values, based on this._mapping.
  56759. *
  56760. * @param scene scene in which the meshes exist
  56761. * @param meshes list of meshes that make up the controller model to process
  56762. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56763. */
  56764. private processModel;
  56765. private createMeshInfo;
  56766. /**
  56767. * Gets the ray of the controller in the direction the controller is pointing
  56768. * @param length the length the resulting ray should be
  56769. * @returns a ray in the direction the controller is pointing
  56770. */
  56771. getForwardRay(length?: number): Ray;
  56772. /**
  56773. * Disposes of the controller
  56774. */
  56775. dispose(): void;
  56776. }
  56777. /**
  56778. * This class represents a new windows motion controller in XR.
  56779. */
  56780. export class XRWindowsMotionController extends WindowsMotionController {
  56781. /**
  56782. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56783. */
  56784. protected readonly _mapping: {
  56785. buttons: string[];
  56786. buttonMeshNames: {
  56787. trigger: string;
  56788. menu: string;
  56789. grip: string;
  56790. thumbstick: string;
  56791. trackpad: string;
  56792. };
  56793. buttonObservableNames: {
  56794. trigger: string;
  56795. menu: string;
  56796. grip: string;
  56797. thumbstick: string;
  56798. trackpad: string;
  56799. };
  56800. axisMeshNames: string[];
  56801. pointingPoseMeshName: string;
  56802. };
  56803. /**
  56804. * Construct a new XR-Based windows motion controller
  56805. *
  56806. * @param gamepadInfo the gamepad object from the browser
  56807. */
  56808. constructor(gamepadInfo: any);
  56809. /**
  56810. * holds the thumbstick values (X,Y)
  56811. */
  56812. thumbstickValues: StickValues;
  56813. /**
  56814. * Fired when the thumbstick on this controller is clicked
  56815. */
  56816. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56817. /**
  56818. * Fired when the thumbstick on this controller is modified
  56819. */
  56820. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56821. /**
  56822. * Fired when the touchpad button on this controller is modified
  56823. */
  56824. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56825. /**
  56826. * Fired when the touchpad values on this controller are modified
  56827. */
  56828. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56829. /**
  56830. * Fired when the thumbstick button on this controller is modified
  56831. * here to prevent breaking changes
  56832. */
  56833. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56834. /**
  56835. * updating the thumbstick(!) and not the trackpad.
  56836. * This is named this way due to the difference between WebVR and XR and to avoid
  56837. * changing the parent class.
  56838. */
  56839. protected _updateTrackpad(): void;
  56840. /**
  56841. * Disposes the class with joy
  56842. */
  56843. dispose(): void;
  56844. }
  56845. }
  56846. declare module BABYLON {
  56847. /**
  56848. * Class containing static functions to help procedurally build meshes
  56849. */
  56850. export class PolyhedronBuilder {
  56851. /**
  56852. * Creates a polyhedron mesh
  56853. * * 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
  56854. * * The parameter `size` (positive float, default 1) sets the polygon size
  56855. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56856. * * 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`
  56857. * * 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
  56858. * * 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)`)
  56859. * * 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
  56860. * * 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
  56861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56862. * * 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
  56863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56864. * @param name defines the name of the mesh
  56865. * @param options defines the options used to create the mesh
  56866. * @param scene defines the hosting scene
  56867. * @returns the polyhedron mesh
  56868. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56869. */
  56870. static CreatePolyhedron(name: string, options: {
  56871. type?: number;
  56872. size?: number;
  56873. sizeX?: number;
  56874. sizeY?: number;
  56875. sizeZ?: number;
  56876. custom?: any;
  56877. faceUV?: Vector4[];
  56878. faceColors?: Color4[];
  56879. flat?: boolean;
  56880. updatable?: boolean;
  56881. sideOrientation?: number;
  56882. frontUVs?: Vector4;
  56883. backUVs?: Vector4;
  56884. }, scene?: Nullable<Scene>): Mesh;
  56885. }
  56886. }
  56887. declare module BABYLON {
  56888. /**
  56889. * Gizmo that enables scaling a mesh along 3 axis
  56890. */
  56891. export class ScaleGizmo extends Gizmo {
  56892. /**
  56893. * Internal gizmo used for interactions on the x axis
  56894. */
  56895. xGizmo: AxisScaleGizmo;
  56896. /**
  56897. * Internal gizmo used for interactions on the y axis
  56898. */
  56899. yGizmo: AxisScaleGizmo;
  56900. /**
  56901. * Internal gizmo used for interactions on the z axis
  56902. */
  56903. zGizmo: AxisScaleGizmo;
  56904. /**
  56905. * Internal gizmo used to scale all axis equally
  56906. */
  56907. uniformScaleGizmo: AxisScaleGizmo;
  56908. private _meshAttached;
  56909. private _nodeAttached;
  56910. private _snapDistance;
  56911. private _uniformScalingMesh;
  56912. private _octahedron;
  56913. private _sensitivity;
  56914. /** Fires an event when any of it's sub gizmos are dragged */
  56915. onDragStartObservable: Observable<unknown>;
  56916. /** Fires an event when any of it's sub gizmos are released from dragging */
  56917. onDragEndObservable: Observable<unknown>;
  56918. get attachedMesh(): Nullable<AbstractMesh>;
  56919. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56920. get attachedNode(): Nullable<Node>;
  56921. set attachedNode(node: Nullable<Node>);
  56922. /**
  56923. * True when the mouse pointer is hovering a gizmo mesh
  56924. */
  56925. get isHovered(): boolean;
  56926. /**
  56927. * Creates a ScaleGizmo
  56928. * @param gizmoLayer The utility layer the gizmo will be added to
  56929. * @param thickness display gizmo axis thickness
  56930. */
  56931. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56932. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56933. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56934. /**
  56935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56936. */
  56937. set snapDistance(value: number);
  56938. get snapDistance(): number;
  56939. /**
  56940. * Ratio for the scale of the gizmo (Default: 1)
  56941. */
  56942. set scaleRatio(value: number);
  56943. get scaleRatio(): number;
  56944. /**
  56945. * Sensitivity factor for dragging (Default: 1)
  56946. */
  56947. set sensitivity(value: number);
  56948. get sensitivity(): number;
  56949. /**
  56950. * Disposes of the gizmo
  56951. */
  56952. dispose(): void;
  56953. }
  56954. }
  56955. declare module BABYLON {
  56956. /**
  56957. * Single axis scale gizmo
  56958. */
  56959. export class AxisScaleGizmo extends Gizmo {
  56960. /**
  56961. * Drag behavior responsible for the gizmos dragging interactions
  56962. */
  56963. dragBehavior: PointerDragBehavior;
  56964. private _pointerObserver;
  56965. /**
  56966. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56967. */
  56968. snapDistance: number;
  56969. /**
  56970. * Event that fires each time the gizmo snaps to a new location.
  56971. * * snapDistance is the the change in distance
  56972. */
  56973. onSnapObservable: Observable<{
  56974. snapDistance: number;
  56975. }>;
  56976. /**
  56977. * If the scaling operation should be done on all axis (default: false)
  56978. */
  56979. uniformScaling: boolean;
  56980. /**
  56981. * Custom sensitivity value for the drag strength
  56982. */
  56983. sensitivity: number;
  56984. private _isEnabled;
  56985. private _parent;
  56986. private _arrow;
  56987. private _coloredMaterial;
  56988. private _hoverMaterial;
  56989. /**
  56990. * Creates an AxisScaleGizmo
  56991. * @param gizmoLayer The utility layer the gizmo will be added to
  56992. * @param dragAxis The axis which the gizmo will be able to scale on
  56993. * @param color The color of the gizmo
  56994. * @param thickness display gizmo axis thickness
  56995. */
  56996. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56997. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56998. /**
  56999. * If the gizmo is enabled
  57000. */
  57001. set isEnabled(value: boolean);
  57002. get isEnabled(): boolean;
  57003. /**
  57004. * Disposes of the gizmo
  57005. */
  57006. dispose(): void;
  57007. /**
  57008. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57009. * @param mesh The mesh to replace the default mesh of the gizmo
  57010. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57011. */
  57012. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57013. }
  57014. }
  57015. declare module BABYLON {
  57016. /**
  57017. * Bounding box gizmo
  57018. */
  57019. export class BoundingBoxGizmo extends Gizmo {
  57020. private _lineBoundingBox;
  57021. private _rotateSpheresParent;
  57022. private _scaleBoxesParent;
  57023. private _boundingDimensions;
  57024. private _renderObserver;
  57025. private _pointerObserver;
  57026. private _scaleDragSpeed;
  57027. private _tmpQuaternion;
  57028. private _tmpVector;
  57029. private _tmpRotationMatrix;
  57030. /**
  57031. * 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)
  57032. */
  57033. ignoreChildren: boolean;
  57034. /**
  57035. * 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)
  57036. */
  57037. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57038. /**
  57039. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57040. */
  57041. rotationSphereSize: number;
  57042. /**
  57043. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57044. */
  57045. scaleBoxSize: number;
  57046. /**
  57047. * 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)
  57048. */
  57049. fixedDragMeshScreenSize: boolean;
  57050. /**
  57051. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57052. */
  57053. fixedDragMeshScreenSizeDistanceFactor: number;
  57054. /**
  57055. * Fired when a rotation sphere or scale box is dragged
  57056. */
  57057. onDragStartObservable: Observable<{}>;
  57058. /**
  57059. * Fired when a scale box is dragged
  57060. */
  57061. onScaleBoxDragObservable: Observable<{}>;
  57062. /**
  57063. * Fired when a scale box drag is ended
  57064. */
  57065. onScaleBoxDragEndObservable: Observable<{}>;
  57066. /**
  57067. * Fired when a rotation sphere is dragged
  57068. */
  57069. onRotationSphereDragObservable: Observable<{}>;
  57070. /**
  57071. * Fired when a rotation sphere drag is ended
  57072. */
  57073. onRotationSphereDragEndObservable: Observable<{}>;
  57074. /**
  57075. * 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)
  57076. */
  57077. scalePivot: Nullable<Vector3>;
  57078. /**
  57079. * Mesh used as a pivot to rotate the attached node
  57080. */
  57081. private _anchorMesh;
  57082. private _existingMeshScale;
  57083. private _dragMesh;
  57084. private pointerDragBehavior;
  57085. private coloredMaterial;
  57086. private hoverColoredMaterial;
  57087. /**
  57088. * Sets the color of the bounding box gizmo
  57089. * @param color the color to set
  57090. */
  57091. setColor(color: Color3): void;
  57092. /**
  57093. * Creates an BoundingBoxGizmo
  57094. * @param gizmoLayer The utility layer the gizmo will be added to
  57095. * @param color The color of the gizmo
  57096. */
  57097. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57098. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57099. private _selectNode;
  57100. /**
  57101. * Updates the bounding box information for the Gizmo
  57102. */
  57103. updateBoundingBox(): void;
  57104. private _updateRotationSpheres;
  57105. private _updateScaleBoxes;
  57106. /**
  57107. * Enables rotation on the specified axis and disables rotation on the others
  57108. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57109. */
  57110. setEnabledRotationAxis(axis: string): void;
  57111. /**
  57112. * Enables/disables scaling
  57113. * @param enable if scaling should be enabled
  57114. * @param homogeneousScaling defines if scaling should only be homogeneous
  57115. */
  57116. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57117. private _updateDummy;
  57118. /**
  57119. * Enables a pointer drag behavior on the bounding box of the gizmo
  57120. */
  57121. enableDragBehavior(): void;
  57122. /**
  57123. * Disposes of the gizmo
  57124. */
  57125. dispose(): void;
  57126. /**
  57127. * 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)
  57128. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57129. * @returns the bounding box mesh with the passed in mesh as a child
  57130. */
  57131. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57132. /**
  57133. * CustomMeshes are not supported by this gizmo
  57134. * @param mesh The mesh to replace the default mesh of the gizmo
  57135. */
  57136. setCustomMesh(mesh: Mesh): void;
  57137. }
  57138. }
  57139. declare module BABYLON {
  57140. /**
  57141. * Single plane rotation gizmo
  57142. */
  57143. export class PlaneRotationGizmo extends Gizmo {
  57144. /**
  57145. * Drag behavior responsible for the gizmos dragging interactions
  57146. */
  57147. dragBehavior: PointerDragBehavior;
  57148. private _pointerObserver;
  57149. /**
  57150. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57151. */
  57152. snapDistance: number;
  57153. /**
  57154. * Event that fires each time the gizmo snaps to a new location.
  57155. * * snapDistance is the the change in distance
  57156. */
  57157. onSnapObservable: Observable<{
  57158. snapDistance: number;
  57159. }>;
  57160. private _isEnabled;
  57161. private _parent;
  57162. /**
  57163. * Creates a PlaneRotationGizmo
  57164. * @param gizmoLayer The utility layer the gizmo will be added to
  57165. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57166. * @param color The color of the gizmo
  57167. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57168. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57169. * @param thickness display gizmo axis thickness
  57170. */
  57171. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57172. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57173. /**
  57174. * If the gizmo is enabled
  57175. */
  57176. set isEnabled(value: boolean);
  57177. get isEnabled(): boolean;
  57178. /**
  57179. * Disposes of the gizmo
  57180. */
  57181. dispose(): void;
  57182. }
  57183. }
  57184. declare module BABYLON {
  57185. /**
  57186. * Gizmo that enables rotating a mesh along 3 axis
  57187. */
  57188. export class RotationGizmo extends Gizmo {
  57189. /**
  57190. * Internal gizmo used for interactions on the x axis
  57191. */
  57192. xGizmo: PlaneRotationGizmo;
  57193. /**
  57194. * Internal gizmo used for interactions on the y axis
  57195. */
  57196. yGizmo: PlaneRotationGizmo;
  57197. /**
  57198. * Internal gizmo used for interactions on the z axis
  57199. */
  57200. zGizmo: PlaneRotationGizmo;
  57201. /** Fires an event when any of it's sub gizmos are dragged */
  57202. onDragStartObservable: Observable<unknown>;
  57203. /** Fires an event when any of it's sub gizmos are released from dragging */
  57204. onDragEndObservable: Observable<unknown>;
  57205. private _meshAttached;
  57206. private _nodeAttached;
  57207. get attachedMesh(): Nullable<AbstractMesh>;
  57208. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57209. get attachedNode(): Nullable<Node>;
  57210. set attachedNode(node: Nullable<Node>);
  57211. protected _checkBillboardTransform(): void;
  57212. /**
  57213. * True when the mouse pointer is hovering a gizmo mesh
  57214. */
  57215. get isHovered(): boolean;
  57216. /**
  57217. * Creates a RotationGizmo
  57218. * @param gizmoLayer The utility layer the gizmo will be added to
  57219. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57220. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57221. * @param thickness display gizmo axis thickness
  57222. */
  57223. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57224. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57225. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57226. /**
  57227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57228. */
  57229. set snapDistance(value: number);
  57230. get snapDistance(): number;
  57231. /**
  57232. * Ratio for the scale of the gizmo (Default: 1)
  57233. */
  57234. set scaleRatio(value: number);
  57235. get scaleRatio(): number;
  57236. /**
  57237. * Disposes of the gizmo
  57238. */
  57239. dispose(): void;
  57240. /**
  57241. * CustomMeshes are not supported by this gizmo
  57242. * @param mesh The mesh to replace the default mesh of the gizmo
  57243. */
  57244. setCustomMesh(mesh: Mesh): void;
  57245. }
  57246. }
  57247. declare module BABYLON {
  57248. /**
  57249. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57250. */
  57251. export class GizmoManager implements IDisposable {
  57252. private scene;
  57253. /**
  57254. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57255. */
  57256. gizmos: {
  57257. positionGizmo: Nullable<PositionGizmo>;
  57258. rotationGizmo: Nullable<RotationGizmo>;
  57259. scaleGizmo: Nullable<ScaleGizmo>;
  57260. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57261. };
  57262. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57263. clearGizmoOnEmptyPointerEvent: boolean;
  57264. /** Fires an event when the manager is attached to a mesh */
  57265. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57266. /** Fires an event when the manager is attached to a node */
  57267. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57268. private _gizmosEnabled;
  57269. private _pointerObserver;
  57270. private _attachedMesh;
  57271. private _attachedNode;
  57272. private _boundingBoxColor;
  57273. private _defaultUtilityLayer;
  57274. private _defaultKeepDepthUtilityLayer;
  57275. private _thickness;
  57276. /**
  57277. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57278. */
  57279. boundingBoxDragBehavior: SixDofDragBehavior;
  57280. /**
  57281. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57282. */
  57283. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57284. /**
  57285. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57286. */
  57287. attachableNodes: Nullable<Array<Node>>;
  57288. /**
  57289. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57290. */
  57291. usePointerToAttachGizmos: boolean;
  57292. /**
  57293. * Utility layer that the bounding box gizmo belongs to
  57294. */
  57295. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57296. /**
  57297. * Utility layer that all gizmos besides bounding box belong to
  57298. */
  57299. get utilityLayer(): UtilityLayerRenderer;
  57300. /**
  57301. * True when the mouse pointer is hovering a gizmo mesh
  57302. */
  57303. get isHovered(): boolean;
  57304. /**
  57305. * Instatiates a gizmo manager
  57306. * @param scene the scene to overlay the gizmos on top of
  57307. * @param thickness display gizmo axis thickness
  57308. */
  57309. constructor(scene: Scene, thickness?: number);
  57310. /**
  57311. * Attaches a set of gizmos to the specified mesh
  57312. * @param mesh The mesh the gizmo's should be attached to
  57313. */
  57314. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57315. /**
  57316. * Attaches a set of gizmos to the specified node
  57317. * @param node The node the gizmo's should be attached to
  57318. */
  57319. attachToNode(node: Nullable<Node>): void;
  57320. /**
  57321. * If the position gizmo is enabled
  57322. */
  57323. set positionGizmoEnabled(value: boolean);
  57324. get positionGizmoEnabled(): boolean;
  57325. /**
  57326. * If the rotation gizmo is enabled
  57327. */
  57328. set rotationGizmoEnabled(value: boolean);
  57329. get rotationGizmoEnabled(): boolean;
  57330. /**
  57331. * If the scale gizmo is enabled
  57332. */
  57333. set scaleGizmoEnabled(value: boolean);
  57334. get scaleGizmoEnabled(): boolean;
  57335. /**
  57336. * If the boundingBox gizmo is enabled
  57337. */
  57338. set boundingBoxGizmoEnabled(value: boolean);
  57339. get boundingBoxGizmoEnabled(): boolean;
  57340. /**
  57341. * Disposes of the gizmo manager
  57342. */
  57343. dispose(): void;
  57344. }
  57345. }
  57346. declare module BABYLON {
  57347. /**
  57348. * A directional light is defined by a direction (what a surprise!).
  57349. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57350. * 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.
  57351. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57352. */
  57353. export class DirectionalLight extends ShadowLight {
  57354. private _shadowFrustumSize;
  57355. /**
  57356. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57357. */
  57358. get shadowFrustumSize(): number;
  57359. /**
  57360. * Specifies a fix frustum size for the shadow generation.
  57361. */
  57362. set shadowFrustumSize(value: number);
  57363. private _shadowOrthoScale;
  57364. /**
  57365. * Gets the shadow projection scale against the optimal computed one.
  57366. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57367. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57368. */
  57369. get shadowOrthoScale(): number;
  57370. /**
  57371. * Sets the shadow projection scale against the optimal computed one.
  57372. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57373. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57374. */
  57375. set shadowOrthoScale(value: number);
  57376. /**
  57377. * Automatically compute the projection matrix to best fit (including all the casters)
  57378. * on each frame.
  57379. */
  57380. autoUpdateExtends: boolean;
  57381. /**
  57382. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57383. * on each frame. autoUpdateExtends must be set to true for this to work
  57384. */
  57385. autoCalcShadowZBounds: boolean;
  57386. private _orthoLeft;
  57387. private _orthoRight;
  57388. private _orthoTop;
  57389. private _orthoBottom;
  57390. /**
  57391. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57392. * The directional light is emitted from everywhere in the given direction.
  57393. * It can cast shadows.
  57394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57395. * @param name The friendly name of the light
  57396. * @param direction The direction of the light
  57397. * @param scene The scene the light belongs to
  57398. */
  57399. constructor(name: string, direction: Vector3, scene: Scene);
  57400. /**
  57401. * Returns the string "DirectionalLight".
  57402. * @return The class name
  57403. */
  57404. getClassName(): string;
  57405. /**
  57406. * Returns the integer 1.
  57407. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57408. */
  57409. getTypeID(): number;
  57410. /**
  57411. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57412. * Returns the DirectionalLight Shadow projection matrix.
  57413. */
  57414. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57415. /**
  57416. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57417. * Returns the DirectionalLight Shadow projection matrix.
  57418. */
  57419. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57420. /**
  57421. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57422. * Returns the DirectionalLight Shadow projection matrix.
  57423. */
  57424. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57425. protected _buildUniformLayout(): void;
  57426. /**
  57427. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57428. * @param effect The effect to update
  57429. * @param lightIndex The index of the light in the effect to update
  57430. * @returns The directional light
  57431. */
  57432. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57433. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57434. /**
  57435. * Gets the minZ used for shadow according to both the scene and the light.
  57436. *
  57437. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57438. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57439. * @param activeCamera The camera we are returning the min for
  57440. * @returns the depth min z
  57441. */
  57442. getDepthMinZ(activeCamera: Camera): number;
  57443. /**
  57444. * Gets the maxZ used for shadow according to both the scene and the light.
  57445. *
  57446. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57447. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57448. * @param activeCamera The camera we are returning the max for
  57449. * @returns the depth max z
  57450. */
  57451. getDepthMaxZ(activeCamera: Camera): number;
  57452. /**
  57453. * Prepares the list of defines specific to the light type.
  57454. * @param defines the list of defines
  57455. * @param lightIndex defines the index of the light for the effect
  57456. */
  57457. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57458. }
  57459. }
  57460. declare module BABYLON {
  57461. /**
  57462. * Class containing static functions to help procedurally build meshes
  57463. */
  57464. export class HemisphereBuilder {
  57465. /**
  57466. * Creates a hemisphere mesh
  57467. * @param name defines the name of the mesh
  57468. * @param options defines the options used to create the mesh
  57469. * @param scene defines the hosting scene
  57470. * @returns the hemisphere mesh
  57471. */
  57472. static CreateHemisphere(name: string, options: {
  57473. segments?: number;
  57474. diameter?: number;
  57475. sideOrientation?: number;
  57476. }, scene: any): Mesh;
  57477. }
  57478. }
  57479. declare module BABYLON {
  57480. /**
  57481. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57482. * These values define a cone of light starting from the position, emitting toward the direction.
  57483. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57484. * and the exponent defines the speed of the decay of the light with distance (reach).
  57485. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57486. */
  57487. export class SpotLight extends ShadowLight {
  57488. private _angle;
  57489. private _innerAngle;
  57490. private _cosHalfAngle;
  57491. private _lightAngleScale;
  57492. private _lightAngleOffset;
  57493. /**
  57494. * Gets the cone angle of the spot light in Radians.
  57495. */
  57496. get angle(): number;
  57497. /**
  57498. * Sets the cone angle of the spot light in Radians.
  57499. */
  57500. set angle(value: number);
  57501. /**
  57502. * Only used in gltf falloff mode, this defines the angle where
  57503. * the directional falloff will start before cutting at angle which could be seen
  57504. * as outer angle.
  57505. */
  57506. get innerAngle(): number;
  57507. /**
  57508. * Only used in gltf falloff mode, this defines the angle where
  57509. * the directional falloff will start before cutting at angle which could be seen
  57510. * as outer angle.
  57511. */
  57512. set innerAngle(value: number);
  57513. private _shadowAngleScale;
  57514. /**
  57515. * Allows scaling the angle of the light for shadow generation only.
  57516. */
  57517. get shadowAngleScale(): number;
  57518. /**
  57519. * Allows scaling the angle of the light for shadow generation only.
  57520. */
  57521. set shadowAngleScale(value: number);
  57522. /**
  57523. * The light decay speed with the distance from the emission spot.
  57524. */
  57525. exponent: number;
  57526. private _projectionTextureMatrix;
  57527. /**
  57528. * Allows reading the projecton texture
  57529. */
  57530. get projectionTextureMatrix(): Matrix;
  57531. protected _projectionTextureLightNear: number;
  57532. /**
  57533. * Gets the near clip of the Spotlight for texture projection.
  57534. */
  57535. get projectionTextureLightNear(): number;
  57536. /**
  57537. * Sets the near clip of the Spotlight for texture projection.
  57538. */
  57539. set projectionTextureLightNear(value: number);
  57540. protected _projectionTextureLightFar: number;
  57541. /**
  57542. * Gets the far clip of the Spotlight for texture projection.
  57543. */
  57544. get projectionTextureLightFar(): number;
  57545. /**
  57546. * Sets the far clip of the Spotlight for texture projection.
  57547. */
  57548. set projectionTextureLightFar(value: number);
  57549. protected _projectionTextureUpDirection: Vector3;
  57550. /**
  57551. * Gets the Up vector of the Spotlight for texture projection.
  57552. */
  57553. get projectionTextureUpDirection(): Vector3;
  57554. /**
  57555. * Sets the Up vector of the Spotlight for texture projection.
  57556. */
  57557. set projectionTextureUpDirection(value: Vector3);
  57558. private _projectionTexture;
  57559. /**
  57560. * Gets the projection texture of the light.
  57561. */
  57562. get projectionTexture(): Nullable<BaseTexture>;
  57563. /**
  57564. * Sets the projection texture of the light.
  57565. */
  57566. set projectionTexture(value: Nullable<BaseTexture>);
  57567. private static _IsProceduralTexture;
  57568. private static _IsTexture;
  57569. private _projectionTextureViewLightDirty;
  57570. private _projectionTextureProjectionLightDirty;
  57571. private _projectionTextureDirty;
  57572. private _projectionTextureViewTargetVector;
  57573. private _projectionTextureViewLightMatrix;
  57574. private _projectionTextureProjectionLightMatrix;
  57575. private _projectionTextureScalingMatrix;
  57576. /**
  57577. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57578. * It can cast shadows.
  57579. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57580. * @param name The light friendly name
  57581. * @param position The position of the spot light in the scene
  57582. * @param direction The direction of the light in the scene
  57583. * @param angle The cone angle of the light in Radians
  57584. * @param exponent The light decay speed with the distance from the emission spot
  57585. * @param scene The scene the lights belongs to
  57586. */
  57587. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57588. /**
  57589. * Returns the string "SpotLight".
  57590. * @returns the class name
  57591. */
  57592. getClassName(): string;
  57593. /**
  57594. * Returns the integer 2.
  57595. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57596. */
  57597. getTypeID(): number;
  57598. /**
  57599. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57600. */
  57601. protected _setDirection(value: Vector3): void;
  57602. /**
  57603. * Overrides the position setter to recompute the projection texture view light Matrix.
  57604. */
  57605. protected _setPosition(value: Vector3): void;
  57606. /**
  57607. * 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.
  57608. * Returns the SpotLight.
  57609. */
  57610. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57611. protected _computeProjectionTextureViewLightMatrix(): void;
  57612. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57613. /**
  57614. * Main function for light texture projection matrix computing.
  57615. */
  57616. protected _computeProjectionTextureMatrix(): void;
  57617. protected _buildUniformLayout(): void;
  57618. private _computeAngleValues;
  57619. /**
  57620. * Sets the passed Effect "effect" with the Light textures.
  57621. * @param effect The effect to update
  57622. * @param lightIndex The index of the light in the effect to update
  57623. * @returns The light
  57624. */
  57625. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57626. /**
  57627. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57628. * @param effect The effect to update
  57629. * @param lightIndex The index of the light in the effect to update
  57630. * @returns The spot light
  57631. */
  57632. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57633. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57634. /**
  57635. * Disposes the light and the associated resources.
  57636. */
  57637. dispose(): void;
  57638. /**
  57639. * Prepares the list of defines specific to the light type.
  57640. * @param defines the list of defines
  57641. * @param lightIndex defines the index of the light for the effect
  57642. */
  57643. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57644. }
  57645. }
  57646. declare module BABYLON {
  57647. /**
  57648. * Gizmo that enables viewing a light
  57649. */
  57650. export class LightGizmo extends Gizmo {
  57651. private _lightMesh;
  57652. private _material;
  57653. private _cachedPosition;
  57654. private _cachedForward;
  57655. private _attachedMeshParent;
  57656. private _pointerObserver;
  57657. /**
  57658. * Event that fires each time the gizmo is clicked
  57659. */
  57660. onClickedObservable: Observable<Light>;
  57661. /**
  57662. * Creates a LightGizmo
  57663. * @param gizmoLayer The utility layer the gizmo will be added to
  57664. */
  57665. constructor(gizmoLayer?: UtilityLayerRenderer);
  57666. private _light;
  57667. /**
  57668. * The light that the gizmo is attached to
  57669. */
  57670. set light(light: Nullable<Light>);
  57671. get light(): Nullable<Light>;
  57672. /**
  57673. * Gets the material used to render the light gizmo
  57674. */
  57675. get material(): StandardMaterial;
  57676. /**
  57677. * @hidden
  57678. * Updates the gizmo to match the attached mesh's position/rotation
  57679. */
  57680. protected _update(): void;
  57681. private static _Scale;
  57682. /**
  57683. * Creates the lines for a light mesh
  57684. */
  57685. private static _CreateLightLines;
  57686. /**
  57687. * Disposes of the light gizmo
  57688. */
  57689. dispose(): void;
  57690. private static _CreateHemisphericLightMesh;
  57691. private static _CreatePointLightMesh;
  57692. private static _CreateSpotLightMesh;
  57693. private static _CreateDirectionalLightMesh;
  57694. }
  57695. }
  57696. declare module BABYLON {
  57697. /**
  57698. * Gizmo that enables viewing a camera
  57699. */
  57700. export class CameraGizmo extends Gizmo {
  57701. private _cameraMesh;
  57702. private _cameraLinesMesh;
  57703. private _material;
  57704. private _pointerObserver;
  57705. /**
  57706. * Event that fires each time the gizmo is clicked
  57707. */
  57708. onClickedObservable: Observable<Camera>;
  57709. /**
  57710. * Creates a CameraGizmo
  57711. * @param gizmoLayer The utility layer the gizmo will be added to
  57712. */
  57713. constructor(gizmoLayer?: UtilityLayerRenderer);
  57714. private _camera;
  57715. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57716. get displayFrustum(): boolean;
  57717. set displayFrustum(value: boolean);
  57718. /**
  57719. * The camera that the gizmo is attached to
  57720. */
  57721. set camera(camera: Nullable<Camera>);
  57722. get camera(): Nullable<Camera>;
  57723. /**
  57724. * Gets the material used to render the camera gizmo
  57725. */
  57726. get material(): StandardMaterial;
  57727. /**
  57728. * @hidden
  57729. * Updates the gizmo to match the attached mesh's position/rotation
  57730. */
  57731. protected _update(): void;
  57732. private static _Scale;
  57733. private _invProjection;
  57734. /**
  57735. * Disposes of the camera gizmo
  57736. */
  57737. dispose(): void;
  57738. private static _CreateCameraMesh;
  57739. private static _CreateCameraFrustum;
  57740. }
  57741. }
  57742. declare module BABYLON {
  57743. /** @hidden */
  57744. export var backgroundFragmentDeclaration: {
  57745. name: string;
  57746. shader: string;
  57747. };
  57748. }
  57749. declare module BABYLON {
  57750. /** @hidden */
  57751. export var backgroundUboDeclaration: {
  57752. name: string;
  57753. shader: string;
  57754. };
  57755. }
  57756. declare module BABYLON {
  57757. /** @hidden */
  57758. export var backgroundPixelShader: {
  57759. name: string;
  57760. shader: string;
  57761. };
  57762. }
  57763. declare module BABYLON {
  57764. /** @hidden */
  57765. export var backgroundVertexDeclaration: {
  57766. name: string;
  57767. shader: string;
  57768. };
  57769. }
  57770. declare module BABYLON {
  57771. /** @hidden */
  57772. export var backgroundVertexShader: {
  57773. name: string;
  57774. shader: string;
  57775. };
  57776. }
  57777. declare module BABYLON {
  57778. /**
  57779. * Background material used to create an efficient environement around your scene.
  57780. */
  57781. export class BackgroundMaterial extends PushMaterial {
  57782. /**
  57783. * Standard reflectance value at parallel view angle.
  57784. */
  57785. static StandardReflectance0: number;
  57786. /**
  57787. * Standard reflectance value at grazing angle.
  57788. */
  57789. static StandardReflectance90: number;
  57790. protected _primaryColor: Color3;
  57791. /**
  57792. * Key light Color (multiply against the environement texture)
  57793. */
  57794. primaryColor: Color3;
  57795. protected __perceptualColor: Nullable<Color3>;
  57796. /**
  57797. * Experimental Internal Use Only.
  57798. *
  57799. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57800. * This acts as a helper to set the primary color to a more "human friendly" value.
  57801. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57802. * output color as close as possible from the chosen value.
  57803. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57804. * part of lighting setup.)
  57805. */
  57806. get _perceptualColor(): Nullable<Color3>;
  57807. set _perceptualColor(value: Nullable<Color3>);
  57808. protected _primaryColorShadowLevel: float;
  57809. /**
  57810. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57811. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57812. */
  57813. get primaryColorShadowLevel(): float;
  57814. set primaryColorShadowLevel(value: float);
  57815. protected _primaryColorHighlightLevel: float;
  57816. /**
  57817. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57818. * The primary color is used at the level chosen to define what the white area would look.
  57819. */
  57820. get primaryColorHighlightLevel(): float;
  57821. set primaryColorHighlightLevel(value: float);
  57822. protected _reflectionTexture: Nullable<BaseTexture>;
  57823. /**
  57824. * Reflection Texture used in the material.
  57825. * Should be author in a specific way for the best result (refer to the documentation).
  57826. */
  57827. reflectionTexture: Nullable<BaseTexture>;
  57828. protected _reflectionBlur: float;
  57829. /**
  57830. * Reflection Texture level of blur.
  57831. *
  57832. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57833. * texture twice.
  57834. */
  57835. reflectionBlur: float;
  57836. protected _diffuseTexture: Nullable<BaseTexture>;
  57837. /**
  57838. * Diffuse Texture used in the material.
  57839. * Should be author in a specific way for the best result (refer to the documentation).
  57840. */
  57841. diffuseTexture: Nullable<BaseTexture>;
  57842. protected _shadowLights: Nullable<IShadowLight[]>;
  57843. /**
  57844. * Specify the list of lights casting shadow on the material.
  57845. * All scene shadow lights will be included if null.
  57846. */
  57847. shadowLights: Nullable<IShadowLight[]>;
  57848. protected _shadowLevel: float;
  57849. /**
  57850. * Helps adjusting the shadow to a softer level if required.
  57851. * 0 means black shadows and 1 means no shadows.
  57852. */
  57853. shadowLevel: float;
  57854. protected _sceneCenter: Vector3;
  57855. /**
  57856. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57857. * It is usually zero but might be interesting to modify according to your setup.
  57858. */
  57859. sceneCenter: Vector3;
  57860. protected _opacityFresnel: boolean;
  57861. /**
  57862. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57863. * This helps ensuring a nice transition when the camera goes under the ground.
  57864. */
  57865. opacityFresnel: boolean;
  57866. protected _reflectionFresnel: boolean;
  57867. /**
  57868. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57869. * This helps adding a mirror texture on the ground.
  57870. */
  57871. reflectionFresnel: boolean;
  57872. protected _reflectionFalloffDistance: number;
  57873. /**
  57874. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57875. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57876. */
  57877. reflectionFalloffDistance: number;
  57878. protected _reflectionAmount: number;
  57879. /**
  57880. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57881. */
  57882. reflectionAmount: number;
  57883. protected _reflectionReflectance0: number;
  57884. /**
  57885. * This specifies the weight of the reflection at grazing angle.
  57886. */
  57887. reflectionReflectance0: number;
  57888. protected _reflectionReflectance90: number;
  57889. /**
  57890. * This specifies the weight of the reflection at a perpendicular point of view.
  57891. */
  57892. reflectionReflectance90: number;
  57893. /**
  57894. * Sets the reflection reflectance fresnel values according to the default standard
  57895. * empirically know to work well :-)
  57896. */
  57897. set reflectionStandardFresnelWeight(value: number);
  57898. protected _useRGBColor: boolean;
  57899. /**
  57900. * Helps to directly use the maps channels instead of their level.
  57901. */
  57902. useRGBColor: boolean;
  57903. protected _enableNoise: boolean;
  57904. /**
  57905. * This helps reducing the banding effect that could occur on the background.
  57906. */
  57907. enableNoise: boolean;
  57908. /**
  57909. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57910. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57911. * Recommended to be keep at 1.0 except for special cases.
  57912. */
  57913. get fovMultiplier(): number;
  57914. set fovMultiplier(value: number);
  57915. private _fovMultiplier;
  57916. /**
  57917. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57918. */
  57919. useEquirectangularFOV: boolean;
  57920. private _maxSimultaneousLights;
  57921. /**
  57922. * Number of Simultaneous lights allowed on the material.
  57923. */
  57924. maxSimultaneousLights: int;
  57925. private _shadowOnly;
  57926. /**
  57927. * Make the material only render shadows
  57928. */
  57929. shadowOnly: boolean;
  57930. /**
  57931. * Default configuration related to image processing available in the Background Material.
  57932. */
  57933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57934. /**
  57935. * Keep track of the image processing observer to allow dispose and replace.
  57936. */
  57937. private _imageProcessingObserver;
  57938. /**
  57939. * Attaches a new image processing configuration to the PBR Material.
  57940. * @param configuration (if null the scene configuration will be use)
  57941. */
  57942. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57943. /**
  57944. * Gets the image processing configuration used either in this material.
  57945. */
  57946. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57947. /**
  57948. * Sets the Default image processing configuration used either in the this material.
  57949. *
  57950. * If sets to null, the scene one is in use.
  57951. */
  57952. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57953. /**
  57954. * Gets wether the color curves effect is enabled.
  57955. */
  57956. get cameraColorCurvesEnabled(): boolean;
  57957. /**
  57958. * Sets wether the color curves effect is enabled.
  57959. */
  57960. set cameraColorCurvesEnabled(value: boolean);
  57961. /**
  57962. * Gets wether the color grading effect is enabled.
  57963. */
  57964. get cameraColorGradingEnabled(): boolean;
  57965. /**
  57966. * Gets wether the color grading effect is enabled.
  57967. */
  57968. set cameraColorGradingEnabled(value: boolean);
  57969. /**
  57970. * Gets wether tonemapping is enabled or not.
  57971. */
  57972. get cameraToneMappingEnabled(): boolean;
  57973. /**
  57974. * Sets wether tonemapping is enabled or not
  57975. */
  57976. set cameraToneMappingEnabled(value: boolean);
  57977. /**
  57978. * The camera exposure used on this material.
  57979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57980. * This corresponds to a photographic exposure.
  57981. */
  57982. get cameraExposure(): float;
  57983. /**
  57984. * The camera exposure used on this material.
  57985. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57986. * This corresponds to a photographic exposure.
  57987. */
  57988. set cameraExposure(value: float);
  57989. /**
  57990. * Gets The camera contrast used on this material.
  57991. */
  57992. get cameraContrast(): float;
  57993. /**
  57994. * Sets The camera contrast used on this material.
  57995. */
  57996. set cameraContrast(value: float);
  57997. /**
  57998. * Gets the Color Grading 2D Lookup Texture.
  57999. */
  58000. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58001. /**
  58002. * Sets the Color Grading 2D Lookup Texture.
  58003. */
  58004. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58005. /**
  58006. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58007. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58008. * 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;
  58009. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58010. */
  58011. get cameraColorCurves(): Nullable<ColorCurves>;
  58012. /**
  58013. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58014. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58015. * 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;
  58016. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58017. */
  58018. set cameraColorCurves(value: Nullable<ColorCurves>);
  58019. /**
  58020. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58021. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58022. */
  58023. switchToBGR: boolean;
  58024. private _renderTargets;
  58025. private _reflectionControls;
  58026. private _white;
  58027. private _primaryShadowColor;
  58028. private _primaryHighlightColor;
  58029. /**
  58030. * Instantiates a Background Material in the given scene
  58031. * @param name The friendly name of the material
  58032. * @param scene The scene to add the material to
  58033. */
  58034. constructor(name: string, scene: Scene);
  58035. /**
  58036. * Gets a boolean indicating that current material needs to register RTT
  58037. */
  58038. get hasRenderTargetTextures(): boolean;
  58039. /**
  58040. * The entire material has been created in order to prevent overdraw.
  58041. * @returns false
  58042. */
  58043. needAlphaTesting(): boolean;
  58044. /**
  58045. * The entire material has been created in order to prevent overdraw.
  58046. * @returns true if blending is enable
  58047. */
  58048. needAlphaBlending(): boolean;
  58049. /**
  58050. * Checks wether the material is ready to be rendered for a given mesh.
  58051. * @param mesh The mesh to render
  58052. * @param subMesh The submesh to check against
  58053. * @param useInstances Specify wether or not the material is used with instances
  58054. * @returns true if all the dependencies are ready (Textures, Effects...)
  58055. */
  58056. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58057. /**
  58058. * Compute the primary color according to the chosen perceptual color.
  58059. */
  58060. private _computePrimaryColorFromPerceptualColor;
  58061. /**
  58062. * Compute the highlights and shadow colors according to their chosen levels.
  58063. */
  58064. private _computePrimaryColors;
  58065. /**
  58066. * Build the uniform buffer used in the material.
  58067. */
  58068. buildUniformLayout(): void;
  58069. /**
  58070. * Unbind the material.
  58071. */
  58072. unbind(): void;
  58073. /**
  58074. * Bind only the world matrix to the material.
  58075. * @param world The world matrix to bind.
  58076. */
  58077. bindOnlyWorldMatrix(world: Matrix): void;
  58078. /**
  58079. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58080. * @param world The world matrix to bind.
  58081. * @param subMesh The submesh to bind for.
  58082. */
  58083. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58084. /**
  58085. * Checks to see if a texture is used in the material.
  58086. * @param texture - Base texture to use.
  58087. * @returns - Boolean specifying if a texture is used in the material.
  58088. */
  58089. hasTexture(texture: BaseTexture): boolean;
  58090. /**
  58091. * Dispose the material.
  58092. * @param forceDisposeEffect Force disposal of the associated effect.
  58093. * @param forceDisposeTextures Force disposal of the associated textures.
  58094. */
  58095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58096. /**
  58097. * Clones the material.
  58098. * @param name The cloned name.
  58099. * @returns The cloned material.
  58100. */
  58101. clone(name: string): BackgroundMaterial;
  58102. /**
  58103. * Serializes the current material to its JSON representation.
  58104. * @returns The JSON representation.
  58105. */
  58106. serialize(): any;
  58107. /**
  58108. * Gets the class name of the material
  58109. * @returns "BackgroundMaterial"
  58110. */
  58111. getClassName(): string;
  58112. /**
  58113. * Parse a JSON input to create back a background material.
  58114. * @param source The JSON data to parse
  58115. * @param scene The scene to create the parsed material in
  58116. * @param rootUrl The root url of the assets the material depends upon
  58117. * @returns the instantiated BackgroundMaterial.
  58118. */
  58119. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58120. }
  58121. }
  58122. declare module BABYLON {
  58123. /**
  58124. * Represents the different options available during the creation of
  58125. * a Environment helper.
  58126. *
  58127. * This can control the default ground, skybox and image processing setup of your scene.
  58128. */
  58129. export interface IEnvironmentHelperOptions {
  58130. /**
  58131. * Specifies whether or not to create a ground.
  58132. * True by default.
  58133. */
  58134. createGround: boolean;
  58135. /**
  58136. * Specifies the ground size.
  58137. * 15 by default.
  58138. */
  58139. groundSize: number;
  58140. /**
  58141. * The texture used on the ground for the main color.
  58142. * Comes from the BabylonJS CDN by default.
  58143. *
  58144. * Remarks: Can be either a texture or a url.
  58145. */
  58146. groundTexture: string | BaseTexture;
  58147. /**
  58148. * The color mixed in the ground texture by default.
  58149. * BabylonJS clearColor by default.
  58150. */
  58151. groundColor: Color3;
  58152. /**
  58153. * Specifies the ground opacity.
  58154. * 1 by default.
  58155. */
  58156. groundOpacity: number;
  58157. /**
  58158. * Enables the ground to receive shadows.
  58159. * True by default.
  58160. */
  58161. enableGroundShadow: boolean;
  58162. /**
  58163. * Helps preventing the shadow to be fully black on the ground.
  58164. * 0.5 by default.
  58165. */
  58166. groundShadowLevel: number;
  58167. /**
  58168. * Creates a mirror texture attach to the ground.
  58169. * false by default.
  58170. */
  58171. enableGroundMirror: boolean;
  58172. /**
  58173. * Specifies the ground mirror size ratio.
  58174. * 0.3 by default as the default kernel is 64.
  58175. */
  58176. groundMirrorSizeRatio: number;
  58177. /**
  58178. * Specifies the ground mirror blur kernel size.
  58179. * 64 by default.
  58180. */
  58181. groundMirrorBlurKernel: number;
  58182. /**
  58183. * Specifies the ground mirror visibility amount.
  58184. * 1 by default
  58185. */
  58186. groundMirrorAmount: number;
  58187. /**
  58188. * Specifies the ground mirror reflectance weight.
  58189. * This uses the standard weight of the background material to setup the fresnel effect
  58190. * of the mirror.
  58191. * 1 by default.
  58192. */
  58193. groundMirrorFresnelWeight: number;
  58194. /**
  58195. * Specifies the ground mirror Falloff distance.
  58196. * This can helps reducing the size of the reflection.
  58197. * 0 by Default.
  58198. */
  58199. groundMirrorFallOffDistance: number;
  58200. /**
  58201. * Specifies the ground mirror texture type.
  58202. * Unsigned Int by Default.
  58203. */
  58204. groundMirrorTextureType: number;
  58205. /**
  58206. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58207. * the shown objects.
  58208. */
  58209. groundYBias: number;
  58210. /**
  58211. * Specifies whether or not to create a skybox.
  58212. * True by default.
  58213. */
  58214. createSkybox: boolean;
  58215. /**
  58216. * Specifies the skybox size.
  58217. * 20 by default.
  58218. */
  58219. skyboxSize: number;
  58220. /**
  58221. * The texture used on the skybox for the main color.
  58222. * Comes from the BabylonJS CDN by default.
  58223. *
  58224. * Remarks: Can be either a texture or a url.
  58225. */
  58226. skyboxTexture: string | BaseTexture;
  58227. /**
  58228. * The color mixed in the skybox texture by default.
  58229. * BabylonJS clearColor by default.
  58230. */
  58231. skyboxColor: Color3;
  58232. /**
  58233. * The background rotation around the Y axis of the scene.
  58234. * This helps aligning the key lights of your scene with the background.
  58235. * 0 by default.
  58236. */
  58237. backgroundYRotation: number;
  58238. /**
  58239. * Compute automatically the size of the elements to best fit with the scene.
  58240. */
  58241. sizeAuto: boolean;
  58242. /**
  58243. * Default position of the rootMesh if autoSize is not true.
  58244. */
  58245. rootPosition: Vector3;
  58246. /**
  58247. * Sets up the image processing in the scene.
  58248. * true by default.
  58249. */
  58250. setupImageProcessing: boolean;
  58251. /**
  58252. * The texture used as your environment texture in the scene.
  58253. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58254. *
  58255. * Remarks: Can be either a texture or a url.
  58256. */
  58257. environmentTexture: string | BaseTexture;
  58258. /**
  58259. * The value of the exposure to apply to the scene.
  58260. * 0.6 by default if setupImageProcessing is true.
  58261. */
  58262. cameraExposure: number;
  58263. /**
  58264. * The value of the contrast to apply to the scene.
  58265. * 1.6 by default if setupImageProcessing is true.
  58266. */
  58267. cameraContrast: number;
  58268. /**
  58269. * Specifies whether or not tonemapping should be enabled in the scene.
  58270. * true by default if setupImageProcessing is true.
  58271. */
  58272. toneMappingEnabled: boolean;
  58273. }
  58274. /**
  58275. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58276. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58277. * It also helps with the default setup of your imageProcessing configuration.
  58278. */
  58279. export class EnvironmentHelper {
  58280. /**
  58281. * Default ground texture URL.
  58282. */
  58283. private static _groundTextureCDNUrl;
  58284. /**
  58285. * Default skybox texture URL.
  58286. */
  58287. private static _skyboxTextureCDNUrl;
  58288. /**
  58289. * Default environment texture URL.
  58290. */
  58291. private static _environmentTextureCDNUrl;
  58292. /**
  58293. * Creates the default options for the helper.
  58294. */
  58295. private static _getDefaultOptions;
  58296. private _rootMesh;
  58297. /**
  58298. * Gets the root mesh created by the helper.
  58299. */
  58300. get rootMesh(): Mesh;
  58301. private _skybox;
  58302. /**
  58303. * Gets the skybox created by the helper.
  58304. */
  58305. get skybox(): Nullable<Mesh>;
  58306. private _skyboxTexture;
  58307. /**
  58308. * Gets the skybox texture created by the helper.
  58309. */
  58310. get skyboxTexture(): Nullable<BaseTexture>;
  58311. private _skyboxMaterial;
  58312. /**
  58313. * Gets the skybox material created by the helper.
  58314. */
  58315. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58316. private _ground;
  58317. /**
  58318. * Gets the ground mesh created by the helper.
  58319. */
  58320. get ground(): Nullable<Mesh>;
  58321. private _groundTexture;
  58322. /**
  58323. * Gets the ground texture created by the helper.
  58324. */
  58325. get groundTexture(): Nullable<BaseTexture>;
  58326. private _groundMirror;
  58327. /**
  58328. * Gets the ground mirror created by the helper.
  58329. */
  58330. get groundMirror(): Nullable<MirrorTexture>;
  58331. /**
  58332. * Gets the ground mirror render list to helps pushing the meshes
  58333. * you wish in the ground reflection.
  58334. */
  58335. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58336. private _groundMaterial;
  58337. /**
  58338. * Gets the ground material created by the helper.
  58339. */
  58340. get groundMaterial(): Nullable<BackgroundMaterial>;
  58341. /**
  58342. * Stores the creation options.
  58343. */
  58344. private readonly _scene;
  58345. private _options;
  58346. /**
  58347. * This observable will be notified with any error during the creation of the environment,
  58348. * mainly texture creation errors.
  58349. */
  58350. onErrorObservable: Observable<{
  58351. message?: string;
  58352. exception?: any;
  58353. }>;
  58354. /**
  58355. * constructor
  58356. * @param options Defines the options we want to customize the helper
  58357. * @param scene The scene to add the material to
  58358. */
  58359. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58360. /**
  58361. * Updates the background according to the new options
  58362. * @param options
  58363. */
  58364. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58365. /**
  58366. * Sets the primary color of all the available elements.
  58367. * @param color the main color to affect to the ground and the background
  58368. */
  58369. setMainColor(color: Color3): void;
  58370. /**
  58371. * Setup the image processing according to the specified options.
  58372. */
  58373. private _setupImageProcessing;
  58374. /**
  58375. * Setup the environment texture according to the specified options.
  58376. */
  58377. private _setupEnvironmentTexture;
  58378. /**
  58379. * Setup the background according to the specified options.
  58380. */
  58381. private _setupBackground;
  58382. /**
  58383. * Get the scene sizes according to the setup.
  58384. */
  58385. private _getSceneSize;
  58386. /**
  58387. * Setup the ground according to the specified options.
  58388. */
  58389. private _setupGround;
  58390. /**
  58391. * Setup the ground material according to the specified options.
  58392. */
  58393. private _setupGroundMaterial;
  58394. /**
  58395. * Setup the ground diffuse texture according to the specified options.
  58396. */
  58397. private _setupGroundDiffuseTexture;
  58398. /**
  58399. * Setup the ground mirror texture according to the specified options.
  58400. */
  58401. private _setupGroundMirrorTexture;
  58402. /**
  58403. * Setup the ground to receive the mirror texture.
  58404. */
  58405. private _setupMirrorInGroundMaterial;
  58406. /**
  58407. * Setup the skybox according to the specified options.
  58408. */
  58409. private _setupSkybox;
  58410. /**
  58411. * Setup the skybox material according to the specified options.
  58412. */
  58413. private _setupSkyboxMaterial;
  58414. /**
  58415. * Setup the skybox reflection texture according to the specified options.
  58416. */
  58417. private _setupSkyboxReflectionTexture;
  58418. private _errorHandler;
  58419. /**
  58420. * Dispose all the elements created by the Helper.
  58421. */
  58422. dispose(): void;
  58423. }
  58424. }
  58425. declare module BABYLON {
  58426. /**
  58427. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58428. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58429. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58430. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58431. */
  58432. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58433. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58434. /**
  58435. * Define the source as a Monoscopic panoramic 360/180.
  58436. */
  58437. static readonly MODE_MONOSCOPIC: number;
  58438. /**
  58439. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58440. */
  58441. static readonly MODE_TOPBOTTOM: number;
  58442. /**
  58443. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58444. */
  58445. static readonly MODE_SIDEBYSIDE: number;
  58446. private _halfDome;
  58447. private _crossEye;
  58448. protected _useDirectMapping: boolean;
  58449. /**
  58450. * The texture being displayed on the sphere
  58451. */
  58452. protected _texture: T;
  58453. /**
  58454. * Gets the texture being displayed on the sphere
  58455. */
  58456. get texture(): T;
  58457. /**
  58458. * Sets the texture being displayed on the sphere
  58459. */
  58460. set texture(newTexture: T);
  58461. /**
  58462. * The skybox material
  58463. */
  58464. protected _material: BackgroundMaterial;
  58465. /**
  58466. * The surface used for the dome
  58467. */
  58468. protected _mesh: Mesh;
  58469. /**
  58470. * Gets the mesh used for the dome.
  58471. */
  58472. get mesh(): Mesh;
  58473. /**
  58474. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58475. */
  58476. private _halfDomeMask;
  58477. /**
  58478. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58479. * Also see the options.resolution property.
  58480. */
  58481. get fovMultiplier(): number;
  58482. set fovMultiplier(value: number);
  58483. protected _textureMode: number;
  58484. /**
  58485. * Gets or set the current texture mode for the texture. It can be:
  58486. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58487. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58488. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58489. */
  58490. get textureMode(): number;
  58491. /**
  58492. * Sets the current texture mode for the texture. It can be:
  58493. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58494. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58495. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58496. */
  58497. set textureMode(value: number);
  58498. /**
  58499. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58500. */
  58501. get halfDome(): boolean;
  58502. /**
  58503. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58504. */
  58505. set halfDome(enabled: boolean);
  58506. /**
  58507. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58508. */
  58509. set crossEye(enabled: boolean);
  58510. /**
  58511. * Is it a cross-eye texture?
  58512. */
  58513. get crossEye(): boolean;
  58514. /**
  58515. * The background material of this dome.
  58516. */
  58517. get material(): BackgroundMaterial;
  58518. /**
  58519. * Oberserver used in Stereoscopic VR Mode.
  58520. */
  58521. private _onBeforeCameraRenderObserver;
  58522. /**
  58523. * Observable raised when an error occured while loading the 360 image
  58524. */
  58525. onLoadErrorObservable: Observable<string>;
  58526. /**
  58527. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58528. * @param name Element's name, child elements will append suffixes for their own names.
  58529. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58530. * @param options An object containing optional or exposed sub element properties
  58531. */
  58532. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58533. resolution?: number;
  58534. clickToPlay?: boolean;
  58535. autoPlay?: boolean;
  58536. loop?: boolean;
  58537. size?: number;
  58538. poster?: string;
  58539. faceForward?: boolean;
  58540. useDirectMapping?: boolean;
  58541. halfDomeMode?: boolean;
  58542. crossEyeMode?: boolean;
  58543. generateMipMaps?: boolean;
  58544. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58545. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58546. protected _changeTextureMode(value: number): void;
  58547. /**
  58548. * Releases resources associated with this node.
  58549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58551. */
  58552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58553. }
  58554. }
  58555. declare module BABYLON {
  58556. /**
  58557. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58558. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58559. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58560. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58561. */
  58562. export class PhotoDome extends TextureDome<Texture> {
  58563. /**
  58564. * Define the image as a Monoscopic panoramic 360 image.
  58565. */
  58566. static readonly MODE_MONOSCOPIC: number;
  58567. /**
  58568. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58569. */
  58570. static readonly MODE_TOPBOTTOM: number;
  58571. /**
  58572. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58573. */
  58574. static readonly MODE_SIDEBYSIDE: number;
  58575. /**
  58576. * Gets or sets the texture being displayed on the sphere
  58577. */
  58578. get photoTexture(): Texture;
  58579. /**
  58580. * sets the texture being displayed on the sphere
  58581. */
  58582. set photoTexture(value: Texture);
  58583. /**
  58584. * Gets the current video mode for the video. It can be:
  58585. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58586. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58587. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58588. */
  58589. get imageMode(): number;
  58590. /**
  58591. * Sets the current video mode for the video. It can be:
  58592. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58593. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58594. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58595. */
  58596. set imageMode(value: number);
  58597. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58598. }
  58599. }
  58600. declare module BABYLON {
  58601. /**
  58602. * Direct draw surface info
  58603. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58604. */
  58605. export interface DDSInfo {
  58606. /**
  58607. * Width of the texture
  58608. */
  58609. width: number;
  58610. /**
  58611. * Width of the texture
  58612. */
  58613. height: number;
  58614. /**
  58615. * Number of Mipmaps for the texture
  58616. * @see https://en.wikipedia.org/wiki/Mipmap
  58617. */
  58618. mipmapCount: number;
  58619. /**
  58620. * If the textures format is a known fourCC format
  58621. * @see https://www.fourcc.org/
  58622. */
  58623. isFourCC: boolean;
  58624. /**
  58625. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58626. */
  58627. isRGB: boolean;
  58628. /**
  58629. * If the texture is a lumincance format
  58630. */
  58631. isLuminance: boolean;
  58632. /**
  58633. * If this is a cube texture
  58634. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58635. */
  58636. isCube: boolean;
  58637. /**
  58638. * If the texture is a compressed format eg. FOURCC_DXT1
  58639. */
  58640. isCompressed: boolean;
  58641. /**
  58642. * The dxgiFormat of the texture
  58643. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58644. */
  58645. dxgiFormat: number;
  58646. /**
  58647. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58648. */
  58649. textureType: number;
  58650. /**
  58651. * Sphericle polynomial created for the dds texture
  58652. */
  58653. sphericalPolynomial?: SphericalPolynomial;
  58654. }
  58655. /**
  58656. * Class used to provide DDS decompression tools
  58657. */
  58658. export class DDSTools {
  58659. /**
  58660. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58661. */
  58662. static StoreLODInAlphaChannel: boolean;
  58663. /**
  58664. * Gets DDS information from an array buffer
  58665. * @param data defines the array buffer view to read data from
  58666. * @returns the DDS information
  58667. */
  58668. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58669. private static _FloatView;
  58670. private static _Int32View;
  58671. private static _ToHalfFloat;
  58672. private static _FromHalfFloat;
  58673. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58674. private static _GetHalfFloatRGBAArrayBuffer;
  58675. private static _GetFloatRGBAArrayBuffer;
  58676. private static _GetFloatAsUIntRGBAArrayBuffer;
  58677. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58678. private static _GetRGBAArrayBuffer;
  58679. private static _ExtractLongWordOrder;
  58680. private static _GetRGBArrayBuffer;
  58681. private static _GetLuminanceArrayBuffer;
  58682. /**
  58683. * Uploads DDS Levels to a Babylon Texture
  58684. * @hidden
  58685. */
  58686. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58687. }
  58688. interface ThinEngine {
  58689. /**
  58690. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58691. * @param rootUrl defines the url where the file to load is located
  58692. * @param scene defines the current scene
  58693. * @param lodScale defines scale to apply to the mip map selection
  58694. * @param lodOffset defines offset to apply to the mip map selection
  58695. * @param onLoad defines an optional callback raised when the texture is loaded
  58696. * @param onError defines an optional callback raised if there is an issue to load the texture
  58697. * @param format defines the format of the data
  58698. * @param forcedExtension defines the extension to use to pick the right loader
  58699. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58700. * @returns the cube texture as an InternalTexture
  58701. */
  58702. 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;
  58703. }
  58704. }
  58705. declare module BABYLON {
  58706. /**
  58707. * Implementation of the DDS Texture Loader.
  58708. * @hidden
  58709. */
  58710. export class _DDSTextureLoader implements IInternalTextureLoader {
  58711. /**
  58712. * Defines wether the loader supports cascade loading the different faces.
  58713. */
  58714. readonly supportCascades: boolean;
  58715. /**
  58716. * This returns if the loader support the current file information.
  58717. * @param extension defines the file extension of the file being loaded
  58718. * @returns true if the loader can load the specified file
  58719. */
  58720. canLoad(extension: string): boolean;
  58721. /**
  58722. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58723. * @param data contains the texture data
  58724. * @param texture defines the BabylonJS internal texture
  58725. * @param createPolynomials will be true if polynomials have been requested
  58726. * @param onLoad defines the callback to trigger once the texture is ready
  58727. * @param onError defines the callback to trigger in case of error
  58728. */
  58729. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58730. /**
  58731. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58732. * @param data contains the texture data
  58733. * @param texture defines the BabylonJS internal texture
  58734. * @param callback defines the method to call once ready to upload
  58735. */
  58736. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58737. }
  58738. }
  58739. declare module BABYLON {
  58740. /**
  58741. * Implementation of the ENV Texture Loader.
  58742. * @hidden
  58743. */
  58744. export class _ENVTextureLoader implements IInternalTextureLoader {
  58745. /**
  58746. * Defines wether the loader supports cascade loading the different faces.
  58747. */
  58748. readonly supportCascades: boolean;
  58749. /**
  58750. * This returns if the loader support the current file information.
  58751. * @param extension defines the file extension of the file being loaded
  58752. * @returns true if the loader can load the specified file
  58753. */
  58754. canLoad(extension: string): boolean;
  58755. /**
  58756. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58757. * @param data contains the texture data
  58758. * @param texture defines the BabylonJS internal texture
  58759. * @param createPolynomials will be true if polynomials have been requested
  58760. * @param onLoad defines the callback to trigger once the texture is ready
  58761. * @param onError defines the callback to trigger in case of error
  58762. */
  58763. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58764. /**
  58765. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58766. * @param data contains the texture data
  58767. * @param texture defines the BabylonJS internal texture
  58768. * @param callback defines the method to call once ready to upload
  58769. */
  58770. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58771. }
  58772. }
  58773. declare module BABYLON {
  58774. /**
  58775. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58776. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58777. */
  58778. export class KhronosTextureContainer {
  58779. /** contents of the KTX container file */
  58780. data: ArrayBufferView;
  58781. private static HEADER_LEN;
  58782. private static COMPRESSED_2D;
  58783. private static COMPRESSED_3D;
  58784. private static TEX_2D;
  58785. private static TEX_3D;
  58786. /**
  58787. * Gets the openGL type
  58788. */
  58789. glType: number;
  58790. /**
  58791. * Gets the openGL type size
  58792. */
  58793. glTypeSize: number;
  58794. /**
  58795. * Gets the openGL format
  58796. */
  58797. glFormat: number;
  58798. /**
  58799. * Gets the openGL internal format
  58800. */
  58801. glInternalFormat: number;
  58802. /**
  58803. * Gets the base internal format
  58804. */
  58805. glBaseInternalFormat: number;
  58806. /**
  58807. * Gets image width in pixel
  58808. */
  58809. pixelWidth: number;
  58810. /**
  58811. * Gets image height in pixel
  58812. */
  58813. pixelHeight: number;
  58814. /**
  58815. * Gets image depth in pixels
  58816. */
  58817. pixelDepth: number;
  58818. /**
  58819. * Gets the number of array elements
  58820. */
  58821. numberOfArrayElements: number;
  58822. /**
  58823. * Gets the number of faces
  58824. */
  58825. numberOfFaces: number;
  58826. /**
  58827. * Gets the number of mipmap levels
  58828. */
  58829. numberOfMipmapLevels: number;
  58830. /**
  58831. * Gets the bytes of key value data
  58832. */
  58833. bytesOfKeyValueData: number;
  58834. /**
  58835. * Gets the load type
  58836. */
  58837. loadType: number;
  58838. /**
  58839. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58840. */
  58841. isInvalid: boolean;
  58842. /**
  58843. * Creates a new KhronosTextureContainer
  58844. * @param data contents of the KTX container file
  58845. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58846. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58847. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58848. */
  58849. constructor(
  58850. /** contents of the KTX container file */
  58851. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58852. /**
  58853. * Uploads KTX content to a Babylon Texture.
  58854. * It is assumed that the texture has already been created & is currently bound
  58855. * @hidden
  58856. */
  58857. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58858. private _upload2DCompressedLevels;
  58859. /**
  58860. * Checks if the given data starts with a KTX file identifier.
  58861. * @param data the data to check
  58862. * @returns true if the data is a KTX file or false otherwise
  58863. */
  58864. static IsValid(data: ArrayBufferView): boolean;
  58865. }
  58866. }
  58867. declare module BABYLON {
  58868. /**
  58869. * Helper class to push actions to a pool of workers.
  58870. */
  58871. export class WorkerPool implements IDisposable {
  58872. private _workerInfos;
  58873. private _pendingActions;
  58874. /**
  58875. * Constructor
  58876. * @param workers Array of workers to use for actions
  58877. */
  58878. constructor(workers: Array<Worker>);
  58879. /**
  58880. * Terminates all workers and clears any pending actions.
  58881. */
  58882. dispose(): void;
  58883. /**
  58884. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58885. * pended until a worker has completed its action.
  58886. * @param action The action to perform. Call onComplete when the action is complete.
  58887. */
  58888. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58889. private _execute;
  58890. }
  58891. }
  58892. declare module BABYLON {
  58893. /**
  58894. * Class for loading KTX2 files
  58895. */
  58896. export class KhronosTextureContainer2 {
  58897. private static _WorkerPoolPromise?;
  58898. private static _Initialized;
  58899. private static _Ktx2Decoder;
  58900. /**
  58901. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58902. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58903. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58904. * Urls you can change:
  58905. * URLConfig.jsDecoderModule
  58906. * URLConfig.wasmUASTCToASTC
  58907. * URLConfig.wasmUASTCToBC7
  58908. * URLConfig.wasmUASTCToRGBA_UNORM
  58909. * URLConfig.wasmUASTCToRGBA_SRGB
  58910. * URLConfig.jsMSCTranscoder
  58911. * URLConfig.wasmMSCTranscoder
  58912. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58913. */
  58914. static URLConfig: {
  58915. jsDecoderModule: string;
  58916. wasmUASTCToASTC: null;
  58917. wasmUASTCToBC7: null;
  58918. wasmUASTCToRGBA_UNORM: null;
  58919. wasmUASTCToRGBA_SRGB: null;
  58920. jsMSCTranscoder: null;
  58921. wasmMSCTranscoder: null;
  58922. };
  58923. /**
  58924. * Default number of workers used to handle data decoding
  58925. */
  58926. static DefaultNumWorkers: number;
  58927. private static GetDefaultNumWorkers;
  58928. private _engine;
  58929. private static _CreateWorkerPool;
  58930. /**
  58931. * Constructor
  58932. * @param engine The engine to use
  58933. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58934. */
  58935. constructor(engine: ThinEngine, numWorkers?: number);
  58936. /** @hidden */
  58937. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58938. /**
  58939. * Stop all async operations and release resources.
  58940. */
  58941. dispose(): void;
  58942. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  58943. /**
  58944. * Checks if the given data starts with a KTX2 file identifier.
  58945. * @param data the data to check
  58946. * @returns true if the data is a KTX2 file or false otherwise
  58947. */
  58948. static IsValid(data: ArrayBufferView): boolean;
  58949. }
  58950. }
  58951. declare module BABYLON {
  58952. /**
  58953. * Implementation of the KTX Texture Loader.
  58954. * @hidden
  58955. */
  58956. export class _KTXTextureLoader implements IInternalTextureLoader {
  58957. /**
  58958. * Defines wether the loader supports cascade loading the different faces.
  58959. */
  58960. readonly supportCascades: boolean;
  58961. /**
  58962. * This returns if the loader support the current file information.
  58963. * @param extension defines the file extension of the file being loaded
  58964. * @param mimeType defines the optional mime type of the file being loaded
  58965. * @returns true if the loader can load the specified file
  58966. */
  58967. canLoad(extension: string, mimeType?: string): boolean;
  58968. /**
  58969. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58970. * @param data contains the texture data
  58971. * @param texture defines the BabylonJS internal texture
  58972. * @param createPolynomials will be true if polynomials have been requested
  58973. * @param onLoad defines the callback to trigger once the texture is ready
  58974. * @param onError defines the callback to trigger in case of error
  58975. */
  58976. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58977. /**
  58978. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58979. * @param data contains the texture data
  58980. * @param texture defines the BabylonJS internal texture
  58981. * @param callback defines the method to call once ready to upload
  58982. */
  58983. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58984. }
  58985. }
  58986. declare module BABYLON {
  58987. /** @hidden */
  58988. export var _forceSceneHelpersToBundle: boolean;
  58989. interface Scene {
  58990. /**
  58991. * Creates a default light for the scene.
  58992. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58993. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58994. */
  58995. createDefaultLight(replace?: boolean): void;
  58996. /**
  58997. * Creates a default camera for the scene.
  58998. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58999. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59000. * @param replace has default false, when true replaces the active camera in the scene
  59001. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59002. */
  59003. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59004. /**
  59005. * Creates a default camera and a default light.
  59006. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59007. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59008. * @param replace has the default false, when true replaces the active camera/light in the scene
  59009. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59010. */
  59011. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59012. /**
  59013. * Creates a new sky box
  59014. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59015. * @param environmentTexture defines the texture to use as environment texture
  59016. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59017. * @param scale defines the overall scale of the skybox
  59018. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59019. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59020. * @returns a new mesh holding the sky box
  59021. */
  59022. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59023. /**
  59024. * Creates a new environment
  59025. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59026. * @param options defines the options you can use to configure the environment
  59027. * @returns the new EnvironmentHelper
  59028. */
  59029. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59030. /**
  59031. * Creates a new VREXperienceHelper
  59032. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59033. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59034. * @returns a new VREXperienceHelper
  59035. */
  59036. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59037. /**
  59038. * Creates a new WebXRDefaultExperience
  59039. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59040. * @param options experience options
  59041. * @returns a promise for a new WebXRDefaultExperience
  59042. */
  59043. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59044. }
  59045. }
  59046. declare module BABYLON {
  59047. /**
  59048. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59049. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59050. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59051. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59052. */
  59053. export class VideoDome extends TextureDome<VideoTexture> {
  59054. /**
  59055. * Define the video source as a Monoscopic panoramic 360 video.
  59056. */
  59057. static readonly MODE_MONOSCOPIC: number;
  59058. /**
  59059. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59060. */
  59061. static readonly MODE_TOPBOTTOM: number;
  59062. /**
  59063. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59064. */
  59065. static readonly MODE_SIDEBYSIDE: number;
  59066. /**
  59067. * Get the video texture associated with this video dome
  59068. */
  59069. get videoTexture(): VideoTexture;
  59070. /**
  59071. * Get the video mode of this dome
  59072. */
  59073. get videoMode(): number;
  59074. /**
  59075. * Set the video mode of this dome.
  59076. * @see textureMode
  59077. */
  59078. set videoMode(value: number);
  59079. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59080. }
  59081. }
  59082. declare module BABYLON {
  59083. /**
  59084. * This class can be used to get instrumentation data from a Babylon engine
  59085. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59086. */
  59087. export class EngineInstrumentation implements IDisposable {
  59088. /**
  59089. * Define the instrumented engine.
  59090. */
  59091. engine: Engine;
  59092. private _captureGPUFrameTime;
  59093. private _gpuFrameTimeToken;
  59094. private _gpuFrameTime;
  59095. private _captureShaderCompilationTime;
  59096. private _shaderCompilationTime;
  59097. private _onBeginFrameObserver;
  59098. private _onEndFrameObserver;
  59099. private _onBeforeShaderCompilationObserver;
  59100. private _onAfterShaderCompilationObserver;
  59101. /**
  59102. * Gets the perf counter used for GPU frame time
  59103. */
  59104. get gpuFrameTimeCounter(): PerfCounter;
  59105. /**
  59106. * Gets the GPU frame time capture status
  59107. */
  59108. get captureGPUFrameTime(): boolean;
  59109. /**
  59110. * Enable or disable the GPU frame time capture
  59111. */
  59112. set captureGPUFrameTime(value: boolean);
  59113. /**
  59114. * Gets the perf counter used for shader compilation time
  59115. */
  59116. get shaderCompilationTimeCounter(): PerfCounter;
  59117. /**
  59118. * Gets the shader compilation time capture status
  59119. */
  59120. get captureShaderCompilationTime(): boolean;
  59121. /**
  59122. * Enable or disable the shader compilation time capture
  59123. */
  59124. set captureShaderCompilationTime(value: boolean);
  59125. /**
  59126. * Instantiates a new engine instrumentation.
  59127. * This class can be used to get instrumentation data from a Babylon engine
  59128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59129. * @param engine Defines the engine to instrument
  59130. */
  59131. constructor(
  59132. /**
  59133. * Define the instrumented engine.
  59134. */
  59135. engine: Engine);
  59136. /**
  59137. * Dispose and release associated resources.
  59138. */
  59139. dispose(): void;
  59140. }
  59141. }
  59142. declare module BABYLON {
  59143. /**
  59144. * This class can be used to get instrumentation data from a Babylon engine
  59145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59146. */
  59147. export class SceneInstrumentation implements IDisposable {
  59148. /**
  59149. * Defines the scene to instrument
  59150. */
  59151. scene: Scene;
  59152. private _captureActiveMeshesEvaluationTime;
  59153. private _activeMeshesEvaluationTime;
  59154. private _captureRenderTargetsRenderTime;
  59155. private _renderTargetsRenderTime;
  59156. private _captureFrameTime;
  59157. private _frameTime;
  59158. private _captureRenderTime;
  59159. private _renderTime;
  59160. private _captureInterFrameTime;
  59161. private _interFrameTime;
  59162. private _captureParticlesRenderTime;
  59163. private _particlesRenderTime;
  59164. private _captureSpritesRenderTime;
  59165. private _spritesRenderTime;
  59166. private _capturePhysicsTime;
  59167. private _physicsTime;
  59168. private _captureAnimationsTime;
  59169. private _animationsTime;
  59170. private _captureCameraRenderTime;
  59171. private _cameraRenderTime;
  59172. private _onBeforeActiveMeshesEvaluationObserver;
  59173. private _onAfterActiveMeshesEvaluationObserver;
  59174. private _onBeforeRenderTargetsRenderObserver;
  59175. private _onAfterRenderTargetsRenderObserver;
  59176. private _onAfterRenderObserver;
  59177. private _onBeforeDrawPhaseObserver;
  59178. private _onAfterDrawPhaseObserver;
  59179. private _onBeforeAnimationsObserver;
  59180. private _onBeforeParticlesRenderingObserver;
  59181. private _onAfterParticlesRenderingObserver;
  59182. private _onBeforeSpritesRenderingObserver;
  59183. private _onAfterSpritesRenderingObserver;
  59184. private _onBeforePhysicsObserver;
  59185. private _onAfterPhysicsObserver;
  59186. private _onAfterAnimationsObserver;
  59187. private _onBeforeCameraRenderObserver;
  59188. private _onAfterCameraRenderObserver;
  59189. /**
  59190. * Gets the perf counter used for active meshes evaluation time
  59191. */
  59192. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59193. /**
  59194. * Gets the active meshes evaluation time capture status
  59195. */
  59196. get captureActiveMeshesEvaluationTime(): boolean;
  59197. /**
  59198. * Enable or disable the active meshes evaluation time capture
  59199. */
  59200. set captureActiveMeshesEvaluationTime(value: boolean);
  59201. /**
  59202. * Gets the perf counter used for render targets render time
  59203. */
  59204. get renderTargetsRenderTimeCounter(): PerfCounter;
  59205. /**
  59206. * Gets the render targets render time capture status
  59207. */
  59208. get captureRenderTargetsRenderTime(): boolean;
  59209. /**
  59210. * Enable or disable the render targets render time capture
  59211. */
  59212. set captureRenderTargetsRenderTime(value: boolean);
  59213. /**
  59214. * Gets the perf counter used for particles render time
  59215. */
  59216. get particlesRenderTimeCounter(): PerfCounter;
  59217. /**
  59218. * Gets the particles render time capture status
  59219. */
  59220. get captureParticlesRenderTime(): boolean;
  59221. /**
  59222. * Enable or disable the particles render time capture
  59223. */
  59224. set captureParticlesRenderTime(value: boolean);
  59225. /**
  59226. * Gets the perf counter used for sprites render time
  59227. */
  59228. get spritesRenderTimeCounter(): PerfCounter;
  59229. /**
  59230. * Gets the sprites render time capture status
  59231. */
  59232. get captureSpritesRenderTime(): boolean;
  59233. /**
  59234. * Enable or disable the sprites render time capture
  59235. */
  59236. set captureSpritesRenderTime(value: boolean);
  59237. /**
  59238. * Gets the perf counter used for physics time
  59239. */
  59240. get physicsTimeCounter(): PerfCounter;
  59241. /**
  59242. * Gets the physics time capture status
  59243. */
  59244. get capturePhysicsTime(): boolean;
  59245. /**
  59246. * Enable or disable the physics time capture
  59247. */
  59248. set capturePhysicsTime(value: boolean);
  59249. /**
  59250. * Gets the perf counter used for animations time
  59251. */
  59252. get animationsTimeCounter(): PerfCounter;
  59253. /**
  59254. * Gets the animations time capture status
  59255. */
  59256. get captureAnimationsTime(): boolean;
  59257. /**
  59258. * Enable or disable the animations time capture
  59259. */
  59260. set captureAnimationsTime(value: boolean);
  59261. /**
  59262. * Gets the perf counter used for frame time capture
  59263. */
  59264. get frameTimeCounter(): PerfCounter;
  59265. /**
  59266. * Gets the frame time capture status
  59267. */
  59268. get captureFrameTime(): boolean;
  59269. /**
  59270. * Enable or disable the frame time capture
  59271. */
  59272. set captureFrameTime(value: boolean);
  59273. /**
  59274. * Gets the perf counter used for inter-frames time capture
  59275. */
  59276. get interFrameTimeCounter(): PerfCounter;
  59277. /**
  59278. * Gets the inter-frames time capture status
  59279. */
  59280. get captureInterFrameTime(): boolean;
  59281. /**
  59282. * Enable or disable the inter-frames time capture
  59283. */
  59284. set captureInterFrameTime(value: boolean);
  59285. /**
  59286. * Gets the perf counter used for render time capture
  59287. */
  59288. get renderTimeCounter(): PerfCounter;
  59289. /**
  59290. * Gets the render time capture status
  59291. */
  59292. get captureRenderTime(): boolean;
  59293. /**
  59294. * Enable or disable the render time capture
  59295. */
  59296. set captureRenderTime(value: boolean);
  59297. /**
  59298. * Gets the perf counter used for camera render time capture
  59299. */
  59300. get cameraRenderTimeCounter(): PerfCounter;
  59301. /**
  59302. * Gets the camera render time capture status
  59303. */
  59304. get captureCameraRenderTime(): boolean;
  59305. /**
  59306. * Enable or disable the camera render time capture
  59307. */
  59308. set captureCameraRenderTime(value: boolean);
  59309. /**
  59310. * Gets the perf counter used for draw calls
  59311. */
  59312. get drawCallsCounter(): PerfCounter;
  59313. /**
  59314. * Instantiates a new scene instrumentation.
  59315. * This class can be used to get instrumentation data from a Babylon engine
  59316. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59317. * @param scene Defines the scene to instrument
  59318. */
  59319. constructor(
  59320. /**
  59321. * Defines the scene to instrument
  59322. */
  59323. scene: Scene);
  59324. /**
  59325. * Dispose and release associated resources.
  59326. */
  59327. dispose(): void;
  59328. }
  59329. }
  59330. declare module BABYLON {
  59331. /** @hidden */
  59332. export var glowMapGenerationPixelShader: {
  59333. name: string;
  59334. shader: string;
  59335. };
  59336. }
  59337. declare module BABYLON {
  59338. /** @hidden */
  59339. export var glowMapGenerationVertexShader: {
  59340. name: string;
  59341. shader: string;
  59342. };
  59343. }
  59344. declare module BABYLON {
  59345. /**
  59346. * Effect layer options. This helps customizing the behaviour
  59347. * of the effect layer.
  59348. */
  59349. export interface IEffectLayerOptions {
  59350. /**
  59351. * Multiplication factor apply to the canvas size to compute the render target size
  59352. * used to generated the objects (the smaller the faster).
  59353. */
  59354. mainTextureRatio: number;
  59355. /**
  59356. * Enforces a fixed size texture to ensure effect stability across devices.
  59357. */
  59358. mainTextureFixedSize?: number;
  59359. /**
  59360. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59361. */
  59362. alphaBlendingMode: number;
  59363. /**
  59364. * The camera attached to the layer.
  59365. */
  59366. camera: Nullable<Camera>;
  59367. /**
  59368. * The rendering group to draw the layer in.
  59369. */
  59370. renderingGroupId: number;
  59371. }
  59372. /**
  59373. * The effect layer Helps adding post process effect blended with the main pass.
  59374. *
  59375. * This can be for instance use to generate glow or higlight effects on the scene.
  59376. *
  59377. * The effect layer class can not be used directly and is intented to inherited from to be
  59378. * customized per effects.
  59379. */
  59380. export abstract class EffectLayer {
  59381. private _vertexBuffers;
  59382. private _indexBuffer;
  59383. private _cachedDefines;
  59384. private _effectLayerMapGenerationEffect;
  59385. private _effectLayerOptions;
  59386. private _mergeEffect;
  59387. protected _scene: Scene;
  59388. protected _engine: Engine;
  59389. protected _maxSize: number;
  59390. protected _mainTextureDesiredSize: ISize;
  59391. protected _mainTexture: RenderTargetTexture;
  59392. protected _shouldRender: boolean;
  59393. protected _postProcesses: PostProcess[];
  59394. protected _textures: BaseTexture[];
  59395. protected _emissiveTextureAndColor: {
  59396. texture: Nullable<BaseTexture>;
  59397. color: Color4;
  59398. };
  59399. /**
  59400. * The name of the layer
  59401. */
  59402. name: string;
  59403. /**
  59404. * The clear color of the texture used to generate the glow map.
  59405. */
  59406. neutralColor: Color4;
  59407. /**
  59408. * Specifies whether the highlight layer is enabled or not.
  59409. */
  59410. isEnabled: boolean;
  59411. /**
  59412. * Gets the camera attached to the layer.
  59413. */
  59414. get camera(): Nullable<Camera>;
  59415. /**
  59416. * Gets the rendering group id the layer should render in.
  59417. */
  59418. get renderingGroupId(): number;
  59419. set renderingGroupId(renderingGroupId: number);
  59420. /**
  59421. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59422. */
  59423. disableBoundingBoxesFromEffectLayer: boolean;
  59424. /**
  59425. * An event triggered when the effect layer has been disposed.
  59426. */
  59427. onDisposeObservable: Observable<EffectLayer>;
  59428. /**
  59429. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59430. */
  59431. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59432. /**
  59433. * An event triggered when the generated texture is being merged in the scene.
  59434. */
  59435. onBeforeComposeObservable: Observable<EffectLayer>;
  59436. /**
  59437. * An event triggered when the mesh is rendered into the effect render target.
  59438. */
  59439. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59440. /**
  59441. * An event triggered after the mesh has been rendered into the effect render target.
  59442. */
  59443. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59444. /**
  59445. * An event triggered when the generated texture has been merged in the scene.
  59446. */
  59447. onAfterComposeObservable: Observable<EffectLayer>;
  59448. /**
  59449. * An event triggered when the efffect layer changes its size.
  59450. */
  59451. onSizeChangedObservable: Observable<EffectLayer>;
  59452. /** @hidden */
  59453. static _SceneComponentInitialization: (scene: Scene) => void;
  59454. /**
  59455. * Instantiates a new effect Layer and references it in the scene.
  59456. * @param name The name of the layer
  59457. * @param scene The scene to use the layer in
  59458. */
  59459. constructor(
  59460. /** The Friendly of the effect in the scene */
  59461. name: string, scene: Scene);
  59462. /**
  59463. * Get the effect name of the layer.
  59464. * @return The effect name
  59465. */
  59466. abstract getEffectName(): string;
  59467. /**
  59468. * Checks for the readiness of the element composing the layer.
  59469. * @param subMesh the mesh to check for
  59470. * @param useInstances specify whether or not to use instances to render the mesh
  59471. * @return true if ready otherwise, false
  59472. */
  59473. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59474. /**
  59475. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59476. * @returns true if the effect requires stencil during the main canvas render pass.
  59477. */
  59478. abstract needStencil(): boolean;
  59479. /**
  59480. * Create the merge effect. This is the shader use to blit the information back
  59481. * to the main canvas at the end of the scene rendering.
  59482. * @returns The effect containing the shader used to merge the effect on the main canvas
  59483. */
  59484. protected abstract _createMergeEffect(): Effect;
  59485. /**
  59486. * Creates the render target textures and post processes used in the effect layer.
  59487. */
  59488. protected abstract _createTextureAndPostProcesses(): void;
  59489. /**
  59490. * Implementation specific of rendering the generating effect on the main canvas.
  59491. * @param effect The effect used to render through
  59492. */
  59493. protected abstract _internalRender(effect: Effect): void;
  59494. /**
  59495. * Sets the required values for both the emissive texture and and the main color.
  59496. */
  59497. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59498. /**
  59499. * Free any resources and references associated to a mesh.
  59500. * Internal use
  59501. * @param mesh The mesh to free.
  59502. */
  59503. abstract _disposeMesh(mesh: Mesh): void;
  59504. /**
  59505. * Serializes this layer (Glow or Highlight for example)
  59506. * @returns a serialized layer object
  59507. */
  59508. abstract serialize?(): any;
  59509. /**
  59510. * Initializes the effect layer with the required options.
  59511. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59512. */
  59513. protected _init(options: Partial<IEffectLayerOptions>): void;
  59514. /**
  59515. * Generates the index buffer of the full screen quad blending to the main canvas.
  59516. */
  59517. private _generateIndexBuffer;
  59518. /**
  59519. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59520. */
  59521. private _generateVertexBuffer;
  59522. /**
  59523. * Sets the main texture desired size which is the closest power of two
  59524. * of the engine canvas size.
  59525. */
  59526. private _setMainTextureSize;
  59527. /**
  59528. * Creates the main texture for the effect layer.
  59529. */
  59530. protected _createMainTexture(): void;
  59531. /**
  59532. * Adds specific effects defines.
  59533. * @param defines The defines to add specifics to.
  59534. */
  59535. protected _addCustomEffectDefines(defines: string[]): void;
  59536. /**
  59537. * Checks for the readiness of the element composing the layer.
  59538. * @param subMesh the mesh to check for
  59539. * @param useInstances specify whether or not to use instances to render the mesh
  59540. * @param emissiveTexture the associated emissive texture used to generate the glow
  59541. * @return true if ready otherwise, false
  59542. */
  59543. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59544. /**
  59545. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59546. */
  59547. render(): void;
  59548. /**
  59549. * Determine if a given mesh will be used in the current effect.
  59550. * @param mesh mesh to test
  59551. * @returns true if the mesh will be used
  59552. */
  59553. hasMesh(mesh: AbstractMesh): boolean;
  59554. /**
  59555. * Returns true if the layer contains information to display, otherwise false.
  59556. * @returns true if the glow layer should be rendered
  59557. */
  59558. shouldRender(): boolean;
  59559. /**
  59560. * Returns true if the mesh should render, otherwise false.
  59561. * @param mesh The mesh to render
  59562. * @returns true if it should render otherwise false
  59563. */
  59564. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59565. /**
  59566. * Returns true if the mesh can be rendered, otherwise false.
  59567. * @param mesh The mesh to render
  59568. * @param material The material used on the mesh
  59569. * @returns true if it can be rendered otherwise false
  59570. */
  59571. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59572. /**
  59573. * Returns true if the mesh should render, otherwise false.
  59574. * @param mesh The mesh to render
  59575. * @returns true if it should render otherwise false
  59576. */
  59577. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59578. /**
  59579. * Renders the submesh passed in parameter to the generation map.
  59580. */
  59581. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59582. /**
  59583. * Defines whether the current material of the mesh should be use to render the effect.
  59584. * @param mesh defines the current mesh to render
  59585. */
  59586. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59587. /**
  59588. * Rebuild the required buffers.
  59589. * @hidden Internal use only.
  59590. */
  59591. _rebuild(): void;
  59592. /**
  59593. * Dispose only the render target textures and post process.
  59594. */
  59595. private _disposeTextureAndPostProcesses;
  59596. /**
  59597. * Dispose the highlight layer and free resources.
  59598. */
  59599. dispose(): void;
  59600. /**
  59601. * Gets the class name of the effect layer
  59602. * @returns the string with the class name of the effect layer
  59603. */
  59604. getClassName(): string;
  59605. /**
  59606. * Creates an effect layer from parsed effect layer data
  59607. * @param parsedEffectLayer defines effect layer data
  59608. * @param scene defines the current scene
  59609. * @param rootUrl defines the root URL containing the effect layer information
  59610. * @returns a parsed effect Layer
  59611. */
  59612. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59613. }
  59614. }
  59615. declare module BABYLON {
  59616. interface AbstractScene {
  59617. /**
  59618. * The list of effect layers (highlights/glow) added to the scene
  59619. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59620. * @see https://doc.babylonjs.com/how_to/glow_layer
  59621. */
  59622. effectLayers: Array<EffectLayer>;
  59623. /**
  59624. * Removes the given effect layer from this scene.
  59625. * @param toRemove defines the effect layer to remove
  59626. * @returns the index of the removed effect layer
  59627. */
  59628. removeEffectLayer(toRemove: EffectLayer): number;
  59629. /**
  59630. * Adds the given effect layer to this scene
  59631. * @param newEffectLayer defines the effect layer to add
  59632. */
  59633. addEffectLayer(newEffectLayer: EffectLayer): void;
  59634. }
  59635. /**
  59636. * Defines the layer scene component responsible to manage any effect layers
  59637. * in a given scene.
  59638. */
  59639. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59640. /**
  59641. * The component name helpfull to identify the component in the list of scene components.
  59642. */
  59643. readonly name: string;
  59644. /**
  59645. * The scene the component belongs to.
  59646. */
  59647. scene: Scene;
  59648. private _engine;
  59649. private _renderEffects;
  59650. private _needStencil;
  59651. private _previousStencilState;
  59652. /**
  59653. * Creates a new instance of the component for the given scene
  59654. * @param scene Defines the scene to register the component in
  59655. */
  59656. constructor(scene: Scene);
  59657. /**
  59658. * Registers the component in a given scene
  59659. */
  59660. register(): void;
  59661. /**
  59662. * Rebuilds the elements related to this component in case of
  59663. * context lost for instance.
  59664. */
  59665. rebuild(): void;
  59666. /**
  59667. * Serializes the component data to the specified json object
  59668. * @param serializationObject The object to serialize to
  59669. */
  59670. serialize(serializationObject: any): void;
  59671. /**
  59672. * Adds all the elements from the container to the scene
  59673. * @param container the container holding the elements
  59674. */
  59675. addFromContainer(container: AbstractScene): void;
  59676. /**
  59677. * Removes all the elements in the container from the scene
  59678. * @param container contains the elements to remove
  59679. * @param dispose if the removed element should be disposed (default: false)
  59680. */
  59681. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59682. /**
  59683. * Disposes the component and the associated ressources.
  59684. */
  59685. dispose(): void;
  59686. private _isReadyForMesh;
  59687. private _renderMainTexture;
  59688. private _setStencil;
  59689. private _setStencilBack;
  59690. private _draw;
  59691. private _drawCamera;
  59692. private _drawRenderingGroup;
  59693. }
  59694. }
  59695. declare module BABYLON {
  59696. /** @hidden */
  59697. export var glowMapMergePixelShader: {
  59698. name: string;
  59699. shader: string;
  59700. };
  59701. }
  59702. declare module BABYLON {
  59703. /** @hidden */
  59704. export var glowMapMergeVertexShader: {
  59705. name: string;
  59706. shader: string;
  59707. };
  59708. }
  59709. declare module BABYLON {
  59710. interface AbstractScene {
  59711. /**
  59712. * Return a the first highlight layer of the scene with a given name.
  59713. * @param name The name of the highlight layer to look for.
  59714. * @return The highlight layer if found otherwise null.
  59715. */
  59716. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59717. }
  59718. /**
  59719. * Glow layer options. This helps customizing the behaviour
  59720. * of the glow layer.
  59721. */
  59722. export interface IGlowLayerOptions {
  59723. /**
  59724. * Multiplication factor apply to the canvas size to compute the render target size
  59725. * used to generated the glowing objects (the smaller the faster).
  59726. */
  59727. mainTextureRatio: number;
  59728. /**
  59729. * Enforces a fixed size texture to ensure resize independant blur.
  59730. */
  59731. mainTextureFixedSize?: number;
  59732. /**
  59733. * How big is the kernel of the blur texture.
  59734. */
  59735. blurKernelSize: number;
  59736. /**
  59737. * The camera attached to the layer.
  59738. */
  59739. camera: Nullable<Camera>;
  59740. /**
  59741. * Enable MSAA by chosing the number of samples.
  59742. */
  59743. mainTextureSamples?: number;
  59744. /**
  59745. * The rendering group to draw the layer in.
  59746. */
  59747. renderingGroupId: number;
  59748. }
  59749. /**
  59750. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59751. *
  59752. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59753. *
  59754. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59755. */
  59756. export class GlowLayer extends EffectLayer {
  59757. /**
  59758. * Effect Name of the layer.
  59759. */
  59760. static readonly EffectName: string;
  59761. /**
  59762. * The default blur kernel size used for the glow.
  59763. */
  59764. static DefaultBlurKernelSize: number;
  59765. /**
  59766. * The default texture size ratio used for the glow.
  59767. */
  59768. static DefaultTextureRatio: number;
  59769. /**
  59770. * Sets the kernel size of the blur.
  59771. */
  59772. set blurKernelSize(value: number);
  59773. /**
  59774. * Gets the kernel size of the blur.
  59775. */
  59776. get blurKernelSize(): number;
  59777. /**
  59778. * Sets the glow intensity.
  59779. */
  59780. set intensity(value: number);
  59781. /**
  59782. * Gets the glow intensity.
  59783. */
  59784. get intensity(): number;
  59785. private _options;
  59786. private _intensity;
  59787. private _horizontalBlurPostprocess1;
  59788. private _verticalBlurPostprocess1;
  59789. private _horizontalBlurPostprocess2;
  59790. private _verticalBlurPostprocess2;
  59791. private _blurTexture1;
  59792. private _blurTexture2;
  59793. private _postProcesses1;
  59794. private _postProcesses2;
  59795. private _includedOnlyMeshes;
  59796. private _excludedMeshes;
  59797. private _meshesUsingTheirOwnMaterials;
  59798. /**
  59799. * Callback used to let the user override the color selection on a per mesh basis
  59800. */
  59801. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59802. /**
  59803. * Callback used to let the user override the texture selection on a per mesh basis
  59804. */
  59805. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59806. /**
  59807. * Instantiates a new glow Layer and references it to the scene.
  59808. * @param name The name of the layer
  59809. * @param scene The scene to use the layer in
  59810. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59811. */
  59812. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59813. /**
  59814. * Get the effect name of the layer.
  59815. * @return The effect name
  59816. */
  59817. getEffectName(): string;
  59818. /**
  59819. * Create the merge effect. This is the shader use to blit the information back
  59820. * to the main canvas at the end of the scene rendering.
  59821. */
  59822. protected _createMergeEffect(): Effect;
  59823. /**
  59824. * Creates the render target textures and post processes used in the glow layer.
  59825. */
  59826. protected _createTextureAndPostProcesses(): void;
  59827. /**
  59828. * Checks for the readiness of the element composing the layer.
  59829. * @param subMesh the mesh to check for
  59830. * @param useInstances specify wether or not to use instances to render the mesh
  59831. * @param emissiveTexture the associated emissive texture used to generate the glow
  59832. * @return true if ready otherwise, false
  59833. */
  59834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59835. /**
  59836. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59837. */
  59838. needStencil(): boolean;
  59839. /**
  59840. * Returns true if the mesh can be rendered, otherwise false.
  59841. * @param mesh The mesh to render
  59842. * @param material The material used on the mesh
  59843. * @returns true if it can be rendered otherwise false
  59844. */
  59845. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59846. /**
  59847. * Implementation specific of rendering the generating effect on the main canvas.
  59848. * @param effect The effect used to render through
  59849. */
  59850. protected _internalRender(effect: Effect): void;
  59851. /**
  59852. * Sets the required values for both the emissive texture and and the main color.
  59853. */
  59854. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59855. /**
  59856. * Returns true if the mesh should render, otherwise false.
  59857. * @param mesh The mesh to render
  59858. * @returns true if it should render otherwise false
  59859. */
  59860. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59861. /**
  59862. * Adds specific effects defines.
  59863. * @param defines The defines to add specifics to.
  59864. */
  59865. protected _addCustomEffectDefines(defines: string[]): void;
  59866. /**
  59867. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59868. * @param mesh The mesh to exclude from the glow layer
  59869. */
  59870. addExcludedMesh(mesh: Mesh): void;
  59871. /**
  59872. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59873. * @param mesh The mesh to remove
  59874. */
  59875. removeExcludedMesh(mesh: Mesh): void;
  59876. /**
  59877. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59878. * @param mesh The mesh to include in the glow layer
  59879. */
  59880. addIncludedOnlyMesh(mesh: Mesh): void;
  59881. /**
  59882. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59883. * @param mesh The mesh to remove
  59884. */
  59885. removeIncludedOnlyMesh(mesh: Mesh): void;
  59886. /**
  59887. * Determine if a given mesh will be used in the glow layer
  59888. * @param mesh The mesh to test
  59889. * @returns true if the mesh will be highlighted by the current glow layer
  59890. */
  59891. hasMesh(mesh: AbstractMesh): boolean;
  59892. /**
  59893. * Defines whether the current material of the mesh should be use to render the effect.
  59894. * @param mesh defines the current mesh to render
  59895. */
  59896. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59897. /**
  59898. * Add a mesh to be rendered through its own material and not with emissive only.
  59899. * @param mesh The mesh for which we need to use its material
  59900. */
  59901. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59902. /**
  59903. * Remove a mesh from being rendered through its own material and not with emissive only.
  59904. * @param mesh The mesh for which we need to not use its material
  59905. */
  59906. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59907. /**
  59908. * Free any resources and references associated to a mesh.
  59909. * Internal use
  59910. * @param mesh The mesh to free.
  59911. * @hidden
  59912. */
  59913. _disposeMesh(mesh: Mesh): void;
  59914. /**
  59915. * Gets the class name of the effect layer
  59916. * @returns the string with the class name of the effect layer
  59917. */
  59918. getClassName(): string;
  59919. /**
  59920. * Serializes this glow layer
  59921. * @returns a serialized glow layer object
  59922. */
  59923. serialize(): any;
  59924. /**
  59925. * Creates a Glow Layer from parsed glow layer data
  59926. * @param parsedGlowLayer defines glow layer data
  59927. * @param scene defines the current scene
  59928. * @param rootUrl defines the root URL containing the glow layer information
  59929. * @returns a parsed Glow Layer
  59930. */
  59931. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /** @hidden */
  59936. export var glowBlurPostProcessPixelShader: {
  59937. name: string;
  59938. shader: string;
  59939. };
  59940. }
  59941. declare module BABYLON {
  59942. interface AbstractScene {
  59943. /**
  59944. * Return a the first highlight layer of the scene with a given name.
  59945. * @param name The name of the highlight layer to look for.
  59946. * @return The highlight layer if found otherwise null.
  59947. */
  59948. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59949. }
  59950. /**
  59951. * Highlight layer options. This helps customizing the behaviour
  59952. * of the highlight layer.
  59953. */
  59954. export interface IHighlightLayerOptions {
  59955. /**
  59956. * Multiplication factor apply to the canvas size to compute the render target size
  59957. * used to generated the glowing objects (the smaller the faster).
  59958. */
  59959. mainTextureRatio: number;
  59960. /**
  59961. * Enforces a fixed size texture to ensure resize independant blur.
  59962. */
  59963. mainTextureFixedSize?: number;
  59964. /**
  59965. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59966. * of the picture to blur (the smaller the faster).
  59967. */
  59968. blurTextureSizeRatio: number;
  59969. /**
  59970. * How big in texel of the blur texture is the vertical blur.
  59971. */
  59972. blurVerticalSize: number;
  59973. /**
  59974. * How big in texel of the blur texture is the horizontal blur.
  59975. */
  59976. blurHorizontalSize: number;
  59977. /**
  59978. * Alpha blending mode used to apply the blur. Default is combine.
  59979. */
  59980. alphaBlendingMode: number;
  59981. /**
  59982. * The camera attached to the layer.
  59983. */
  59984. camera: Nullable<Camera>;
  59985. /**
  59986. * Should we display highlight as a solid stroke?
  59987. */
  59988. isStroke?: boolean;
  59989. /**
  59990. * The rendering group to draw the layer in.
  59991. */
  59992. renderingGroupId: number;
  59993. }
  59994. /**
  59995. * The highlight layer Helps adding a glow effect around a mesh.
  59996. *
  59997. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59998. * glowy meshes to your scene.
  59999. *
  60000. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60001. */
  60002. export class HighlightLayer extends EffectLayer {
  60003. name: string;
  60004. /**
  60005. * Effect Name of the highlight layer.
  60006. */
  60007. static readonly EffectName: string;
  60008. /**
  60009. * The neutral color used during the preparation of the glow effect.
  60010. * This is black by default as the blend operation is a blend operation.
  60011. */
  60012. static NeutralColor: Color4;
  60013. /**
  60014. * Stencil value used for glowing meshes.
  60015. */
  60016. static GlowingMeshStencilReference: number;
  60017. /**
  60018. * Stencil value used for the other meshes in the scene.
  60019. */
  60020. static NormalMeshStencilReference: number;
  60021. /**
  60022. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60023. */
  60024. innerGlow: boolean;
  60025. /**
  60026. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60027. */
  60028. outerGlow: boolean;
  60029. /**
  60030. * Specifies the horizontal size of the blur.
  60031. */
  60032. set blurHorizontalSize(value: number);
  60033. /**
  60034. * Specifies the vertical size of the blur.
  60035. */
  60036. set blurVerticalSize(value: number);
  60037. /**
  60038. * Gets the horizontal size of the blur.
  60039. */
  60040. get blurHorizontalSize(): number;
  60041. /**
  60042. * Gets the vertical size of the blur.
  60043. */
  60044. get blurVerticalSize(): number;
  60045. /**
  60046. * An event triggered when the highlight layer is being blurred.
  60047. */
  60048. onBeforeBlurObservable: Observable<HighlightLayer>;
  60049. /**
  60050. * An event triggered when the highlight layer has been blurred.
  60051. */
  60052. onAfterBlurObservable: Observable<HighlightLayer>;
  60053. private _instanceGlowingMeshStencilReference;
  60054. private _options;
  60055. private _downSamplePostprocess;
  60056. private _horizontalBlurPostprocess;
  60057. private _verticalBlurPostprocess;
  60058. private _blurTexture;
  60059. private _meshes;
  60060. private _excludedMeshes;
  60061. /**
  60062. * Instantiates a new highlight Layer and references it to the scene..
  60063. * @param name The name of the layer
  60064. * @param scene The scene to use the layer in
  60065. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60066. */
  60067. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60068. /**
  60069. * Get the effect name of the layer.
  60070. * @return The effect name
  60071. */
  60072. getEffectName(): string;
  60073. /**
  60074. * Create the merge effect. This is the shader use to blit the information back
  60075. * to the main canvas at the end of the scene rendering.
  60076. */
  60077. protected _createMergeEffect(): Effect;
  60078. /**
  60079. * Creates the render target textures and post processes used in the highlight layer.
  60080. */
  60081. protected _createTextureAndPostProcesses(): void;
  60082. /**
  60083. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60084. */
  60085. needStencil(): boolean;
  60086. /**
  60087. * Checks for the readiness of the element composing the layer.
  60088. * @param subMesh the mesh to check for
  60089. * @param useInstances specify wether or not to use instances to render the mesh
  60090. * @param emissiveTexture the associated emissive texture used to generate the glow
  60091. * @return true if ready otherwise, false
  60092. */
  60093. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60094. /**
  60095. * Implementation specific of rendering the generating effect on the main canvas.
  60096. * @param effect The effect used to render through
  60097. */
  60098. protected _internalRender(effect: Effect): void;
  60099. /**
  60100. * Returns true if the layer contains information to display, otherwise false.
  60101. */
  60102. shouldRender(): boolean;
  60103. /**
  60104. * Returns true if the mesh should render, otherwise false.
  60105. * @param mesh The mesh to render
  60106. * @returns true if it should render otherwise false
  60107. */
  60108. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60109. /**
  60110. * Returns true if the mesh can be rendered, otherwise false.
  60111. * @param mesh The mesh to render
  60112. * @param material The material used on the mesh
  60113. * @returns true if it can be rendered otherwise false
  60114. */
  60115. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60116. /**
  60117. * Adds specific effects defines.
  60118. * @param defines The defines to add specifics to.
  60119. */
  60120. protected _addCustomEffectDefines(defines: string[]): void;
  60121. /**
  60122. * Sets the required values for both the emissive texture and and the main color.
  60123. */
  60124. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60125. /**
  60126. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60127. * @param mesh The mesh to exclude from the highlight layer
  60128. */
  60129. addExcludedMesh(mesh: Mesh): void;
  60130. /**
  60131. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60132. * @param mesh The mesh to highlight
  60133. */
  60134. removeExcludedMesh(mesh: Mesh): void;
  60135. /**
  60136. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60137. * @param mesh mesh to test
  60138. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60139. */
  60140. hasMesh(mesh: AbstractMesh): boolean;
  60141. /**
  60142. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60143. * @param mesh The mesh to highlight
  60144. * @param color The color of the highlight
  60145. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60146. */
  60147. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60148. /**
  60149. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60150. * @param mesh The mesh to highlight
  60151. */
  60152. removeMesh(mesh: Mesh): void;
  60153. /**
  60154. * Remove all the meshes currently referenced in the highlight layer
  60155. */
  60156. removeAllMeshes(): void;
  60157. /**
  60158. * Force the stencil to the normal expected value for none glowing parts
  60159. */
  60160. private _defaultStencilReference;
  60161. /**
  60162. * Free any resources and references associated to a mesh.
  60163. * Internal use
  60164. * @param mesh The mesh to free.
  60165. * @hidden
  60166. */
  60167. _disposeMesh(mesh: Mesh): void;
  60168. /**
  60169. * Dispose the highlight layer and free resources.
  60170. */
  60171. dispose(): void;
  60172. /**
  60173. * Gets the class name of the effect layer
  60174. * @returns the string with the class name of the effect layer
  60175. */
  60176. getClassName(): string;
  60177. /**
  60178. * Serializes this Highlight layer
  60179. * @returns a serialized Highlight layer object
  60180. */
  60181. serialize(): any;
  60182. /**
  60183. * Creates a Highlight layer from parsed Highlight layer data
  60184. * @param parsedHightlightLayer defines the Highlight layer data
  60185. * @param scene defines the current scene
  60186. * @param rootUrl defines the root URL containing the Highlight layer information
  60187. * @returns a parsed Highlight layer
  60188. */
  60189. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60190. }
  60191. }
  60192. declare module BABYLON {
  60193. interface AbstractScene {
  60194. /**
  60195. * The list of layers (background and foreground) of the scene
  60196. */
  60197. layers: Array<Layer>;
  60198. }
  60199. /**
  60200. * Defines the layer scene component responsible to manage any layers
  60201. * in a given scene.
  60202. */
  60203. export class LayerSceneComponent implements ISceneComponent {
  60204. /**
  60205. * The component name helpfull to identify the component in the list of scene components.
  60206. */
  60207. readonly name: string;
  60208. /**
  60209. * The scene the component belongs to.
  60210. */
  60211. scene: Scene;
  60212. private _engine;
  60213. /**
  60214. * Creates a new instance of the component for the given scene
  60215. * @param scene Defines the scene to register the component in
  60216. */
  60217. constructor(scene: Scene);
  60218. /**
  60219. * Registers the component in a given scene
  60220. */
  60221. register(): void;
  60222. /**
  60223. * Rebuilds the elements related to this component in case of
  60224. * context lost for instance.
  60225. */
  60226. rebuild(): void;
  60227. /**
  60228. * Disposes the component and the associated ressources.
  60229. */
  60230. dispose(): void;
  60231. private _draw;
  60232. private _drawCameraPredicate;
  60233. private _drawCameraBackground;
  60234. private _drawCameraForeground;
  60235. private _drawRenderTargetPredicate;
  60236. private _drawRenderTargetBackground;
  60237. private _drawRenderTargetForeground;
  60238. /**
  60239. * Adds all the elements from the container to the scene
  60240. * @param container the container holding the elements
  60241. */
  60242. addFromContainer(container: AbstractScene): void;
  60243. /**
  60244. * Removes all the elements in the container from the scene
  60245. * @param container contains the elements to remove
  60246. * @param dispose if the removed element should be disposed (default: false)
  60247. */
  60248. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60249. }
  60250. }
  60251. declare module BABYLON {
  60252. /** @hidden */
  60253. export var layerPixelShader: {
  60254. name: string;
  60255. shader: string;
  60256. };
  60257. }
  60258. declare module BABYLON {
  60259. /** @hidden */
  60260. export var layerVertexShader: {
  60261. name: string;
  60262. shader: string;
  60263. };
  60264. }
  60265. declare module BABYLON {
  60266. /**
  60267. * This represents a full screen 2d layer.
  60268. * This can be useful to display a picture in the background of your scene for instance.
  60269. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60270. */
  60271. export class Layer {
  60272. /**
  60273. * Define the name of the layer.
  60274. */
  60275. name: string;
  60276. /**
  60277. * Define the texture the layer should display.
  60278. */
  60279. texture: Nullable<Texture>;
  60280. /**
  60281. * Is the layer in background or foreground.
  60282. */
  60283. isBackground: boolean;
  60284. /**
  60285. * Define the color of the layer (instead of texture).
  60286. */
  60287. color: Color4;
  60288. /**
  60289. * Define the scale of the layer in order to zoom in out of the texture.
  60290. */
  60291. scale: Vector2;
  60292. /**
  60293. * Define an offset for the layer in order to shift the texture.
  60294. */
  60295. offset: Vector2;
  60296. /**
  60297. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60298. */
  60299. alphaBlendingMode: number;
  60300. /**
  60301. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60302. * Alpha test will not mix with the background color in case of transparency.
  60303. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60304. */
  60305. alphaTest: boolean;
  60306. /**
  60307. * Define a mask to restrict the layer to only some of the scene cameras.
  60308. */
  60309. layerMask: number;
  60310. /**
  60311. * Define the list of render target the layer is visible into.
  60312. */
  60313. renderTargetTextures: RenderTargetTexture[];
  60314. /**
  60315. * Define if the layer is only used in renderTarget or if it also
  60316. * renders in the main frame buffer of the canvas.
  60317. */
  60318. renderOnlyInRenderTargetTextures: boolean;
  60319. private _scene;
  60320. private _vertexBuffers;
  60321. private _indexBuffer;
  60322. private _effect;
  60323. private _previousDefines;
  60324. /**
  60325. * An event triggered when the layer is disposed.
  60326. */
  60327. onDisposeObservable: Observable<Layer>;
  60328. private _onDisposeObserver;
  60329. /**
  60330. * Back compatibility with callback before the onDisposeObservable existed.
  60331. * The set callback will be triggered when the layer has been disposed.
  60332. */
  60333. set onDispose(callback: () => void);
  60334. /**
  60335. * An event triggered before rendering the scene
  60336. */
  60337. onBeforeRenderObservable: Observable<Layer>;
  60338. private _onBeforeRenderObserver;
  60339. /**
  60340. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60341. * The set callback will be triggered just before rendering the layer.
  60342. */
  60343. set onBeforeRender(callback: () => void);
  60344. /**
  60345. * An event triggered after rendering the scene
  60346. */
  60347. onAfterRenderObservable: Observable<Layer>;
  60348. private _onAfterRenderObserver;
  60349. /**
  60350. * Back compatibility with callback before the onAfterRenderObservable existed.
  60351. * The set callback will be triggered just after rendering the layer.
  60352. */
  60353. set onAfterRender(callback: () => void);
  60354. /**
  60355. * Instantiates a new layer.
  60356. * This represents a full screen 2d layer.
  60357. * This can be useful to display a picture in the background of your scene for instance.
  60358. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60359. * @param name Define the name of the layer in the scene
  60360. * @param imgUrl Define the url of the texture to display in the layer
  60361. * @param scene Define the scene the layer belongs to
  60362. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60363. * @param color Defines a color for the layer
  60364. */
  60365. constructor(
  60366. /**
  60367. * Define the name of the layer.
  60368. */
  60369. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60370. private _createIndexBuffer;
  60371. /** @hidden */
  60372. _rebuild(): void;
  60373. /**
  60374. * Renders the layer in the scene.
  60375. */
  60376. render(): void;
  60377. /**
  60378. * Disposes and releases the associated ressources.
  60379. */
  60380. dispose(): void;
  60381. }
  60382. }
  60383. declare module BABYLON {
  60384. /** @hidden */
  60385. export var lensFlarePixelShader: {
  60386. name: string;
  60387. shader: string;
  60388. };
  60389. }
  60390. declare module BABYLON {
  60391. /** @hidden */
  60392. export var lensFlareVertexShader: {
  60393. name: string;
  60394. shader: string;
  60395. };
  60396. }
  60397. declare module BABYLON {
  60398. /**
  60399. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60400. * It is usually composed of several `lensFlare`.
  60401. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60402. */
  60403. export class LensFlareSystem {
  60404. /**
  60405. * Define the name of the lens flare system
  60406. */
  60407. name: string;
  60408. /**
  60409. * List of lens flares used in this system.
  60410. */
  60411. lensFlares: LensFlare[];
  60412. /**
  60413. * Define a limit from the border the lens flare can be visible.
  60414. */
  60415. borderLimit: number;
  60416. /**
  60417. * Define a viewport border we do not want to see the lens flare in.
  60418. */
  60419. viewportBorder: number;
  60420. /**
  60421. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60422. */
  60423. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60424. /**
  60425. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60426. */
  60427. layerMask: number;
  60428. /**
  60429. * Define the id of the lens flare system in the scene.
  60430. * (equal to name by default)
  60431. */
  60432. id: string;
  60433. private _scene;
  60434. private _emitter;
  60435. private _vertexBuffers;
  60436. private _indexBuffer;
  60437. private _effect;
  60438. private _positionX;
  60439. private _positionY;
  60440. private _isEnabled;
  60441. /** @hidden */
  60442. static _SceneComponentInitialization: (scene: Scene) => void;
  60443. /**
  60444. * Instantiates a lens flare system.
  60445. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60446. * It is usually composed of several `lensFlare`.
  60447. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60448. * @param name Define the name of the lens flare system in the scene
  60449. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60450. * @param scene Define the scene the lens flare system belongs to
  60451. */
  60452. constructor(
  60453. /**
  60454. * Define the name of the lens flare system
  60455. */
  60456. name: string, emitter: any, scene: Scene);
  60457. /**
  60458. * Define if the lens flare system is enabled.
  60459. */
  60460. get isEnabled(): boolean;
  60461. set isEnabled(value: boolean);
  60462. /**
  60463. * Get the scene the effects belongs to.
  60464. * @returns the scene holding the lens flare system
  60465. */
  60466. getScene(): Scene;
  60467. /**
  60468. * Get the emitter of the lens flare system.
  60469. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60470. * @returns the emitter of the lens flare system
  60471. */
  60472. getEmitter(): any;
  60473. /**
  60474. * Set the emitter of the lens flare system.
  60475. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60476. * @param newEmitter Define the new emitter of the system
  60477. */
  60478. setEmitter(newEmitter: any): void;
  60479. /**
  60480. * Get the lens flare system emitter position.
  60481. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60482. * @returns the position
  60483. */
  60484. getEmitterPosition(): Vector3;
  60485. /**
  60486. * @hidden
  60487. */
  60488. computeEffectivePosition(globalViewport: Viewport): boolean;
  60489. /** @hidden */
  60490. _isVisible(): boolean;
  60491. /**
  60492. * @hidden
  60493. */
  60494. render(): boolean;
  60495. /**
  60496. * Dispose and release the lens flare with its associated resources.
  60497. */
  60498. dispose(): void;
  60499. /**
  60500. * Parse a lens flare system from a JSON repressentation
  60501. * @param parsedLensFlareSystem Define the JSON to parse
  60502. * @param scene Define the scene the parsed system should be instantiated in
  60503. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60504. * @returns the parsed system
  60505. */
  60506. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60507. /**
  60508. * Serialize the current Lens Flare System into a JSON representation.
  60509. * @returns the serialized JSON
  60510. */
  60511. serialize(): any;
  60512. }
  60513. }
  60514. declare module BABYLON {
  60515. /**
  60516. * This represents one of the lens effect in a `lensFlareSystem`.
  60517. * It controls one of the indiviual texture used in the effect.
  60518. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60519. */
  60520. export class LensFlare {
  60521. /**
  60522. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60523. */
  60524. size: number;
  60525. /**
  60526. * 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.
  60527. */
  60528. position: number;
  60529. /**
  60530. * Define the lens color.
  60531. */
  60532. color: Color3;
  60533. /**
  60534. * Define the lens texture.
  60535. */
  60536. texture: Nullable<Texture>;
  60537. /**
  60538. * Define the alpha mode to render this particular lens.
  60539. */
  60540. alphaMode: number;
  60541. private _system;
  60542. /**
  60543. * Creates a new Lens Flare.
  60544. * This represents one of the lens effect in a `lensFlareSystem`.
  60545. * It controls one of the indiviual texture used in the effect.
  60546. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60547. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60548. * @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.
  60549. * @param color Define the lens color
  60550. * @param imgUrl Define the lens texture url
  60551. * @param system Define the `lensFlareSystem` this flare is part of
  60552. * @returns The newly created Lens Flare
  60553. */
  60554. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60555. /**
  60556. * Instantiates a new Lens Flare.
  60557. * This represents one of the lens effect in a `lensFlareSystem`.
  60558. * It controls one of the indiviual texture used in the effect.
  60559. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60560. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60561. * @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.
  60562. * @param color Define the lens color
  60563. * @param imgUrl Define the lens texture url
  60564. * @param system Define the `lensFlareSystem` this flare is part of
  60565. */
  60566. constructor(
  60567. /**
  60568. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60569. */
  60570. size: number,
  60571. /**
  60572. * 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.
  60573. */
  60574. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60575. /**
  60576. * Dispose and release the lens flare with its associated resources.
  60577. */
  60578. dispose(): void;
  60579. }
  60580. }
  60581. declare module BABYLON {
  60582. interface AbstractScene {
  60583. /**
  60584. * The list of lens flare system added to the scene
  60585. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60586. */
  60587. lensFlareSystems: Array<LensFlareSystem>;
  60588. /**
  60589. * Removes the given lens flare system from this scene.
  60590. * @param toRemove The lens flare system to remove
  60591. * @returns The index of the removed lens flare system
  60592. */
  60593. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60594. /**
  60595. * Adds the given lens flare system to this scene
  60596. * @param newLensFlareSystem The lens flare system to add
  60597. */
  60598. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60599. /**
  60600. * Gets a lens flare system using its name
  60601. * @param name defines the name to look for
  60602. * @returns the lens flare system or null if not found
  60603. */
  60604. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60605. /**
  60606. * Gets a lens flare system using its id
  60607. * @param id defines the id to look for
  60608. * @returns the lens flare system or null if not found
  60609. */
  60610. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60611. }
  60612. /**
  60613. * Defines the lens flare scene component responsible to manage any lens flares
  60614. * in a given scene.
  60615. */
  60616. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60617. /**
  60618. * The component name helpfull to identify the component in the list of scene components.
  60619. */
  60620. readonly name: string;
  60621. /**
  60622. * The scene the component belongs to.
  60623. */
  60624. scene: Scene;
  60625. /**
  60626. * Creates a new instance of the component for the given scene
  60627. * @param scene Defines the scene to register the component in
  60628. */
  60629. constructor(scene: Scene);
  60630. /**
  60631. * Registers the component in a given scene
  60632. */
  60633. register(): void;
  60634. /**
  60635. * Rebuilds the elements related to this component in case of
  60636. * context lost for instance.
  60637. */
  60638. rebuild(): void;
  60639. /**
  60640. * Adds all the elements from the container to the scene
  60641. * @param container the container holding the elements
  60642. */
  60643. addFromContainer(container: AbstractScene): void;
  60644. /**
  60645. * Removes all the elements in the container from the scene
  60646. * @param container contains the elements to remove
  60647. * @param dispose if the removed element should be disposed (default: false)
  60648. */
  60649. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60650. /**
  60651. * Serializes the component data to the specified json object
  60652. * @param serializationObject The object to serialize to
  60653. */
  60654. serialize(serializationObject: any): void;
  60655. /**
  60656. * Disposes the component and the associated ressources.
  60657. */
  60658. dispose(): void;
  60659. private _draw;
  60660. }
  60661. }
  60662. declare module BABYLON {
  60663. /** @hidden */
  60664. export var depthPixelShader: {
  60665. name: string;
  60666. shader: string;
  60667. };
  60668. }
  60669. declare module BABYLON {
  60670. /** @hidden */
  60671. export var depthVertexShader: {
  60672. name: string;
  60673. shader: string;
  60674. };
  60675. }
  60676. declare module BABYLON {
  60677. /**
  60678. * This represents a depth renderer in Babylon.
  60679. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60680. */
  60681. export class DepthRenderer {
  60682. private _scene;
  60683. private _depthMap;
  60684. private _effect;
  60685. private readonly _storeNonLinearDepth;
  60686. private readonly _clearColor;
  60687. /** Get if the depth renderer is using packed depth or not */
  60688. readonly isPacked: boolean;
  60689. private _cachedDefines;
  60690. private _camera;
  60691. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60692. enabled: boolean;
  60693. /**
  60694. * Specifiess that the depth renderer will only be used within
  60695. * the camera it is created for.
  60696. * This can help forcing its rendering during the camera processing.
  60697. */
  60698. useOnlyInActiveCamera: boolean;
  60699. /** @hidden */
  60700. static _SceneComponentInitialization: (scene: Scene) => void;
  60701. /**
  60702. * Instantiates a depth renderer
  60703. * @param scene The scene the renderer belongs to
  60704. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60705. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60706. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60707. */
  60708. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60709. /**
  60710. * Creates the depth rendering effect and checks if the effect is ready.
  60711. * @param subMesh The submesh to be used to render the depth map of
  60712. * @param useInstances If multiple world instances should be used
  60713. * @returns if the depth renderer is ready to render the depth map
  60714. */
  60715. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60716. /**
  60717. * Gets the texture which the depth map will be written to.
  60718. * @returns The depth map texture
  60719. */
  60720. getDepthMap(): RenderTargetTexture;
  60721. /**
  60722. * Disposes of the depth renderer.
  60723. */
  60724. dispose(): void;
  60725. }
  60726. }
  60727. declare module BABYLON {
  60728. /** @hidden */
  60729. export var minmaxReduxPixelShader: {
  60730. name: string;
  60731. shader: string;
  60732. };
  60733. }
  60734. declare module BABYLON {
  60735. /**
  60736. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60737. * and maximum values from all values of the texture.
  60738. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60739. * The source values are read from the red channel of the texture.
  60740. */
  60741. export class MinMaxReducer {
  60742. /**
  60743. * Observable triggered when the computation has been performed
  60744. */
  60745. onAfterReductionPerformed: Observable<{
  60746. min: number;
  60747. max: number;
  60748. }>;
  60749. protected _camera: Camera;
  60750. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60751. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60752. protected _postProcessManager: PostProcessManager;
  60753. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60754. protected _forceFullscreenViewport: boolean;
  60755. /**
  60756. * Creates a min/max reducer
  60757. * @param camera The camera to use for the post processes
  60758. */
  60759. constructor(camera: Camera);
  60760. /**
  60761. * Gets the texture used to read the values from.
  60762. */
  60763. get sourceTexture(): Nullable<RenderTargetTexture>;
  60764. /**
  60765. * Sets the source texture to read the values from.
  60766. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60767. * because in such textures '1' value must not be taken into account to compute the maximum
  60768. * as this value is used to clear the texture.
  60769. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60770. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60771. * @param depthRedux Indicates if the texture is a depth texture or not
  60772. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60773. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60774. */
  60775. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60776. /**
  60777. * Defines the refresh rate of the computation.
  60778. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60779. */
  60780. get refreshRate(): number;
  60781. set refreshRate(value: number);
  60782. protected _activated: boolean;
  60783. /**
  60784. * Gets the activation status of the reducer
  60785. */
  60786. get activated(): boolean;
  60787. /**
  60788. * Activates the reduction computation.
  60789. * When activated, the observers registered in onAfterReductionPerformed are
  60790. * called after the compuation is performed
  60791. */
  60792. activate(): void;
  60793. /**
  60794. * Deactivates the reduction computation.
  60795. */
  60796. deactivate(): void;
  60797. /**
  60798. * Disposes the min/max reducer
  60799. * @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.
  60800. */
  60801. dispose(disposeAll?: boolean): void;
  60802. }
  60803. }
  60804. declare module BABYLON {
  60805. /**
  60806. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60807. */
  60808. export class DepthReducer extends MinMaxReducer {
  60809. private _depthRenderer;
  60810. private _depthRendererId;
  60811. /**
  60812. * Gets the depth renderer used for the computation.
  60813. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60814. */
  60815. get depthRenderer(): Nullable<DepthRenderer>;
  60816. /**
  60817. * Creates a depth reducer
  60818. * @param camera The camera used to render the depth texture
  60819. */
  60820. constructor(camera: Camera);
  60821. /**
  60822. * Sets the depth renderer to use to generate the depth map
  60823. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60824. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60825. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60826. */
  60827. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60828. /** @hidden */
  60829. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60830. /**
  60831. * Activates the reduction computation.
  60832. * When activated, the observers registered in onAfterReductionPerformed are
  60833. * called after the compuation is performed
  60834. */
  60835. activate(): void;
  60836. /**
  60837. * Deactivates the reduction computation.
  60838. */
  60839. deactivate(): void;
  60840. /**
  60841. * Disposes the depth reducer
  60842. * @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.
  60843. */
  60844. dispose(disposeAll?: boolean): void;
  60845. }
  60846. }
  60847. declare module BABYLON {
  60848. /**
  60849. * A CSM implementation allowing casting shadows on large scenes.
  60850. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60851. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60852. */
  60853. export class CascadedShadowGenerator extends ShadowGenerator {
  60854. private static readonly frustumCornersNDCSpace;
  60855. /**
  60856. * Name of the CSM class
  60857. */
  60858. static CLASSNAME: string;
  60859. /**
  60860. * Defines the default number of cascades used by the CSM.
  60861. */
  60862. static readonly DEFAULT_CASCADES_COUNT: number;
  60863. /**
  60864. * Defines the minimum number of cascades used by the CSM.
  60865. */
  60866. static readonly MIN_CASCADES_COUNT: number;
  60867. /**
  60868. * Defines the maximum number of cascades used by the CSM.
  60869. */
  60870. static readonly MAX_CASCADES_COUNT: number;
  60871. protected _validateFilter(filter: number): number;
  60872. /**
  60873. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60874. */
  60875. penumbraDarkness: number;
  60876. private _numCascades;
  60877. /**
  60878. * Gets or set the number of cascades used by the CSM.
  60879. */
  60880. get numCascades(): number;
  60881. set numCascades(value: number);
  60882. /**
  60883. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60884. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60885. */
  60886. stabilizeCascades: boolean;
  60887. private _freezeShadowCastersBoundingInfo;
  60888. private _freezeShadowCastersBoundingInfoObservable;
  60889. /**
  60890. * Enables or disables the shadow casters bounding info computation.
  60891. * If your shadow casters don't move, you can disable this feature.
  60892. * If it is enabled, the bounding box computation is done every frame.
  60893. */
  60894. get freezeShadowCastersBoundingInfo(): boolean;
  60895. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60896. private _scbiMin;
  60897. private _scbiMax;
  60898. protected _computeShadowCastersBoundingInfo(): void;
  60899. protected _shadowCastersBoundingInfo: BoundingInfo;
  60900. /**
  60901. * Gets or sets the shadow casters bounding info.
  60902. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60903. * so that the system won't overwrite the bounds you provide
  60904. */
  60905. get shadowCastersBoundingInfo(): BoundingInfo;
  60906. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60907. protected _breaksAreDirty: boolean;
  60908. protected _minDistance: number;
  60909. protected _maxDistance: number;
  60910. /**
  60911. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60912. *
  60913. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60914. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60915. * @param min minimal distance for the breaks (default to 0.)
  60916. * @param max maximal distance for the breaks (default to 1.)
  60917. */
  60918. setMinMaxDistance(min: number, max: number): void;
  60919. /** Gets the minimal distance used in the cascade break computation */
  60920. get minDistance(): number;
  60921. /** Gets the maximal distance used in the cascade break computation */
  60922. get maxDistance(): number;
  60923. /**
  60924. * Gets the class name of that object
  60925. * @returns "CascadedShadowGenerator"
  60926. */
  60927. getClassName(): string;
  60928. private _cascadeMinExtents;
  60929. private _cascadeMaxExtents;
  60930. /**
  60931. * Gets a cascade minimum extents
  60932. * @param cascadeIndex index of the cascade
  60933. * @returns the minimum cascade extents
  60934. */
  60935. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60936. /**
  60937. * Gets a cascade maximum extents
  60938. * @param cascadeIndex index of the cascade
  60939. * @returns the maximum cascade extents
  60940. */
  60941. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60942. private _cascades;
  60943. private _currentLayer;
  60944. private _viewSpaceFrustumsZ;
  60945. private _viewMatrices;
  60946. private _projectionMatrices;
  60947. private _transformMatrices;
  60948. private _transformMatricesAsArray;
  60949. private _frustumLengths;
  60950. private _lightSizeUVCorrection;
  60951. private _depthCorrection;
  60952. private _frustumCornersWorldSpace;
  60953. private _frustumCenter;
  60954. private _shadowCameraPos;
  60955. private _shadowMaxZ;
  60956. /**
  60957. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60958. * It defaults to camera.maxZ
  60959. */
  60960. get shadowMaxZ(): number;
  60961. /**
  60962. * Sets the shadow max z distance.
  60963. */
  60964. set shadowMaxZ(value: number);
  60965. protected _debug: boolean;
  60966. /**
  60967. * Gets or sets the debug flag.
  60968. * When enabled, the cascades are materialized by different colors on the screen.
  60969. */
  60970. get debug(): boolean;
  60971. set debug(dbg: boolean);
  60972. private _depthClamp;
  60973. /**
  60974. * Gets or sets the depth clamping value.
  60975. *
  60976. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60977. * to account for the shadow casters far away.
  60978. *
  60979. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60980. */
  60981. get depthClamp(): boolean;
  60982. set depthClamp(value: boolean);
  60983. private _cascadeBlendPercentage;
  60984. /**
  60985. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60986. * It defaults to 0.1 (10% blending).
  60987. */
  60988. get cascadeBlendPercentage(): number;
  60989. set cascadeBlendPercentage(value: number);
  60990. private _lambda;
  60991. /**
  60992. * Gets or set the lambda parameter.
  60993. * This parameter is used to split the camera frustum and create the cascades.
  60994. * 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.
  60995. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60996. */
  60997. get lambda(): number;
  60998. set lambda(value: number);
  60999. /**
  61000. * Gets the view matrix corresponding to a given cascade
  61001. * @param cascadeNum cascade to retrieve the view matrix from
  61002. * @returns the cascade view matrix
  61003. */
  61004. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61005. /**
  61006. * Gets the projection matrix corresponding to a given cascade
  61007. * @param cascadeNum cascade to retrieve the projection matrix from
  61008. * @returns the cascade projection matrix
  61009. */
  61010. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61011. /**
  61012. * Gets the transformation matrix corresponding to a given cascade
  61013. * @param cascadeNum cascade to retrieve the transformation matrix from
  61014. * @returns the cascade transformation matrix
  61015. */
  61016. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61017. private _depthRenderer;
  61018. /**
  61019. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61020. *
  61021. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61022. *
  61023. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61024. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61025. * @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
  61026. */
  61027. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61028. private _depthReducer;
  61029. private _autoCalcDepthBounds;
  61030. /**
  61031. * Gets or sets the autoCalcDepthBounds property.
  61032. *
  61033. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61034. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61035. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61036. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61037. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61038. */
  61039. get autoCalcDepthBounds(): boolean;
  61040. set autoCalcDepthBounds(value: boolean);
  61041. /**
  61042. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61043. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61044. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61045. * for setting the refresh rate on the renderer yourself!
  61046. */
  61047. get autoCalcDepthBoundsRefreshRate(): number;
  61048. set autoCalcDepthBoundsRefreshRate(value: number);
  61049. /**
  61050. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61051. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61052. * you change the camera near/far planes!
  61053. */
  61054. splitFrustum(): void;
  61055. private _splitFrustum;
  61056. private _computeMatrices;
  61057. private _computeFrustumInWorldSpace;
  61058. private _computeCascadeFrustum;
  61059. /**
  61060. * Support test.
  61061. */
  61062. static get IsSupported(): boolean;
  61063. /** @hidden */
  61064. static _SceneComponentInitialization: (scene: Scene) => void;
  61065. /**
  61066. * Creates a Cascaded Shadow Generator object.
  61067. * A ShadowGenerator is the required tool to use the shadows.
  61068. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61069. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61070. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61071. * @param light The directional light object generating the shadows.
  61072. * @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.
  61073. */
  61074. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61075. protected _initializeGenerator(): void;
  61076. protected _createTargetRenderTexture(): void;
  61077. protected _initializeShadowMap(): void;
  61078. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61079. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61080. /**
  61081. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61082. * @param defines Defines of the material we want to update
  61083. * @param lightIndex Index of the light in the enabled light list of the material
  61084. */
  61085. prepareDefines(defines: any, lightIndex: number): void;
  61086. /**
  61087. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61088. * defined in the generator but impacting the effect).
  61089. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61090. * @param effect The effect we are binfing the information for
  61091. */
  61092. bindShadowLight(lightIndex: string, effect: Effect): void;
  61093. /**
  61094. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61095. * (eq to view projection * shadow projection matrices)
  61096. * @returns The transform matrix used to create the shadow map
  61097. */
  61098. getTransformMatrix(): Matrix;
  61099. /**
  61100. * Disposes the ShadowGenerator.
  61101. * Returns nothing.
  61102. */
  61103. dispose(): void;
  61104. /**
  61105. * Serializes the shadow generator setup to a json object.
  61106. * @returns The serialized JSON object
  61107. */
  61108. serialize(): any;
  61109. /**
  61110. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61111. * @param parsedShadowGenerator The JSON object to parse
  61112. * @param scene The scene to create the shadow map for
  61113. * @returns The parsed shadow generator
  61114. */
  61115. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61116. }
  61117. }
  61118. declare module BABYLON {
  61119. /**
  61120. * Defines the shadow generator component responsible to manage any shadow generators
  61121. * in a given scene.
  61122. */
  61123. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61124. /**
  61125. * The component name helpfull to identify the component in the list of scene components.
  61126. */
  61127. readonly name: string;
  61128. /**
  61129. * The scene the component belongs to.
  61130. */
  61131. scene: Scene;
  61132. /**
  61133. * Creates a new instance of the component for the given scene
  61134. * @param scene Defines the scene to register the component in
  61135. */
  61136. constructor(scene: Scene);
  61137. /**
  61138. * Registers the component in a given scene
  61139. */
  61140. register(): void;
  61141. /**
  61142. * Rebuilds the elements related to this component in case of
  61143. * context lost for instance.
  61144. */
  61145. rebuild(): void;
  61146. /**
  61147. * Serializes the component data to the specified json object
  61148. * @param serializationObject The object to serialize to
  61149. */
  61150. serialize(serializationObject: any): void;
  61151. /**
  61152. * Adds all the elements from the container to the scene
  61153. * @param container the container holding the elements
  61154. */
  61155. addFromContainer(container: AbstractScene): void;
  61156. /**
  61157. * Removes all the elements in the container from the scene
  61158. * @param container contains the elements to remove
  61159. * @param dispose if the removed element should be disposed (default: false)
  61160. */
  61161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61162. /**
  61163. * Rebuilds the elements related to this component in case of
  61164. * context lost for instance.
  61165. */
  61166. dispose(): void;
  61167. private _gatherRenderTargets;
  61168. }
  61169. }
  61170. declare module BABYLON {
  61171. /**
  61172. * A point light is a light defined by an unique point in world space.
  61173. * The light is emitted in every direction from this point.
  61174. * A good example of a point light is a standard light bulb.
  61175. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61176. */
  61177. export class PointLight extends ShadowLight {
  61178. private _shadowAngle;
  61179. /**
  61180. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61181. * This specifies what angle the shadow will use to be created.
  61182. *
  61183. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61184. */
  61185. get shadowAngle(): number;
  61186. /**
  61187. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61188. * This specifies what angle the shadow will use to be created.
  61189. *
  61190. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61191. */
  61192. set shadowAngle(value: number);
  61193. /**
  61194. * Gets the direction if it has been set.
  61195. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61196. */
  61197. get direction(): Vector3;
  61198. /**
  61199. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61200. */
  61201. set direction(value: Vector3);
  61202. /**
  61203. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61204. * A PointLight emits the light in every direction.
  61205. * It can cast shadows.
  61206. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61207. * ```javascript
  61208. * var pointLight = new PointLight("pl", camera.position, scene);
  61209. * ```
  61210. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61211. * @param name The light friendly name
  61212. * @param position The position of the point light in the scene
  61213. * @param scene The scene the lights belongs to
  61214. */
  61215. constructor(name: string, position: Vector3, scene: Scene);
  61216. /**
  61217. * Returns the string "PointLight"
  61218. * @returns the class name
  61219. */
  61220. getClassName(): string;
  61221. /**
  61222. * Returns the integer 0.
  61223. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61224. */
  61225. getTypeID(): number;
  61226. /**
  61227. * Specifies wether or not the shadowmap should be a cube texture.
  61228. * @returns true if the shadowmap needs to be a cube texture.
  61229. */
  61230. needCube(): boolean;
  61231. /**
  61232. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61233. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61234. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61235. */
  61236. getShadowDirection(faceIndex?: number): Vector3;
  61237. /**
  61238. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61239. * - fov = PI / 2
  61240. * - aspect ratio : 1.0
  61241. * - z-near and far equal to the active camera minZ and maxZ.
  61242. * Returns the PointLight.
  61243. */
  61244. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61245. protected _buildUniformLayout(): void;
  61246. /**
  61247. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61248. * @param effect The effect to update
  61249. * @param lightIndex The index of the light in the effect to update
  61250. * @returns The point light
  61251. */
  61252. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61253. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61254. /**
  61255. * Prepares the list of defines specific to the light type.
  61256. * @param defines the list of defines
  61257. * @param lightIndex defines the index of the light for the effect
  61258. */
  61259. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61260. }
  61261. }
  61262. declare module BABYLON {
  61263. /**
  61264. * Header information of HDR texture files.
  61265. */
  61266. export interface HDRInfo {
  61267. /**
  61268. * The height of the texture in pixels.
  61269. */
  61270. height: number;
  61271. /**
  61272. * The width of the texture in pixels.
  61273. */
  61274. width: number;
  61275. /**
  61276. * The index of the beginning of the data in the binary file.
  61277. */
  61278. dataPosition: number;
  61279. }
  61280. /**
  61281. * This groups tools to convert HDR texture to native colors array.
  61282. */
  61283. export class HDRTools {
  61284. private static Ldexp;
  61285. private static Rgbe2float;
  61286. private static readStringLine;
  61287. /**
  61288. * Reads header information from an RGBE texture stored in a native array.
  61289. * More information on this format are available here:
  61290. * https://en.wikipedia.org/wiki/RGBE_image_format
  61291. *
  61292. * @param uint8array The binary file stored in native array.
  61293. * @return The header information.
  61294. */
  61295. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61296. /**
  61297. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61298. * This RGBE texture needs to store the information as a panorama.
  61299. *
  61300. * More information on this format are available here:
  61301. * https://en.wikipedia.org/wiki/RGBE_image_format
  61302. *
  61303. * @param buffer The binary file stored in an array buffer.
  61304. * @param size The expected size of the extracted cubemap.
  61305. * @return The Cube Map information.
  61306. */
  61307. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61308. /**
  61309. * Returns the pixels data extracted from an RGBE texture.
  61310. * This pixels will be stored left to right up to down in the R G B order in one array.
  61311. *
  61312. * More information on this format are available here:
  61313. * https://en.wikipedia.org/wiki/RGBE_image_format
  61314. *
  61315. * @param uint8array The binary file stored in an array buffer.
  61316. * @param hdrInfo The header information of the file.
  61317. * @return The pixels data in RGB right to left up to down order.
  61318. */
  61319. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61320. private static RGBE_ReadPixels_RLE;
  61321. private static RGBE_ReadPixels_NOT_RLE;
  61322. }
  61323. }
  61324. declare module BABYLON {
  61325. /**
  61326. * Effect Render Options
  61327. */
  61328. export interface IEffectRendererOptions {
  61329. /**
  61330. * Defines the vertices positions.
  61331. */
  61332. positions?: number[];
  61333. /**
  61334. * Defines the indices.
  61335. */
  61336. indices?: number[];
  61337. }
  61338. /**
  61339. * Helper class to render one or more effects.
  61340. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61341. */
  61342. export class EffectRenderer {
  61343. private engine;
  61344. private static _DefaultOptions;
  61345. private _vertexBuffers;
  61346. private _indexBuffer;
  61347. private _fullscreenViewport;
  61348. /**
  61349. * Creates an effect renderer
  61350. * @param engine the engine to use for rendering
  61351. * @param options defines the options of the effect renderer
  61352. */
  61353. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61354. /**
  61355. * Sets the current viewport in normalized coordinates 0-1
  61356. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61357. */
  61358. setViewport(viewport?: Viewport): void;
  61359. /**
  61360. * Binds the embedded attributes buffer to the effect.
  61361. * @param effect Defines the effect to bind the attributes for
  61362. */
  61363. bindBuffers(effect: Effect): void;
  61364. /**
  61365. * Sets the current effect wrapper to use during draw.
  61366. * The effect needs to be ready before calling this api.
  61367. * This also sets the default full screen position attribute.
  61368. * @param effectWrapper Defines the effect to draw with
  61369. */
  61370. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61371. /**
  61372. * Restores engine states
  61373. */
  61374. restoreStates(): void;
  61375. /**
  61376. * Draws a full screen quad.
  61377. */
  61378. draw(): void;
  61379. private isRenderTargetTexture;
  61380. /**
  61381. * renders one or more effects to a specified texture
  61382. * @param effectWrapper the effect to renderer
  61383. * @param outputTexture texture to draw to, if null it will render to the screen.
  61384. */
  61385. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61386. /**
  61387. * Disposes of the effect renderer
  61388. */
  61389. dispose(): void;
  61390. }
  61391. /**
  61392. * Options to create an EffectWrapper
  61393. */
  61394. interface EffectWrapperCreationOptions {
  61395. /**
  61396. * Engine to use to create the effect
  61397. */
  61398. engine: ThinEngine;
  61399. /**
  61400. * Fragment shader for the effect
  61401. */
  61402. fragmentShader: string;
  61403. /**
  61404. * Use the shader store instead of direct source code
  61405. */
  61406. useShaderStore?: boolean;
  61407. /**
  61408. * Vertex shader for the effect
  61409. */
  61410. vertexShader?: string;
  61411. /**
  61412. * Attributes to use in the shader
  61413. */
  61414. attributeNames?: Array<string>;
  61415. /**
  61416. * Uniforms to use in the shader
  61417. */
  61418. uniformNames?: Array<string>;
  61419. /**
  61420. * Texture sampler names to use in the shader
  61421. */
  61422. samplerNames?: Array<string>;
  61423. /**
  61424. * Defines to use in the shader
  61425. */
  61426. defines?: Array<string>;
  61427. /**
  61428. * Callback when effect is compiled
  61429. */
  61430. onCompiled?: Nullable<(effect: Effect) => void>;
  61431. /**
  61432. * The friendly name of the effect displayed in Spector.
  61433. */
  61434. name?: string;
  61435. }
  61436. /**
  61437. * Wraps an effect to be used for rendering
  61438. */
  61439. export class EffectWrapper {
  61440. /**
  61441. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61442. */
  61443. onApplyObservable: Observable<{}>;
  61444. /**
  61445. * The underlying effect
  61446. */
  61447. effect: Effect;
  61448. /**
  61449. * Creates an effect to be renderer
  61450. * @param creationOptions options to create the effect
  61451. */
  61452. constructor(creationOptions: EffectWrapperCreationOptions);
  61453. /**
  61454. * Disposes of the effect wrapper
  61455. */
  61456. dispose(): void;
  61457. }
  61458. }
  61459. declare module BABYLON {
  61460. /** @hidden */
  61461. export var hdrFilteringVertexShader: {
  61462. name: string;
  61463. shader: string;
  61464. };
  61465. }
  61466. declare module BABYLON {
  61467. /** @hidden */
  61468. export var hdrFilteringPixelShader: {
  61469. name: string;
  61470. shader: string;
  61471. };
  61472. }
  61473. declare module BABYLON {
  61474. /**
  61475. * Options for texture filtering
  61476. */
  61477. interface IHDRFilteringOptions {
  61478. /**
  61479. * Scales pixel intensity for the input HDR map.
  61480. */
  61481. hdrScale?: number;
  61482. /**
  61483. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61484. */
  61485. quality?: number;
  61486. }
  61487. /**
  61488. * Filters HDR maps to get correct renderings of PBR reflections
  61489. */
  61490. export class HDRFiltering {
  61491. private _engine;
  61492. private _effectRenderer;
  61493. private _effectWrapper;
  61494. private _lodGenerationOffset;
  61495. private _lodGenerationScale;
  61496. /**
  61497. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61498. * you care about baking speed.
  61499. */
  61500. quality: number;
  61501. /**
  61502. * Scales pixel intensity for the input HDR map.
  61503. */
  61504. hdrScale: number;
  61505. /**
  61506. * Instantiates HDR filter for reflection maps
  61507. *
  61508. * @param engine Thin engine
  61509. * @param options Options
  61510. */
  61511. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61512. private _createRenderTarget;
  61513. private _prefilterInternal;
  61514. private _createEffect;
  61515. /**
  61516. * Get a value indicating if the filter is ready to be used
  61517. * @param texture Texture to filter
  61518. * @returns true if the filter is ready
  61519. */
  61520. isReady(texture: BaseTexture): boolean;
  61521. /**
  61522. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61523. * Prefiltering will be invoked at the end of next rendering pass.
  61524. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61525. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61526. * @param texture Texture to filter
  61527. * @param onFinished Callback when filtering is done
  61528. * @return Promise called when prefiltering is done
  61529. */
  61530. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61531. }
  61532. }
  61533. declare module BABYLON {
  61534. /**
  61535. * This represents a texture coming from an HDR input.
  61536. *
  61537. * The only supported format is currently panorama picture stored in RGBE format.
  61538. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61539. */
  61540. export class HDRCubeTexture extends BaseTexture {
  61541. private static _facesMapping;
  61542. private _generateHarmonics;
  61543. private _noMipmap;
  61544. private _prefilterOnLoad;
  61545. private _textureMatrix;
  61546. private _size;
  61547. private _onLoad;
  61548. private _onError;
  61549. /**
  61550. * The texture URL.
  61551. */
  61552. url: string;
  61553. protected _isBlocking: boolean;
  61554. /**
  61555. * Sets wether or not the texture is blocking during loading.
  61556. */
  61557. set isBlocking(value: boolean);
  61558. /**
  61559. * Gets wether or not the texture is blocking during loading.
  61560. */
  61561. get isBlocking(): boolean;
  61562. protected _rotationY: number;
  61563. /**
  61564. * Sets texture matrix rotation angle around Y axis in radians.
  61565. */
  61566. set rotationY(value: number);
  61567. /**
  61568. * Gets texture matrix rotation angle around Y axis radians.
  61569. */
  61570. get rotationY(): number;
  61571. /**
  61572. * Gets or sets the center of the bounding box associated with the cube texture
  61573. * It must define where the camera used to render the texture was set
  61574. */
  61575. boundingBoxPosition: Vector3;
  61576. private _boundingBoxSize;
  61577. /**
  61578. * Gets or sets the size of the bounding box associated with the cube texture
  61579. * When defined, the cubemap will switch to local mode
  61580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61581. * @example https://www.babylonjs-playground.com/#RNASML
  61582. */
  61583. set boundingBoxSize(value: Vector3);
  61584. get boundingBoxSize(): Vector3;
  61585. /**
  61586. * Instantiates an HDRTexture from the following parameters.
  61587. *
  61588. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61589. * @param sceneOrEngine The scene or engine the texture will be used in
  61590. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61591. * @param noMipmap Forces to not generate the mipmap if true
  61592. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61593. * @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)
  61594. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61595. */
  61596. 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>);
  61597. /**
  61598. * Get the current class name of the texture useful for serialization or dynamic coding.
  61599. * @returns "HDRCubeTexture"
  61600. */
  61601. getClassName(): string;
  61602. /**
  61603. * Occurs when the file is raw .hdr file.
  61604. */
  61605. private loadTexture;
  61606. clone(): HDRCubeTexture;
  61607. delayLoad(): void;
  61608. /**
  61609. * Get the texture reflection matrix used to rotate/transform the reflection.
  61610. * @returns the reflection matrix
  61611. */
  61612. getReflectionTextureMatrix(): Matrix;
  61613. /**
  61614. * Set the texture reflection matrix used to rotate/transform the reflection.
  61615. * @param value Define the reflection matrix to set
  61616. */
  61617. setReflectionTextureMatrix(value: Matrix): void;
  61618. /**
  61619. * Parses a JSON representation of an HDR Texture in order to create the texture
  61620. * @param parsedTexture Define the JSON representation
  61621. * @param scene Define the scene the texture should be created in
  61622. * @param rootUrl Define the root url in case we need to load relative dependencies
  61623. * @returns the newly created texture after parsing
  61624. */
  61625. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61626. serialize(): any;
  61627. }
  61628. }
  61629. declare module BABYLON {
  61630. /**
  61631. * Class used to control physics engine
  61632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61633. */
  61634. export class PhysicsEngine implements IPhysicsEngine {
  61635. private _physicsPlugin;
  61636. /**
  61637. * Global value used to control the smallest number supported by the simulation
  61638. */
  61639. static Epsilon: number;
  61640. private _impostors;
  61641. private _joints;
  61642. private _subTimeStep;
  61643. /**
  61644. * Gets the gravity vector used by the simulation
  61645. */
  61646. gravity: Vector3;
  61647. /**
  61648. * Factory used to create the default physics plugin.
  61649. * @returns The default physics plugin
  61650. */
  61651. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61652. /**
  61653. * Creates a new Physics Engine
  61654. * @param gravity defines the gravity vector used by the simulation
  61655. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61656. */
  61657. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61658. /**
  61659. * Sets the gravity vector used by the simulation
  61660. * @param gravity defines the gravity vector to use
  61661. */
  61662. setGravity(gravity: Vector3): void;
  61663. /**
  61664. * Set the time step of the physics engine.
  61665. * Default is 1/60.
  61666. * To slow it down, enter 1/600 for example.
  61667. * To speed it up, 1/30
  61668. * @param newTimeStep defines the new timestep to apply to this world.
  61669. */
  61670. setTimeStep(newTimeStep?: number): void;
  61671. /**
  61672. * Get the time step of the physics engine.
  61673. * @returns the current time step
  61674. */
  61675. getTimeStep(): number;
  61676. /**
  61677. * Set the sub time step of the physics engine.
  61678. * Default is 0 meaning there is no sub steps
  61679. * To increase physics resolution precision, set a small value (like 1 ms)
  61680. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61681. */
  61682. setSubTimeStep(subTimeStep?: number): void;
  61683. /**
  61684. * Get the sub time step of the physics engine.
  61685. * @returns the current sub time step
  61686. */
  61687. getSubTimeStep(): number;
  61688. /**
  61689. * Release all resources
  61690. */
  61691. dispose(): void;
  61692. /**
  61693. * Gets the name of the current physics plugin
  61694. * @returns the name of the plugin
  61695. */
  61696. getPhysicsPluginName(): string;
  61697. /**
  61698. * Adding a new impostor for the impostor tracking.
  61699. * This will be done by the impostor itself.
  61700. * @param impostor the impostor to add
  61701. */
  61702. addImpostor(impostor: PhysicsImpostor): void;
  61703. /**
  61704. * Remove an impostor from the engine.
  61705. * This impostor and its mesh will not longer be updated by the physics engine.
  61706. * @param impostor the impostor to remove
  61707. */
  61708. removeImpostor(impostor: PhysicsImpostor): void;
  61709. /**
  61710. * Add a joint to the physics engine
  61711. * @param mainImpostor defines the main impostor to which the joint is added.
  61712. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61713. * @param joint defines the joint that will connect both impostors.
  61714. */
  61715. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61716. /**
  61717. * Removes a joint from the simulation
  61718. * @param mainImpostor defines the impostor used with the joint
  61719. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61720. * @param joint defines the joint to remove
  61721. */
  61722. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61723. /**
  61724. * Called by the scene. No need to call it.
  61725. * @param delta defines the timespam between frames
  61726. */
  61727. _step(delta: number): void;
  61728. /**
  61729. * Gets the current plugin used to run the simulation
  61730. * @returns current plugin
  61731. */
  61732. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61733. /**
  61734. * Gets the list of physic impostors
  61735. * @returns an array of PhysicsImpostor
  61736. */
  61737. getImpostors(): Array<PhysicsImpostor>;
  61738. /**
  61739. * Gets the impostor for a physics enabled object
  61740. * @param object defines the object impersonated by the impostor
  61741. * @returns the PhysicsImpostor or null if not found
  61742. */
  61743. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61744. /**
  61745. * Gets the impostor for a physics body object
  61746. * @param body defines physics body used by the impostor
  61747. * @returns the PhysicsImpostor or null if not found
  61748. */
  61749. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61750. /**
  61751. * Does a raycast in the physics world
  61752. * @param from when should the ray start?
  61753. * @param to when should the ray end?
  61754. * @returns PhysicsRaycastResult
  61755. */
  61756. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61757. }
  61758. }
  61759. declare module BABYLON {
  61760. /** @hidden */
  61761. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61762. private _useDeltaForWorldStep;
  61763. world: any;
  61764. name: string;
  61765. private _physicsMaterials;
  61766. private _fixedTimeStep;
  61767. private _cannonRaycastResult;
  61768. private _raycastResult;
  61769. private _physicsBodysToRemoveAfterStep;
  61770. private _firstFrame;
  61771. BJSCANNON: any;
  61772. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61773. setGravity(gravity: Vector3): void;
  61774. setTimeStep(timeStep: number): void;
  61775. getTimeStep(): number;
  61776. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61777. private _removeMarkedPhysicsBodiesFromWorld;
  61778. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61779. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61780. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61781. private _processChildMeshes;
  61782. removePhysicsBody(impostor: PhysicsImpostor): void;
  61783. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61784. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61785. private _addMaterial;
  61786. private _checkWithEpsilon;
  61787. private _createShape;
  61788. private _createHeightmap;
  61789. private _minus90X;
  61790. private _plus90X;
  61791. private _tmpPosition;
  61792. private _tmpDeltaPosition;
  61793. private _tmpUnityRotation;
  61794. private _updatePhysicsBodyTransformation;
  61795. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61796. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61797. isSupported(): boolean;
  61798. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61800. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61801. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61802. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61803. getBodyMass(impostor: PhysicsImpostor): number;
  61804. getBodyFriction(impostor: PhysicsImpostor): number;
  61805. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61806. getBodyRestitution(impostor: PhysicsImpostor): number;
  61807. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61808. sleepBody(impostor: PhysicsImpostor): void;
  61809. wakeUpBody(impostor: PhysicsImpostor): void;
  61810. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61811. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61812. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61813. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61814. getRadius(impostor: PhysicsImpostor): number;
  61815. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61816. dispose(): void;
  61817. private _extendNamespace;
  61818. /**
  61819. * Does a raycast in the physics world
  61820. * @param from when should the ray start?
  61821. * @param to when should the ray end?
  61822. * @returns PhysicsRaycastResult
  61823. */
  61824. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61825. }
  61826. }
  61827. declare module BABYLON {
  61828. /** @hidden */
  61829. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61830. private _useDeltaForWorldStep;
  61831. world: any;
  61832. name: string;
  61833. BJSOIMO: any;
  61834. private _raycastResult;
  61835. private _fixedTimeStep;
  61836. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61837. setGravity(gravity: Vector3): void;
  61838. setTimeStep(timeStep: number): void;
  61839. getTimeStep(): number;
  61840. private _tmpImpostorsArray;
  61841. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61842. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61843. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61844. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61845. private _tmpPositionVector;
  61846. removePhysicsBody(impostor: PhysicsImpostor): void;
  61847. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61848. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61849. isSupported(): boolean;
  61850. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61851. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61852. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61854. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61855. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61856. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61857. getBodyMass(impostor: PhysicsImpostor): number;
  61858. getBodyFriction(impostor: PhysicsImpostor): number;
  61859. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61860. getBodyRestitution(impostor: PhysicsImpostor): number;
  61861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61862. sleepBody(impostor: PhysicsImpostor): void;
  61863. wakeUpBody(impostor: PhysicsImpostor): void;
  61864. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61865. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61866. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61867. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61868. getRadius(impostor: PhysicsImpostor): number;
  61869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61870. dispose(): void;
  61871. /**
  61872. * Does a raycast in the physics world
  61873. * @param from when should the ray start?
  61874. * @param to when should the ray end?
  61875. * @returns PhysicsRaycastResult
  61876. */
  61877. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /**
  61882. * AmmoJS Physics plugin
  61883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61884. * @see https://github.com/kripken/ammo.js/
  61885. */
  61886. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61887. private _useDeltaForWorldStep;
  61888. /**
  61889. * Reference to the Ammo library
  61890. */
  61891. bjsAMMO: any;
  61892. /**
  61893. * Created ammoJS world which physics bodies are added to
  61894. */
  61895. world: any;
  61896. /**
  61897. * Name of the plugin
  61898. */
  61899. name: string;
  61900. private _timeStep;
  61901. private _fixedTimeStep;
  61902. private _maxSteps;
  61903. private _tmpQuaternion;
  61904. private _tmpAmmoTransform;
  61905. private _tmpAmmoQuaternion;
  61906. private _tmpAmmoConcreteContactResultCallback;
  61907. private _collisionConfiguration;
  61908. private _dispatcher;
  61909. private _overlappingPairCache;
  61910. private _solver;
  61911. private _softBodySolver;
  61912. private _tmpAmmoVectorA;
  61913. private _tmpAmmoVectorB;
  61914. private _tmpAmmoVectorC;
  61915. private _tmpAmmoVectorD;
  61916. private _tmpContactCallbackResult;
  61917. private _tmpAmmoVectorRCA;
  61918. private _tmpAmmoVectorRCB;
  61919. private _raycastResult;
  61920. private _tmpContactPoint;
  61921. private static readonly DISABLE_COLLISION_FLAG;
  61922. private static readonly KINEMATIC_FLAG;
  61923. private static readonly DISABLE_DEACTIVATION_FLAG;
  61924. /**
  61925. * Initializes the ammoJS plugin
  61926. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61927. * @param ammoInjection can be used to inject your own ammo reference
  61928. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61929. */
  61930. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61931. /**
  61932. * Sets the gravity of the physics world (m/(s^2))
  61933. * @param gravity Gravity to set
  61934. */
  61935. setGravity(gravity: Vector3): void;
  61936. /**
  61937. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61938. * @param timeStep timestep to use in seconds
  61939. */
  61940. setTimeStep(timeStep: number): void;
  61941. /**
  61942. * 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)
  61943. * @param fixedTimeStep fixedTimeStep to use in seconds
  61944. */
  61945. setFixedTimeStep(fixedTimeStep: number): void;
  61946. /**
  61947. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61948. * @param maxSteps the maximum number of steps by the physics engine per frame
  61949. */
  61950. setMaxSteps(maxSteps: number): void;
  61951. /**
  61952. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61953. * @returns the current timestep in seconds
  61954. */
  61955. getTimeStep(): number;
  61956. /**
  61957. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61958. */
  61959. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61960. private _isImpostorInContact;
  61961. private _isImpostorPairInContact;
  61962. private _stepSimulation;
  61963. /**
  61964. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61965. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61966. * After the step the babylon meshes are set to the position of the physics imposters
  61967. * @param delta amount of time to step forward
  61968. * @param impostors array of imposters to update before/after the step
  61969. */
  61970. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61971. /**
  61972. * Update babylon mesh to match physics world object
  61973. * @param impostor imposter to match
  61974. */
  61975. private _afterSoftStep;
  61976. /**
  61977. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61978. * @param impostor imposter to match
  61979. */
  61980. private _ropeStep;
  61981. /**
  61982. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61983. * @param impostor imposter to match
  61984. */
  61985. private _softbodyOrClothStep;
  61986. private _tmpMatrix;
  61987. /**
  61988. * Applies an impulse on the imposter
  61989. * @param impostor imposter to apply impulse to
  61990. * @param force amount of force to be applied to the imposter
  61991. * @param contactPoint the location to apply the impulse on the imposter
  61992. */
  61993. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61994. /**
  61995. * Applies a force on the imposter
  61996. * @param impostor imposter to apply force
  61997. * @param force amount of force to be applied to the imposter
  61998. * @param contactPoint the location to apply the force on the imposter
  61999. */
  62000. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62001. /**
  62002. * Creates a physics body using the plugin
  62003. * @param impostor the imposter to create the physics body on
  62004. */
  62005. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62006. /**
  62007. * Removes the physics body from the imposter and disposes of the body's memory
  62008. * @param impostor imposter to remove the physics body from
  62009. */
  62010. removePhysicsBody(impostor: PhysicsImpostor): void;
  62011. /**
  62012. * Generates a joint
  62013. * @param impostorJoint the imposter joint to create the joint with
  62014. */
  62015. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62016. /**
  62017. * Removes a joint
  62018. * @param impostorJoint the imposter joint to remove the joint from
  62019. */
  62020. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62021. private _addMeshVerts;
  62022. /**
  62023. * Initialise the soft body vertices to match its object's (mesh) vertices
  62024. * Softbody vertices (nodes) are in world space and to match this
  62025. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62026. * @param impostor to create the softbody for
  62027. */
  62028. private _softVertexData;
  62029. /**
  62030. * Create an impostor's soft body
  62031. * @param impostor to create the softbody for
  62032. */
  62033. private _createSoftbody;
  62034. /**
  62035. * Create cloth for an impostor
  62036. * @param impostor to create the softbody for
  62037. */
  62038. private _createCloth;
  62039. /**
  62040. * Create rope for an impostor
  62041. * @param impostor to create the softbody for
  62042. */
  62043. private _createRope;
  62044. /**
  62045. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62046. * @param impostor to create the custom physics shape for
  62047. */
  62048. private _createCustom;
  62049. private _addHullVerts;
  62050. private _createShape;
  62051. /**
  62052. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62053. * @param impostor imposter containing the physics body and babylon object
  62054. */
  62055. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62056. /**
  62057. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62058. * @param impostor imposter containing the physics body and babylon object
  62059. * @param newPosition new position
  62060. * @param newRotation new rotation
  62061. */
  62062. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62063. /**
  62064. * If this plugin is supported
  62065. * @returns true if its supported
  62066. */
  62067. isSupported(): boolean;
  62068. /**
  62069. * Sets the linear velocity of the physics body
  62070. * @param impostor imposter to set the velocity on
  62071. * @param velocity velocity to set
  62072. */
  62073. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62074. /**
  62075. * Sets the angular velocity of the physics body
  62076. * @param impostor imposter to set the velocity on
  62077. * @param velocity velocity to set
  62078. */
  62079. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62080. /**
  62081. * gets the linear velocity
  62082. * @param impostor imposter to get linear velocity from
  62083. * @returns linear velocity
  62084. */
  62085. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62086. /**
  62087. * gets the angular velocity
  62088. * @param impostor imposter to get angular velocity from
  62089. * @returns angular velocity
  62090. */
  62091. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62092. /**
  62093. * Sets the mass of physics body
  62094. * @param impostor imposter to set the mass on
  62095. * @param mass mass to set
  62096. */
  62097. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62098. /**
  62099. * Gets the mass of the physics body
  62100. * @param impostor imposter to get the mass from
  62101. * @returns mass
  62102. */
  62103. getBodyMass(impostor: PhysicsImpostor): number;
  62104. /**
  62105. * Gets friction of the impostor
  62106. * @param impostor impostor to get friction from
  62107. * @returns friction value
  62108. */
  62109. getBodyFriction(impostor: PhysicsImpostor): number;
  62110. /**
  62111. * Sets friction of the impostor
  62112. * @param impostor impostor to set friction on
  62113. * @param friction friction value
  62114. */
  62115. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62116. /**
  62117. * Gets restitution of the impostor
  62118. * @param impostor impostor to get restitution from
  62119. * @returns restitution value
  62120. */
  62121. getBodyRestitution(impostor: PhysicsImpostor): number;
  62122. /**
  62123. * Sets resitution of the impostor
  62124. * @param impostor impostor to set resitution on
  62125. * @param restitution resitution value
  62126. */
  62127. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62128. /**
  62129. * Gets pressure inside the impostor
  62130. * @param impostor impostor to get pressure from
  62131. * @returns pressure value
  62132. */
  62133. getBodyPressure(impostor: PhysicsImpostor): number;
  62134. /**
  62135. * Sets pressure inside a soft body impostor
  62136. * Cloth and rope must remain 0 pressure
  62137. * @param impostor impostor to set pressure on
  62138. * @param pressure pressure value
  62139. */
  62140. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62141. /**
  62142. * Gets stiffness of the impostor
  62143. * @param impostor impostor to get stiffness from
  62144. * @returns pressure value
  62145. */
  62146. getBodyStiffness(impostor: PhysicsImpostor): number;
  62147. /**
  62148. * Sets stiffness of the impostor
  62149. * @param impostor impostor to set stiffness on
  62150. * @param stiffness stiffness value from 0 to 1
  62151. */
  62152. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62153. /**
  62154. * Gets velocityIterations of the impostor
  62155. * @param impostor impostor to get velocity iterations from
  62156. * @returns velocityIterations value
  62157. */
  62158. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62159. /**
  62160. * Sets velocityIterations of the impostor
  62161. * @param impostor impostor to set velocity iterations on
  62162. * @param velocityIterations velocityIterations value
  62163. */
  62164. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62165. /**
  62166. * Gets positionIterations of the impostor
  62167. * @param impostor impostor to get position iterations from
  62168. * @returns positionIterations value
  62169. */
  62170. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62171. /**
  62172. * Sets positionIterations of the impostor
  62173. * @param impostor impostor to set position on
  62174. * @param positionIterations positionIterations value
  62175. */
  62176. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62177. /**
  62178. * Append an anchor to a cloth object
  62179. * @param impostor is the cloth impostor to add anchor to
  62180. * @param otherImpostor is the rigid impostor to anchor to
  62181. * @param width ratio across width from 0 to 1
  62182. * @param height ratio up height from 0 to 1
  62183. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62184. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62185. */
  62186. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62187. /**
  62188. * Append an hook to a rope object
  62189. * @param impostor is the rope impostor to add hook to
  62190. * @param otherImpostor is the rigid impostor to hook to
  62191. * @param length ratio along the rope from 0 to 1
  62192. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62193. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62194. */
  62195. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62196. /**
  62197. * Sleeps the physics body and stops it from being active
  62198. * @param impostor impostor to sleep
  62199. */
  62200. sleepBody(impostor: PhysicsImpostor): void;
  62201. /**
  62202. * Activates the physics body
  62203. * @param impostor impostor to activate
  62204. */
  62205. wakeUpBody(impostor: PhysicsImpostor): void;
  62206. /**
  62207. * Updates the distance parameters of the joint
  62208. * @param joint joint to update
  62209. * @param maxDistance maximum distance of the joint
  62210. * @param minDistance minimum distance of the joint
  62211. */
  62212. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62213. /**
  62214. * Sets a motor on the joint
  62215. * @param joint joint to set motor on
  62216. * @param speed speed of the motor
  62217. * @param maxForce maximum force of the motor
  62218. * @param motorIndex index of the motor
  62219. */
  62220. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62221. /**
  62222. * Sets the motors limit
  62223. * @param joint joint to set limit on
  62224. * @param upperLimit upper limit
  62225. * @param lowerLimit lower limit
  62226. */
  62227. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62228. /**
  62229. * Syncs the position and rotation of a mesh with the impostor
  62230. * @param mesh mesh to sync
  62231. * @param impostor impostor to update the mesh with
  62232. */
  62233. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62234. /**
  62235. * Gets the radius of the impostor
  62236. * @param impostor impostor to get radius from
  62237. * @returns the radius
  62238. */
  62239. getRadius(impostor: PhysicsImpostor): number;
  62240. /**
  62241. * Gets the box size of the impostor
  62242. * @param impostor impostor to get box size from
  62243. * @param result the resulting box size
  62244. */
  62245. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62246. /**
  62247. * Disposes of the impostor
  62248. */
  62249. dispose(): void;
  62250. /**
  62251. * Does a raycast in the physics world
  62252. * @param from when should the ray start?
  62253. * @param to when should the ray end?
  62254. * @returns PhysicsRaycastResult
  62255. */
  62256. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62257. }
  62258. }
  62259. declare module BABYLON {
  62260. interface AbstractScene {
  62261. /**
  62262. * The list of reflection probes added to the scene
  62263. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62264. */
  62265. reflectionProbes: Array<ReflectionProbe>;
  62266. /**
  62267. * Removes the given reflection probe from this scene.
  62268. * @param toRemove The reflection probe to remove
  62269. * @returns The index of the removed reflection probe
  62270. */
  62271. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62272. /**
  62273. * Adds the given reflection probe to this scene.
  62274. * @param newReflectionProbe The reflection probe to add
  62275. */
  62276. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62277. }
  62278. /**
  62279. * Class used to generate realtime reflection / refraction cube textures
  62280. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62281. */
  62282. export class ReflectionProbe {
  62283. /** defines the name of the probe */
  62284. name: string;
  62285. private _scene;
  62286. private _renderTargetTexture;
  62287. private _projectionMatrix;
  62288. private _viewMatrix;
  62289. private _target;
  62290. private _add;
  62291. private _attachedMesh;
  62292. private _invertYAxis;
  62293. /** Gets or sets probe position (center of the cube map) */
  62294. position: Vector3;
  62295. /**
  62296. * Creates a new reflection probe
  62297. * @param name defines the name of the probe
  62298. * @param size defines the texture resolution (for each face)
  62299. * @param scene defines the hosting scene
  62300. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62301. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62302. */
  62303. constructor(
  62304. /** defines the name of the probe */
  62305. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62306. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62307. get samples(): number;
  62308. set samples(value: number);
  62309. /** Gets or sets the refresh rate to use (on every frame by default) */
  62310. get refreshRate(): number;
  62311. set refreshRate(value: number);
  62312. /**
  62313. * Gets the hosting scene
  62314. * @returns a Scene
  62315. */
  62316. getScene(): Scene;
  62317. /** Gets the internal CubeTexture used to render to */
  62318. get cubeTexture(): RenderTargetTexture;
  62319. /** Gets the list of meshes to render */
  62320. get renderList(): Nullable<AbstractMesh[]>;
  62321. /**
  62322. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62323. * @param mesh defines the mesh to attach to
  62324. */
  62325. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62326. /**
  62327. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62328. * @param renderingGroupId The rendering group id corresponding to its index
  62329. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62330. */
  62331. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62332. /**
  62333. * Clean all associated resources
  62334. */
  62335. dispose(): void;
  62336. /**
  62337. * Converts the reflection probe information to a readable string for debug purpose.
  62338. * @param fullDetails Supports for multiple levels of logging within scene loading
  62339. * @returns the human readable reflection probe info
  62340. */
  62341. toString(fullDetails?: boolean): string;
  62342. /**
  62343. * Get the class name of the relfection probe.
  62344. * @returns "ReflectionProbe"
  62345. */
  62346. getClassName(): string;
  62347. /**
  62348. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62349. * @returns The JSON representation of the texture
  62350. */
  62351. serialize(): any;
  62352. /**
  62353. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62354. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62355. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62356. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62357. * @returns The parsed reflection probe if successful
  62358. */
  62359. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62360. }
  62361. }
  62362. declare module BABYLON {
  62363. /** @hidden */
  62364. export var _BabylonLoaderRegistered: boolean;
  62365. /**
  62366. * Helps setting up some configuration for the babylon file loader.
  62367. */
  62368. export class BabylonFileLoaderConfiguration {
  62369. /**
  62370. * The loader does not allow injecting custom physix engine into the plugins.
  62371. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62372. * So you could set this variable to your engine import to make it work.
  62373. */
  62374. static LoaderInjectedPhysicsEngine: any;
  62375. }
  62376. }
  62377. declare module BABYLON {
  62378. /**
  62379. * The Physically based simple base material of BJS.
  62380. *
  62381. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62382. * It is used as the base class for both the specGloss and metalRough conventions.
  62383. */
  62384. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62385. /**
  62386. * Number of Simultaneous lights allowed on the material.
  62387. */
  62388. maxSimultaneousLights: number;
  62389. /**
  62390. * If sets to true, disables all the lights affecting the material.
  62391. */
  62392. disableLighting: boolean;
  62393. /**
  62394. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62395. */
  62396. environmentTexture: BaseTexture;
  62397. /**
  62398. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62399. */
  62400. invertNormalMapX: boolean;
  62401. /**
  62402. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62403. */
  62404. invertNormalMapY: boolean;
  62405. /**
  62406. * Normal map used in the model.
  62407. */
  62408. normalTexture: BaseTexture;
  62409. /**
  62410. * Emissivie color used to self-illuminate the model.
  62411. */
  62412. emissiveColor: Color3;
  62413. /**
  62414. * Emissivie texture used to self-illuminate the model.
  62415. */
  62416. emissiveTexture: BaseTexture;
  62417. /**
  62418. * Occlusion Channel Strenght.
  62419. */
  62420. occlusionStrength: number;
  62421. /**
  62422. * Occlusion Texture of the material (adding extra occlusion effects).
  62423. */
  62424. occlusionTexture: BaseTexture;
  62425. /**
  62426. * Defines the alpha limits in alpha test mode.
  62427. */
  62428. alphaCutOff: number;
  62429. /**
  62430. * Gets the current double sided mode.
  62431. */
  62432. get doubleSided(): boolean;
  62433. /**
  62434. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62435. */
  62436. set doubleSided(value: boolean);
  62437. /**
  62438. * Stores the pre-calculated light information of a mesh in a texture.
  62439. */
  62440. lightmapTexture: BaseTexture;
  62441. /**
  62442. * If true, the light map contains occlusion information instead of lighting info.
  62443. */
  62444. useLightmapAsShadowmap: boolean;
  62445. /**
  62446. * Instantiates a new PBRMaterial instance.
  62447. *
  62448. * @param name The material name
  62449. * @param scene The scene the material will be use in.
  62450. */
  62451. constructor(name: string, scene: Scene);
  62452. getClassName(): string;
  62453. }
  62454. }
  62455. declare module BABYLON {
  62456. /**
  62457. * The PBR material of BJS following the metal roughness convention.
  62458. *
  62459. * This fits to the PBR convention in the GLTF definition:
  62460. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62461. */
  62462. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62463. /**
  62464. * The base color has two different interpretations depending on the value of metalness.
  62465. * When the material is a metal, the base color is the specific measured reflectance value
  62466. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62467. * of the material.
  62468. */
  62469. baseColor: Color3;
  62470. /**
  62471. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62472. * well as opacity information in the alpha channel.
  62473. */
  62474. baseTexture: BaseTexture;
  62475. /**
  62476. * Specifies the metallic scalar value of the material.
  62477. * Can also be used to scale the metalness values of the metallic texture.
  62478. */
  62479. metallic: number;
  62480. /**
  62481. * Specifies the roughness scalar value of the material.
  62482. * Can also be used to scale the roughness values of the metallic texture.
  62483. */
  62484. roughness: number;
  62485. /**
  62486. * Texture containing both the metallic value in the B channel and the
  62487. * roughness value in the G channel to keep better precision.
  62488. */
  62489. metallicRoughnessTexture: BaseTexture;
  62490. /**
  62491. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62492. *
  62493. * @param name The material name
  62494. * @param scene The scene the material will be use in.
  62495. */
  62496. constructor(name: string, scene: Scene);
  62497. /**
  62498. * Return the currrent class name of the material.
  62499. */
  62500. getClassName(): string;
  62501. /**
  62502. * Makes a duplicate of the current material.
  62503. * @param name - name to use for the new material.
  62504. */
  62505. clone(name: string): PBRMetallicRoughnessMaterial;
  62506. /**
  62507. * Serialize the material to a parsable JSON object.
  62508. */
  62509. serialize(): any;
  62510. /**
  62511. * Parses a JSON object correponding to the serialize function.
  62512. */
  62513. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62514. }
  62515. }
  62516. declare module BABYLON {
  62517. /**
  62518. * The PBR material of BJS following the specular glossiness convention.
  62519. *
  62520. * This fits to the PBR convention in the GLTF definition:
  62521. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62522. */
  62523. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62524. /**
  62525. * Specifies the diffuse color of the material.
  62526. */
  62527. diffuseColor: Color3;
  62528. /**
  62529. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62530. * channel.
  62531. */
  62532. diffuseTexture: BaseTexture;
  62533. /**
  62534. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62535. */
  62536. specularColor: Color3;
  62537. /**
  62538. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62539. */
  62540. glossiness: number;
  62541. /**
  62542. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62543. */
  62544. specularGlossinessTexture: BaseTexture;
  62545. /**
  62546. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62547. *
  62548. * @param name The material name
  62549. * @param scene The scene the material will be use in.
  62550. */
  62551. constructor(name: string, scene: Scene);
  62552. /**
  62553. * Return the currrent class name of the material.
  62554. */
  62555. getClassName(): string;
  62556. /**
  62557. * Makes a duplicate of the current material.
  62558. * @param name - name to use for the new material.
  62559. */
  62560. clone(name: string): PBRSpecularGlossinessMaterial;
  62561. /**
  62562. * Serialize the material to a parsable JSON object.
  62563. */
  62564. serialize(): any;
  62565. /**
  62566. * Parses a JSON object correponding to the serialize function.
  62567. */
  62568. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62569. }
  62570. }
  62571. declare module BABYLON {
  62572. /**
  62573. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62574. * It can help converting any input color in a desired output one. This can then be used to create effects
  62575. * from sepia, black and white to sixties or futuristic rendering...
  62576. *
  62577. * The only supported format is currently 3dl.
  62578. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62579. */
  62580. export class ColorGradingTexture extends BaseTexture {
  62581. /**
  62582. * The texture URL.
  62583. */
  62584. url: string;
  62585. /**
  62586. * Empty line regex stored for GC.
  62587. */
  62588. private static _noneEmptyLineRegex;
  62589. private _textureMatrix;
  62590. private _onLoad;
  62591. /**
  62592. * Instantiates a ColorGradingTexture from the following parameters.
  62593. *
  62594. * @param url The location of the color gradind data (currently only supporting 3dl)
  62595. * @param sceneOrEngine The scene or engine the texture will be used in
  62596. * @param onLoad defines a callback triggered when the texture has been loaded
  62597. */
  62598. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62599. /**
  62600. * Fires the onload event from the constructor if requested.
  62601. */
  62602. private _triggerOnLoad;
  62603. /**
  62604. * Returns the texture matrix used in most of the material.
  62605. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62606. */
  62607. getTextureMatrix(): Matrix;
  62608. /**
  62609. * Occurs when the file being loaded is a .3dl LUT file.
  62610. */
  62611. private load3dlTexture;
  62612. /**
  62613. * Starts the loading process of the texture.
  62614. */
  62615. private loadTexture;
  62616. /**
  62617. * Clones the color gradind texture.
  62618. */
  62619. clone(): ColorGradingTexture;
  62620. /**
  62621. * Called during delayed load for textures.
  62622. */
  62623. delayLoad(): void;
  62624. /**
  62625. * Parses a color grading texture serialized by Babylon.
  62626. * @param parsedTexture The texture information being parsedTexture
  62627. * @param scene The scene to load the texture in
  62628. * @param rootUrl The root url of the data assets to load
  62629. * @return A color gradind texture
  62630. */
  62631. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62632. /**
  62633. * Serializes the LUT texture to json format.
  62634. */
  62635. serialize(): any;
  62636. }
  62637. }
  62638. declare module BABYLON {
  62639. /**
  62640. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62641. */
  62642. export class EquiRectangularCubeTexture extends BaseTexture {
  62643. /** The six faces of the cube. */
  62644. private static _FacesMapping;
  62645. private _noMipmap;
  62646. private _onLoad;
  62647. private _onError;
  62648. /** The size of the cubemap. */
  62649. private _size;
  62650. /** The buffer of the image. */
  62651. private _buffer;
  62652. /** The width of the input image. */
  62653. private _width;
  62654. /** The height of the input image. */
  62655. private _height;
  62656. /** The URL to the image. */
  62657. url: string;
  62658. /**
  62659. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62660. * @param url The location of the image
  62661. * @param scene The scene the texture will be used in
  62662. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62663. * @param noMipmap Forces to not generate the mipmap if true
  62664. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62665. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62666. * @param onLoad — defines a callback called when texture is loaded
  62667. * @param onError — defines a callback called if there is an error
  62668. */
  62669. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62670. /**
  62671. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62672. */
  62673. private loadImage;
  62674. /**
  62675. * Convert the image buffer into a cubemap and create a CubeTexture.
  62676. */
  62677. private loadTexture;
  62678. /**
  62679. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62680. * @param buffer The ArrayBuffer that should be converted.
  62681. * @returns The buffer as Float32Array.
  62682. */
  62683. private getFloat32ArrayFromArrayBuffer;
  62684. /**
  62685. * Get the current class name of the texture useful for serialization or dynamic coding.
  62686. * @returns "EquiRectangularCubeTexture"
  62687. */
  62688. getClassName(): string;
  62689. /**
  62690. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62691. * @returns A clone of the current EquiRectangularCubeTexture.
  62692. */
  62693. clone(): EquiRectangularCubeTexture;
  62694. }
  62695. }
  62696. declare module BABYLON {
  62697. /**
  62698. * Defines the options related to the creation of an HtmlElementTexture
  62699. */
  62700. export interface IHtmlElementTextureOptions {
  62701. /**
  62702. * Defines wether mip maps should be created or not.
  62703. */
  62704. generateMipMaps?: boolean;
  62705. /**
  62706. * Defines the sampling mode of the texture.
  62707. */
  62708. samplingMode?: number;
  62709. /**
  62710. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62711. */
  62712. engine: Nullable<ThinEngine>;
  62713. /**
  62714. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62715. */
  62716. scene: Nullable<Scene>;
  62717. }
  62718. /**
  62719. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62720. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62721. * is automatically managed.
  62722. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62723. * in your application.
  62724. *
  62725. * As the update is not automatic, you need to call them manually.
  62726. */
  62727. export class HtmlElementTexture extends BaseTexture {
  62728. /**
  62729. * The texture URL.
  62730. */
  62731. element: HTMLVideoElement | HTMLCanvasElement;
  62732. private static readonly DefaultOptions;
  62733. private _textureMatrix;
  62734. private _isVideo;
  62735. private _generateMipMaps;
  62736. private _samplingMode;
  62737. /**
  62738. * Instantiates a HtmlElementTexture from the following parameters.
  62739. *
  62740. * @param name Defines the name of the texture
  62741. * @param element Defines the video or canvas the texture is filled with
  62742. * @param options Defines the other none mandatory texture creation options
  62743. */
  62744. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62745. private _createInternalTexture;
  62746. /**
  62747. * Returns the texture matrix used in most of the material.
  62748. */
  62749. getTextureMatrix(): Matrix;
  62750. /**
  62751. * Updates the content of the texture.
  62752. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62753. */
  62754. update(invertY?: Nullable<boolean>): void;
  62755. }
  62756. }
  62757. declare module BABYLON {
  62758. /**
  62759. * Based on jsTGALoader - Javascript loader for TGA file
  62760. * By Vincent Thibault
  62761. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62762. */
  62763. export class TGATools {
  62764. private static _TYPE_INDEXED;
  62765. private static _TYPE_RGB;
  62766. private static _TYPE_GREY;
  62767. private static _TYPE_RLE_INDEXED;
  62768. private static _TYPE_RLE_RGB;
  62769. private static _TYPE_RLE_GREY;
  62770. private static _ORIGIN_MASK;
  62771. private static _ORIGIN_SHIFT;
  62772. private static _ORIGIN_BL;
  62773. private static _ORIGIN_BR;
  62774. private static _ORIGIN_UL;
  62775. private static _ORIGIN_UR;
  62776. /**
  62777. * Gets the header of a TGA file
  62778. * @param data defines the TGA data
  62779. * @returns the header
  62780. */
  62781. static GetTGAHeader(data: Uint8Array): any;
  62782. /**
  62783. * Uploads TGA content to a Babylon Texture
  62784. * @hidden
  62785. */
  62786. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62787. /** @hidden */
  62788. 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;
  62789. /** @hidden */
  62790. 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;
  62791. /** @hidden */
  62792. 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;
  62793. /** @hidden */
  62794. 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;
  62795. /** @hidden */
  62796. 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;
  62797. /** @hidden */
  62798. 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;
  62799. }
  62800. }
  62801. declare module BABYLON {
  62802. /**
  62803. * Implementation of the TGA Texture Loader.
  62804. * @hidden
  62805. */
  62806. export class _TGATextureLoader implements IInternalTextureLoader {
  62807. /**
  62808. * Defines wether the loader supports cascade loading the different faces.
  62809. */
  62810. readonly supportCascades: boolean;
  62811. /**
  62812. * This returns if the loader support the current file information.
  62813. * @param extension defines the file extension of the file being loaded
  62814. * @returns true if the loader can load the specified file
  62815. */
  62816. canLoad(extension: string): boolean;
  62817. /**
  62818. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62819. * @param data contains the texture data
  62820. * @param texture defines the BabylonJS internal texture
  62821. * @param createPolynomials will be true if polynomials have been requested
  62822. * @param onLoad defines the callback to trigger once the texture is ready
  62823. * @param onError defines the callback to trigger in case of error
  62824. */
  62825. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62826. /**
  62827. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62828. * @param data contains the texture data
  62829. * @param texture defines the BabylonJS internal texture
  62830. * @param callback defines the method to call once ready to upload
  62831. */
  62832. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62833. }
  62834. }
  62835. declare module BABYLON {
  62836. /**
  62837. * Info about the .basis files
  62838. */
  62839. class BasisFileInfo {
  62840. /**
  62841. * If the file has alpha
  62842. */
  62843. hasAlpha: boolean;
  62844. /**
  62845. * Info about each image of the basis file
  62846. */
  62847. images: Array<{
  62848. levels: Array<{
  62849. width: number;
  62850. height: number;
  62851. transcodedPixels: ArrayBufferView;
  62852. }>;
  62853. }>;
  62854. }
  62855. /**
  62856. * Result of transcoding a basis file
  62857. */
  62858. class TranscodeResult {
  62859. /**
  62860. * Info about the .basis file
  62861. */
  62862. fileInfo: BasisFileInfo;
  62863. /**
  62864. * Format to use when loading the file
  62865. */
  62866. format: number;
  62867. }
  62868. /**
  62869. * Configuration options for the Basis transcoder
  62870. */
  62871. export class BasisTranscodeConfiguration {
  62872. /**
  62873. * Supported compression formats used to determine the supported output format of the transcoder
  62874. */
  62875. supportedCompressionFormats?: {
  62876. /**
  62877. * etc1 compression format
  62878. */
  62879. etc1?: boolean;
  62880. /**
  62881. * s3tc compression format
  62882. */
  62883. s3tc?: boolean;
  62884. /**
  62885. * pvrtc compression format
  62886. */
  62887. pvrtc?: boolean;
  62888. /**
  62889. * etc2 compression format
  62890. */
  62891. etc2?: boolean;
  62892. };
  62893. /**
  62894. * If mipmap levels should be loaded for transcoded images (Default: true)
  62895. */
  62896. loadMipmapLevels?: boolean;
  62897. /**
  62898. * Index of a single image to load (Default: all images)
  62899. */
  62900. loadSingleImage?: number;
  62901. }
  62902. /**
  62903. * Used to load .Basis files
  62904. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62905. */
  62906. export class BasisTools {
  62907. private static _IgnoreSupportedFormats;
  62908. /**
  62909. * URL to use when loading the basis transcoder
  62910. */
  62911. static JSModuleURL: string;
  62912. /**
  62913. * URL to use when loading the wasm module for the transcoder
  62914. */
  62915. static WasmModuleURL: string;
  62916. /**
  62917. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62918. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62919. * @returns internal format corresponding to the Basis format
  62920. */
  62921. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62922. private static _WorkerPromise;
  62923. private static _Worker;
  62924. private static _actionId;
  62925. private static _CreateWorkerAsync;
  62926. /**
  62927. * Transcodes a loaded image file to compressed pixel data
  62928. * @param data image data to transcode
  62929. * @param config configuration options for the transcoding
  62930. * @returns a promise resulting in the transcoded image
  62931. */
  62932. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62933. /**
  62934. * Loads a texture from the transcode result
  62935. * @param texture texture load to
  62936. * @param transcodeResult the result of transcoding the basis file to load from
  62937. */
  62938. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62939. }
  62940. }
  62941. declare module BABYLON {
  62942. /**
  62943. * Loader for .basis file format
  62944. */
  62945. export class _BasisTextureLoader implements IInternalTextureLoader {
  62946. /**
  62947. * Defines whether the loader supports cascade loading the different faces.
  62948. */
  62949. readonly supportCascades: boolean;
  62950. /**
  62951. * This returns if the loader support the current file information.
  62952. * @param extension defines the file extension of the file being loaded
  62953. * @returns true if the loader can load the specified file
  62954. */
  62955. canLoad(extension: string): boolean;
  62956. /**
  62957. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62958. * @param data contains the texture data
  62959. * @param texture defines the BabylonJS internal texture
  62960. * @param createPolynomials will be true if polynomials have been requested
  62961. * @param onLoad defines the callback to trigger once the texture is ready
  62962. * @param onError defines the callback to trigger in case of error
  62963. */
  62964. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62965. /**
  62966. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62967. * @param data contains the texture data
  62968. * @param texture defines the BabylonJS internal texture
  62969. * @param callback defines the method to call once ready to upload
  62970. */
  62971. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * Defines the basic options interface of a TexturePacker Frame
  62977. */
  62978. export interface ITexturePackerFrame {
  62979. /**
  62980. * The frame ID
  62981. */
  62982. id: number;
  62983. /**
  62984. * The frames Scale
  62985. */
  62986. scale: Vector2;
  62987. /**
  62988. * The Frames offset
  62989. */
  62990. offset: Vector2;
  62991. }
  62992. /**
  62993. * This is a support class for frame Data on texture packer sets.
  62994. */
  62995. export class TexturePackerFrame implements ITexturePackerFrame {
  62996. /**
  62997. * The frame ID
  62998. */
  62999. id: number;
  63000. /**
  63001. * The frames Scale
  63002. */
  63003. scale: Vector2;
  63004. /**
  63005. * The Frames offset
  63006. */
  63007. offset: Vector2;
  63008. /**
  63009. * Initializes a texture package frame.
  63010. * @param id The numerical frame identifier
  63011. * @param scale Scalar Vector2 for UV frame
  63012. * @param offset Vector2 for the frame position in UV units.
  63013. * @returns TexturePackerFrame
  63014. */
  63015. constructor(id: number, scale: Vector2, offset: Vector2);
  63016. }
  63017. }
  63018. declare module BABYLON {
  63019. /**
  63020. * Defines the basic options interface of a TexturePacker
  63021. */
  63022. export interface ITexturePackerOptions {
  63023. /**
  63024. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63025. */
  63026. map?: string[];
  63027. /**
  63028. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63029. */
  63030. uvsIn?: string;
  63031. /**
  63032. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63033. */
  63034. uvsOut?: string;
  63035. /**
  63036. * number representing the layout style. Defaults to LAYOUT_STRIP
  63037. */
  63038. layout?: number;
  63039. /**
  63040. * number of columns if using custom column count layout(2). This defaults to 4.
  63041. */
  63042. colnum?: number;
  63043. /**
  63044. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63045. */
  63046. updateInputMeshes?: boolean;
  63047. /**
  63048. * boolean flag to dispose all the source textures. Defaults to true.
  63049. */
  63050. disposeSources?: boolean;
  63051. /**
  63052. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63053. */
  63054. fillBlanks?: boolean;
  63055. /**
  63056. * string value representing the context fill style color. Defaults to 'black'.
  63057. */
  63058. customFillColor?: string;
  63059. /**
  63060. * Width and Height Value of each Frame in the TexturePacker Sets
  63061. */
  63062. frameSize?: number;
  63063. /**
  63064. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63065. */
  63066. paddingRatio?: number;
  63067. /**
  63068. * Number that declares the fill method for the padding gutter.
  63069. */
  63070. paddingMode?: number;
  63071. /**
  63072. * If in SUBUV_COLOR padding mode what color to use.
  63073. */
  63074. paddingColor?: Color3 | Color4;
  63075. }
  63076. /**
  63077. * Defines the basic interface of a TexturePacker JSON File
  63078. */
  63079. export interface ITexturePackerJSON {
  63080. /**
  63081. * The frame ID
  63082. */
  63083. name: string;
  63084. /**
  63085. * The base64 channel data
  63086. */
  63087. sets: any;
  63088. /**
  63089. * The options of the Packer
  63090. */
  63091. options: ITexturePackerOptions;
  63092. /**
  63093. * The frame data of the Packer
  63094. */
  63095. frames: Array<number>;
  63096. }
  63097. /**
  63098. * This is a support class that generates a series of packed texture sets.
  63099. * @see https://doc.babylonjs.com/babylon101/materials
  63100. */
  63101. export class TexturePacker {
  63102. /** Packer Layout Constant 0 */
  63103. static readonly LAYOUT_STRIP: number;
  63104. /** Packer Layout Constant 1 */
  63105. static readonly LAYOUT_POWER2: number;
  63106. /** Packer Layout Constant 2 */
  63107. static readonly LAYOUT_COLNUM: number;
  63108. /** Packer Layout Constant 0 */
  63109. static readonly SUBUV_WRAP: number;
  63110. /** Packer Layout Constant 1 */
  63111. static readonly SUBUV_EXTEND: number;
  63112. /** Packer Layout Constant 2 */
  63113. static readonly SUBUV_COLOR: number;
  63114. /** The Name of the Texture Package */
  63115. name: string;
  63116. /** The scene scope of the TexturePacker */
  63117. scene: Scene;
  63118. /** The Meshes to target */
  63119. meshes: AbstractMesh[];
  63120. /** Arguments passed with the Constructor */
  63121. options: ITexturePackerOptions;
  63122. /** The promise that is started upon initialization */
  63123. promise: Nullable<Promise<TexturePacker | string>>;
  63124. /** The Container object for the channel sets that are generated */
  63125. sets: object;
  63126. /** The Container array for the frames that are generated */
  63127. frames: TexturePackerFrame[];
  63128. /** The expected number of textures the system is parsing. */
  63129. private _expecting;
  63130. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63131. private _paddingValue;
  63132. /**
  63133. * Initializes a texture package series from an array of meshes or a single mesh.
  63134. * @param name The name of the package
  63135. * @param meshes The target meshes to compose the package from
  63136. * @param options The arguments that texture packer should follow while building.
  63137. * @param scene The scene which the textures are scoped to.
  63138. * @returns TexturePacker
  63139. */
  63140. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63141. /**
  63142. * Starts the package process
  63143. * @param resolve The promises resolution function
  63144. * @returns TexturePacker
  63145. */
  63146. private _createFrames;
  63147. /**
  63148. * Calculates the Size of the Channel Sets
  63149. * @returns Vector2
  63150. */
  63151. private _calculateSize;
  63152. /**
  63153. * Calculates the UV data for the frames.
  63154. * @param baseSize the base frameSize
  63155. * @param padding the base frame padding
  63156. * @param dtSize size of the Dynamic Texture for that channel
  63157. * @param dtUnits is 1/dtSize
  63158. * @param update flag to update the input meshes
  63159. */
  63160. private _calculateMeshUVFrames;
  63161. /**
  63162. * Calculates the frames Offset.
  63163. * @param index of the frame
  63164. * @returns Vector2
  63165. */
  63166. private _getFrameOffset;
  63167. /**
  63168. * Updates a Mesh to the frame data
  63169. * @param mesh that is the target
  63170. * @param frameID or the frame index
  63171. */
  63172. private _updateMeshUV;
  63173. /**
  63174. * Updates a Meshes materials to use the texture packer channels
  63175. * @param m is the mesh to target
  63176. * @param force all channels on the packer to be set.
  63177. */
  63178. private _updateTextureReferences;
  63179. /**
  63180. * Public method to set a Mesh to a frame
  63181. * @param m that is the target
  63182. * @param frameID or the frame index
  63183. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63184. */
  63185. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63186. /**
  63187. * Starts the async promise to compile the texture packer.
  63188. * @returns Promise<void>
  63189. */
  63190. processAsync(): Promise<void>;
  63191. /**
  63192. * Disposes all textures associated with this packer
  63193. */
  63194. dispose(): void;
  63195. /**
  63196. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63197. * @param imageType is the image type to use.
  63198. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63199. */
  63200. download(imageType?: string, quality?: number): void;
  63201. /**
  63202. * Public method to load a texturePacker JSON file.
  63203. * @param data of the JSON file in string format.
  63204. */
  63205. updateFromJSON(data: string): void;
  63206. }
  63207. }
  63208. declare module BABYLON {
  63209. /**
  63210. * 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.
  63211. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63212. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63213. */
  63214. export class CustomProceduralTexture extends ProceduralTexture {
  63215. private _animate;
  63216. private _time;
  63217. private _config;
  63218. private _texturePath;
  63219. /**
  63220. * Instantiates a new Custom Procedural Texture.
  63221. * 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.
  63222. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63223. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63224. * @param name Define the name of the texture
  63225. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63226. * @param size Define the size of the texture to create
  63227. * @param scene Define the scene the texture belongs to
  63228. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63229. * @param generateMipMaps Define if the texture should creates mip maps or not
  63230. */
  63231. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63232. private _loadJson;
  63233. /**
  63234. * Is the texture ready to be used ? (rendered at least once)
  63235. * @returns true if ready, otherwise, false.
  63236. */
  63237. isReady(): boolean;
  63238. /**
  63239. * Render the texture to its associated render target.
  63240. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63241. */
  63242. render(useCameraPostProcess?: boolean): void;
  63243. /**
  63244. * Update the list of dependant textures samplers in the shader.
  63245. */
  63246. updateTextures(): void;
  63247. /**
  63248. * Update the uniform values of the procedural texture in the shader.
  63249. */
  63250. updateShaderUniforms(): void;
  63251. /**
  63252. * Define if the texture animates or not.
  63253. */
  63254. get animate(): boolean;
  63255. set animate(value: boolean);
  63256. }
  63257. }
  63258. declare module BABYLON {
  63259. /** @hidden */
  63260. export var noisePixelShader: {
  63261. name: string;
  63262. shader: string;
  63263. };
  63264. }
  63265. declare module BABYLON {
  63266. /**
  63267. * Class used to generate noise procedural textures
  63268. */
  63269. export class NoiseProceduralTexture extends ProceduralTexture {
  63270. /** Gets or sets the start time (default is 0) */
  63271. time: number;
  63272. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63273. brightness: number;
  63274. /** Defines the number of octaves to process */
  63275. octaves: number;
  63276. /** Defines the level of persistence (0.8 by default) */
  63277. persistence: number;
  63278. /** Gets or sets animation speed factor (default is 1) */
  63279. animationSpeedFactor: number;
  63280. /**
  63281. * Creates a new NoiseProceduralTexture
  63282. * @param name defines the name fo the texture
  63283. * @param size defines the size of the texture (default is 256)
  63284. * @param scene defines the hosting scene
  63285. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63286. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63287. */
  63288. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63289. private _updateShaderUniforms;
  63290. protected _getDefines(): string;
  63291. /** Generate the current state of the procedural texture */
  63292. render(useCameraPostProcess?: boolean): void;
  63293. /**
  63294. * Serializes this noise procedural texture
  63295. * @returns a serialized noise procedural texture object
  63296. */
  63297. serialize(): any;
  63298. /**
  63299. * Clone the texture.
  63300. * @returns the cloned texture
  63301. */
  63302. clone(): NoiseProceduralTexture;
  63303. /**
  63304. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63305. * @param parsedTexture defines parsed texture data
  63306. * @param scene defines the current scene
  63307. * @param rootUrl defines the root URL containing noise procedural texture information
  63308. * @returns a parsed NoiseProceduralTexture
  63309. */
  63310. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63311. }
  63312. }
  63313. declare module BABYLON {
  63314. /**
  63315. * Raw cube texture where the raw buffers are passed in
  63316. */
  63317. export class RawCubeTexture extends CubeTexture {
  63318. /**
  63319. * Creates a cube texture where the raw buffers are passed in.
  63320. * @param scene defines the scene the texture is attached to
  63321. * @param data defines the array of data to use to create each face
  63322. * @param size defines the size of the textures
  63323. * @param format defines the format of the data
  63324. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63325. * @param generateMipMaps defines if the engine should generate the mip levels
  63326. * @param invertY defines if data must be stored with Y axis inverted
  63327. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63328. * @param compression defines the compression used (null by default)
  63329. */
  63330. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63331. /**
  63332. * Updates the raw cube texture.
  63333. * @param data defines the data to store
  63334. * @param format defines the data format
  63335. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63336. * @param invertY defines if data must be stored with Y axis inverted
  63337. * @param compression defines the compression used (null by default)
  63338. * @param level defines which level of the texture to update
  63339. */
  63340. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63341. /**
  63342. * Updates a raw cube texture with RGBD encoded data.
  63343. * @param data defines the array of data [mipmap][face] to use to create each face
  63344. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63345. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63346. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63347. * @returns a promsie that resolves when the operation is complete
  63348. */
  63349. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63350. /**
  63351. * Clones the raw cube texture.
  63352. * @return a new cube texture
  63353. */
  63354. clone(): CubeTexture;
  63355. /** @hidden */
  63356. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * Class used to store 2D array textures containing user data
  63362. */
  63363. export class RawTexture2DArray extends Texture {
  63364. /** Gets or sets the texture format to use */
  63365. format: number;
  63366. /**
  63367. * Create a new RawTexture2DArray
  63368. * @param data defines the data of the texture
  63369. * @param width defines the width of the texture
  63370. * @param height defines the height of the texture
  63371. * @param depth defines the number of layers of the texture
  63372. * @param format defines the texture format to use
  63373. * @param scene defines the hosting scene
  63374. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63375. * @param invertY defines if texture must be stored with Y axis inverted
  63376. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63377. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63378. */
  63379. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63380. /** Gets or sets the texture format to use */
  63381. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63382. /**
  63383. * Update the texture with new data
  63384. * @param data defines the data to store in the texture
  63385. */
  63386. update(data: ArrayBufferView): void;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /**
  63391. * Class used to store 3D textures containing user data
  63392. */
  63393. export class RawTexture3D extends Texture {
  63394. /** Gets or sets the texture format to use */
  63395. format: number;
  63396. /**
  63397. * Create a new RawTexture3D
  63398. * @param data defines the data of the texture
  63399. * @param width defines the width of the texture
  63400. * @param height defines the height of the texture
  63401. * @param depth defines the depth of the texture
  63402. * @param format defines the texture format to use
  63403. * @param scene defines the hosting scene
  63404. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63405. * @param invertY defines if texture must be stored with Y axis inverted
  63406. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63407. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63408. */
  63409. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63410. /** Gets or sets the texture format to use */
  63411. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63412. /**
  63413. * Update the texture with new data
  63414. * @param data defines the data to store in the texture
  63415. */
  63416. update(data: ArrayBufferView): void;
  63417. }
  63418. }
  63419. declare module BABYLON {
  63420. /**
  63421. * Creates a refraction texture used by refraction channel of the standard material.
  63422. * It is like a mirror but to see through a material.
  63423. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63424. */
  63425. export class RefractionTexture extends RenderTargetTexture {
  63426. /**
  63427. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63428. * 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.
  63429. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63430. */
  63431. refractionPlane: Plane;
  63432. /**
  63433. * Define how deep under the surface we should see.
  63434. */
  63435. depth: number;
  63436. /**
  63437. * Creates a refraction texture used by refraction channel of the standard material.
  63438. * It is like a mirror but to see through a material.
  63439. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63440. * @param name Define the texture name
  63441. * @param size Define the size of the underlying texture
  63442. * @param scene Define the scene the refraction belongs to
  63443. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63444. */
  63445. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63446. /**
  63447. * Clone the refraction texture.
  63448. * @returns the cloned texture
  63449. */
  63450. clone(): RefractionTexture;
  63451. /**
  63452. * Serialize the texture to a JSON representation you could use in Parse later on
  63453. * @returns the serialized JSON representation
  63454. */
  63455. serialize(): any;
  63456. }
  63457. }
  63458. declare module BABYLON {
  63459. /**
  63460. * Block used to add support for vertex skinning (bones)
  63461. */
  63462. export class BonesBlock extends NodeMaterialBlock {
  63463. /**
  63464. * Creates a new BonesBlock
  63465. * @param name defines the block name
  63466. */
  63467. constructor(name: string);
  63468. /**
  63469. * Initialize the block and prepare the context for build
  63470. * @param state defines the state that will be used for the build
  63471. */
  63472. initialize(state: NodeMaterialBuildState): void;
  63473. /**
  63474. * Gets the current class name
  63475. * @returns the class name
  63476. */
  63477. getClassName(): string;
  63478. /**
  63479. * Gets the matrix indices input component
  63480. */
  63481. get matricesIndices(): NodeMaterialConnectionPoint;
  63482. /**
  63483. * Gets the matrix weights input component
  63484. */
  63485. get matricesWeights(): NodeMaterialConnectionPoint;
  63486. /**
  63487. * Gets the extra matrix indices input component
  63488. */
  63489. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the extra matrix weights input component
  63492. */
  63493. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the world input component
  63496. */
  63497. get world(): NodeMaterialConnectionPoint;
  63498. /**
  63499. * Gets the output component
  63500. */
  63501. get output(): NodeMaterialConnectionPoint;
  63502. autoConfigure(material: NodeMaterial): void;
  63503. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63506. protected _buildBlock(state: NodeMaterialBuildState): this;
  63507. }
  63508. }
  63509. declare module BABYLON {
  63510. /**
  63511. * Block used to add support for instances
  63512. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63513. */
  63514. export class InstancesBlock extends NodeMaterialBlock {
  63515. /**
  63516. * Creates a new InstancesBlock
  63517. * @param name defines the block name
  63518. */
  63519. constructor(name: string);
  63520. /**
  63521. * Gets the current class name
  63522. * @returns the class name
  63523. */
  63524. getClassName(): string;
  63525. /**
  63526. * Gets the first world row input component
  63527. */
  63528. get world0(): NodeMaterialConnectionPoint;
  63529. /**
  63530. * Gets the second world row input component
  63531. */
  63532. get world1(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the third world row input component
  63535. */
  63536. get world2(): NodeMaterialConnectionPoint;
  63537. /**
  63538. * Gets the forth world row input component
  63539. */
  63540. get world3(): NodeMaterialConnectionPoint;
  63541. /**
  63542. * Gets the world input component
  63543. */
  63544. get world(): NodeMaterialConnectionPoint;
  63545. /**
  63546. * Gets the output component
  63547. */
  63548. get output(): NodeMaterialConnectionPoint;
  63549. /**
  63550. * Gets the isntanceID component
  63551. */
  63552. get instanceID(): NodeMaterialConnectionPoint;
  63553. autoConfigure(material: NodeMaterial): void;
  63554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63555. protected _buildBlock(state: NodeMaterialBuildState): this;
  63556. }
  63557. }
  63558. declare module BABYLON {
  63559. /**
  63560. * Block used to add morph targets support to vertex shader
  63561. */
  63562. export class MorphTargetsBlock extends NodeMaterialBlock {
  63563. private _repeatableContentAnchor;
  63564. /**
  63565. * Create a new MorphTargetsBlock
  63566. * @param name defines the block name
  63567. */
  63568. constructor(name: string);
  63569. /**
  63570. * Gets the current class name
  63571. * @returns the class name
  63572. */
  63573. getClassName(): string;
  63574. /**
  63575. * Gets the position input component
  63576. */
  63577. get position(): NodeMaterialConnectionPoint;
  63578. /**
  63579. * Gets the normal input component
  63580. */
  63581. get normal(): NodeMaterialConnectionPoint;
  63582. /**
  63583. * Gets the tangent input component
  63584. */
  63585. get tangent(): NodeMaterialConnectionPoint;
  63586. /**
  63587. * Gets the tangent input component
  63588. */
  63589. get uv(): NodeMaterialConnectionPoint;
  63590. /**
  63591. * Gets the position output component
  63592. */
  63593. get positionOutput(): NodeMaterialConnectionPoint;
  63594. /**
  63595. * Gets the normal output component
  63596. */
  63597. get normalOutput(): NodeMaterialConnectionPoint;
  63598. /**
  63599. * Gets the tangent output component
  63600. */
  63601. get tangentOutput(): NodeMaterialConnectionPoint;
  63602. /**
  63603. * Gets the tangent output component
  63604. */
  63605. get uvOutput(): NodeMaterialConnectionPoint;
  63606. initialize(state: NodeMaterialBuildState): void;
  63607. autoConfigure(material: NodeMaterial): void;
  63608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63609. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63610. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63611. protected _buildBlock(state: NodeMaterialBuildState): this;
  63612. }
  63613. }
  63614. declare module BABYLON {
  63615. /**
  63616. * Block used to get data information from a light
  63617. */
  63618. export class LightInformationBlock extends NodeMaterialBlock {
  63619. private _lightDataUniformName;
  63620. private _lightColorUniformName;
  63621. private _lightTypeDefineName;
  63622. /**
  63623. * Gets or sets the light associated with this block
  63624. */
  63625. light: Nullable<Light>;
  63626. /**
  63627. * Creates a new LightInformationBlock
  63628. * @param name defines the block name
  63629. */
  63630. constructor(name: string);
  63631. /**
  63632. * Gets the current class name
  63633. * @returns the class name
  63634. */
  63635. getClassName(): string;
  63636. /**
  63637. * Gets the world position input component
  63638. */
  63639. get worldPosition(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Gets the direction output component
  63642. */
  63643. get direction(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the direction output component
  63646. */
  63647. get color(): NodeMaterialConnectionPoint;
  63648. /**
  63649. * Gets the direction output component
  63650. */
  63651. get intensity(): NodeMaterialConnectionPoint;
  63652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63654. protected _buildBlock(state: NodeMaterialBuildState): this;
  63655. serialize(): any;
  63656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63657. }
  63658. }
  63659. declare module BABYLON {
  63660. /**
  63661. * Block used to add image processing support to fragment shader
  63662. */
  63663. export class ImageProcessingBlock extends NodeMaterialBlock {
  63664. /**
  63665. * Create a new ImageProcessingBlock
  63666. * @param name defines the block name
  63667. */
  63668. constructor(name: string);
  63669. /**
  63670. * Gets the current class name
  63671. * @returns the class name
  63672. */
  63673. getClassName(): string;
  63674. /**
  63675. * Gets the color input component
  63676. */
  63677. get color(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the output component
  63680. */
  63681. get output(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Initialize the block and prepare the context for build
  63684. * @param state defines the state that will be used for the build
  63685. */
  63686. initialize(state: NodeMaterialBuildState): void;
  63687. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63689. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63690. protected _buildBlock(state: NodeMaterialBuildState): this;
  63691. }
  63692. }
  63693. declare module BABYLON {
  63694. /**
  63695. * Block used to pertub normals based on a normal map
  63696. */
  63697. export class PerturbNormalBlock extends NodeMaterialBlock {
  63698. private _tangentSpaceParameterName;
  63699. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63700. invertX: boolean;
  63701. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63702. invertY: boolean;
  63703. /**
  63704. * Create a new PerturbNormalBlock
  63705. * @param name defines the block name
  63706. */
  63707. constructor(name: string);
  63708. /**
  63709. * Gets the current class name
  63710. * @returns the class name
  63711. */
  63712. getClassName(): string;
  63713. /**
  63714. * Gets the world position input component
  63715. */
  63716. get worldPosition(): NodeMaterialConnectionPoint;
  63717. /**
  63718. * Gets the world normal input component
  63719. */
  63720. get worldNormal(): NodeMaterialConnectionPoint;
  63721. /**
  63722. * Gets the world tangent input component
  63723. */
  63724. get worldTangent(): NodeMaterialConnectionPoint;
  63725. /**
  63726. * Gets the uv input component
  63727. */
  63728. get uv(): NodeMaterialConnectionPoint;
  63729. /**
  63730. * Gets the normal map color input component
  63731. */
  63732. get normalMapColor(): NodeMaterialConnectionPoint;
  63733. /**
  63734. * Gets the strength input component
  63735. */
  63736. get strength(): NodeMaterialConnectionPoint;
  63737. /**
  63738. * Gets the output component
  63739. */
  63740. get output(): NodeMaterialConnectionPoint;
  63741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63743. autoConfigure(material: NodeMaterial): void;
  63744. protected _buildBlock(state: NodeMaterialBuildState): this;
  63745. protected _dumpPropertiesCode(): string;
  63746. serialize(): any;
  63747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /**
  63752. * Block used to discard a pixel if a value is smaller than a cutoff
  63753. */
  63754. export class DiscardBlock extends NodeMaterialBlock {
  63755. /**
  63756. * Create a new DiscardBlock
  63757. * @param name defines the block name
  63758. */
  63759. constructor(name: string);
  63760. /**
  63761. * Gets the current class name
  63762. * @returns the class name
  63763. */
  63764. getClassName(): string;
  63765. /**
  63766. * Gets the color input component
  63767. */
  63768. get value(): NodeMaterialConnectionPoint;
  63769. /**
  63770. * Gets the cutoff input component
  63771. */
  63772. get cutoff(): NodeMaterialConnectionPoint;
  63773. protected _buildBlock(state: NodeMaterialBuildState): this;
  63774. }
  63775. }
  63776. declare module BABYLON {
  63777. /**
  63778. * Block used to test if the fragment shader is front facing
  63779. */
  63780. export class FrontFacingBlock extends NodeMaterialBlock {
  63781. /**
  63782. * Creates a new FrontFacingBlock
  63783. * @param name defines the block name
  63784. */
  63785. constructor(name: string);
  63786. /**
  63787. * Gets the current class name
  63788. * @returns the class name
  63789. */
  63790. getClassName(): string;
  63791. /**
  63792. * Gets the output component
  63793. */
  63794. get output(): NodeMaterialConnectionPoint;
  63795. protected _buildBlock(state: NodeMaterialBuildState): this;
  63796. }
  63797. }
  63798. declare module BABYLON {
  63799. /**
  63800. * Block used to get the derivative value on x and y of a given input
  63801. */
  63802. export class DerivativeBlock extends NodeMaterialBlock {
  63803. /**
  63804. * Create a new DerivativeBlock
  63805. * @param name defines the block name
  63806. */
  63807. constructor(name: string);
  63808. /**
  63809. * Gets the current class name
  63810. * @returns the class name
  63811. */
  63812. getClassName(): string;
  63813. /**
  63814. * Gets the input component
  63815. */
  63816. get input(): NodeMaterialConnectionPoint;
  63817. /**
  63818. * Gets the derivative output on x
  63819. */
  63820. get dx(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the derivative output on y
  63823. */
  63824. get dy(): NodeMaterialConnectionPoint;
  63825. protected _buildBlock(state: NodeMaterialBuildState): this;
  63826. }
  63827. }
  63828. declare module BABYLON {
  63829. /**
  63830. * Block used to make gl_FragCoord available
  63831. */
  63832. export class FragCoordBlock extends NodeMaterialBlock {
  63833. /**
  63834. * Creates a new FragCoordBlock
  63835. * @param name defines the block name
  63836. */
  63837. constructor(name: string);
  63838. /**
  63839. * Gets the current class name
  63840. * @returns the class name
  63841. */
  63842. getClassName(): string;
  63843. /**
  63844. * Gets the xy component
  63845. */
  63846. get xy(): NodeMaterialConnectionPoint;
  63847. /**
  63848. * Gets the xyz component
  63849. */
  63850. get xyz(): NodeMaterialConnectionPoint;
  63851. /**
  63852. * Gets the xyzw component
  63853. */
  63854. get xyzw(): NodeMaterialConnectionPoint;
  63855. /**
  63856. * Gets the x component
  63857. */
  63858. get x(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the y component
  63861. */
  63862. get y(): NodeMaterialConnectionPoint;
  63863. /**
  63864. * Gets the z component
  63865. */
  63866. get z(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the w component
  63869. */
  63870. get output(): NodeMaterialConnectionPoint;
  63871. protected writeOutputs(state: NodeMaterialBuildState): string;
  63872. protected _buildBlock(state: NodeMaterialBuildState): this;
  63873. }
  63874. }
  63875. declare module BABYLON {
  63876. /**
  63877. * Block used to get the screen sizes
  63878. */
  63879. export class ScreenSizeBlock extends NodeMaterialBlock {
  63880. private _varName;
  63881. private _scene;
  63882. /**
  63883. * Creates a new ScreenSizeBlock
  63884. * @param name defines the block name
  63885. */
  63886. constructor(name: string);
  63887. /**
  63888. * Gets the current class name
  63889. * @returns the class name
  63890. */
  63891. getClassName(): string;
  63892. /**
  63893. * Gets the xy component
  63894. */
  63895. get xy(): NodeMaterialConnectionPoint;
  63896. /**
  63897. * Gets the x component
  63898. */
  63899. get x(): NodeMaterialConnectionPoint;
  63900. /**
  63901. * Gets the y component
  63902. */
  63903. get y(): NodeMaterialConnectionPoint;
  63904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63905. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63906. protected _buildBlock(state: NodeMaterialBuildState): this;
  63907. }
  63908. }
  63909. declare module BABYLON {
  63910. /**
  63911. * Block used to add support for scene fog
  63912. */
  63913. export class FogBlock extends NodeMaterialBlock {
  63914. private _fogDistanceName;
  63915. private _fogParameters;
  63916. /**
  63917. * Create a new FogBlock
  63918. * @param name defines the block name
  63919. */
  63920. constructor(name: string);
  63921. /**
  63922. * Gets the current class name
  63923. * @returns the class name
  63924. */
  63925. getClassName(): string;
  63926. /**
  63927. * Gets the world position input component
  63928. */
  63929. get worldPosition(): NodeMaterialConnectionPoint;
  63930. /**
  63931. * Gets the view input component
  63932. */
  63933. get view(): NodeMaterialConnectionPoint;
  63934. /**
  63935. * Gets the color input component
  63936. */
  63937. get input(): NodeMaterialConnectionPoint;
  63938. /**
  63939. * Gets the fog color input component
  63940. */
  63941. get fogColor(): NodeMaterialConnectionPoint;
  63942. /**
  63943. * Gets the output component
  63944. */
  63945. get output(): NodeMaterialConnectionPoint;
  63946. autoConfigure(material: NodeMaterial): void;
  63947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63949. protected _buildBlock(state: NodeMaterialBuildState): this;
  63950. }
  63951. }
  63952. declare module BABYLON {
  63953. /**
  63954. * Block used to add light in the fragment shader
  63955. */
  63956. export class LightBlock extends NodeMaterialBlock {
  63957. private _lightId;
  63958. /**
  63959. * Gets or sets the light associated with this block
  63960. */
  63961. light: Nullable<Light>;
  63962. /**
  63963. * Create a new LightBlock
  63964. * @param name defines the block name
  63965. */
  63966. constructor(name: string);
  63967. /**
  63968. * Gets the current class name
  63969. * @returns the class name
  63970. */
  63971. getClassName(): string;
  63972. /**
  63973. * Gets the world position input component
  63974. */
  63975. get worldPosition(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the world normal input component
  63978. */
  63979. get worldNormal(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the camera (or eye) position component
  63982. */
  63983. get cameraPosition(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the glossiness component
  63986. */
  63987. get glossiness(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the glossinness power component
  63990. */
  63991. get glossPower(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the diffuse color component
  63994. */
  63995. get diffuseColor(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the specular color component
  63998. */
  63999. get specularColor(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the view matrix component
  64002. */
  64003. get view(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the diffuse output component
  64006. */
  64007. get diffuseOutput(): NodeMaterialConnectionPoint;
  64008. /**
  64009. * Gets the specular output component
  64010. */
  64011. get specularOutput(): NodeMaterialConnectionPoint;
  64012. /**
  64013. * Gets the shadow output component
  64014. */
  64015. get shadow(): NodeMaterialConnectionPoint;
  64016. autoConfigure(material: NodeMaterial): void;
  64017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64018. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64020. private _injectVertexCode;
  64021. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64022. serialize(): any;
  64023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64024. }
  64025. }
  64026. declare module BABYLON {
  64027. /**
  64028. * Block used to read a reflection texture from a sampler
  64029. */
  64030. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64031. /**
  64032. * Create a new ReflectionTextureBlock
  64033. * @param name defines the block name
  64034. */
  64035. constructor(name: string);
  64036. /**
  64037. * Gets the current class name
  64038. * @returns the class name
  64039. */
  64040. getClassName(): string;
  64041. /**
  64042. * Gets the world position input component
  64043. */
  64044. get position(): NodeMaterialConnectionPoint;
  64045. /**
  64046. * Gets the world position input component
  64047. */
  64048. get worldPosition(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the world normal input component
  64051. */
  64052. get worldNormal(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the world input component
  64055. */
  64056. get world(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the camera (or eye) position component
  64059. */
  64060. get cameraPosition(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the view input component
  64063. */
  64064. get view(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the rgb output component
  64067. */
  64068. get rgb(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the rgba output component
  64071. */
  64072. get rgba(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the r output component
  64075. */
  64076. get r(): NodeMaterialConnectionPoint;
  64077. /**
  64078. * Gets the g output component
  64079. */
  64080. get g(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the b output component
  64083. */
  64084. get b(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the a output component
  64087. */
  64088. get a(): NodeMaterialConnectionPoint;
  64089. autoConfigure(material: NodeMaterial): void;
  64090. protected _buildBlock(state: NodeMaterialBuildState): this;
  64091. }
  64092. }
  64093. declare module BABYLON {
  64094. /**
  64095. * Block used to add 2 vectors
  64096. */
  64097. export class AddBlock extends NodeMaterialBlock {
  64098. /**
  64099. * Creates a new AddBlock
  64100. * @param name defines the block name
  64101. */
  64102. constructor(name: string);
  64103. /**
  64104. * Gets the current class name
  64105. * @returns the class name
  64106. */
  64107. getClassName(): string;
  64108. /**
  64109. * Gets the left operand input component
  64110. */
  64111. get left(): NodeMaterialConnectionPoint;
  64112. /**
  64113. * Gets the right operand input component
  64114. */
  64115. get right(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the output component
  64118. */
  64119. get output(): NodeMaterialConnectionPoint;
  64120. protected _buildBlock(state: NodeMaterialBuildState): this;
  64121. }
  64122. }
  64123. declare module BABYLON {
  64124. /**
  64125. * Block used to scale a vector by a float
  64126. */
  64127. export class ScaleBlock extends NodeMaterialBlock {
  64128. /**
  64129. * Creates a new ScaleBlock
  64130. * @param name defines the block name
  64131. */
  64132. constructor(name: string);
  64133. /**
  64134. * Gets the current class name
  64135. * @returns the class name
  64136. */
  64137. getClassName(): string;
  64138. /**
  64139. * Gets the input component
  64140. */
  64141. get input(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the factor input component
  64144. */
  64145. get factor(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the output component
  64148. */
  64149. get output(): NodeMaterialConnectionPoint;
  64150. protected _buildBlock(state: NodeMaterialBuildState): this;
  64151. }
  64152. }
  64153. declare module BABYLON {
  64154. /**
  64155. * Block used to clamp a float
  64156. */
  64157. export class ClampBlock extends NodeMaterialBlock {
  64158. /** Gets or sets the minimum range */
  64159. minimum: number;
  64160. /** Gets or sets the maximum range */
  64161. maximum: number;
  64162. /**
  64163. * Creates a new ClampBlock
  64164. * @param name defines the block name
  64165. */
  64166. constructor(name: string);
  64167. /**
  64168. * Gets the current class name
  64169. * @returns the class name
  64170. */
  64171. getClassName(): string;
  64172. /**
  64173. * Gets the value input component
  64174. */
  64175. get value(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the output component
  64178. */
  64179. get output(): NodeMaterialConnectionPoint;
  64180. protected _buildBlock(state: NodeMaterialBuildState): this;
  64181. protected _dumpPropertiesCode(): string;
  64182. serialize(): any;
  64183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64184. }
  64185. }
  64186. declare module BABYLON {
  64187. /**
  64188. * Block used to apply a cross product between 2 vectors
  64189. */
  64190. export class CrossBlock extends NodeMaterialBlock {
  64191. /**
  64192. * Creates a new CrossBlock
  64193. * @param name defines the block name
  64194. */
  64195. constructor(name: string);
  64196. /**
  64197. * Gets the current class name
  64198. * @returns the class name
  64199. */
  64200. getClassName(): string;
  64201. /**
  64202. * Gets the left operand input component
  64203. */
  64204. get left(): NodeMaterialConnectionPoint;
  64205. /**
  64206. * Gets the right operand input component
  64207. */
  64208. get right(): NodeMaterialConnectionPoint;
  64209. /**
  64210. * Gets the output component
  64211. */
  64212. get output(): NodeMaterialConnectionPoint;
  64213. protected _buildBlock(state: NodeMaterialBuildState): this;
  64214. }
  64215. }
  64216. declare module BABYLON {
  64217. /**
  64218. * Block used to apply a dot product between 2 vectors
  64219. */
  64220. export class DotBlock extends NodeMaterialBlock {
  64221. /**
  64222. * Creates a new DotBlock
  64223. * @param name defines the block name
  64224. */
  64225. constructor(name: string);
  64226. /**
  64227. * Gets the current class name
  64228. * @returns the class name
  64229. */
  64230. getClassName(): string;
  64231. /**
  64232. * Gets the left operand input component
  64233. */
  64234. get left(): NodeMaterialConnectionPoint;
  64235. /**
  64236. * Gets the right operand input component
  64237. */
  64238. get right(): NodeMaterialConnectionPoint;
  64239. /**
  64240. * Gets the output component
  64241. */
  64242. get output(): NodeMaterialConnectionPoint;
  64243. protected _buildBlock(state: NodeMaterialBuildState): this;
  64244. }
  64245. }
  64246. declare module BABYLON {
  64247. /**
  64248. * Block used to normalize a vector
  64249. */
  64250. export class NormalizeBlock extends NodeMaterialBlock {
  64251. /**
  64252. * Creates a new NormalizeBlock
  64253. * @param name defines the block name
  64254. */
  64255. constructor(name: string);
  64256. /**
  64257. * Gets the current class name
  64258. * @returns the class name
  64259. */
  64260. getClassName(): string;
  64261. /**
  64262. * Gets the input component
  64263. */
  64264. get input(): NodeMaterialConnectionPoint;
  64265. /**
  64266. * Gets the output component
  64267. */
  64268. get output(): NodeMaterialConnectionPoint;
  64269. protected _buildBlock(state: NodeMaterialBuildState): this;
  64270. }
  64271. }
  64272. declare module BABYLON {
  64273. /**
  64274. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64275. */
  64276. export class ColorMergerBlock extends NodeMaterialBlock {
  64277. /**
  64278. * Create a new ColorMergerBlock
  64279. * @param name defines the block name
  64280. */
  64281. constructor(name: string);
  64282. /**
  64283. * Gets the current class name
  64284. * @returns the class name
  64285. */
  64286. getClassName(): string;
  64287. /**
  64288. * Gets the rgb component (input)
  64289. */
  64290. get rgbIn(): NodeMaterialConnectionPoint;
  64291. /**
  64292. * Gets the r component (input)
  64293. */
  64294. get r(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the g component (input)
  64297. */
  64298. get g(): NodeMaterialConnectionPoint;
  64299. /**
  64300. * Gets the b component (input)
  64301. */
  64302. get b(): NodeMaterialConnectionPoint;
  64303. /**
  64304. * Gets the a component (input)
  64305. */
  64306. get a(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the rgba component (output)
  64309. */
  64310. get rgba(): NodeMaterialConnectionPoint;
  64311. /**
  64312. * Gets the rgb component (output)
  64313. */
  64314. get rgbOut(): NodeMaterialConnectionPoint;
  64315. /**
  64316. * Gets the rgb component (output)
  64317. * @deprecated Please use rgbOut instead.
  64318. */
  64319. get rgb(): NodeMaterialConnectionPoint;
  64320. protected _buildBlock(state: NodeMaterialBuildState): this;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64326. */
  64327. export class VectorSplitterBlock extends NodeMaterialBlock {
  64328. /**
  64329. * Create a new VectorSplitterBlock
  64330. * @param name defines the block name
  64331. */
  64332. constructor(name: string);
  64333. /**
  64334. * Gets the current class name
  64335. * @returns the class name
  64336. */
  64337. getClassName(): string;
  64338. /**
  64339. * Gets the xyzw component (input)
  64340. */
  64341. get xyzw(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the xyz component (input)
  64344. */
  64345. get xyzIn(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the xy component (input)
  64348. */
  64349. get xyIn(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the xyz component (output)
  64352. */
  64353. get xyzOut(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the xy component (output)
  64356. */
  64357. get xyOut(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the x component (output)
  64360. */
  64361. get x(): NodeMaterialConnectionPoint;
  64362. /**
  64363. * Gets the y component (output)
  64364. */
  64365. get y(): NodeMaterialConnectionPoint;
  64366. /**
  64367. * Gets the z component (output)
  64368. */
  64369. get z(): NodeMaterialConnectionPoint;
  64370. /**
  64371. * Gets the w component (output)
  64372. */
  64373. get w(): NodeMaterialConnectionPoint;
  64374. protected _inputRename(name: string): string;
  64375. protected _outputRename(name: string): string;
  64376. protected _buildBlock(state: NodeMaterialBuildState): this;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * Block used to lerp between 2 values
  64382. */
  64383. export class LerpBlock extends NodeMaterialBlock {
  64384. /**
  64385. * Creates a new LerpBlock
  64386. * @param name defines the block name
  64387. */
  64388. constructor(name: string);
  64389. /**
  64390. * Gets the current class name
  64391. * @returns the class name
  64392. */
  64393. getClassName(): string;
  64394. /**
  64395. * Gets the left operand input component
  64396. */
  64397. get left(): NodeMaterialConnectionPoint;
  64398. /**
  64399. * Gets the right operand input component
  64400. */
  64401. get right(): NodeMaterialConnectionPoint;
  64402. /**
  64403. * Gets the gradient operand input component
  64404. */
  64405. get gradient(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the output component
  64408. */
  64409. get output(): NodeMaterialConnectionPoint;
  64410. protected _buildBlock(state: NodeMaterialBuildState): this;
  64411. }
  64412. }
  64413. declare module BABYLON {
  64414. /**
  64415. * Block used to divide 2 vectors
  64416. */
  64417. export class DivideBlock extends NodeMaterialBlock {
  64418. /**
  64419. * Creates a new DivideBlock
  64420. * @param name defines the block name
  64421. */
  64422. constructor(name: string);
  64423. /**
  64424. * Gets the current class name
  64425. * @returns the class name
  64426. */
  64427. getClassName(): string;
  64428. /**
  64429. * Gets the left operand input component
  64430. */
  64431. get left(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the right operand input component
  64434. */
  64435. get right(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the output component
  64438. */
  64439. get output(): NodeMaterialConnectionPoint;
  64440. protected _buildBlock(state: NodeMaterialBuildState): this;
  64441. }
  64442. }
  64443. declare module BABYLON {
  64444. /**
  64445. * Block used to subtract 2 vectors
  64446. */
  64447. export class SubtractBlock extends NodeMaterialBlock {
  64448. /**
  64449. * Creates a new SubtractBlock
  64450. * @param name defines the block name
  64451. */
  64452. constructor(name: string);
  64453. /**
  64454. * Gets the current class name
  64455. * @returns the class name
  64456. */
  64457. getClassName(): string;
  64458. /**
  64459. * Gets the left operand input component
  64460. */
  64461. get left(): NodeMaterialConnectionPoint;
  64462. /**
  64463. * Gets the right operand input component
  64464. */
  64465. get right(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the output component
  64468. */
  64469. get output(): NodeMaterialConnectionPoint;
  64470. protected _buildBlock(state: NodeMaterialBuildState): this;
  64471. }
  64472. }
  64473. declare module BABYLON {
  64474. /**
  64475. * Block used to step a value
  64476. */
  64477. export class StepBlock extends NodeMaterialBlock {
  64478. /**
  64479. * Creates a new StepBlock
  64480. * @param name defines the block name
  64481. */
  64482. constructor(name: string);
  64483. /**
  64484. * Gets the current class name
  64485. * @returns the class name
  64486. */
  64487. getClassName(): string;
  64488. /**
  64489. * Gets the value operand input component
  64490. */
  64491. get value(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the edge operand input component
  64494. */
  64495. get edge(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the output component
  64498. */
  64499. get output(): NodeMaterialConnectionPoint;
  64500. protected _buildBlock(state: NodeMaterialBuildState): this;
  64501. }
  64502. }
  64503. declare module BABYLON {
  64504. /**
  64505. * Block used to get the opposite (1 - x) of a value
  64506. */
  64507. export class OneMinusBlock extends NodeMaterialBlock {
  64508. /**
  64509. * Creates a new OneMinusBlock
  64510. * @param name defines the block name
  64511. */
  64512. constructor(name: string);
  64513. /**
  64514. * Gets the current class name
  64515. * @returns the class name
  64516. */
  64517. getClassName(): string;
  64518. /**
  64519. * Gets the input component
  64520. */
  64521. get input(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the output component
  64524. */
  64525. get output(): NodeMaterialConnectionPoint;
  64526. protected _buildBlock(state: NodeMaterialBuildState): this;
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /**
  64531. * Block used to get the view direction
  64532. */
  64533. export class ViewDirectionBlock extends NodeMaterialBlock {
  64534. /**
  64535. * Creates a new ViewDirectionBlock
  64536. * @param name defines the block name
  64537. */
  64538. constructor(name: string);
  64539. /**
  64540. * Gets the current class name
  64541. * @returns the class name
  64542. */
  64543. getClassName(): string;
  64544. /**
  64545. * Gets the world position component
  64546. */
  64547. get worldPosition(): NodeMaterialConnectionPoint;
  64548. /**
  64549. * Gets the camera position component
  64550. */
  64551. get cameraPosition(): NodeMaterialConnectionPoint;
  64552. /**
  64553. * Gets the output component
  64554. */
  64555. get output(): NodeMaterialConnectionPoint;
  64556. autoConfigure(material: NodeMaterial): void;
  64557. protected _buildBlock(state: NodeMaterialBuildState): this;
  64558. }
  64559. }
  64560. declare module BABYLON {
  64561. /**
  64562. * Block used to compute fresnel value
  64563. */
  64564. export class FresnelBlock extends NodeMaterialBlock {
  64565. /**
  64566. * Create a new FresnelBlock
  64567. * @param name defines the block name
  64568. */
  64569. constructor(name: string);
  64570. /**
  64571. * Gets the current class name
  64572. * @returns the class name
  64573. */
  64574. getClassName(): string;
  64575. /**
  64576. * Gets the world normal input component
  64577. */
  64578. get worldNormal(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the view direction input component
  64581. */
  64582. get viewDirection(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the bias input component
  64585. */
  64586. get bias(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the camera (or eye) position component
  64589. */
  64590. get power(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the fresnel output component
  64593. */
  64594. get fresnel(): NodeMaterialConnectionPoint;
  64595. autoConfigure(material: NodeMaterial): void;
  64596. protected _buildBlock(state: NodeMaterialBuildState): this;
  64597. }
  64598. }
  64599. declare module BABYLON {
  64600. /**
  64601. * Block used to get the max of 2 values
  64602. */
  64603. export class MaxBlock extends NodeMaterialBlock {
  64604. /**
  64605. * Creates a new MaxBlock
  64606. * @param name defines the block name
  64607. */
  64608. constructor(name: string);
  64609. /**
  64610. * Gets the current class name
  64611. * @returns the class name
  64612. */
  64613. getClassName(): string;
  64614. /**
  64615. * Gets the left operand input component
  64616. */
  64617. get left(): NodeMaterialConnectionPoint;
  64618. /**
  64619. * Gets the right operand input component
  64620. */
  64621. get right(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the output component
  64624. */
  64625. get output(): NodeMaterialConnectionPoint;
  64626. protected _buildBlock(state: NodeMaterialBuildState): this;
  64627. }
  64628. }
  64629. declare module BABYLON {
  64630. /**
  64631. * Block used to get the min of 2 values
  64632. */
  64633. export class MinBlock extends NodeMaterialBlock {
  64634. /**
  64635. * Creates a new MinBlock
  64636. * @param name defines the block name
  64637. */
  64638. constructor(name: string);
  64639. /**
  64640. * Gets the current class name
  64641. * @returns the class name
  64642. */
  64643. getClassName(): string;
  64644. /**
  64645. * Gets the left operand input component
  64646. */
  64647. get left(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the right operand input component
  64650. */
  64651. get right(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the output component
  64654. */
  64655. get output(): NodeMaterialConnectionPoint;
  64656. protected _buildBlock(state: NodeMaterialBuildState): this;
  64657. }
  64658. }
  64659. declare module BABYLON {
  64660. /**
  64661. * Block used to get the distance between 2 values
  64662. */
  64663. export class DistanceBlock extends NodeMaterialBlock {
  64664. /**
  64665. * Creates a new DistanceBlock
  64666. * @param name defines the block name
  64667. */
  64668. constructor(name: string);
  64669. /**
  64670. * Gets the current class name
  64671. * @returns the class name
  64672. */
  64673. getClassName(): string;
  64674. /**
  64675. * Gets the left operand input component
  64676. */
  64677. get left(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the right operand input component
  64680. */
  64681. get right(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the output component
  64684. */
  64685. get output(): NodeMaterialConnectionPoint;
  64686. protected _buildBlock(state: NodeMaterialBuildState): this;
  64687. }
  64688. }
  64689. declare module BABYLON {
  64690. /**
  64691. * Block used to get the length of a vector
  64692. */
  64693. export class LengthBlock extends NodeMaterialBlock {
  64694. /**
  64695. * Creates a new LengthBlock
  64696. * @param name defines the block name
  64697. */
  64698. constructor(name: string);
  64699. /**
  64700. * Gets the current class name
  64701. * @returns the class name
  64702. */
  64703. getClassName(): string;
  64704. /**
  64705. * Gets the value input component
  64706. */
  64707. get value(): NodeMaterialConnectionPoint;
  64708. /**
  64709. * Gets the output component
  64710. */
  64711. get output(): NodeMaterialConnectionPoint;
  64712. protected _buildBlock(state: NodeMaterialBuildState): this;
  64713. }
  64714. }
  64715. declare module BABYLON {
  64716. /**
  64717. * Block used to get negative version of a value (i.e. x * -1)
  64718. */
  64719. export class NegateBlock extends NodeMaterialBlock {
  64720. /**
  64721. * Creates a new NegateBlock
  64722. * @param name defines the block name
  64723. */
  64724. constructor(name: string);
  64725. /**
  64726. * Gets the current class name
  64727. * @returns the class name
  64728. */
  64729. getClassName(): string;
  64730. /**
  64731. * Gets the value input component
  64732. */
  64733. get value(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the output component
  64736. */
  64737. get output(): NodeMaterialConnectionPoint;
  64738. protected _buildBlock(state: NodeMaterialBuildState): this;
  64739. }
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * Block used to get the value of the first parameter raised to the power of the second
  64744. */
  64745. export class PowBlock extends NodeMaterialBlock {
  64746. /**
  64747. * Creates a new PowBlock
  64748. * @param name defines the block name
  64749. */
  64750. constructor(name: string);
  64751. /**
  64752. * Gets the current class name
  64753. * @returns the class name
  64754. */
  64755. getClassName(): string;
  64756. /**
  64757. * Gets the value operand input component
  64758. */
  64759. get value(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the power operand input component
  64762. */
  64763. get power(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the output component
  64766. */
  64767. get output(): NodeMaterialConnectionPoint;
  64768. protected _buildBlock(state: NodeMaterialBuildState): this;
  64769. }
  64770. }
  64771. declare module BABYLON {
  64772. /**
  64773. * Block used to get a random number
  64774. */
  64775. export class RandomNumberBlock extends NodeMaterialBlock {
  64776. /**
  64777. * Creates a new RandomNumberBlock
  64778. * @param name defines the block name
  64779. */
  64780. constructor(name: string);
  64781. /**
  64782. * Gets the current class name
  64783. * @returns the class name
  64784. */
  64785. getClassName(): string;
  64786. /**
  64787. * Gets the seed input component
  64788. */
  64789. get seed(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the output component
  64792. */
  64793. get output(): NodeMaterialConnectionPoint;
  64794. protected _buildBlock(state: NodeMaterialBuildState): this;
  64795. }
  64796. }
  64797. declare module BABYLON {
  64798. /**
  64799. * Block used to compute arc tangent of 2 values
  64800. */
  64801. export class ArcTan2Block extends NodeMaterialBlock {
  64802. /**
  64803. * Creates a new ArcTan2Block
  64804. * @param name defines the block name
  64805. */
  64806. constructor(name: string);
  64807. /**
  64808. * Gets the current class name
  64809. * @returns the class name
  64810. */
  64811. getClassName(): string;
  64812. /**
  64813. * Gets the x operand input component
  64814. */
  64815. get x(): NodeMaterialConnectionPoint;
  64816. /**
  64817. * Gets the y operand input component
  64818. */
  64819. get y(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the output component
  64822. */
  64823. get output(): NodeMaterialConnectionPoint;
  64824. protected _buildBlock(state: NodeMaterialBuildState): this;
  64825. }
  64826. }
  64827. declare module BABYLON {
  64828. /**
  64829. * Block used to smooth step a value
  64830. */
  64831. export class SmoothStepBlock extends NodeMaterialBlock {
  64832. /**
  64833. * Creates a new SmoothStepBlock
  64834. * @param name defines the block name
  64835. */
  64836. constructor(name: string);
  64837. /**
  64838. * Gets the current class name
  64839. * @returns the class name
  64840. */
  64841. getClassName(): string;
  64842. /**
  64843. * Gets the value operand input component
  64844. */
  64845. get value(): NodeMaterialConnectionPoint;
  64846. /**
  64847. * Gets the first edge operand input component
  64848. */
  64849. get edge0(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the second edge operand input component
  64852. */
  64853. get edge1(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the output component
  64856. */
  64857. get output(): NodeMaterialConnectionPoint;
  64858. protected _buildBlock(state: NodeMaterialBuildState): this;
  64859. }
  64860. }
  64861. declare module BABYLON {
  64862. /**
  64863. * Block used to get the reciprocal (1 / x) of a value
  64864. */
  64865. export class ReciprocalBlock extends NodeMaterialBlock {
  64866. /**
  64867. * Creates a new ReciprocalBlock
  64868. * @param name defines the block name
  64869. */
  64870. constructor(name: string);
  64871. /**
  64872. * Gets the current class name
  64873. * @returns the class name
  64874. */
  64875. getClassName(): string;
  64876. /**
  64877. * Gets the input component
  64878. */
  64879. get input(): NodeMaterialConnectionPoint;
  64880. /**
  64881. * Gets the output component
  64882. */
  64883. get output(): NodeMaterialConnectionPoint;
  64884. protected _buildBlock(state: NodeMaterialBuildState): this;
  64885. }
  64886. }
  64887. declare module BABYLON {
  64888. /**
  64889. * Block used to replace a color by another one
  64890. */
  64891. export class ReplaceColorBlock extends NodeMaterialBlock {
  64892. /**
  64893. * Creates a new ReplaceColorBlock
  64894. * @param name defines the block name
  64895. */
  64896. constructor(name: string);
  64897. /**
  64898. * Gets the current class name
  64899. * @returns the class name
  64900. */
  64901. getClassName(): string;
  64902. /**
  64903. * Gets the value input component
  64904. */
  64905. get value(): NodeMaterialConnectionPoint;
  64906. /**
  64907. * Gets the reference input component
  64908. */
  64909. get reference(): NodeMaterialConnectionPoint;
  64910. /**
  64911. * Gets the distance input component
  64912. */
  64913. get distance(): NodeMaterialConnectionPoint;
  64914. /**
  64915. * Gets the replacement input component
  64916. */
  64917. get replacement(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the output component
  64920. */
  64921. get output(): NodeMaterialConnectionPoint;
  64922. protected _buildBlock(state: NodeMaterialBuildState): this;
  64923. }
  64924. }
  64925. declare module BABYLON {
  64926. /**
  64927. * Block used to posterize a value
  64928. * @see https://en.wikipedia.org/wiki/Posterization
  64929. */
  64930. export class PosterizeBlock extends NodeMaterialBlock {
  64931. /**
  64932. * Creates a new PosterizeBlock
  64933. * @param name defines the block name
  64934. */
  64935. constructor(name: string);
  64936. /**
  64937. * Gets the current class name
  64938. * @returns the class name
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * Gets the value input component
  64943. */
  64944. get value(): NodeMaterialConnectionPoint;
  64945. /**
  64946. * Gets the steps input component
  64947. */
  64948. get steps(): NodeMaterialConnectionPoint;
  64949. /**
  64950. * Gets the output component
  64951. */
  64952. get output(): NodeMaterialConnectionPoint;
  64953. protected _buildBlock(state: NodeMaterialBuildState): this;
  64954. }
  64955. }
  64956. declare module BABYLON {
  64957. /**
  64958. * Operations supported by the Wave block
  64959. */
  64960. export enum WaveBlockKind {
  64961. /** SawTooth */
  64962. SawTooth = 0,
  64963. /** Square */
  64964. Square = 1,
  64965. /** Triangle */
  64966. Triangle = 2
  64967. }
  64968. /**
  64969. * Block used to apply wave operation to floats
  64970. */
  64971. export class WaveBlock extends NodeMaterialBlock {
  64972. /**
  64973. * Gets or sets the kibnd of wave to be applied by the block
  64974. */
  64975. kind: WaveBlockKind;
  64976. /**
  64977. * Creates a new WaveBlock
  64978. * @param name defines the block name
  64979. */
  64980. constructor(name: string);
  64981. /**
  64982. * Gets the current class name
  64983. * @returns the class name
  64984. */
  64985. getClassName(): string;
  64986. /**
  64987. * Gets the input component
  64988. */
  64989. get input(): NodeMaterialConnectionPoint;
  64990. /**
  64991. * Gets the output component
  64992. */
  64993. get output(): NodeMaterialConnectionPoint;
  64994. protected _buildBlock(state: NodeMaterialBuildState): this;
  64995. serialize(): any;
  64996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64997. }
  64998. }
  64999. declare module BABYLON {
  65000. /**
  65001. * Class used to store a color step for the GradientBlock
  65002. */
  65003. export class GradientBlockColorStep {
  65004. private _step;
  65005. /**
  65006. * Gets value indicating which step this color is associated with (between 0 and 1)
  65007. */
  65008. get step(): number;
  65009. /**
  65010. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65011. */
  65012. set step(val: number);
  65013. private _color;
  65014. /**
  65015. * Gets the color associated with this step
  65016. */
  65017. get color(): Color3;
  65018. /**
  65019. * Sets the color associated with this step
  65020. */
  65021. set color(val: Color3);
  65022. /**
  65023. * Creates a new GradientBlockColorStep
  65024. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65025. * @param color defines the color associated with this step
  65026. */
  65027. constructor(step: number, color: Color3);
  65028. }
  65029. /**
  65030. * Block used to return a color from a gradient based on an input value between 0 and 1
  65031. */
  65032. export class GradientBlock extends NodeMaterialBlock {
  65033. /**
  65034. * Gets or sets the list of color steps
  65035. */
  65036. colorSteps: GradientBlockColorStep[];
  65037. /** Gets an observable raised when the value is changed */
  65038. onValueChangedObservable: Observable<GradientBlock>;
  65039. /** calls observable when the value is changed*/
  65040. colorStepsUpdated(): void;
  65041. /**
  65042. * Creates a new GradientBlock
  65043. * @param name defines the block name
  65044. */
  65045. constructor(name: string);
  65046. /**
  65047. * Gets the current class name
  65048. * @returns the class name
  65049. */
  65050. getClassName(): string;
  65051. /**
  65052. * Gets the gradient input component
  65053. */
  65054. get gradient(): NodeMaterialConnectionPoint;
  65055. /**
  65056. * Gets the output component
  65057. */
  65058. get output(): NodeMaterialConnectionPoint;
  65059. private _writeColorConstant;
  65060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65061. serialize(): any;
  65062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65063. protected _dumpPropertiesCode(): string;
  65064. }
  65065. }
  65066. declare module BABYLON {
  65067. /**
  65068. * Block used to normalize lerp between 2 values
  65069. */
  65070. export class NLerpBlock extends NodeMaterialBlock {
  65071. /**
  65072. * Creates a new NLerpBlock
  65073. * @param name defines the block name
  65074. */
  65075. constructor(name: string);
  65076. /**
  65077. * Gets the current class name
  65078. * @returns the class name
  65079. */
  65080. getClassName(): string;
  65081. /**
  65082. * Gets the left operand input component
  65083. */
  65084. get left(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the right operand input component
  65087. */
  65088. get right(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the gradient operand input component
  65091. */
  65092. get gradient(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the output component
  65095. */
  65096. get output(): NodeMaterialConnectionPoint;
  65097. protected _buildBlock(state: NodeMaterialBuildState): this;
  65098. }
  65099. }
  65100. declare module BABYLON {
  65101. /**
  65102. * block used to Generate a Worley Noise 3D Noise Pattern
  65103. */
  65104. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65105. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65106. manhattanDistance: boolean;
  65107. /**
  65108. * Creates a new WorleyNoise3DBlock
  65109. * @param name defines the block name
  65110. */
  65111. constructor(name: string);
  65112. /**
  65113. * Gets the current class name
  65114. * @returns the class name
  65115. */
  65116. getClassName(): string;
  65117. /**
  65118. * Gets the seed input component
  65119. */
  65120. get seed(): NodeMaterialConnectionPoint;
  65121. /**
  65122. * Gets the jitter input component
  65123. */
  65124. get jitter(): NodeMaterialConnectionPoint;
  65125. /**
  65126. * Gets the output component
  65127. */
  65128. get output(): NodeMaterialConnectionPoint;
  65129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65130. /**
  65131. * Exposes the properties to the UI?
  65132. */
  65133. protected _dumpPropertiesCode(): string;
  65134. /**
  65135. * Exposes the properties to the Seralize?
  65136. */
  65137. serialize(): any;
  65138. /**
  65139. * Exposes the properties to the deseralize?
  65140. */
  65141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65142. }
  65143. }
  65144. declare module BABYLON {
  65145. /**
  65146. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65147. */
  65148. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65149. /**
  65150. * Creates a new SimplexPerlin3DBlock
  65151. * @param name defines the block name
  65152. */
  65153. constructor(name: string);
  65154. /**
  65155. * Gets the current class name
  65156. * @returns the class name
  65157. */
  65158. getClassName(): string;
  65159. /**
  65160. * Gets the seed operand input component
  65161. */
  65162. get seed(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the output component
  65165. */
  65166. get output(): NodeMaterialConnectionPoint;
  65167. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65168. }
  65169. }
  65170. declare module BABYLON {
  65171. /**
  65172. * Block used to blend normals
  65173. */
  65174. export class NormalBlendBlock extends NodeMaterialBlock {
  65175. /**
  65176. * Creates a new NormalBlendBlock
  65177. * @param name defines the block name
  65178. */
  65179. constructor(name: string);
  65180. /**
  65181. * Gets the current class name
  65182. * @returns the class name
  65183. */
  65184. getClassName(): string;
  65185. /**
  65186. * Gets the first input component
  65187. */
  65188. get normalMap0(): NodeMaterialConnectionPoint;
  65189. /**
  65190. * Gets the second input component
  65191. */
  65192. get normalMap1(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the output component
  65195. */
  65196. get output(): NodeMaterialConnectionPoint;
  65197. protected _buildBlock(state: NodeMaterialBuildState): this;
  65198. }
  65199. }
  65200. declare module BABYLON {
  65201. /**
  65202. * Block used to rotate a 2d vector by a given angle
  65203. */
  65204. export class Rotate2dBlock extends NodeMaterialBlock {
  65205. /**
  65206. * Creates a new Rotate2dBlock
  65207. * @param name defines the block name
  65208. */
  65209. constructor(name: string);
  65210. /**
  65211. * Gets the current class name
  65212. * @returns the class name
  65213. */
  65214. getClassName(): string;
  65215. /**
  65216. * Gets the input vector
  65217. */
  65218. get input(): NodeMaterialConnectionPoint;
  65219. /**
  65220. * Gets the input angle
  65221. */
  65222. get angle(): NodeMaterialConnectionPoint;
  65223. /**
  65224. * Gets the output component
  65225. */
  65226. get output(): NodeMaterialConnectionPoint;
  65227. autoConfigure(material: NodeMaterial): void;
  65228. protected _buildBlock(state: NodeMaterialBuildState): this;
  65229. }
  65230. }
  65231. declare module BABYLON {
  65232. /**
  65233. * Block used to get the reflected vector from a direction and a normal
  65234. */
  65235. export class ReflectBlock extends NodeMaterialBlock {
  65236. /**
  65237. * Creates a new ReflectBlock
  65238. * @param name defines the block name
  65239. */
  65240. constructor(name: string);
  65241. /**
  65242. * Gets the current class name
  65243. * @returns the class name
  65244. */
  65245. getClassName(): string;
  65246. /**
  65247. * Gets the incident component
  65248. */
  65249. get incident(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the normal component
  65252. */
  65253. get normal(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the output component
  65256. */
  65257. get output(): NodeMaterialConnectionPoint;
  65258. protected _buildBlock(state: NodeMaterialBuildState): this;
  65259. }
  65260. }
  65261. declare module BABYLON {
  65262. /**
  65263. * Block used to get the refracted vector from a direction and a normal
  65264. */
  65265. export class RefractBlock extends NodeMaterialBlock {
  65266. /**
  65267. * Creates a new RefractBlock
  65268. * @param name defines the block name
  65269. */
  65270. constructor(name: string);
  65271. /**
  65272. * Gets the current class name
  65273. * @returns the class name
  65274. */
  65275. getClassName(): string;
  65276. /**
  65277. * Gets the incident component
  65278. */
  65279. get incident(): NodeMaterialConnectionPoint;
  65280. /**
  65281. * Gets the normal component
  65282. */
  65283. get normal(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the index of refraction component
  65286. */
  65287. get ior(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the output component
  65290. */
  65291. get output(): NodeMaterialConnectionPoint;
  65292. protected _buildBlock(state: NodeMaterialBuildState): this;
  65293. }
  65294. }
  65295. declare module BABYLON {
  65296. /**
  65297. * Block used to desaturate a color
  65298. */
  65299. export class DesaturateBlock extends NodeMaterialBlock {
  65300. /**
  65301. * Creates a new DesaturateBlock
  65302. * @param name defines the block name
  65303. */
  65304. constructor(name: string);
  65305. /**
  65306. * Gets the current class name
  65307. * @returns the class name
  65308. */
  65309. getClassName(): string;
  65310. /**
  65311. * Gets the color operand input component
  65312. */
  65313. get color(): NodeMaterialConnectionPoint;
  65314. /**
  65315. * Gets the level operand input component
  65316. */
  65317. get level(): NodeMaterialConnectionPoint;
  65318. /**
  65319. * Gets the output component
  65320. */
  65321. get output(): NodeMaterialConnectionPoint;
  65322. protected _buildBlock(state: NodeMaterialBuildState): this;
  65323. }
  65324. }
  65325. declare module BABYLON {
  65326. /**
  65327. * Block used to implement the ambient occlusion module of the PBR material
  65328. */
  65329. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65330. /**
  65331. * Create a new AmbientOcclusionBlock
  65332. * @param name defines the block name
  65333. */
  65334. constructor(name: string);
  65335. /**
  65336. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65337. */
  65338. useAmbientInGrayScale: boolean;
  65339. /**
  65340. * Initialize the block and prepare the context for build
  65341. * @param state defines the state that will be used for the build
  65342. */
  65343. initialize(state: NodeMaterialBuildState): void;
  65344. /**
  65345. * Gets the current class name
  65346. * @returns the class name
  65347. */
  65348. getClassName(): string;
  65349. /**
  65350. * Gets the texture input component
  65351. */
  65352. get texture(): NodeMaterialConnectionPoint;
  65353. /**
  65354. * Gets the texture intensity component
  65355. */
  65356. get intensity(): NodeMaterialConnectionPoint;
  65357. /**
  65358. * Gets the direct light intensity input component
  65359. */
  65360. get directLightIntensity(): NodeMaterialConnectionPoint;
  65361. /**
  65362. * Gets the ambient occlusion object output component
  65363. */
  65364. get ambientOcc(): NodeMaterialConnectionPoint;
  65365. /**
  65366. * Gets the main code of the block (fragment side)
  65367. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65368. * @returns the shader code
  65369. */
  65370. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65372. protected _buildBlock(state: NodeMaterialBuildState): this;
  65373. protected _dumpPropertiesCode(): string;
  65374. serialize(): any;
  65375. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65376. }
  65377. }
  65378. declare module BABYLON {
  65379. /**
  65380. * Block used to implement the reflection module of the PBR material
  65381. */
  65382. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65383. /** @hidden */
  65384. _defineLODReflectionAlpha: string;
  65385. /** @hidden */
  65386. _defineLinearSpecularReflection: string;
  65387. private _vEnvironmentIrradianceName;
  65388. /** @hidden */
  65389. _vReflectionMicrosurfaceInfosName: string;
  65390. /** @hidden */
  65391. _vReflectionInfosName: string;
  65392. /** @hidden */
  65393. _vReflectionFilteringInfoName: string;
  65394. private _scene;
  65395. /**
  65396. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65397. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65398. * It's less burden on the user side in the editor part.
  65399. */
  65400. /** @hidden */
  65401. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65402. /** @hidden */
  65403. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65404. /** @hidden */
  65405. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65406. /**
  65407. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65408. * diffuse part of the IBL.
  65409. */
  65410. useSphericalHarmonics: boolean;
  65411. /**
  65412. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65413. */
  65414. forceIrradianceInFragment: boolean;
  65415. /**
  65416. * Create a new ReflectionBlock
  65417. * @param name defines the block name
  65418. */
  65419. constructor(name: string);
  65420. /**
  65421. * Gets the current class name
  65422. * @returns the class name
  65423. */
  65424. getClassName(): string;
  65425. /**
  65426. * Gets the position input component
  65427. */
  65428. get position(): NodeMaterialConnectionPoint;
  65429. /**
  65430. * Gets the world position input component
  65431. */
  65432. get worldPosition(): NodeMaterialConnectionPoint;
  65433. /**
  65434. * Gets the world normal input component
  65435. */
  65436. get worldNormal(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the world input component
  65439. */
  65440. get world(): NodeMaterialConnectionPoint;
  65441. /**
  65442. * Gets the camera (or eye) position component
  65443. */
  65444. get cameraPosition(): NodeMaterialConnectionPoint;
  65445. /**
  65446. * Gets the view input component
  65447. */
  65448. get view(): NodeMaterialConnectionPoint;
  65449. /**
  65450. * Gets the color input component
  65451. */
  65452. get color(): NodeMaterialConnectionPoint;
  65453. /**
  65454. * Gets the reflection object output component
  65455. */
  65456. get reflection(): NodeMaterialConnectionPoint;
  65457. /**
  65458. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65459. */
  65460. get hasTexture(): boolean;
  65461. /**
  65462. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65463. */
  65464. get reflectionColor(): string;
  65465. protected _getTexture(): Nullable<BaseTexture>;
  65466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65467. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65468. /**
  65469. * Gets the code to inject in the vertex shader
  65470. * @param state current state of the node material building
  65471. * @returns the shader code
  65472. */
  65473. handleVertexSide(state: NodeMaterialBuildState): string;
  65474. /**
  65475. * Gets the main code of the block (fragment side)
  65476. * @param state current state of the node material building
  65477. * @param normalVarName name of the existing variable corresponding to the normal
  65478. * @returns the shader code
  65479. */
  65480. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65481. protected _buildBlock(state: NodeMaterialBuildState): this;
  65482. protected _dumpPropertiesCode(): string;
  65483. serialize(): any;
  65484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. /**
  65489. * Block used to implement the sheen module of the PBR material
  65490. */
  65491. export class SheenBlock extends NodeMaterialBlock {
  65492. /**
  65493. * Create a new SheenBlock
  65494. * @param name defines the block name
  65495. */
  65496. constructor(name: string);
  65497. /**
  65498. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65499. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65500. * making it easier to setup and tweak the effect
  65501. */
  65502. albedoScaling: boolean;
  65503. /**
  65504. * Defines if the sheen is linked to the sheen color.
  65505. */
  65506. linkSheenWithAlbedo: boolean;
  65507. /**
  65508. * Initialize the block and prepare the context for build
  65509. * @param state defines the state that will be used for the build
  65510. */
  65511. initialize(state: NodeMaterialBuildState): void;
  65512. /**
  65513. * Gets the current class name
  65514. * @returns the class name
  65515. */
  65516. getClassName(): string;
  65517. /**
  65518. * Gets the intensity input component
  65519. */
  65520. get intensity(): NodeMaterialConnectionPoint;
  65521. /**
  65522. * Gets the color input component
  65523. */
  65524. get color(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the roughness input component
  65527. */
  65528. get roughness(): NodeMaterialConnectionPoint;
  65529. /**
  65530. * Gets the sheen object output component
  65531. */
  65532. get sheen(): NodeMaterialConnectionPoint;
  65533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65534. /**
  65535. * Gets the main code of the block (fragment side)
  65536. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65537. * @returns the shader code
  65538. */
  65539. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65540. protected _buildBlock(state: NodeMaterialBuildState): this;
  65541. protected _dumpPropertiesCode(): string;
  65542. serialize(): any;
  65543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65544. }
  65545. }
  65546. declare module BABYLON {
  65547. /**
  65548. * Block used to implement the reflectivity module of the PBR material
  65549. */
  65550. export class ReflectivityBlock extends NodeMaterialBlock {
  65551. private _metallicReflectanceColor;
  65552. private _metallicF0Factor;
  65553. /** @hidden */
  65554. _vMetallicReflectanceFactorsName: string;
  65555. /**
  65556. * The property below is set by the main PBR block prior to calling methods of this class.
  65557. */
  65558. /** @hidden */
  65559. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65560. /**
  65561. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65562. */
  65563. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65564. /**
  65565. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65566. */
  65567. useMetallnessFromMetallicTextureBlue: boolean;
  65568. /**
  65569. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65570. */
  65571. useRoughnessFromMetallicTextureAlpha: boolean;
  65572. /**
  65573. * Specifies if the metallic texture contains the roughness information in its green channel.
  65574. */
  65575. useRoughnessFromMetallicTextureGreen: boolean;
  65576. /**
  65577. * Create a new ReflectivityBlock
  65578. * @param name defines the block name
  65579. */
  65580. constructor(name: string);
  65581. /**
  65582. * Initialize the block and prepare the context for build
  65583. * @param state defines the state that will be used for the build
  65584. */
  65585. initialize(state: NodeMaterialBuildState): void;
  65586. /**
  65587. * Gets the current class name
  65588. * @returns the class name
  65589. */
  65590. getClassName(): string;
  65591. /**
  65592. * Gets the metallic input component
  65593. */
  65594. get metallic(): NodeMaterialConnectionPoint;
  65595. /**
  65596. * Gets the roughness input component
  65597. */
  65598. get roughness(): NodeMaterialConnectionPoint;
  65599. /**
  65600. * Gets the texture input component
  65601. */
  65602. get texture(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the reflectivity object output component
  65605. */
  65606. get reflectivity(): NodeMaterialConnectionPoint;
  65607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65608. /**
  65609. * Gets the main code of the block (fragment side)
  65610. * @param state current state of the node material building
  65611. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65612. * @returns the shader code
  65613. */
  65614. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65616. protected _buildBlock(state: NodeMaterialBuildState): this;
  65617. protected _dumpPropertiesCode(): string;
  65618. serialize(): any;
  65619. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65620. }
  65621. }
  65622. declare module BABYLON {
  65623. /**
  65624. * Block used to implement the anisotropy module of the PBR material
  65625. */
  65626. export class AnisotropyBlock extends NodeMaterialBlock {
  65627. /**
  65628. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65629. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65630. * It's less burden on the user side in the editor part.
  65631. */
  65632. /** @hidden */
  65633. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65634. /** @hidden */
  65635. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65636. /**
  65637. * Create a new AnisotropyBlock
  65638. * @param name defines the block name
  65639. */
  65640. constructor(name: string);
  65641. /**
  65642. * Initialize the block and prepare the context for build
  65643. * @param state defines the state that will be used for the build
  65644. */
  65645. initialize(state: NodeMaterialBuildState): void;
  65646. /**
  65647. * Gets the current class name
  65648. * @returns the class name
  65649. */
  65650. getClassName(): string;
  65651. /**
  65652. * Gets the intensity input component
  65653. */
  65654. get intensity(): NodeMaterialConnectionPoint;
  65655. /**
  65656. * Gets the direction input component
  65657. */
  65658. get direction(): NodeMaterialConnectionPoint;
  65659. /**
  65660. * Gets the texture input component
  65661. */
  65662. get texture(): NodeMaterialConnectionPoint;
  65663. /**
  65664. * Gets the uv input component
  65665. */
  65666. get uv(): NodeMaterialConnectionPoint;
  65667. /**
  65668. * Gets the worldTangent input component
  65669. */
  65670. get worldTangent(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the anisotropy object output component
  65673. */
  65674. get anisotropy(): NodeMaterialConnectionPoint;
  65675. private _generateTBNSpace;
  65676. /**
  65677. * Gets the main code of the block (fragment side)
  65678. * @param state current state of the node material building
  65679. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65680. * @returns the shader code
  65681. */
  65682. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65684. protected _buildBlock(state: NodeMaterialBuildState): this;
  65685. }
  65686. }
  65687. declare module BABYLON {
  65688. /**
  65689. * Block used to implement the clear coat module of the PBR material
  65690. */
  65691. export class ClearCoatBlock extends NodeMaterialBlock {
  65692. private _scene;
  65693. /**
  65694. * Create a new ClearCoatBlock
  65695. * @param name defines the block name
  65696. */
  65697. constructor(name: string);
  65698. /**
  65699. * Initialize the block and prepare the context for build
  65700. * @param state defines the state that will be used for the build
  65701. */
  65702. initialize(state: NodeMaterialBuildState): void;
  65703. /**
  65704. * Gets the current class name
  65705. * @returns the class name
  65706. */
  65707. getClassName(): string;
  65708. /**
  65709. * Gets the intensity input component
  65710. */
  65711. get intensity(): NodeMaterialConnectionPoint;
  65712. /**
  65713. * Gets the roughness input component
  65714. */
  65715. get roughness(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the ior input component
  65718. */
  65719. get ior(): NodeMaterialConnectionPoint;
  65720. /**
  65721. * Gets the texture input component
  65722. */
  65723. get texture(): NodeMaterialConnectionPoint;
  65724. /**
  65725. * Gets the bump texture input component
  65726. */
  65727. get bumpTexture(): NodeMaterialConnectionPoint;
  65728. /**
  65729. * Gets the uv input component
  65730. */
  65731. get uv(): NodeMaterialConnectionPoint;
  65732. /**
  65733. * Gets the tint color input component
  65734. */
  65735. get tintColor(): NodeMaterialConnectionPoint;
  65736. /**
  65737. * Gets the tint "at distance" input component
  65738. */
  65739. get tintAtDistance(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Gets the tint thickness input component
  65742. */
  65743. get tintThickness(): NodeMaterialConnectionPoint;
  65744. /**
  65745. * Gets the world tangent input component
  65746. */
  65747. get worldTangent(): NodeMaterialConnectionPoint;
  65748. /**
  65749. * Gets the clear coat object output component
  65750. */
  65751. get clearcoat(): NodeMaterialConnectionPoint;
  65752. autoConfigure(material: NodeMaterial): void;
  65753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65755. private _generateTBNSpace;
  65756. /**
  65757. * Gets the main code of the block (fragment side)
  65758. * @param state current state of the node material building
  65759. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65760. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65761. * @param worldPosVarName name of the variable holding the world position
  65762. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65763. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65764. * @param worldNormalVarName name of the variable holding the world normal
  65765. * @returns the shader code
  65766. */
  65767. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65768. protected _buildBlock(state: NodeMaterialBuildState): this;
  65769. }
  65770. }
  65771. declare module BABYLON {
  65772. /**
  65773. * Block used to implement the sub surface module of the PBR material
  65774. */
  65775. export class SubSurfaceBlock extends NodeMaterialBlock {
  65776. /**
  65777. * Create a new SubSurfaceBlock
  65778. * @param name defines the block name
  65779. */
  65780. constructor(name: string);
  65781. /**
  65782. * Stores the intensity of the different subsurface effects in the thickness texture.
  65783. * * the green channel is the translucency intensity.
  65784. * * the blue channel is the scattering intensity.
  65785. * * the alpha channel is the refraction intensity.
  65786. */
  65787. useMaskFromThicknessTexture: boolean;
  65788. /**
  65789. * Initialize the block and prepare the context for build
  65790. * @param state defines the state that will be used for the build
  65791. */
  65792. initialize(state: NodeMaterialBuildState): void;
  65793. /**
  65794. * Gets the current class name
  65795. * @returns the class name
  65796. */
  65797. getClassName(): string;
  65798. /**
  65799. * Gets the min thickness input component
  65800. */
  65801. get minThickness(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the max thickness input component
  65804. */
  65805. get maxThickness(): NodeMaterialConnectionPoint;
  65806. /**
  65807. * Gets the thickness texture component
  65808. */
  65809. get thicknessTexture(): NodeMaterialConnectionPoint;
  65810. /**
  65811. * Gets the tint color input component
  65812. */
  65813. get tintColor(): NodeMaterialConnectionPoint;
  65814. /**
  65815. * Gets the translucency intensity input component
  65816. */
  65817. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65818. /**
  65819. * Gets the translucency diffusion distance input component
  65820. */
  65821. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65822. /**
  65823. * Gets the refraction object parameters
  65824. */
  65825. get refraction(): NodeMaterialConnectionPoint;
  65826. /**
  65827. * Gets the sub surface object output component
  65828. */
  65829. get subsurface(): NodeMaterialConnectionPoint;
  65830. autoConfigure(material: NodeMaterial): void;
  65831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65832. /**
  65833. * Gets the main code of the block (fragment side)
  65834. * @param state current state of the node material building
  65835. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65836. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65837. * @param worldPosVarName name of the variable holding the world position
  65838. * @returns the shader code
  65839. */
  65840. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65841. protected _buildBlock(state: NodeMaterialBuildState): this;
  65842. }
  65843. }
  65844. declare module BABYLON {
  65845. /**
  65846. * Block used to implement the PBR metallic/roughness model
  65847. */
  65848. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65849. /**
  65850. * Gets or sets the light associated with this block
  65851. */
  65852. light: Nullable<Light>;
  65853. private _lightId;
  65854. private _scene;
  65855. private _environmentBRDFTexture;
  65856. private _environmentBrdfSamplerName;
  65857. private _vNormalWName;
  65858. private _invertNormalName;
  65859. /**
  65860. * Create a new ReflectionBlock
  65861. * @param name defines the block name
  65862. */
  65863. constructor(name: string);
  65864. /**
  65865. * Intensity of the direct lights e.g. the four lights available in your scene.
  65866. * This impacts both the direct diffuse and specular highlights.
  65867. */
  65868. directIntensity: number;
  65869. /**
  65870. * Intensity of the environment e.g. how much the environment will light the object
  65871. * either through harmonics for rough material or through the refelction for shiny ones.
  65872. */
  65873. environmentIntensity: number;
  65874. /**
  65875. * This is a special control allowing the reduction of the specular highlights coming from the
  65876. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65877. */
  65878. specularIntensity: number;
  65879. /**
  65880. * Defines the falloff type used in this material.
  65881. * It by default is Physical.
  65882. */
  65883. lightFalloff: number;
  65884. /**
  65885. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65886. */
  65887. useAlphaFromAlbedoTexture: boolean;
  65888. /**
  65889. * Specifies that alpha test should be used
  65890. */
  65891. useAlphaTest: boolean;
  65892. /**
  65893. * Defines the alpha limits in alpha test mode.
  65894. */
  65895. alphaTestCutoff: number;
  65896. /**
  65897. * Specifies that alpha blending should be used
  65898. */
  65899. useAlphaBlending: boolean;
  65900. /**
  65901. * Defines if the alpha value should be determined via the rgb values.
  65902. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65903. */
  65904. opacityRGB: boolean;
  65905. /**
  65906. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65907. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65908. */
  65909. useRadianceOverAlpha: boolean;
  65910. /**
  65911. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65912. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65913. */
  65914. useSpecularOverAlpha: boolean;
  65915. /**
  65916. * Enables specular anti aliasing in the PBR shader.
  65917. * It will both interacts on the Geometry for analytical and IBL lighting.
  65918. * It also prefilter the roughness map based on the bump values.
  65919. */
  65920. enableSpecularAntiAliasing: boolean;
  65921. /**
  65922. * Enables realtime filtering on the texture.
  65923. */
  65924. realTimeFiltering: boolean;
  65925. /**
  65926. * Quality switch for realtime filtering
  65927. */
  65928. realTimeFilteringQuality: number;
  65929. /**
  65930. * Defines if the material uses energy conservation.
  65931. */
  65932. useEnergyConservation: boolean;
  65933. /**
  65934. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65935. * too much the area relying on ambient texture to define their ambient occlusion.
  65936. */
  65937. useRadianceOcclusion: boolean;
  65938. /**
  65939. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65940. * makes the reflect vector face the model (under horizon).
  65941. */
  65942. useHorizonOcclusion: boolean;
  65943. /**
  65944. * If set to true, no lighting calculations will be applied.
  65945. */
  65946. unlit: boolean;
  65947. /**
  65948. * Force normal to face away from face.
  65949. */
  65950. forceNormalForward: boolean;
  65951. /**
  65952. * Defines the material debug mode.
  65953. * It helps seeing only some components of the material while troubleshooting.
  65954. */
  65955. debugMode: number;
  65956. /**
  65957. * Specify from where on screen the debug mode should start.
  65958. * The value goes from -1 (full screen) to 1 (not visible)
  65959. * It helps with side by side comparison against the final render
  65960. * This defaults to 0
  65961. */
  65962. debugLimit: number;
  65963. /**
  65964. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65965. * You can use the factor to better multiply the final value.
  65966. */
  65967. debugFactor: number;
  65968. /**
  65969. * Initialize the block and prepare the context for build
  65970. * @param state defines the state that will be used for the build
  65971. */
  65972. initialize(state: NodeMaterialBuildState): void;
  65973. /**
  65974. * Gets the current class name
  65975. * @returns the class name
  65976. */
  65977. getClassName(): string;
  65978. /**
  65979. * Gets the world position input component
  65980. */
  65981. get worldPosition(): NodeMaterialConnectionPoint;
  65982. /**
  65983. * Gets the world normal input component
  65984. */
  65985. get worldNormal(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the perturbed normal input component
  65988. */
  65989. get perturbedNormal(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the camera position input component
  65992. */
  65993. get cameraPosition(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the base color input component
  65996. */
  65997. get baseColor(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the opacity texture input component
  66000. */
  66001. get opacityTexture(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the ambient color input component
  66004. */
  66005. get ambientColor(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the reflectivity object parameters
  66008. */
  66009. get reflectivity(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the ambient occlusion object parameters
  66012. */
  66013. get ambientOcc(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the reflection object parameters
  66016. */
  66017. get reflection(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the sheen object parameters
  66020. */
  66021. get sheen(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the clear coat object parameters
  66024. */
  66025. get clearcoat(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the sub surface object parameters
  66028. */
  66029. get subsurface(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the anisotropy object parameters
  66032. */
  66033. get anisotropy(): NodeMaterialConnectionPoint;
  66034. /**
  66035. * Gets the view matrix parameter
  66036. */
  66037. get view(): NodeMaterialConnectionPoint;
  66038. /**
  66039. * Gets the ambient output component
  66040. */
  66041. get ambient(): NodeMaterialConnectionPoint;
  66042. /**
  66043. * Gets the diffuse output component
  66044. */
  66045. get diffuse(): NodeMaterialConnectionPoint;
  66046. /**
  66047. * Gets the specular output component
  66048. */
  66049. get specular(): NodeMaterialConnectionPoint;
  66050. /**
  66051. * Gets the sheen output component
  66052. */
  66053. get sheenDir(): NodeMaterialConnectionPoint;
  66054. /**
  66055. * Gets the clear coat output component
  66056. */
  66057. get clearcoatDir(): NodeMaterialConnectionPoint;
  66058. /**
  66059. * Gets the indirect diffuse output component
  66060. */
  66061. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66062. /**
  66063. * Gets the indirect specular output component
  66064. */
  66065. get specularIndirect(): NodeMaterialConnectionPoint;
  66066. /**
  66067. * Gets the indirect sheen output component
  66068. */
  66069. get sheenIndirect(): NodeMaterialConnectionPoint;
  66070. /**
  66071. * Gets the indirect clear coat output component
  66072. */
  66073. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66074. /**
  66075. * Gets the refraction output component
  66076. */
  66077. get refraction(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the global lighting output component
  66080. */
  66081. get lighting(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the shadow output component
  66084. */
  66085. get shadow(): NodeMaterialConnectionPoint;
  66086. /**
  66087. * Gets the alpha output component
  66088. */
  66089. get alpha(): NodeMaterialConnectionPoint;
  66090. autoConfigure(material: NodeMaterial): void;
  66091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66092. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66094. private _injectVertexCode;
  66095. /**
  66096. * Gets the code corresponding to the albedo/opacity module
  66097. * @returns the shader code
  66098. */
  66099. getAlbedoOpacityCode(): string;
  66100. protected _buildBlock(state: NodeMaterialBuildState): this;
  66101. protected _dumpPropertiesCode(): string;
  66102. serialize(): any;
  66103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66104. }
  66105. }
  66106. declare module BABYLON {
  66107. /**
  66108. * Block used to compute value of one parameter modulo another
  66109. */
  66110. export class ModBlock extends NodeMaterialBlock {
  66111. /**
  66112. * Creates a new ModBlock
  66113. * @param name defines the block name
  66114. */
  66115. constructor(name: string);
  66116. /**
  66117. * Gets the current class name
  66118. * @returns the class name
  66119. */
  66120. getClassName(): string;
  66121. /**
  66122. * Gets the left operand input component
  66123. */
  66124. get left(): NodeMaterialConnectionPoint;
  66125. /**
  66126. * Gets the right operand input component
  66127. */
  66128. get right(): NodeMaterialConnectionPoint;
  66129. /**
  66130. * Gets the output component
  66131. */
  66132. get output(): NodeMaterialConnectionPoint;
  66133. protected _buildBlock(state: NodeMaterialBuildState): this;
  66134. }
  66135. }
  66136. declare module BABYLON {
  66137. /**
  66138. * Configuration for Draco compression
  66139. */
  66140. export interface IDracoCompressionConfiguration {
  66141. /**
  66142. * Configuration for the decoder.
  66143. */
  66144. decoder: {
  66145. /**
  66146. * The url to the WebAssembly module.
  66147. */
  66148. wasmUrl?: string;
  66149. /**
  66150. * The url to the WebAssembly binary.
  66151. */
  66152. wasmBinaryUrl?: string;
  66153. /**
  66154. * The url to the fallback JavaScript module.
  66155. */
  66156. fallbackUrl?: string;
  66157. };
  66158. }
  66159. /**
  66160. * Draco compression (https://google.github.io/draco/)
  66161. *
  66162. * This class wraps the Draco module.
  66163. *
  66164. * **Encoder**
  66165. *
  66166. * The encoder is not currently implemented.
  66167. *
  66168. * **Decoder**
  66169. *
  66170. * 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.
  66171. *
  66172. * To update the configuration, use the following code:
  66173. * ```javascript
  66174. * DracoCompression.Configuration = {
  66175. * decoder: {
  66176. * wasmUrl: "<url to the WebAssembly library>",
  66177. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66178. * fallbackUrl: "<url to the fallback JavaScript library>",
  66179. * }
  66180. * };
  66181. * ```
  66182. *
  66183. * 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.
  66184. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66185. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66186. *
  66187. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66188. * ```javascript
  66189. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66190. * ```
  66191. *
  66192. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66193. */
  66194. export class DracoCompression implements IDisposable {
  66195. private _workerPoolPromise?;
  66196. private _decoderModulePromise?;
  66197. /**
  66198. * The configuration. Defaults to the following urls:
  66199. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66200. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66201. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66202. */
  66203. static Configuration: IDracoCompressionConfiguration;
  66204. /**
  66205. * Returns true if the decoder configuration is available.
  66206. */
  66207. static get DecoderAvailable(): boolean;
  66208. /**
  66209. * Default number of workers to create when creating the draco compression object.
  66210. */
  66211. static DefaultNumWorkers: number;
  66212. private static GetDefaultNumWorkers;
  66213. private static _Default;
  66214. /**
  66215. * Default instance for the draco compression object.
  66216. */
  66217. static get Default(): DracoCompression;
  66218. /**
  66219. * Constructor
  66220. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66221. */
  66222. constructor(numWorkers?: number);
  66223. /**
  66224. * Stop all async operations and release resources.
  66225. */
  66226. dispose(): void;
  66227. /**
  66228. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66229. * @returns a promise that resolves when ready
  66230. */
  66231. whenReadyAsync(): Promise<void>;
  66232. /**
  66233. * Decode Draco compressed mesh data to vertex data.
  66234. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66235. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66236. * @returns A promise that resolves with the decoded vertex data
  66237. */
  66238. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66239. [kind: string]: number;
  66240. }): Promise<VertexData>;
  66241. }
  66242. }
  66243. declare module BABYLON {
  66244. /**
  66245. * Class for building Constructive Solid Geometry
  66246. */
  66247. export class CSG {
  66248. private polygons;
  66249. /**
  66250. * The world matrix
  66251. */
  66252. matrix: Matrix;
  66253. /**
  66254. * Stores the position
  66255. */
  66256. position: Vector3;
  66257. /**
  66258. * Stores the rotation
  66259. */
  66260. rotation: Vector3;
  66261. /**
  66262. * Stores the rotation quaternion
  66263. */
  66264. rotationQuaternion: Nullable<Quaternion>;
  66265. /**
  66266. * Stores the scaling vector
  66267. */
  66268. scaling: Vector3;
  66269. /**
  66270. * Convert the Mesh to CSG
  66271. * @param mesh The Mesh to convert to CSG
  66272. * @returns A new CSG from the Mesh
  66273. */
  66274. static FromMesh(mesh: Mesh): CSG;
  66275. /**
  66276. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66277. * @param polygons Polygons used to construct a CSG solid
  66278. */
  66279. private static FromPolygons;
  66280. /**
  66281. * Clones, or makes a deep copy, of the CSG
  66282. * @returns A new CSG
  66283. */
  66284. clone(): CSG;
  66285. /**
  66286. * Unions this CSG with another CSG
  66287. * @param csg The CSG to union against this CSG
  66288. * @returns The unioned CSG
  66289. */
  66290. union(csg: CSG): CSG;
  66291. /**
  66292. * Unions this CSG with another CSG in place
  66293. * @param csg The CSG to union against this CSG
  66294. */
  66295. unionInPlace(csg: CSG): void;
  66296. /**
  66297. * Subtracts this CSG with another CSG
  66298. * @param csg The CSG to subtract against this CSG
  66299. * @returns A new CSG
  66300. */
  66301. subtract(csg: CSG): CSG;
  66302. /**
  66303. * Subtracts this CSG with another CSG in place
  66304. * @param csg The CSG to subtact against this CSG
  66305. */
  66306. subtractInPlace(csg: CSG): void;
  66307. /**
  66308. * Intersect this CSG with another CSG
  66309. * @param csg The CSG to intersect against this CSG
  66310. * @returns A new CSG
  66311. */
  66312. intersect(csg: CSG): CSG;
  66313. /**
  66314. * Intersects this CSG with another CSG in place
  66315. * @param csg The CSG to intersect against this CSG
  66316. */
  66317. intersectInPlace(csg: CSG): void;
  66318. /**
  66319. * Return a new CSG solid with solid and empty space switched. This solid is
  66320. * not modified.
  66321. * @returns A new CSG solid with solid and empty space switched
  66322. */
  66323. inverse(): CSG;
  66324. /**
  66325. * Inverses the CSG in place
  66326. */
  66327. inverseInPlace(): void;
  66328. /**
  66329. * This is used to keep meshes transformations so they can be restored
  66330. * when we build back a Babylon Mesh
  66331. * NB : All CSG operations are performed in world coordinates
  66332. * @param csg The CSG to copy the transform attributes from
  66333. * @returns This CSG
  66334. */
  66335. copyTransformAttributes(csg: CSG): CSG;
  66336. /**
  66337. * Build Raw mesh from CSG
  66338. * Coordinates here are in world space
  66339. * @param name The name of the mesh geometry
  66340. * @param scene The Scene
  66341. * @param keepSubMeshes Specifies if the submeshes should be kept
  66342. * @returns A new Mesh
  66343. */
  66344. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66345. /**
  66346. * Build Mesh from CSG taking material and transforms into account
  66347. * @param name The name of the Mesh
  66348. * @param material The material of the Mesh
  66349. * @param scene The Scene
  66350. * @param keepSubMeshes Specifies if submeshes should be kept
  66351. * @returns The new Mesh
  66352. */
  66353. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66354. }
  66355. }
  66356. declare module BABYLON {
  66357. /**
  66358. * Class used to create a trail following a mesh
  66359. */
  66360. export class TrailMesh extends Mesh {
  66361. private _generator;
  66362. private _autoStart;
  66363. private _running;
  66364. private _diameter;
  66365. private _length;
  66366. private _sectionPolygonPointsCount;
  66367. private _sectionVectors;
  66368. private _sectionNormalVectors;
  66369. private _beforeRenderObserver;
  66370. /**
  66371. * @constructor
  66372. * @param name The value used by scene.getMeshByName() to do a lookup.
  66373. * @param generator The mesh or transform node to generate a trail.
  66374. * @param scene The scene to add this mesh to.
  66375. * @param diameter Diameter of trailing mesh. Default is 1.
  66376. * @param length Length of trailing mesh. Default is 60.
  66377. * @param autoStart Automatically start trailing mesh. Default true.
  66378. */
  66379. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66380. /**
  66381. * "TrailMesh"
  66382. * @returns "TrailMesh"
  66383. */
  66384. getClassName(): string;
  66385. private _createMesh;
  66386. /**
  66387. * Start trailing mesh.
  66388. */
  66389. start(): void;
  66390. /**
  66391. * Stop trailing mesh.
  66392. */
  66393. stop(): void;
  66394. /**
  66395. * Update trailing mesh geometry.
  66396. */
  66397. update(): void;
  66398. /**
  66399. * Returns a new TrailMesh object.
  66400. * @param name is a string, the name given to the new mesh
  66401. * @param newGenerator use new generator object for cloned trail mesh
  66402. * @returns a new mesh
  66403. */
  66404. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66405. /**
  66406. * Serializes this trail mesh
  66407. * @param serializationObject object to write serialization to
  66408. */
  66409. serialize(serializationObject: any): void;
  66410. /**
  66411. * Parses a serialized trail mesh
  66412. * @param parsedMesh the serialized mesh
  66413. * @param scene the scene to create the trail mesh in
  66414. * @returns the created trail mesh
  66415. */
  66416. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66417. }
  66418. }
  66419. declare module BABYLON {
  66420. /**
  66421. * Class containing static functions to help procedurally build meshes
  66422. */
  66423. export class TiledBoxBuilder {
  66424. /**
  66425. * Creates a box mesh
  66426. * 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)
  66427. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66429. * * 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
  66430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66431. * @param name defines the name of the mesh
  66432. * @param options defines the options used to create the mesh
  66433. * @param scene defines the hosting scene
  66434. * @returns the box mesh
  66435. */
  66436. static CreateTiledBox(name: string, options: {
  66437. pattern?: number;
  66438. width?: number;
  66439. height?: number;
  66440. depth?: number;
  66441. tileSize?: number;
  66442. tileWidth?: number;
  66443. tileHeight?: number;
  66444. alignHorizontal?: number;
  66445. alignVertical?: number;
  66446. faceUV?: Vector4[];
  66447. faceColors?: Color4[];
  66448. sideOrientation?: number;
  66449. updatable?: boolean;
  66450. }, scene?: Nullable<Scene>): Mesh;
  66451. }
  66452. }
  66453. declare module BABYLON {
  66454. /**
  66455. * Class containing static functions to help procedurally build meshes
  66456. */
  66457. export class TorusKnotBuilder {
  66458. /**
  66459. * Creates a torus knot mesh
  66460. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66461. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66462. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66463. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66465. * * 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
  66466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66467. * @param name defines the name of the mesh
  66468. * @param options defines the options used to create the mesh
  66469. * @param scene defines the hosting scene
  66470. * @returns the torus knot mesh
  66471. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66472. */
  66473. static CreateTorusKnot(name: string, options: {
  66474. radius?: number;
  66475. tube?: number;
  66476. radialSegments?: number;
  66477. tubularSegments?: number;
  66478. p?: number;
  66479. q?: number;
  66480. updatable?: boolean;
  66481. sideOrientation?: number;
  66482. frontUVs?: Vector4;
  66483. backUVs?: Vector4;
  66484. }, scene: any): Mesh;
  66485. }
  66486. }
  66487. declare module BABYLON {
  66488. /**
  66489. * Polygon
  66490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66491. */
  66492. export class Polygon {
  66493. /**
  66494. * Creates a rectangle
  66495. * @param xmin bottom X coord
  66496. * @param ymin bottom Y coord
  66497. * @param xmax top X coord
  66498. * @param ymax top Y coord
  66499. * @returns points that make the resulting rectation
  66500. */
  66501. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66502. /**
  66503. * Creates a circle
  66504. * @param radius radius of circle
  66505. * @param cx scale in x
  66506. * @param cy scale in y
  66507. * @param numberOfSides number of sides that make up the circle
  66508. * @returns points that make the resulting circle
  66509. */
  66510. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66511. /**
  66512. * Creates a polygon from input string
  66513. * @param input Input polygon data
  66514. * @returns the parsed points
  66515. */
  66516. static Parse(input: string): Vector2[];
  66517. /**
  66518. * Starts building a polygon from x and y coordinates
  66519. * @param x x coordinate
  66520. * @param y y coordinate
  66521. * @returns the started path2
  66522. */
  66523. static StartingAt(x: number, y: number): Path2;
  66524. }
  66525. /**
  66526. * Builds a polygon
  66527. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66528. */
  66529. export class PolygonMeshBuilder {
  66530. private _points;
  66531. private _outlinepoints;
  66532. private _holes;
  66533. private _name;
  66534. private _scene;
  66535. private _epoints;
  66536. private _eholes;
  66537. private _addToepoint;
  66538. /**
  66539. * Babylon reference to the earcut plugin.
  66540. */
  66541. bjsEarcut: any;
  66542. /**
  66543. * Creates a PolygonMeshBuilder
  66544. * @param name name of the builder
  66545. * @param contours Path of the polygon
  66546. * @param scene scene to add to when creating the mesh
  66547. * @param earcutInjection can be used to inject your own earcut reference
  66548. */
  66549. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66550. /**
  66551. * Adds a whole within the polygon
  66552. * @param hole Array of points defining the hole
  66553. * @returns this
  66554. */
  66555. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66556. /**
  66557. * Creates the polygon
  66558. * @param updatable If the mesh should be updatable
  66559. * @param depth The depth of the mesh created
  66560. * @returns the created mesh
  66561. */
  66562. build(updatable?: boolean, depth?: number): Mesh;
  66563. /**
  66564. * Creates the polygon
  66565. * @param depth The depth of the mesh created
  66566. * @returns the created VertexData
  66567. */
  66568. buildVertexData(depth?: number): VertexData;
  66569. /**
  66570. * Adds a side to the polygon
  66571. * @param positions points that make the polygon
  66572. * @param normals normals of the polygon
  66573. * @param uvs uvs of the polygon
  66574. * @param indices indices of the polygon
  66575. * @param bounds bounds of the polygon
  66576. * @param points points of the polygon
  66577. * @param depth depth of the polygon
  66578. * @param flip flip of the polygon
  66579. */
  66580. private addSide;
  66581. }
  66582. }
  66583. declare module BABYLON {
  66584. /**
  66585. * Class containing static functions to help procedurally build meshes
  66586. */
  66587. export class PolygonBuilder {
  66588. /**
  66589. * Creates a polygon mesh
  66590. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66591. * * 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
  66592. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66595. * * Remember you can only change the shape positions, not their number when updating a polygon
  66596. * @param name defines the name of the mesh
  66597. * @param options defines the options used to create the mesh
  66598. * @param scene defines the hosting scene
  66599. * @param earcutInjection can be used to inject your own earcut reference
  66600. * @returns the polygon mesh
  66601. */
  66602. static CreatePolygon(name: string, options: {
  66603. shape: Vector3[];
  66604. holes?: Vector3[][];
  66605. depth?: number;
  66606. faceUV?: Vector4[];
  66607. faceColors?: Color4[];
  66608. updatable?: boolean;
  66609. sideOrientation?: number;
  66610. frontUVs?: Vector4;
  66611. backUVs?: Vector4;
  66612. wrap?: boolean;
  66613. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66614. /**
  66615. * Creates an extruded polygon mesh, with depth in the Y direction.
  66616. * * 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)
  66617. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66618. * @param name defines the name of the mesh
  66619. * @param options defines the options used to create the mesh
  66620. * @param scene defines the hosting scene
  66621. * @param earcutInjection can be used to inject your own earcut reference
  66622. * @returns the polygon mesh
  66623. */
  66624. static ExtrudePolygon(name: string, options: {
  66625. shape: Vector3[];
  66626. holes?: Vector3[][];
  66627. depth?: number;
  66628. faceUV?: Vector4[];
  66629. faceColors?: Color4[];
  66630. updatable?: boolean;
  66631. sideOrientation?: number;
  66632. frontUVs?: Vector4;
  66633. backUVs?: Vector4;
  66634. wrap?: boolean;
  66635. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66636. }
  66637. }
  66638. declare module BABYLON {
  66639. /**
  66640. * Class containing static functions to help procedurally build meshes
  66641. */
  66642. export class LatheBuilder {
  66643. /**
  66644. * Creates lathe mesh.
  66645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66646. * * 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
  66647. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66648. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66649. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66650. * * 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
  66651. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66652. * * 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
  66653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66654. * * 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
  66655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66657. * @param name defines the name of the mesh
  66658. * @param options defines the options used to create the mesh
  66659. * @param scene defines the hosting scene
  66660. * @returns the lathe mesh
  66661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66662. */
  66663. static CreateLathe(name: string, options: {
  66664. shape: Vector3[];
  66665. radius?: number;
  66666. tessellation?: number;
  66667. clip?: number;
  66668. arc?: number;
  66669. closed?: boolean;
  66670. updatable?: boolean;
  66671. sideOrientation?: number;
  66672. frontUVs?: Vector4;
  66673. backUVs?: Vector4;
  66674. cap?: number;
  66675. invertUV?: boolean;
  66676. }, scene?: Nullable<Scene>): Mesh;
  66677. }
  66678. }
  66679. declare module BABYLON {
  66680. /**
  66681. * Class containing static functions to help procedurally build meshes
  66682. */
  66683. export class TiledPlaneBuilder {
  66684. /**
  66685. * Creates a tiled plane mesh
  66686. * * The parameter `pattern` will, depending on value, do nothing or
  66687. * * * flip (reflect about central vertical) alternate tiles across and up
  66688. * * * flip every tile on alternate rows
  66689. * * * rotate (180 degs) alternate tiles across and up
  66690. * * * rotate every tile on alternate rows
  66691. * * * flip and rotate alternate tiles across and up
  66692. * * * flip and rotate every tile on alternate rows
  66693. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66694. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66695. * * 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
  66696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66697. * * 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)
  66698. * * 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)
  66699. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66700. * @param name defines the name of the mesh
  66701. * @param options defines the options used to create the mesh
  66702. * @param scene defines the hosting scene
  66703. * @returns the box mesh
  66704. */
  66705. static CreateTiledPlane(name: string, options: {
  66706. pattern?: number;
  66707. tileSize?: number;
  66708. tileWidth?: number;
  66709. tileHeight?: number;
  66710. size?: number;
  66711. width?: number;
  66712. height?: number;
  66713. alignHorizontal?: number;
  66714. alignVertical?: number;
  66715. sideOrientation?: number;
  66716. frontUVs?: Vector4;
  66717. backUVs?: Vector4;
  66718. updatable?: boolean;
  66719. }, scene?: Nullable<Scene>): Mesh;
  66720. }
  66721. }
  66722. declare module BABYLON {
  66723. /**
  66724. * Class containing static functions to help procedurally build meshes
  66725. */
  66726. export class TubeBuilder {
  66727. /**
  66728. * Creates a tube mesh.
  66729. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66730. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66731. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66732. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66733. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66734. * * 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)
  66735. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66736. * * 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
  66737. * * 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
  66738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66739. * * 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
  66740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66742. * @param name defines the name of the mesh
  66743. * @param options defines the options used to create the mesh
  66744. * @param scene defines the hosting scene
  66745. * @returns the tube mesh
  66746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66747. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66748. */
  66749. static CreateTube(name: string, options: {
  66750. path: Vector3[];
  66751. radius?: number;
  66752. tessellation?: number;
  66753. radiusFunction?: {
  66754. (i: number, distance: number): number;
  66755. };
  66756. cap?: number;
  66757. arc?: number;
  66758. updatable?: boolean;
  66759. sideOrientation?: number;
  66760. frontUVs?: Vector4;
  66761. backUVs?: Vector4;
  66762. instance?: Mesh;
  66763. invertUV?: boolean;
  66764. }, scene?: Nullable<Scene>): Mesh;
  66765. }
  66766. }
  66767. declare module BABYLON {
  66768. /**
  66769. * Class containing static functions to help procedurally build meshes
  66770. */
  66771. export class IcoSphereBuilder {
  66772. /**
  66773. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66774. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66775. * * 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`)
  66776. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66777. * * 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
  66778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66779. * * 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
  66780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66781. * @param name defines the name of the mesh
  66782. * @param options defines the options used to create the mesh
  66783. * @param scene defines the hosting scene
  66784. * @returns the icosahedron mesh
  66785. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66786. */
  66787. static CreateIcoSphere(name: string, options: {
  66788. radius?: number;
  66789. radiusX?: number;
  66790. radiusY?: number;
  66791. radiusZ?: number;
  66792. flat?: boolean;
  66793. subdivisions?: number;
  66794. sideOrientation?: number;
  66795. frontUVs?: Vector4;
  66796. backUVs?: Vector4;
  66797. updatable?: boolean;
  66798. }, scene?: Nullable<Scene>): Mesh;
  66799. }
  66800. }
  66801. declare module BABYLON {
  66802. /**
  66803. * Class containing static functions to help procedurally build meshes
  66804. */
  66805. export class DecalBuilder {
  66806. /**
  66807. * Creates a decal mesh.
  66808. * 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
  66809. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66810. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66811. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66812. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66813. * @param name defines the name of the mesh
  66814. * @param sourceMesh defines the mesh where the decal must be applied
  66815. * @param options defines the options used to create the mesh
  66816. * @param scene defines the hosting scene
  66817. * @returns the decal mesh
  66818. * @see https://doc.babylonjs.com/how_to/decals
  66819. */
  66820. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66821. position?: Vector3;
  66822. normal?: Vector3;
  66823. size?: Vector3;
  66824. angle?: number;
  66825. }): Mesh;
  66826. }
  66827. }
  66828. declare module BABYLON {
  66829. /**
  66830. * Class containing static functions to help procedurally build meshes
  66831. */
  66832. export class MeshBuilder {
  66833. /**
  66834. * Creates a box mesh
  66835. * * The parameter `size` sets the size (float) of each box side (default 1)
  66836. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66837. * * 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)
  66838. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66840. * * 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
  66841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66842. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66843. * @param name defines the name of the mesh
  66844. * @param options defines the options used to create the mesh
  66845. * @param scene defines the hosting scene
  66846. * @returns the box mesh
  66847. */
  66848. static CreateBox(name: string, options: {
  66849. size?: number;
  66850. width?: number;
  66851. height?: number;
  66852. depth?: number;
  66853. faceUV?: Vector4[];
  66854. faceColors?: Color4[];
  66855. sideOrientation?: number;
  66856. frontUVs?: Vector4;
  66857. backUVs?: Vector4;
  66858. wrap?: boolean;
  66859. topBaseAt?: number;
  66860. bottomBaseAt?: number;
  66861. updatable?: boolean;
  66862. }, scene?: Nullable<Scene>): Mesh;
  66863. /**
  66864. * Creates a tiled box mesh
  66865. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66867. * @param name defines the name of the mesh
  66868. * @param options defines the options used to create the mesh
  66869. * @param scene defines the hosting scene
  66870. * @returns the tiled box mesh
  66871. */
  66872. static CreateTiledBox(name: string, options: {
  66873. pattern?: number;
  66874. size?: number;
  66875. width?: number;
  66876. height?: number;
  66877. depth: number;
  66878. tileSize?: number;
  66879. tileWidth?: number;
  66880. tileHeight?: number;
  66881. faceUV?: Vector4[];
  66882. faceColors?: Color4[];
  66883. alignHorizontal?: number;
  66884. alignVertical?: number;
  66885. sideOrientation?: number;
  66886. updatable?: boolean;
  66887. }, scene?: Nullable<Scene>): Mesh;
  66888. /**
  66889. * Creates a sphere mesh
  66890. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66891. * * 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`)
  66892. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66893. * * 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
  66894. * * 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)
  66895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66896. * * 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
  66897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66898. * @param name defines the name of the mesh
  66899. * @param options defines the options used to create the mesh
  66900. * @param scene defines the hosting scene
  66901. * @returns the sphere mesh
  66902. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66903. */
  66904. static CreateSphere(name: string, options: {
  66905. segments?: number;
  66906. diameter?: number;
  66907. diameterX?: number;
  66908. diameterY?: number;
  66909. diameterZ?: number;
  66910. arc?: number;
  66911. slice?: number;
  66912. sideOrientation?: number;
  66913. frontUVs?: Vector4;
  66914. backUVs?: Vector4;
  66915. updatable?: boolean;
  66916. }, scene?: Nullable<Scene>): Mesh;
  66917. /**
  66918. * Creates a plane polygonal mesh. By default, this is a disc
  66919. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66920. * * 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
  66921. * * 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
  66922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66923. * * 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
  66924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66925. * @param name defines the name of the mesh
  66926. * @param options defines the options used to create the mesh
  66927. * @param scene defines the hosting scene
  66928. * @returns the plane polygonal mesh
  66929. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66930. */
  66931. static CreateDisc(name: string, options: {
  66932. radius?: number;
  66933. tessellation?: number;
  66934. arc?: number;
  66935. updatable?: boolean;
  66936. sideOrientation?: number;
  66937. frontUVs?: Vector4;
  66938. backUVs?: Vector4;
  66939. }, scene?: Nullable<Scene>): Mesh;
  66940. /**
  66941. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66942. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66943. * * 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`)
  66944. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66945. * * 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
  66946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66947. * * 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
  66948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66949. * @param name defines the name of the mesh
  66950. * @param options defines the options used to create the mesh
  66951. * @param scene defines the hosting scene
  66952. * @returns the icosahedron mesh
  66953. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66954. */
  66955. static CreateIcoSphere(name: string, options: {
  66956. radius?: number;
  66957. radiusX?: number;
  66958. radiusY?: number;
  66959. radiusZ?: number;
  66960. flat?: boolean;
  66961. subdivisions?: number;
  66962. sideOrientation?: number;
  66963. frontUVs?: Vector4;
  66964. backUVs?: Vector4;
  66965. updatable?: boolean;
  66966. }, scene?: Nullable<Scene>): Mesh;
  66967. /**
  66968. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66969. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66970. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66971. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66972. * * 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
  66973. * * 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
  66974. * * 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
  66975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66976. * * 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
  66977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66978. * * 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
  66979. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66980. * * 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
  66981. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66983. * @param name defines the name of the mesh
  66984. * @param options defines the options used to create the mesh
  66985. * @param scene defines the hosting scene
  66986. * @returns the ribbon mesh
  66987. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66989. */
  66990. static CreateRibbon(name: string, options: {
  66991. pathArray: Vector3[][];
  66992. closeArray?: boolean;
  66993. closePath?: boolean;
  66994. offset?: number;
  66995. updatable?: boolean;
  66996. sideOrientation?: number;
  66997. frontUVs?: Vector4;
  66998. backUVs?: Vector4;
  66999. instance?: Mesh;
  67000. invertUV?: boolean;
  67001. uvs?: Vector2[];
  67002. colors?: Color4[];
  67003. }, scene?: Nullable<Scene>): Mesh;
  67004. /**
  67005. * Creates a cylinder or a cone mesh
  67006. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67007. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67008. * * 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.
  67009. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67010. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67011. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67012. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67013. * * 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).
  67014. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67015. * * 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).
  67016. * * 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
  67017. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67018. * * 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
  67019. * * 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.
  67020. * * If `enclose` is false, a ring surface is one element.
  67021. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67022. * * 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
  67023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67024. * * 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
  67025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67026. * @param name defines the name of the mesh
  67027. * @param options defines the options used to create the mesh
  67028. * @param scene defines the hosting scene
  67029. * @returns the cylinder mesh
  67030. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67031. */
  67032. static CreateCylinder(name: string, options: {
  67033. height?: number;
  67034. diameterTop?: number;
  67035. diameterBottom?: number;
  67036. diameter?: number;
  67037. tessellation?: number;
  67038. subdivisions?: number;
  67039. arc?: number;
  67040. faceColors?: Color4[];
  67041. faceUV?: Vector4[];
  67042. updatable?: boolean;
  67043. hasRings?: boolean;
  67044. enclose?: boolean;
  67045. cap?: number;
  67046. sideOrientation?: number;
  67047. frontUVs?: Vector4;
  67048. backUVs?: Vector4;
  67049. }, scene?: Nullable<Scene>): Mesh;
  67050. /**
  67051. * Creates a torus mesh
  67052. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67053. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67054. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67056. * * 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
  67057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67058. * @param name defines the name of the mesh
  67059. * @param options defines the options used to create the mesh
  67060. * @param scene defines the hosting scene
  67061. * @returns the torus mesh
  67062. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67063. */
  67064. static CreateTorus(name: string, options: {
  67065. diameter?: number;
  67066. thickness?: number;
  67067. tessellation?: number;
  67068. updatable?: boolean;
  67069. sideOrientation?: number;
  67070. frontUVs?: Vector4;
  67071. backUVs?: Vector4;
  67072. }, scene?: Nullable<Scene>): Mesh;
  67073. /**
  67074. * Creates a torus knot mesh
  67075. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67076. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67077. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67078. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67080. * * 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
  67081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67082. * @param name defines the name of the mesh
  67083. * @param options defines the options used to create the mesh
  67084. * @param scene defines the hosting scene
  67085. * @returns the torus knot mesh
  67086. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67087. */
  67088. static CreateTorusKnot(name: string, options: {
  67089. radius?: number;
  67090. tube?: number;
  67091. radialSegments?: number;
  67092. tubularSegments?: number;
  67093. p?: number;
  67094. q?: number;
  67095. updatable?: boolean;
  67096. sideOrientation?: number;
  67097. frontUVs?: Vector4;
  67098. backUVs?: Vector4;
  67099. }, scene?: Nullable<Scene>): Mesh;
  67100. /**
  67101. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67102. * * 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
  67103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67104. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67105. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67106. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67108. * * 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
  67109. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67112. * @param name defines the name of the new line system
  67113. * @param options defines the options used to create the line system
  67114. * @param scene defines the hosting scene
  67115. * @returns a new line system mesh
  67116. */
  67117. static CreateLineSystem(name: string, options: {
  67118. lines: Vector3[][];
  67119. updatable?: boolean;
  67120. instance?: Nullable<LinesMesh>;
  67121. colors?: Nullable<Color4[][]>;
  67122. useVertexAlpha?: boolean;
  67123. }, scene: Nullable<Scene>): LinesMesh;
  67124. /**
  67125. * Creates a line mesh
  67126. * 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
  67127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67128. * * The parameter `points` is an array successive Vector3
  67129. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  67130. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67132. * * When updating an instance, remember that only point positions can change, not the number of points
  67133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67135. * @param name defines the name of the new line system
  67136. * @param options defines the options used to create the line system
  67137. * @param scene defines the hosting scene
  67138. * @returns a new line mesh
  67139. */
  67140. static CreateLines(name: string, options: {
  67141. points: Vector3[];
  67142. updatable?: boolean;
  67143. instance?: Nullable<LinesMesh>;
  67144. colors?: Color4[];
  67145. useVertexAlpha?: boolean;
  67146. }, scene?: Nullable<Scene>): LinesMesh;
  67147. /**
  67148. * Creates a dashed line mesh
  67149. * * 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
  67150. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67151. * * The parameter `points` is an array successive Vector3
  67152. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67153. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67154. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67155. * * 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
  67156. * * When updating an instance, remember that only point positions can change, not the number of points
  67157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67158. * @param name defines the name of the mesh
  67159. * @param options defines the options used to create the mesh
  67160. * @param scene defines the hosting scene
  67161. * @returns the dashed line mesh
  67162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67163. */
  67164. static CreateDashedLines(name: string, options: {
  67165. points: Vector3[];
  67166. dashSize?: number;
  67167. gapSize?: number;
  67168. dashNb?: number;
  67169. updatable?: boolean;
  67170. instance?: LinesMesh;
  67171. }, scene?: Nullable<Scene>): LinesMesh;
  67172. /**
  67173. * 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.
  67174. * * 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.
  67175. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67176. * * 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.
  67177. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67178. * * 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
  67179. * * 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
  67180. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67182. * * 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
  67183. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67185. * @param name defines the name of the mesh
  67186. * @param options defines the options used to create the mesh
  67187. * @param scene defines the hosting scene
  67188. * @returns the extruded shape mesh
  67189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67191. */
  67192. static ExtrudeShape(name: string, options: {
  67193. shape: Vector3[];
  67194. path: Vector3[];
  67195. scale?: number;
  67196. rotation?: number;
  67197. cap?: number;
  67198. updatable?: boolean;
  67199. sideOrientation?: number;
  67200. frontUVs?: Vector4;
  67201. backUVs?: Vector4;
  67202. instance?: Mesh;
  67203. invertUV?: boolean;
  67204. }, scene?: Nullable<Scene>): Mesh;
  67205. /**
  67206. * Creates an custom extruded shape mesh.
  67207. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67208. * * 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.
  67209. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67210. * * 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
  67211. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67212. * * 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
  67213. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67214. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67215. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67216. * * 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
  67217. * * 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
  67218. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67220. * * 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
  67221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67223. * @param name defines the name of the mesh
  67224. * @param options defines the options used to create the mesh
  67225. * @param scene defines the hosting scene
  67226. * @returns the custom extruded shape mesh
  67227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67230. */
  67231. static ExtrudeShapeCustom(name: string, options: {
  67232. shape: Vector3[];
  67233. path: Vector3[];
  67234. scaleFunction?: any;
  67235. rotationFunction?: any;
  67236. ribbonCloseArray?: boolean;
  67237. ribbonClosePath?: boolean;
  67238. cap?: number;
  67239. updatable?: boolean;
  67240. sideOrientation?: number;
  67241. frontUVs?: Vector4;
  67242. backUVs?: Vector4;
  67243. instance?: Mesh;
  67244. invertUV?: boolean;
  67245. }, scene?: Nullable<Scene>): Mesh;
  67246. /**
  67247. * Creates lathe mesh.
  67248. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67249. * * 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
  67250. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67251. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67252. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67253. * * 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
  67254. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67255. * * 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
  67256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67257. * * 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
  67258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67260. * @param name defines the name of the mesh
  67261. * @param options defines the options used to create the mesh
  67262. * @param scene defines the hosting scene
  67263. * @returns the lathe mesh
  67264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67265. */
  67266. static CreateLathe(name: string, options: {
  67267. shape: Vector3[];
  67268. radius?: number;
  67269. tessellation?: number;
  67270. clip?: number;
  67271. arc?: number;
  67272. closed?: boolean;
  67273. updatable?: boolean;
  67274. sideOrientation?: number;
  67275. frontUVs?: Vector4;
  67276. backUVs?: Vector4;
  67277. cap?: number;
  67278. invertUV?: boolean;
  67279. }, scene?: Nullable<Scene>): Mesh;
  67280. /**
  67281. * Creates a tiled plane mesh
  67282. * * You can set a limited pattern arrangement with the tiles
  67283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67284. * * 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
  67285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67286. * @param name defines the name of the mesh
  67287. * @param options defines the options used to create the mesh
  67288. * @param scene defines the hosting scene
  67289. * @returns the plane mesh
  67290. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67291. */
  67292. static CreateTiledPlane(name: string, options: {
  67293. pattern?: number;
  67294. tileSize?: number;
  67295. tileWidth?: number;
  67296. tileHeight?: number;
  67297. size?: number;
  67298. width?: number;
  67299. height?: number;
  67300. alignHorizontal?: number;
  67301. alignVertical?: number;
  67302. sideOrientation?: number;
  67303. frontUVs?: Vector4;
  67304. backUVs?: Vector4;
  67305. updatable?: boolean;
  67306. }, scene?: Nullable<Scene>): Mesh;
  67307. /**
  67308. * Creates a plane mesh
  67309. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67310. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67311. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67313. * * 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
  67314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67315. * @param name defines the name of the mesh
  67316. * @param options defines the options used to create the mesh
  67317. * @param scene defines the hosting scene
  67318. * @returns the plane mesh
  67319. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67320. */
  67321. static CreatePlane(name: string, options: {
  67322. size?: number;
  67323. width?: number;
  67324. height?: number;
  67325. sideOrientation?: number;
  67326. frontUVs?: Vector4;
  67327. backUVs?: Vector4;
  67328. updatable?: boolean;
  67329. sourcePlane?: Plane;
  67330. }, scene?: Nullable<Scene>): Mesh;
  67331. /**
  67332. * Creates a ground mesh
  67333. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67334. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67336. * @param name defines the name of the mesh
  67337. * @param options defines the options used to create the mesh
  67338. * @param scene defines the hosting scene
  67339. * @returns the ground mesh
  67340. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67341. */
  67342. static CreateGround(name: string, options: {
  67343. width?: number;
  67344. height?: number;
  67345. subdivisions?: number;
  67346. subdivisionsX?: number;
  67347. subdivisionsY?: number;
  67348. updatable?: boolean;
  67349. }, scene?: Nullable<Scene>): Mesh;
  67350. /**
  67351. * Creates a tiled ground mesh
  67352. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67353. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67354. * * 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
  67355. * * 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
  67356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67357. * @param name defines the name of the mesh
  67358. * @param options defines the options used to create the mesh
  67359. * @param scene defines the hosting scene
  67360. * @returns the tiled ground mesh
  67361. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67362. */
  67363. static CreateTiledGround(name: string, options: {
  67364. xmin: number;
  67365. zmin: number;
  67366. xmax: number;
  67367. zmax: number;
  67368. subdivisions?: {
  67369. w: number;
  67370. h: number;
  67371. };
  67372. precision?: {
  67373. w: number;
  67374. h: number;
  67375. };
  67376. updatable?: boolean;
  67377. }, scene?: Nullable<Scene>): Mesh;
  67378. /**
  67379. * Creates a ground mesh from a height map
  67380. * * The parameter `url` sets the URL of the height map image resource.
  67381. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67382. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67383. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67384. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67385. * * 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.
  67386. * * 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).
  67387. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67389. * @param name defines the name of the mesh
  67390. * @param url defines the url to the height map
  67391. * @param options defines the options used to create the mesh
  67392. * @param scene defines the hosting scene
  67393. * @returns the ground mesh
  67394. * @see https://doc.babylonjs.com/babylon101/height_map
  67395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67396. */
  67397. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67398. width?: number;
  67399. height?: number;
  67400. subdivisions?: number;
  67401. minHeight?: number;
  67402. maxHeight?: number;
  67403. colorFilter?: Color3;
  67404. alphaFilter?: number;
  67405. updatable?: boolean;
  67406. onReady?: (mesh: GroundMesh) => void;
  67407. }, scene?: Nullable<Scene>): GroundMesh;
  67408. /**
  67409. * Creates a polygon mesh
  67410. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67411. * * 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
  67412. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67414. * * 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)
  67415. * * Remember you can only change the shape positions, not their number when updating a polygon
  67416. * @param name defines the name of the mesh
  67417. * @param options defines the options used to create the mesh
  67418. * @param scene defines the hosting scene
  67419. * @param earcutInjection can be used to inject your own earcut reference
  67420. * @returns the polygon mesh
  67421. */
  67422. static CreatePolygon(name: string, options: {
  67423. shape: Vector3[];
  67424. holes?: Vector3[][];
  67425. depth?: number;
  67426. faceUV?: Vector4[];
  67427. faceColors?: Color4[];
  67428. updatable?: boolean;
  67429. sideOrientation?: number;
  67430. frontUVs?: Vector4;
  67431. backUVs?: Vector4;
  67432. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67433. /**
  67434. * Creates an extruded polygon mesh, with depth in the Y direction.
  67435. * * 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)
  67436. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67437. * @param name defines the name of the mesh
  67438. * @param options defines the options used to create the mesh
  67439. * @param scene defines the hosting scene
  67440. * @param earcutInjection can be used to inject your own earcut reference
  67441. * @returns the polygon mesh
  67442. */
  67443. static ExtrudePolygon(name: string, options: {
  67444. shape: Vector3[];
  67445. holes?: Vector3[][];
  67446. depth?: number;
  67447. faceUV?: Vector4[];
  67448. faceColors?: Color4[];
  67449. updatable?: boolean;
  67450. sideOrientation?: number;
  67451. frontUVs?: Vector4;
  67452. backUVs?: Vector4;
  67453. wrap?: boolean;
  67454. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67455. /**
  67456. * Creates a tube mesh.
  67457. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67458. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67459. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67460. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67461. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67462. * * 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)
  67463. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67464. * * 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
  67465. * * 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
  67466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67467. * * 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
  67468. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67470. * @param name defines the name of the mesh
  67471. * @param options defines the options used to create the mesh
  67472. * @param scene defines the hosting scene
  67473. * @returns the tube mesh
  67474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67475. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67476. */
  67477. static CreateTube(name: string, options: {
  67478. path: Vector3[];
  67479. radius?: number;
  67480. tessellation?: number;
  67481. radiusFunction?: {
  67482. (i: number, distance: number): number;
  67483. };
  67484. cap?: number;
  67485. arc?: number;
  67486. updatable?: boolean;
  67487. sideOrientation?: number;
  67488. frontUVs?: Vector4;
  67489. backUVs?: Vector4;
  67490. instance?: Mesh;
  67491. invertUV?: boolean;
  67492. }, scene?: Nullable<Scene>): Mesh;
  67493. /**
  67494. * Creates a polyhedron mesh
  67495. * * 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
  67496. * * The parameter `size` (positive float, default 1) sets the polygon size
  67497. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67498. * * 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`
  67499. * * 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
  67500. * * 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)`)
  67501. * * 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
  67502. * * 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
  67503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67504. * * 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
  67505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67506. * @param name defines the name of the mesh
  67507. * @param options defines the options used to create the mesh
  67508. * @param scene defines the hosting scene
  67509. * @returns the polyhedron mesh
  67510. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67511. */
  67512. static CreatePolyhedron(name: string, options: {
  67513. type?: number;
  67514. size?: number;
  67515. sizeX?: number;
  67516. sizeY?: number;
  67517. sizeZ?: number;
  67518. custom?: any;
  67519. faceUV?: Vector4[];
  67520. faceColors?: Color4[];
  67521. flat?: boolean;
  67522. updatable?: boolean;
  67523. sideOrientation?: number;
  67524. frontUVs?: Vector4;
  67525. backUVs?: Vector4;
  67526. }, scene?: Nullable<Scene>): Mesh;
  67527. /**
  67528. * Creates a decal mesh.
  67529. * 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
  67530. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67531. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67532. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67533. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67534. * @param name defines the name of the mesh
  67535. * @param sourceMesh defines the mesh where the decal must be applied
  67536. * @param options defines the options used to create the mesh
  67537. * @param scene defines the hosting scene
  67538. * @returns the decal mesh
  67539. * @see https://doc.babylonjs.com/how_to/decals
  67540. */
  67541. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67542. position?: Vector3;
  67543. normal?: Vector3;
  67544. size?: Vector3;
  67545. angle?: number;
  67546. }): Mesh;
  67547. /**
  67548. * Creates a Capsule Mesh
  67549. * @param name defines the name of the mesh.
  67550. * @param options the constructors options used to shape the mesh.
  67551. * @param scene defines the scene the mesh is scoped to.
  67552. * @returns the capsule mesh
  67553. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67554. */
  67555. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67556. }
  67557. }
  67558. declare module BABYLON {
  67559. /**
  67560. * A simplifier interface for future simplification implementations
  67561. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67562. */
  67563. export interface ISimplifier {
  67564. /**
  67565. * Simplification of a given mesh according to the given settings.
  67566. * Since this requires computation, it is assumed that the function runs async.
  67567. * @param settings The settings of the simplification, including quality and distance
  67568. * @param successCallback A callback that will be called after the mesh was simplified.
  67569. * @param errorCallback in case of an error, this callback will be called. optional.
  67570. */
  67571. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67572. }
  67573. /**
  67574. * Expected simplification settings.
  67575. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67576. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67577. */
  67578. export interface ISimplificationSettings {
  67579. /**
  67580. * Gets or sets the expected quality
  67581. */
  67582. quality: number;
  67583. /**
  67584. * Gets or sets the distance when this optimized version should be used
  67585. */
  67586. distance: number;
  67587. /**
  67588. * Gets an already optimized mesh
  67589. */
  67590. optimizeMesh?: boolean;
  67591. }
  67592. /**
  67593. * Class used to specify simplification options
  67594. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67595. */
  67596. export class SimplificationSettings implements ISimplificationSettings {
  67597. /** expected quality */
  67598. quality: number;
  67599. /** distance when this optimized version should be used */
  67600. distance: number;
  67601. /** already optimized mesh */
  67602. optimizeMesh?: boolean | undefined;
  67603. /**
  67604. * Creates a SimplificationSettings
  67605. * @param quality expected quality
  67606. * @param distance distance when this optimized version should be used
  67607. * @param optimizeMesh already optimized mesh
  67608. */
  67609. constructor(
  67610. /** expected quality */
  67611. quality: number,
  67612. /** distance when this optimized version should be used */
  67613. distance: number,
  67614. /** already optimized mesh */
  67615. optimizeMesh?: boolean | undefined);
  67616. }
  67617. /**
  67618. * Interface used to define a simplification task
  67619. */
  67620. export interface ISimplificationTask {
  67621. /**
  67622. * Array of settings
  67623. */
  67624. settings: Array<ISimplificationSettings>;
  67625. /**
  67626. * Simplification type
  67627. */
  67628. simplificationType: SimplificationType;
  67629. /**
  67630. * Mesh to simplify
  67631. */
  67632. mesh: Mesh;
  67633. /**
  67634. * Callback called on success
  67635. */
  67636. successCallback?: () => void;
  67637. /**
  67638. * Defines if parallel processing can be used
  67639. */
  67640. parallelProcessing: boolean;
  67641. }
  67642. /**
  67643. * Queue used to order the simplification tasks
  67644. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67645. */
  67646. export class SimplificationQueue {
  67647. private _simplificationArray;
  67648. /**
  67649. * Gets a boolean indicating that the process is still running
  67650. */
  67651. running: boolean;
  67652. /**
  67653. * Creates a new queue
  67654. */
  67655. constructor();
  67656. /**
  67657. * Adds a new simplification task
  67658. * @param task defines a task to add
  67659. */
  67660. addTask(task: ISimplificationTask): void;
  67661. /**
  67662. * Execute next task
  67663. */
  67664. executeNext(): void;
  67665. /**
  67666. * Execute a simplification task
  67667. * @param task defines the task to run
  67668. */
  67669. runSimplification(task: ISimplificationTask): void;
  67670. private getSimplifier;
  67671. }
  67672. /**
  67673. * The implemented types of simplification
  67674. * At the moment only Quadratic Error Decimation is implemented
  67675. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67676. */
  67677. export enum SimplificationType {
  67678. /** Quadratic error decimation */
  67679. QUADRATIC = 0
  67680. }
  67681. /**
  67682. * An implementation of the Quadratic Error simplification algorithm.
  67683. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67684. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67685. * @author RaananW
  67686. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67687. */
  67688. export class QuadraticErrorSimplification implements ISimplifier {
  67689. private _mesh;
  67690. private triangles;
  67691. private vertices;
  67692. private references;
  67693. private _reconstructedMesh;
  67694. /** Gets or sets the number pf sync interations */
  67695. syncIterations: number;
  67696. /** Gets or sets the aggressiveness of the simplifier */
  67697. aggressiveness: number;
  67698. /** Gets or sets the number of allowed iterations for decimation */
  67699. decimationIterations: number;
  67700. /** Gets or sets the espilon to use for bounding box computation */
  67701. boundingBoxEpsilon: number;
  67702. /**
  67703. * Creates a new QuadraticErrorSimplification
  67704. * @param _mesh defines the target mesh
  67705. */
  67706. constructor(_mesh: Mesh);
  67707. /**
  67708. * Simplification of a given mesh according to the given settings.
  67709. * Since this requires computation, it is assumed that the function runs async.
  67710. * @param settings The settings of the simplification, including quality and distance
  67711. * @param successCallback A callback that will be called after the mesh was simplified.
  67712. */
  67713. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67714. private runDecimation;
  67715. private initWithMesh;
  67716. private init;
  67717. private reconstructMesh;
  67718. private initDecimatedMesh;
  67719. private isFlipped;
  67720. private updateTriangles;
  67721. private identifyBorder;
  67722. private updateMesh;
  67723. private vertexError;
  67724. private calculateError;
  67725. }
  67726. }
  67727. declare module BABYLON {
  67728. interface Scene {
  67729. /** @hidden (Backing field) */
  67730. _simplificationQueue: SimplificationQueue;
  67731. /**
  67732. * Gets or sets the simplification queue attached to the scene
  67733. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67734. */
  67735. simplificationQueue: SimplificationQueue;
  67736. }
  67737. interface Mesh {
  67738. /**
  67739. * Simplify the mesh according to the given array of settings.
  67740. * Function will return immediately and will simplify async
  67741. * @param settings a collection of simplification settings
  67742. * @param parallelProcessing should all levels calculate parallel or one after the other
  67743. * @param simplificationType the type of simplification to run
  67744. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67745. * @returns the current mesh
  67746. */
  67747. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67748. }
  67749. /**
  67750. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67751. * created in a scene
  67752. */
  67753. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67754. /**
  67755. * The component name helpfull to identify the component in the list of scene components.
  67756. */
  67757. readonly name: string;
  67758. /**
  67759. * The scene the component belongs to.
  67760. */
  67761. scene: Scene;
  67762. /**
  67763. * Creates a new instance of the component for the given scene
  67764. * @param scene Defines the scene to register the component in
  67765. */
  67766. constructor(scene: Scene);
  67767. /**
  67768. * Registers the component in a given scene
  67769. */
  67770. register(): void;
  67771. /**
  67772. * Rebuilds the elements related to this component in case of
  67773. * context lost for instance.
  67774. */
  67775. rebuild(): void;
  67776. /**
  67777. * Disposes the component and the associated ressources
  67778. */
  67779. dispose(): void;
  67780. private _beforeCameraUpdate;
  67781. }
  67782. }
  67783. declare module BABYLON {
  67784. interface Mesh {
  67785. /**
  67786. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67787. */
  67788. thinInstanceEnablePicking: boolean;
  67789. /**
  67790. * Creates a new thin instance
  67791. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67792. * @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
  67793. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67794. */
  67795. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67796. /**
  67797. * Adds the transformation (matrix) of the current mesh as a thin instance
  67798. * @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
  67799. * @returns the thin instance index number
  67800. */
  67801. thinInstanceAddSelf(refresh: boolean): number;
  67802. /**
  67803. * Registers a custom attribute to be used with thin instances
  67804. * @param kind name of the attribute
  67805. * @param stride size in floats of the attribute
  67806. */
  67807. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67808. /**
  67809. * Sets the matrix of a thin instance
  67810. * @param index index of the thin instance
  67811. * @param matrix matrix to set
  67812. * @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
  67813. */
  67814. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67815. /**
  67816. * Sets the value of a custom attribute for a thin instance
  67817. * @param kind name of the attribute
  67818. * @param index index of the thin instance
  67819. * @param value value to set
  67820. * @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
  67821. */
  67822. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67823. /**
  67824. * 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.
  67825. */
  67826. thinInstanceCount: number;
  67827. /**
  67828. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67829. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67830. * @param buffer buffer to set
  67831. * @param stride size in floats of each value of the buffer
  67832. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67833. */
  67834. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67835. /**
  67836. * Gets the list of world matrices
  67837. * @return an array containing all the world matrices from the thin instances
  67838. */
  67839. thinInstanceGetWorldMatrices(): Matrix[];
  67840. /**
  67841. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67842. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67843. */
  67844. thinInstanceBufferUpdated(kind: string): void;
  67845. /**
  67846. * Applies a partial update to a buffer directly on the GPU
  67847. * 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
  67848. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67849. * @param data the data to set in the GPU buffer
  67850. * @param offset the offset in the GPU buffer where to update the data
  67851. */
  67852. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67853. /**
  67854. * Refreshes the bounding info, taking into account all the thin instances defined
  67855. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67856. */
  67857. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67858. /** @hidden */
  67859. _thinInstanceInitializeUserStorage(): void;
  67860. /** @hidden */
  67861. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67862. /** @hidden */
  67863. _userThinInstanceBuffersStorage: {
  67864. data: {
  67865. [key: string]: Float32Array;
  67866. };
  67867. sizes: {
  67868. [key: string]: number;
  67869. };
  67870. vertexBuffers: {
  67871. [key: string]: Nullable<VertexBuffer>;
  67872. };
  67873. strides: {
  67874. [key: string]: number;
  67875. };
  67876. };
  67877. }
  67878. }
  67879. declare module BABYLON {
  67880. /**
  67881. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67882. */
  67883. export interface INavigationEnginePlugin {
  67884. /**
  67885. * plugin name
  67886. */
  67887. name: string;
  67888. /**
  67889. * Creates a navigation mesh
  67890. * @param meshes array of all the geometry used to compute the navigatio mesh
  67891. * @param parameters bunch of parameters used to filter geometry
  67892. */
  67893. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67894. /**
  67895. * Create a navigation mesh debug mesh
  67896. * @param scene is where the mesh will be added
  67897. * @returns debug display mesh
  67898. */
  67899. createDebugNavMesh(scene: Scene): Mesh;
  67900. /**
  67901. * Get a navigation mesh constrained position, closest to the parameter position
  67902. * @param position world position
  67903. * @returns the closest point to position constrained by the navigation mesh
  67904. */
  67905. getClosestPoint(position: Vector3): Vector3;
  67906. /**
  67907. * Get a navigation mesh constrained position, closest to the parameter position
  67908. * @param position world position
  67909. * @param result output the closest point to position constrained by the navigation mesh
  67910. */
  67911. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67912. /**
  67913. * Get a navigation mesh constrained position, within a particular radius
  67914. * @param position world position
  67915. * @param maxRadius the maximum distance to the constrained world position
  67916. * @returns the closest point to position constrained by the navigation mesh
  67917. */
  67918. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67919. /**
  67920. * Get a navigation mesh constrained position, within a particular radius
  67921. * @param position world position
  67922. * @param maxRadius the maximum distance to the constrained world position
  67923. * @param result output the closest point to position constrained by the navigation mesh
  67924. */
  67925. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67926. /**
  67927. * Compute the final position from a segment made of destination-position
  67928. * @param position world position
  67929. * @param destination world position
  67930. * @returns the resulting point along the navmesh
  67931. */
  67932. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67933. /**
  67934. * Compute the final position from a segment made of destination-position
  67935. * @param position world position
  67936. * @param destination world position
  67937. * @param result output the resulting point along the navmesh
  67938. */
  67939. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67940. /**
  67941. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67942. * @param start world position
  67943. * @param end world position
  67944. * @returns array containing world position composing the path
  67945. */
  67946. computePath(start: Vector3, end: Vector3): Vector3[];
  67947. /**
  67948. * If this plugin is supported
  67949. * @returns true if plugin is supported
  67950. */
  67951. isSupported(): boolean;
  67952. /**
  67953. * Create a new Crowd so you can add agents
  67954. * @param maxAgents the maximum agent count in the crowd
  67955. * @param maxAgentRadius the maximum radius an agent can have
  67956. * @param scene to attach the crowd to
  67957. * @returns the crowd you can add agents to
  67958. */
  67959. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67960. /**
  67961. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67962. * The queries will try to find a solution within those bounds
  67963. * default is (1,1,1)
  67964. * @param extent x,y,z value that define the extent around the queries point of reference
  67965. */
  67966. setDefaultQueryExtent(extent: Vector3): void;
  67967. /**
  67968. * Get the Bounding box extent specified by setDefaultQueryExtent
  67969. * @returns the box extent values
  67970. */
  67971. getDefaultQueryExtent(): Vector3;
  67972. /**
  67973. * build the navmesh from a previously saved state using getNavmeshData
  67974. * @param data the Uint8Array returned by getNavmeshData
  67975. */
  67976. buildFromNavmeshData(data: Uint8Array): void;
  67977. /**
  67978. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67979. * @returns data the Uint8Array that can be saved and reused
  67980. */
  67981. getNavmeshData(): Uint8Array;
  67982. /**
  67983. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67984. * @param result output the box extent values
  67985. */
  67986. getDefaultQueryExtentToRef(result: Vector3): void;
  67987. /**
  67988. * Release all resources
  67989. */
  67990. dispose(): void;
  67991. }
  67992. /**
  67993. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67994. */
  67995. export interface ICrowd {
  67996. /**
  67997. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67998. * You can attach anything to that node. The node position is updated in the scene update tick.
  67999. * @param pos world position that will be constrained by the navigation mesh
  68000. * @param parameters agent parameters
  68001. * @param transform hooked to the agent that will be update by the scene
  68002. * @returns agent index
  68003. */
  68004. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68005. /**
  68006. * Returns the agent position in world space
  68007. * @param index agent index returned by addAgent
  68008. * @returns world space position
  68009. */
  68010. getAgentPosition(index: number): Vector3;
  68011. /**
  68012. * Gets the agent position result in world space
  68013. * @param index agent index returned by addAgent
  68014. * @param result output world space position
  68015. */
  68016. getAgentPositionToRef(index: number, result: Vector3): void;
  68017. /**
  68018. * Gets the agent velocity in world space
  68019. * @param index agent index returned by addAgent
  68020. * @returns world space velocity
  68021. */
  68022. getAgentVelocity(index: number): Vector3;
  68023. /**
  68024. * Gets the agent velocity result in world space
  68025. * @param index agent index returned by addAgent
  68026. * @param result output world space velocity
  68027. */
  68028. getAgentVelocityToRef(index: number, result: Vector3): void;
  68029. /**
  68030. * Gets the agent next target point on the path
  68031. * @param index agent index returned by addAgent
  68032. * @returns world space position
  68033. */
  68034. getAgentNextTargetPath(index: number): Vector3;
  68035. /**
  68036. * Gets the agent state
  68037. * @param index agent index returned by addAgent
  68038. * @returns agent state
  68039. */
  68040. getAgentState(index: number): number;
  68041. /**
  68042. * returns true if the agent in over an off mesh link connection
  68043. * @param index agent index returned by addAgent
  68044. * @returns true if over an off mesh link connection
  68045. */
  68046. overOffmeshConnection(index: number): boolean;
  68047. /**
  68048. * Gets the agent next target point on the path
  68049. * @param index agent index returned by addAgent
  68050. * @param result output world space position
  68051. */
  68052. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68053. /**
  68054. * remove a particular agent previously created
  68055. * @param index agent index returned by addAgent
  68056. */
  68057. removeAgent(index: number): void;
  68058. /**
  68059. * get the list of all agents attached to this crowd
  68060. * @returns list of agent indices
  68061. */
  68062. getAgents(): number[];
  68063. /**
  68064. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68065. * @param deltaTime in seconds
  68066. */
  68067. update(deltaTime: number): void;
  68068. /**
  68069. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68070. * @param index agent index returned by addAgent
  68071. * @param destination targeted world position
  68072. */
  68073. agentGoto(index: number, destination: Vector3): void;
  68074. /**
  68075. * Teleport the agent to a new position
  68076. * @param index agent index returned by addAgent
  68077. * @param destination targeted world position
  68078. */
  68079. agentTeleport(index: number, destination: Vector3): void;
  68080. /**
  68081. * Update agent parameters
  68082. * @param index agent index returned by addAgent
  68083. * @param parameters agent parameters
  68084. */
  68085. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68086. /**
  68087. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68088. * The queries will try to find a solution within those bounds
  68089. * default is (1,1,1)
  68090. * @param extent x,y,z value that define the extent around the queries point of reference
  68091. */
  68092. setDefaultQueryExtent(extent: Vector3): void;
  68093. /**
  68094. * Get the Bounding box extent specified by setDefaultQueryExtent
  68095. * @returns the box extent values
  68096. */
  68097. getDefaultQueryExtent(): Vector3;
  68098. /**
  68099. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68100. * @param result output the box extent values
  68101. */
  68102. getDefaultQueryExtentToRef(result: Vector3): void;
  68103. /**
  68104. * Release all resources
  68105. */
  68106. dispose(): void;
  68107. }
  68108. /**
  68109. * Configures an agent
  68110. */
  68111. export interface IAgentParameters {
  68112. /**
  68113. * Agent radius. [Limit: >= 0]
  68114. */
  68115. radius: number;
  68116. /**
  68117. * Agent height. [Limit: > 0]
  68118. */
  68119. height: number;
  68120. /**
  68121. * Maximum allowed acceleration. [Limit: >= 0]
  68122. */
  68123. maxAcceleration: number;
  68124. /**
  68125. * Maximum allowed speed. [Limit: >= 0]
  68126. */
  68127. maxSpeed: number;
  68128. /**
  68129. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68130. */
  68131. collisionQueryRange: number;
  68132. /**
  68133. * The path visibility optimization range. [Limit: > 0]
  68134. */
  68135. pathOptimizationRange: number;
  68136. /**
  68137. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68138. */
  68139. separationWeight: number;
  68140. }
  68141. /**
  68142. * Configures the navigation mesh creation
  68143. */
  68144. export interface INavMeshParameters {
  68145. /**
  68146. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68147. */
  68148. cs: number;
  68149. /**
  68150. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68151. */
  68152. ch: number;
  68153. /**
  68154. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68155. */
  68156. walkableSlopeAngle: number;
  68157. /**
  68158. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68159. * be considered walkable. [Limit: >= 3] [Units: vx]
  68160. */
  68161. walkableHeight: number;
  68162. /**
  68163. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68164. */
  68165. walkableClimb: number;
  68166. /**
  68167. * The distance to erode/shrink the walkable area of the heightfield away from
  68168. * obstructions. [Limit: >=0] [Units: vx]
  68169. */
  68170. walkableRadius: number;
  68171. /**
  68172. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68173. */
  68174. maxEdgeLen: number;
  68175. /**
  68176. * The maximum distance a simplfied contour's border edges should deviate
  68177. * the original raw contour. [Limit: >=0] [Units: vx]
  68178. */
  68179. maxSimplificationError: number;
  68180. /**
  68181. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68182. */
  68183. minRegionArea: number;
  68184. /**
  68185. * Any regions with a span count smaller than this value will, if possible,
  68186. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68187. */
  68188. mergeRegionArea: number;
  68189. /**
  68190. * The maximum number of vertices allowed for polygons generated during the
  68191. * contour to polygon conversion process. [Limit: >= 3]
  68192. */
  68193. maxVertsPerPoly: number;
  68194. /**
  68195. * Sets the sampling distance to use when generating the detail mesh.
  68196. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68197. */
  68198. detailSampleDist: number;
  68199. /**
  68200. * The maximum distance the detail mesh surface should deviate from heightfield
  68201. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68202. */
  68203. detailSampleMaxError: number;
  68204. }
  68205. }
  68206. declare module BABYLON {
  68207. /**
  68208. * RecastJS navigation plugin
  68209. */
  68210. export class RecastJSPlugin implements INavigationEnginePlugin {
  68211. /**
  68212. * Reference to the Recast library
  68213. */
  68214. bjsRECAST: any;
  68215. /**
  68216. * plugin name
  68217. */
  68218. name: string;
  68219. /**
  68220. * the first navmesh created. We might extend this to support multiple navmeshes
  68221. */
  68222. navMesh: any;
  68223. /**
  68224. * Initializes the recastJS plugin
  68225. * @param recastInjection can be used to inject your own recast reference
  68226. */
  68227. constructor(recastInjection?: any);
  68228. /**
  68229. * Creates a navigation mesh
  68230. * @param meshes array of all the geometry used to compute the navigatio mesh
  68231. * @param parameters bunch of parameters used to filter geometry
  68232. */
  68233. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68234. /**
  68235. * Create a navigation mesh debug mesh
  68236. * @param scene is where the mesh will be added
  68237. * @returns debug display mesh
  68238. */
  68239. createDebugNavMesh(scene: Scene): Mesh;
  68240. /**
  68241. * Get a navigation mesh constrained position, closest to the parameter position
  68242. * @param position world position
  68243. * @returns the closest point to position constrained by the navigation mesh
  68244. */
  68245. getClosestPoint(position: Vector3): Vector3;
  68246. /**
  68247. * Get a navigation mesh constrained position, closest to the parameter position
  68248. * @param position world position
  68249. * @param result output the closest point to position constrained by the navigation mesh
  68250. */
  68251. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68252. /**
  68253. * Get a navigation mesh constrained position, within a particular radius
  68254. * @param position world position
  68255. * @param maxRadius the maximum distance to the constrained world position
  68256. * @returns the closest point to position constrained by the navigation mesh
  68257. */
  68258. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68259. /**
  68260. * Get a navigation mesh constrained position, within a particular radius
  68261. * @param position world position
  68262. * @param maxRadius the maximum distance to the constrained world position
  68263. * @param result output the closest point to position constrained by the navigation mesh
  68264. */
  68265. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68266. /**
  68267. * Compute the final position from a segment made of destination-position
  68268. * @param position world position
  68269. * @param destination world position
  68270. * @returns the resulting point along the navmesh
  68271. */
  68272. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68273. /**
  68274. * Compute the final position from a segment made of destination-position
  68275. * @param position world position
  68276. * @param destination world position
  68277. * @param result output the resulting point along the navmesh
  68278. */
  68279. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68280. /**
  68281. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68282. * @param start world position
  68283. * @param end world position
  68284. * @returns array containing world position composing the path
  68285. */
  68286. computePath(start: Vector3, end: Vector3): Vector3[];
  68287. /**
  68288. * Create a new Crowd so you can add agents
  68289. * @param maxAgents the maximum agent count in the crowd
  68290. * @param maxAgentRadius the maximum radius an agent can have
  68291. * @param scene to attach the crowd to
  68292. * @returns the crowd you can add agents to
  68293. */
  68294. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68295. /**
  68296. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68297. * The queries will try to find a solution within those bounds
  68298. * default is (1,1,1)
  68299. * @param extent x,y,z value that define the extent around the queries point of reference
  68300. */
  68301. setDefaultQueryExtent(extent: Vector3): void;
  68302. /**
  68303. * Get the Bounding box extent specified by setDefaultQueryExtent
  68304. * @returns the box extent values
  68305. */
  68306. getDefaultQueryExtent(): Vector3;
  68307. /**
  68308. * build the navmesh from a previously saved state using getNavmeshData
  68309. * @param data the Uint8Array returned by getNavmeshData
  68310. */
  68311. buildFromNavmeshData(data: Uint8Array): void;
  68312. /**
  68313. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68314. * @returns data the Uint8Array that can be saved and reused
  68315. */
  68316. getNavmeshData(): Uint8Array;
  68317. /**
  68318. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68319. * @param result output the box extent values
  68320. */
  68321. getDefaultQueryExtentToRef(result: Vector3): void;
  68322. /**
  68323. * Disposes
  68324. */
  68325. dispose(): void;
  68326. /**
  68327. * If this plugin is supported
  68328. * @returns true if plugin is supported
  68329. */
  68330. isSupported(): boolean;
  68331. }
  68332. /**
  68333. * Recast detour crowd implementation
  68334. */
  68335. export class RecastJSCrowd implements ICrowd {
  68336. /**
  68337. * Recast/detour plugin
  68338. */
  68339. bjsRECASTPlugin: RecastJSPlugin;
  68340. /**
  68341. * Link to the detour crowd
  68342. */
  68343. recastCrowd: any;
  68344. /**
  68345. * One transform per agent
  68346. */
  68347. transforms: TransformNode[];
  68348. /**
  68349. * All agents created
  68350. */
  68351. agents: number[];
  68352. /**
  68353. * Link to the scene is kept to unregister the crowd from the scene
  68354. */
  68355. private _scene;
  68356. /**
  68357. * Observer for crowd updates
  68358. */
  68359. private _onBeforeAnimationsObserver;
  68360. /**
  68361. * Constructor
  68362. * @param plugin recastJS plugin
  68363. * @param maxAgents the maximum agent count in the crowd
  68364. * @param maxAgentRadius the maximum radius an agent can have
  68365. * @param scene to attach the crowd to
  68366. * @returns the crowd you can add agents to
  68367. */
  68368. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68369. /**
  68370. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68371. * You can attach anything to that node. The node position is updated in the scene update tick.
  68372. * @param pos world position that will be constrained by the navigation mesh
  68373. * @param parameters agent parameters
  68374. * @param transform hooked to the agent that will be update by the scene
  68375. * @returns agent index
  68376. */
  68377. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68378. /**
  68379. * Returns the agent position in world space
  68380. * @param index agent index returned by addAgent
  68381. * @returns world space position
  68382. */
  68383. getAgentPosition(index: number): Vector3;
  68384. /**
  68385. * Returns the agent position result in world space
  68386. * @param index agent index returned by addAgent
  68387. * @param result output world space position
  68388. */
  68389. getAgentPositionToRef(index: number, result: Vector3): void;
  68390. /**
  68391. * Returns the agent velocity in world space
  68392. * @param index agent index returned by addAgent
  68393. * @returns world space velocity
  68394. */
  68395. getAgentVelocity(index: number): Vector3;
  68396. /**
  68397. * Returns the agent velocity result in world space
  68398. * @param index agent index returned by addAgent
  68399. * @param result output world space velocity
  68400. */
  68401. getAgentVelocityToRef(index: number, result: Vector3): void;
  68402. /**
  68403. * Returns the agent next target point on the path
  68404. * @param index agent index returned by addAgent
  68405. * @returns world space position
  68406. */
  68407. getAgentNextTargetPath(index: number): Vector3;
  68408. /**
  68409. * Returns the agent next target point on the path
  68410. * @param index agent index returned by addAgent
  68411. * @param result output world space position
  68412. */
  68413. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68414. /**
  68415. * Gets the agent state
  68416. * @param index agent index returned by addAgent
  68417. * @returns agent state
  68418. */
  68419. getAgentState(index: number): number;
  68420. /**
  68421. * returns true if the agent in over an off mesh link connection
  68422. * @param index agent index returned by addAgent
  68423. * @returns true if over an off mesh link connection
  68424. */
  68425. overOffmeshConnection(index: number): boolean;
  68426. /**
  68427. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68428. * @param index agent index returned by addAgent
  68429. * @param destination targeted world position
  68430. */
  68431. agentGoto(index: number, destination: Vector3): void;
  68432. /**
  68433. * Teleport the agent to a new position
  68434. * @param index agent index returned by addAgent
  68435. * @param destination targeted world position
  68436. */
  68437. agentTeleport(index: number, destination: Vector3): void;
  68438. /**
  68439. * Update agent parameters
  68440. * @param index agent index returned by addAgent
  68441. * @param parameters agent parameters
  68442. */
  68443. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68444. /**
  68445. * remove a particular agent previously created
  68446. * @param index agent index returned by addAgent
  68447. */
  68448. removeAgent(index: number): void;
  68449. /**
  68450. * get the list of all agents attached to this crowd
  68451. * @returns list of agent indices
  68452. */
  68453. getAgents(): number[];
  68454. /**
  68455. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68456. * @param deltaTime in seconds
  68457. */
  68458. update(deltaTime: number): void;
  68459. /**
  68460. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68461. * The queries will try to find a solution within those bounds
  68462. * default is (1,1,1)
  68463. * @param extent x,y,z value that define the extent around the queries point of reference
  68464. */
  68465. setDefaultQueryExtent(extent: Vector3): void;
  68466. /**
  68467. * Get the Bounding box extent specified by setDefaultQueryExtent
  68468. * @returns the box extent values
  68469. */
  68470. getDefaultQueryExtent(): Vector3;
  68471. /**
  68472. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68473. * @param result output the box extent values
  68474. */
  68475. getDefaultQueryExtentToRef(result: Vector3): void;
  68476. /**
  68477. * Release all resources
  68478. */
  68479. dispose(): void;
  68480. }
  68481. }
  68482. declare module BABYLON {
  68483. /**
  68484. * Class used to enable access to IndexedDB
  68485. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68486. */
  68487. export class Database implements IOfflineProvider {
  68488. private _callbackManifestChecked;
  68489. private _currentSceneUrl;
  68490. private _db;
  68491. private _enableSceneOffline;
  68492. private _enableTexturesOffline;
  68493. private _manifestVersionFound;
  68494. private _mustUpdateRessources;
  68495. private _hasReachedQuota;
  68496. private _isSupported;
  68497. private _idbFactory;
  68498. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68499. private static IsUASupportingBlobStorage;
  68500. /**
  68501. * Gets a boolean indicating if Database storate is enabled (off by default)
  68502. */
  68503. static IDBStorageEnabled: boolean;
  68504. /**
  68505. * Gets a boolean indicating if scene must be saved in the database
  68506. */
  68507. get enableSceneOffline(): boolean;
  68508. /**
  68509. * Gets a boolean indicating if textures must be saved in the database
  68510. */
  68511. get enableTexturesOffline(): boolean;
  68512. /**
  68513. * Creates a new Database
  68514. * @param urlToScene defines the url to load the scene
  68515. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68516. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68517. */
  68518. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68519. private static _ParseURL;
  68520. private static _ReturnFullUrlLocation;
  68521. private _checkManifestFile;
  68522. /**
  68523. * Open the database and make it available
  68524. * @param successCallback defines the callback to call on success
  68525. * @param errorCallback defines the callback to call on error
  68526. */
  68527. open(successCallback: () => void, errorCallback: () => void): void;
  68528. /**
  68529. * Loads an image from the database
  68530. * @param url defines the url to load from
  68531. * @param image defines the target DOM image
  68532. */
  68533. loadImage(url: string, image: HTMLImageElement): void;
  68534. private _loadImageFromDBAsync;
  68535. private _saveImageIntoDBAsync;
  68536. private _checkVersionFromDB;
  68537. private _loadVersionFromDBAsync;
  68538. private _saveVersionIntoDBAsync;
  68539. /**
  68540. * Loads a file from database
  68541. * @param url defines the URL to load from
  68542. * @param sceneLoaded defines a callback to call on success
  68543. * @param progressCallBack defines a callback to call when progress changed
  68544. * @param errorCallback defines a callback to call on error
  68545. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68546. */
  68547. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68548. private _loadFileAsync;
  68549. private _saveFileAsync;
  68550. /**
  68551. * Validates if xhr data is correct
  68552. * @param xhr defines the request to validate
  68553. * @param dataType defines the expected data type
  68554. * @returns true if data is correct
  68555. */
  68556. private static _ValidateXHRData;
  68557. }
  68558. }
  68559. declare module BABYLON {
  68560. /** @hidden */
  68561. export var gpuUpdateParticlesPixelShader: {
  68562. name: string;
  68563. shader: string;
  68564. };
  68565. }
  68566. declare module BABYLON {
  68567. /** @hidden */
  68568. export var gpuUpdateParticlesVertexShader: {
  68569. name: string;
  68570. shader: string;
  68571. };
  68572. }
  68573. declare module BABYLON {
  68574. /** @hidden */
  68575. export var clipPlaneFragmentDeclaration2: {
  68576. name: string;
  68577. shader: string;
  68578. };
  68579. }
  68580. declare module BABYLON {
  68581. /** @hidden */
  68582. export var gpuRenderParticlesPixelShader: {
  68583. name: string;
  68584. shader: string;
  68585. };
  68586. }
  68587. declare module BABYLON {
  68588. /** @hidden */
  68589. export var clipPlaneVertexDeclaration2: {
  68590. name: string;
  68591. shader: string;
  68592. };
  68593. }
  68594. declare module BABYLON {
  68595. /** @hidden */
  68596. export var gpuRenderParticlesVertexShader: {
  68597. name: string;
  68598. shader: string;
  68599. };
  68600. }
  68601. declare module BABYLON {
  68602. /**
  68603. * This represents a GPU particle system in Babylon
  68604. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68605. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68606. */
  68607. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68608. /**
  68609. * The layer mask we are rendering the particles through.
  68610. */
  68611. layerMask: number;
  68612. private _capacity;
  68613. private _activeCount;
  68614. private _currentActiveCount;
  68615. private _accumulatedCount;
  68616. private _renderEffect;
  68617. private _updateEffect;
  68618. private _buffer0;
  68619. private _buffer1;
  68620. private _spriteBuffer;
  68621. private _updateVAO;
  68622. private _renderVAO;
  68623. private _targetIndex;
  68624. private _sourceBuffer;
  68625. private _targetBuffer;
  68626. private _currentRenderId;
  68627. private _started;
  68628. private _stopped;
  68629. private _timeDelta;
  68630. private _randomTexture;
  68631. private _randomTexture2;
  68632. private _attributesStrideSize;
  68633. private _updateEffectOptions;
  68634. private _randomTextureSize;
  68635. private _actualFrame;
  68636. private _customEffect;
  68637. private readonly _rawTextureWidth;
  68638. /**
  68639. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68640. */
  68641. static get IsSupported(): boolean;
  68642. /**
  68643. * An event triggered when the system is disposed.
  68644. */
  68645. onDisposeObservable: Observable<IParticleSystem>;
  68646. /**
  68647. * An event triggered when the system is stopped
  68648. */
  68649. onStoppedObservable: Observable<IParticleSystem>;
  68650. /**
  68651. * Gets the maximum number of particles active at the same time.
  68652. * @returns The max number of active particles.
  68653. */
  68654. getCapacity(): number;
  68655. /**
  68656. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68657. * to override the particles.
  68658. */
  68659. forceDepthWrite: boolean;
  68660. /**
  68661. * Gets or set the number of active particles
  68662. */
  68663. get activeParticleCount(): number;
  68664. set activeParticleCount(value: number);
  68665. private _preWarmDone;
  68666. /**
  68667. * Specifies if the particles are updated in emitter local space or world space.
  68668. */
  68669. isLocal: boolean;
  68670. /** Gets or sets a matrix to use to compute projection */
  68671. defaultProjectionMatrix: Matrix;
  68672. /**
  68673. * Is this system ready to be used/rendered
  68674. * @return true if the system is ready
  68675. */
  68676. isReady(): boolean;
  68677. /**
  68678. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68679. * @returns True if it has been started, otherwise false.
  68680. */
  68681. isStarted(): boolean;
  68682. /**
  68683. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68684. * @returns True if it has been stopped, otherwise false.
  68685. */
  68686. isStopped(): boolean;
  68687. /**
  68688. * Gets a boolean indicating that the system is stopping
  68689. * @returns true if the system is currently stopping
  68690. */
  68691. isStopping(): boolean;
  68692. /**
  68693. * Gets the number of particles active at the same time.
  68694. * @returns The number of active particles.
  68695. */
  68696. getActiveCount(): number;
  68697. /**
  68698. * Starts the particle system and begins to emit
  68699. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68700. */
  68701. start(delay?: number): void;
  68702. /**
  68703. * Stops the particle system.
  68704. */
  68705. stop(): void;
  68706. /**
  68707. * Remove all active particles
  68708. */
  68709. reset(): void;
  68710. /**
  68711. * Returns the string "GPUParticleSystem"
  68712. * @returns a string containing the class name
  68713. */
  68714. getClassName(): string;
  68715. /**
  68716. * Gets the custom effect used to render the particles
  68717. * @param blendMode Blend mode for which the effect should be retrieved
  68718. * @returns The effect
  68719. */
  68720. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68721. /**
  68722. * Sets the custom effect used to render the particles
  68723. * @param effect The effect to set
  68724. * @param blendMode Blend mode for which the effect should be set
  68725. */
  68726. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68727. /** @hidden */
  68728. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68729. /**
  68730. * Observable that will be called just before the particles are drawn
  68731. */
  68732. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68733. /**
  68734. * Gets the name of the particle vertex shader
  68735. */
  68736. get vertexShaderName(): string;
  68737. private _colorGradientsTexture;
  68738. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68739. /**
  68740. * Adds a new color gradient
  68741. * @param gradient defines the gradient to use (between 0 and 1)
  68742. * @param color1 defines the color to affect to the specified gradient
  68743. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68744. * @returns the current particle system
  68745. */
  68746. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68747. private _refreshColorGradient;
  68748. /** Force the system to rebuild all gradients that need to be resync */
  68749. forceRefreshGradients(): void;
  68750. /**
  68751. * Remove a specific color gradient
  68752. * @param gradient defines the gradient to remove
  68753. * @returns the current particle system
  68754. */
  68755. removeColorGradient(gradient: number): GPUParticleSystem;
  68756. private _angularSpeedGradientsTexture;
  68757. private _sizeGradientsTexture;
  68758. private _velocityGradientsTexture;
  68759. private _limitVelocityGradientsTexture;
  68760. private _dragGradientsTexture;
  68761. private _addFactorGradient;
  68762. /**
  68763. * Adds a new size gradient
  68764. * @param gradient defines the gradient to use (between 0 and 1)
  68765. * @param factor defines the size factor to affect to the specified gradient
  68766. * @returns the current particle system
  68767. */
  68768. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68769. /**
  68770. * Remove a specific size gradient
  68771. * @param gradient defines the gradient to remove
  68772. * @returns the current particle system
  68773. */
  68774. removeSizeGradient(gradient: number): GPUParticleSystem;
  68775. private _refreshFactorGradient;
  68776. /**
  68777. * Adds a new angular speed gradient
  68778. * @param gradient defines the gradient to use (between 0 and 1)
  68779. * @param factor defines the angular speed to affect to the specified gradient
  68780. * @returns the current particle system
  68781. */
  68782. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68783. /**
  68784. * Remove a specific angular speed gradient
  68785. * @param gradient defines the gradient to remove
  68786. * @returns the current particle system
  68787. */
  68788. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68789. /**
  68790. * Adds a new velocity gradient
  68791. * @param gradient defines the gradient to use (between 0 and 1)
  68792. * @param factor defines the velocity to affect to the specified gradient
  68793. * @returns the current particle system
  68794. */
  68795. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68796. /**
  68797. * Remove a specific velocity gradient
  68798. * @param gradient defines the gradient to remove
  68799. * @returns the current particle system
  68800. */
  68801. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68802. /**
  68803. * Adds a new limit velocity gradient
  68804. * @param gradient defines the gradient to use (between 0 and 1)
  68805. * @param factor defines the limit velocity value to affect to the specified gradient
  68806. * @returns the current particle system
  68807. */
  68808. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68809. /**
  68810. * Remove a specific limit velocity gradient
  68811. * @param gradient defines the gradient to remove
  68812. * @returns the current particle system
  68813. */
  68814. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68815. /**
  68816. * Adds a new drag gradient
  68817. * @param gradient defines the gradient to use (between 0 and 1)
  68818. * @param factor defines the drag value to affect to the specified gradient
  68819. * @returns the current particle system
  68820. */
  68821. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68822. /**
  68823. * Remove a specific drag gradient
  68824. * @param gradient defines the gradient to remove
  68825. * @returns the current particle system
  68826. */
  68827. removeDragGradient(gradient: number): GPUParticleSystem;
  68828. /**
  68829. * Not supported by GPUParticleSystem
  68830. * @param gradient defines the gradient to use (between 0 and 1)
  68831. * @param factor defines the emit rate value to affect to the specified gradient
  68832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68833. * @returns the current particle system
  68834. */
  68835. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68836. /**
  68837. * Not supported by GPUParticleSystem
  68838. * @param gradient defines the gradient to remove
  68839. * @returns the current particle system
  68840. */
  68841. removeEmitRateGradient(gradient: number): IParticleSystem;
  68842. /**
  68843. * Not supported by GPUParticleSystem
  68844. * @param gradient defines the gradient to use (between 0 and 1)
  68845. * @param factor defines the start size value to affect to the specified gradient
  68846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68847. * @returns the current particle system
  68848. */
  68849. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68850. /**
  68851. * Not supported by GPUParticleSystem
  68852. * @param gradient defines the gradient to remove
  68853. * @returns the current particle system
  68854. */
  68855. removeStartSizeGradient(gradient: number): IParticleSystem;
  68856. /**
  68857. * Not supported by GPUParticleSystem
  68858. * @param gradient defines the gradient to use (between 0 and 1)
  68859. * @param min defines the color remap minimal range
  68860. * @param max defines the color remap maximal range
  68861. * @returns the current particle system
  68862. */
  68863. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68864. /**
  68865. * Not supported by GPUParticleSystem
  68866. * @param gradient defines the gradient to remove
  68867. * @returns the current particle system
  68868. */
  68869. removeColorRemapGradient(): IParticleSystem;
  68870. /**
  68871. * Not supported by GPUParticleSystem
  68872. * @param gradient defines the gradient to use (between 0 and 1)
  68873. * @param min defines the alpha remap minimal range
  68874. * @param max defines the alpha remap maximal range
  68875. * @returns the current particle system
  68876. */
  68877. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68878. /**
  68879. * Not supported by GPUParticleSystem
  68880. * @param gradient defines the gradient to remove
  68881. * @returns the current particle system
  68882. */
  68883. removeAlphaRemapGradient(): IParticleSystem;
  68884. /**
  68885. * Not supported by GPUParticleSystem
  68886. * @param gradient defines the gradient to use (between 0 and 1)
  68887. * @param color defines the color to affect to the specified gradient
  68888. * @returns the current particle system
  68889. */
  68890. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68891. /**
  68892. * Not supported by GPUParticleSystem
  68893. * @param gradient defines the gradient to remove
  68894. * @returns the current particle system
  68895. */
  68896. removeRampGradient(): IParticleSystem;
  68897. /**
  68898. * Not supported by GPUParticleSystem
  68899. * @returns the list of ramp gradients
  68900. */
  68901. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68902. /**
  68903. * Not supported by GPUParticleSystem
  68904. * Gets or sets a boolean indicating that ramp gradients must be used
  68905. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68906. */
  68907. get useRampGradients(): boolean;
  68908. set useRampGradients(value: boolean);
  68909. /**
  68910. * Not supported by GPUParticleSystem
  68911. * @param gradient defines the gradient to use (between 0 and 1)
  68912. * @param factor defines the life time factor to affect to the specified gradient
  68913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68914. * @returns the current particle system
  68915. */
  68916. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68917. /**
  68918. * Not supported by GPUParticleSystem
  68919. * @param gradient defines the gradient to remove
  68920. * @returns the current particle system
  68921. */
  68922. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68923. /**
  68924. * Instantiates a GPU particle system.
  68925. * 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.
  68926. * @param name The name of the particle system
  68927. * @param options The options used to create the system
  68928. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68929. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68930. * @param customEffect a custom effect used to change the way particles are rendered by default
  68931. */
  68932. constructor(name: string, options: Partial<{
  68933. capacity: number;
  68934. randomTextureSize: number;
  68935. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68936. protected _reset(): void;
  68937. private _createUpdateVAO;
  68938. private _createRenderVAO;
  68939. private _initialize;
  68940. /** @hidden */
  68941. _recreateUpdateEffect(): void;
  68942. private _getEffect;
  68943. /**
  68944. * Fill the defines array according to the current settings of the particle system
  68945. * @param defines Array to be updated
  68946. * @param blendMode blend mode to take into account when updating the array
  68947. */
  68948. fillDefines(defines: Array<string>, blendMode?: number): void;
  68949. /**
  68950. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68951. * @param uniforms Uniforms array to fill
  68952. * @param attributes Attributes array to fill
  68953. * @param samplers Samplers array to fill
  68954. */
  68955. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68956. /** @hidden */
  68957. _recreateRenderEffect(): Effect;
  68958. /**
  68959. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68960. * @param preWarm defines if we are in the pre-warmimg phase
  68961. */
  68962. animate(preWarm?: boolean): void;
  68963. private _createFactorGradientTexture;
  68964. private _createSizeGradientTexture;
  68965. private _createAngularSpeedGradientTexture;
  68966. private _createVelocityGradientTexture;
  68967. private _createLimitVelocityGradientTexture;
  68968. private _createDragGradientTexture;
  68969. private _createColorGradientTexture;
  68970. /**
  68971. * Renders the particle system in its current state
  68972. * @param preWarm defines if the system should only update the particles but not render them
  68973. * @returns the current number of particles
  68974. */
  68975. render(preWarm?: boolean): number;
  68976. /**
  68977. * Rebuilds the particle system
  68978. */
  68979. rebuild(): void;
  68980. private _releaseBuffers;
  68981. private _releaseVAOs;
  68982. /**
  68983. * Disposes the particle system and free the associated resources
  68984. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68985. */
  68986. dispose(disposeTexture?: boolean): void;
  68987. /**
  68988. * Clones the particle system.
  68989. * @param name The name of the cloned object
  68990. * @param newEmitter The new emitter to use
  68991. * @returns the cloned particle system
  68992. */
  68993. clone(name: string, newEmitter: any): GPUParticleSystem;
  68994. /**
  68995. * Serializes the particle system to a JSON object
  68996. * @param serializeTexture defines if the texture must be serialized as well
  68997. * @returns the JSON object
  68998. */
  68999. serialize(serializeTexture?: boolean): any;
  69000. /**
  69001. * Parses a JSON object to create a GPU particle system.
  69002. * @param parsedParticleSystem The JSON object to parse
  69003. * @param sceneOrEngine The scene or the engine to create the particle system in
  69004. * @param rootUrl The root url to use to load external dependencies like texture
  69005. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69006. * @returns the parsed GPU particle system
  69007. */
  69008. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69009. }
  69010. }
  69011. declare module BABYLON {
  69012. /**
  69013. * Represents a set of particle systems working together to create a specific effect
  69014. */
  69015. export class ParticleSystemSet implements IDisposable {
  69016. /**
  69017. * Gets or sets base Assets URL
  69018. */
  69019. static BaseAssetsUrl: string;
  69020. private _emitterCreationOptions;
  69021. private _emitterNode;
  69022. /**
  69023. * Gets the particle system list
  69024. */
  69025. systems: IParticleSystem[];
  69026. /**
  69027. * Gets the emitter node used with this set
  69028. */
  69029. get emitterNode(): Nullable<TransformNode>;
  69030. /**
  69031. * Creates a new emitter mesh as a sphere
  69032. * @param options defines the options used to create the sphere
  69033. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69034. * @param scene defines the hosting scene
  69035. */
  69036. setEmitterAsSphere(options: {
  69037. diameter: number;
  69038. segments: number;
  69039. color: Color3;
  69040. }, renderingGroupId: number, scene: Scene): void;
  69041. /**
  69042. * Starts all particle systems of the set
  69043. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69044. */
  69045. start(emitter?: AbstractMesh): void;
  69046. /**
  69047. * Release all associated resources
  69048. */
  69049. dispose(): void;
  69050. /**
  69051. * Serialize the set into a JSON compatible object
  69052. * @param serializeTexture defines if the texture must be serialized as well
  69053. * @returns a JSON compatible representation of the set
  69054. */
  69055. serialize(serializeTexture?: boolean): any;
  69056. /**
  69057. * Parse a new ParticleSystemSet from a serialized source
  69058. * @param data defines a JSON compatible representation of the set
  69059. * @param scene defines the hosting scene
  69060. * @param gpu defines if we want GPU particles or CPU particles
  69061. * @returns a new ParticleSystemSet
  69062. */
  69063. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /**
  69068. * This class is made for on one-liner static method to help creating particle system set.
  69069. */
  69070. export class ParticleHelper {
  69071. /**
  69072. * Gets or sets base Assets URL
  69073. */
  69074. static BaseAssetsUrl: string;
  69075. /** Define the Url to load snippets */
  69076. static SnippetUrl: string;
  69077. /**
  69078. * Create a default particle system that you can tweak
  69079. * @param emitter defines the emitter to use
  69080. * @param capacity defines the system capacity (default is 500 particles)
  69081. * @param scene defines the hosting scene
  69082. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69083. * @returns the new Particle system
  69084. */
  69085. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69086. /**
  69087. * This is the main static method (one-liner) of this helper to create different particle systems
  69088. * @param type This string represents the type to the particle system to create
  69089. * @param scene The scene where the particle system should live
  69090. * @param gpu If the system will use gpu
  69091. * @returns the ParticleSystemSet created
  69092. */
  69093. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69094. /**
  69095. * Static function used to export a particle system to a ParticleSystemSet variable.
  69096. * Please note that the emitter shape is not exported
  69097. * @param systems defines the particle systems to export
  69098. * @returns the created particle system set
  69099. */
  69100. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69101. /**
  69102. * Creates a particle system from a snippet saved in a remote file
  69103. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69104. * @param url defines the url to load from
  69105. * @param scene defines the hosting scene
  69106. * @param gpu If the system will use gpu
  69107. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69108. * @returns a promise that will resolve to the new particle system
  69109. */
  69110. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69111. /**
  69112. * Creates a particle system from a snippet saved by the particle system editor
  69113. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69114. * @param scene defines the hosting scene
  69115. * @param gpu If the system will use gpu
  69116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69117. * @returns a promise that will resolve to the new particle system
  69118. */
  69119. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. interface Engine {
  69124. /**
  69125. * Create an effect to use with particle systems.
  69126. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69127. * the particle system for which you want to create a custom effect in the last parameter
  69128. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69129. * @param uniformsNames defines a list of attribute names
  69130. * @param samplers defines an array of string used to represent textures
  69131. * @param defines defines the string containing the defines to use to compile the shaders
  69132. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69133. * @param onCompiled defines a function to call when the effect creation is successful
  69134. * @param onError defines a function to call when the effect creation has failed
  69135. * @param particleSystem the particle system you want to create the effect for
  69136. * @returns the new Effect
  69137. */
  69138. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69139. }
  69140. interface Mesh {
  69141. /**
  69142. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69143. * @returns an array of IParticleSystem
  69144. */
  69145. getEmittedParticleSystems(): IParticleSystem[];
  69146. /**
  69147. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69148. * @returns an array of IParticleSystem
  69149. */
  69150. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69151. }
  69152. }
  69153. declare module BABYLON {
  69154. /** Defines the 4 color options */
  69155. export enum PointColor {
  69156. /** color value */
  69157. Color = 2,
  69158. /** uv value */
  69159. UV = 1,
  69160. /** random value */
  69161. Random = 0,
  69162. /** stated value */
  69163. Stated = 3
  69164. }
  69165. /**
  69166. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69167. * 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.
  69168. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69169. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69170. *
  69171. * Full documentation here : TO BE ENTERED
  69172. */
  69173. export class PointsCloudSystem implements IDisposable {
  69174. /**
  69175. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69176. * Example : var p = SPS.particles[i];
  69177. */
  69178. particles: CloudPoint[];
  69179. /**
  69180. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69181. */
  69182. nbParticles: number;
  69183. /**
  69184. * This a counter for your own usage. It's not set by any SPS functions.
  69185. */
  69186. counter: number;
  69187. /**
  69188. * The PCS name. This name is also given to the underlying mesh.
  69189. */
  69190. name: string;
  69191. /**
  69192. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69193. */
  69194. mesh: Mesh;
  69195. /**
  69196. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69197. * Please read :
  69198. */
  69199. vars: any;
  69200. /**
  69201. * @hidden
  69202. */
  69203. _size: number;
  69204. private _scene;
  69205. private _promises;
  69206. private _positions;
  69207. private _indices;
  69208. private _normals;
  69209. private _colors;
  69210. private _uvs;
  69211. private _indices32;
  69212. private _positions32;
  69213. private _colors32;
  69214. private _uvs32;
  69215. private _updatable;
  69216. private _isVisibilityBoxLocked;
  69217. private _alwaysVisible;
  69218. private _groups;
  69219. private _groupCounter;
  69220. private _computeParticleColor;
  69221. private _computeParticleTexture;
  69222. private _computeParticleRotation;
  69223. private _computeBoundingBox;
  69224. private _isReady;
  69225. /**
  69226. * Creates a PCS (Points Cloud System) object
  69227. * @param name (String) is the PCS name, this will be the underlying mesh name
  69228. * @param pointSize (number) is the size for each point
  69229. * @param scene (Scene) is the scene in which the PCS is added
  69230. * @param options defines the options of the PCS e.g.
  69231. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69232. */
  69233. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69234. updatable?: boolean;
  69235. });
  69236. /**
  69237. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69238. * If no points were added to the PCS, the returned mesh is just a single point.
  69239. * @returns a promise for the created mesh
  69240. */
  69241. buildMeshAsync(): Promise<Mesh>;
  69242. /**
  69243. * @hidden
  69244. */
  69245. private _buildMesh;
  69246. private _addParticle;
  69247. private _randomUnitVector;
  69248. private _getColorIndicesForCoord;
  69249. private _setPointsColorOrUV;
  69250. private _colorFromTexture;
  69251. private _calculateDensity;
  69252. /**
  69253. * Adds points to the PCS in random positions within a unit sphere
  69254. * @param nb (positive integer) the number of particles to be created from this model
  69255. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69256. * @returns the number of groups in the system
  69257. */
  69258. addPoints(nb: number, pointFunction?: any): number;
  69259. /**
  69260. * Adds points to the PCS from the surface of the model shape
  69261. * @param mesh is any Mesh object that will be used as a surface model for the points
  69262. * @param nb (positive integer) the number of particles to be created from this model
  69263. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69264. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69265. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69266. * @returns the number of groups in the system
  69267. */
  69268. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69269. /**
  69270. * Adds points to the PCS inside the model shape
  69271. * @param mesh is any Mesh object that will be used as a surface model for the points
  69272. * @param nb (positive integer) the number of particles to be created from this model
  69273. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69274. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69275. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69276. * @returns the number of groups in the system
  69277. */
  69278. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69279. /**
  69280. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69281. * This method calls `updateParticle()` for each particle of the SPS.
  69282. * For an animated SPS, it is usually called within the render loop.
  69283. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69284. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69285. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69286. * @returns the PCS.
  69287. */
  69288. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69289. /**
  69290. * Disposes the PCS.
  69291. */
  69292. dispose(): void;
  69293. /**
  69294. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69295. * doc :
  69296. * @returns the PCS.
  69297. */
  69298. refreshVisibleSize(): PointsCloudSystem;
  69299. /**
  69300. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69301. * @param size the size (float) of the visibility box
  69302. * note : this doesn't lock the PCS mesh bounding box.
  69303. * doc :
  69304. */
  69305. setVisibilityBox(size: number): void;
  69306. /**
  69307. * Gets whether the PCS is always visible or not
  69308. * doc :
  69309. */
  69310. get isAlwaysVisible(): boolean;
  69311. /**
  69312. * Sets the PCS as always visible or not
  69313. * doc :
  69314. */
  69315. set isAlwaysVisible(val: boolean);
  69316. /**
  69317. * Tells to `setParticles()` to compute the particle rotations or not
  69318. * Default value : false. The PCS is faster when it's set to false
  69319. * Note : particle rotations are only applied to parent particles
  69320. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69321. */
  69322. set computeParticleRotation(val: boolean);
  69323. /**
  69324. * Tells to `setParticles()` to compute the particle colors or not.
  69325. * Default value : true. The PCS is faster when it's set to false.
  69326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69327. */
  69328. set computeParticleColor(val: boolean);
  69329. set computeParticleTexture(val: boolean);
  69330. /**
  69331. * Gets if `setParticles()` computes the particle colors or not.
  69332. * Default value : false. The PCS is faster when it's set to false.
  69333. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69334. */
  69335. get computeParticleColor(): boolean;
  69336. /**
  69337. * Gets if `setParticles()` computes the particle textures or not.
  69338. * Default value : false. The PCS is faster when it's set to false.
  69339. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69340. */
  69341. get computeParticleTexture(): boolean;
  69342. /**
  69343. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69344. */
  69345. set computeBoundingBox(val: boolean);
  69346. /**
  69347. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69348. */
  69349. get computeBoundingBox(): boolean;
  69350. /**
  69351. * This function does nothing. It may be overwritten to set all the particle first values.
  69352. * The PCS doesn't call this function, you may have to call it by your own.
  69353. * doc :
  69354. */
  69355. initParticles(): void;
  69356. /**
  69357. * This function does nothing. It may be overwritten to recycle a particle
  69358. * The PCS doesn't call this function, you can to call it
  69359. * doc :
  69360. * @param particle The particle to recycle
  69361. * @returns the recycled particle
  69362. */
  69363. recycleParticle(particle: CloudPoint): CloudPoint;
  69364. /**
  69365. * Updates a particle : this function should be overwritten by the user.
  69366. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69367. * doc :
  69368. * @example : just set a particle position or velocity and recycle conditions
  69369. * @param particle The particle to update
  69370. * @returns the updated particle
  69371. */
  69372. updateParticle(particle: CloudPoint): CloudPoint;
  69373. /**
  69374. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69375. * This does nothing and may be overwritten by the user.
  69376. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69377. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69378. * @param update the boolean update value actually passed to setParticles()
  69379. */
  69380. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69381. /**
  69382. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69383. * This will be passed three parameters.
  69384. * This does nothing and may be overwritten by the user.
  69385. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69386. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69387. * @param update the boolean update value actually passed to setParticles()
  69388. */
  69389. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69390. }
  69391. }
  69392. declare module BABYLON {
  69393. /**
  69394. * Represents one particle of a points cloud system.
  69395. */
  69396. export class CloudPoint {
  69397. /**
  69398. * particle global index
  69399. */
  69400. idx: number;
  69401. /**
  69402. * The color of the particle
  69403. */
  69404. color: Nullable<Color4>;
  69405. /**
  69406. * The world space position of the particle.
  69407. */
  69408. position: Vector3;
  69409. /**
  69410. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69411. */
  69412. rotation: Vector3;
  69413. /**
  69414. * The world space rotation quaternion of the particle.
  69415. */
  69416. rotationQuaternion: Nullable<Quaternion>;
  69417. /**
  69418. * The uv of the particle.
  69419. */
  69420. uv: Nullable<Vector2>;
  69421. /**
  69422. * The current speed of the particle.
  69423. */
  69424. velocity: Vector3;
  69425. /**
  69426. * The pivot point in the particle local space.
  69427. */
  69428. pivot: Vector3;
  69429. /**
  69430. * Must the particle be translated from its pivot point in its local space ?
  69431. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69432. * Default : false
  69433. */
  69434. translateFromPivot: boolean;
  69435. /**
  69436. * Index of this particle in the global "positions" array (Internal use)
  69437. * @hidden
  69438. */
  69439. _pos: number;
  69440. /**
  69441. * @hidden Index of this particle in the global "indices" array (Internal use)
  69442. */
  69443. _ind: number;
  69444. /**
  69445. * Group this particle belongs to
  69446. */
  69447. _group: PointsGroup;
  69448. /**
  69449. * Group id of this particle
  69450. */
  69451. groupId: number;
  69452. /**
  69453. * Index of the particle in its group id (Internal use)
  69454. */
  69455. idxInGroup: number;
  69456. /**
  69457. * @hidden Particle BoundingInfo object (Internal use)
  69458. */
  69459. _boundingInfo: BoundingInfo;
  69460. /**
  69461. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69462. */
  69463. _pcs: PointsCloudSystem;
  69464. /**
  69465. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69466. */
  69467. _stillInvisible: boolean;
  69468. /**
  69469. * @hidden Last computed particle rotation matrix
  69470. */
  69471. _rotationMatrix: number[];
  69472. /**
  69473. * Parent particle Id, if any.
  69474. * Default null.
  69475. */
  69476. parentId: Nullable<number>;
  69477. /**
  69478. * @hidden Internal global position in the PCS.
  69479. */
  69480. _globalPosition: Vector3;
  69481. /**
  69482. * Creates a Point Cloud object.
  69483. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69484. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69485. * @param group (PointsGroup) is the group the particle belongs to
  69486. * @param groupId (integer) is the group identifier in the PCS.
  69487. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69488. * @param pcs defines the PCS it is associated to
  69489. */
  69490. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69491. /**
  69492. * get point size
  69493. */
  69494. get size(): Vector3;
  69495. /**
  69496. * Set point size
  69497. */
  69498. set size(scale: Vector3);
  69499. /**
  69500. * Legacy support, changed quaternion to rotationQuaternion
  69501. */
  69502. get quaternion(): Nullable<Quaternion>;
  69503. /**
  69504. * Legacy support, changed quaternion to rotationQuaternion
  69505. */
  69506. set quaternion(q: Nullable<Quaternion>);
  69507. /**
  69508. * Returns a boolean. True if the particle intersects a mesh, else false
  69509. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69510. * @param target is the object (point or mesh) what the intersection is computed against
  69511. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69512. * @returns true if it intersects
  69513. */
  69514. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69515. /**
  69516. * get the rotation matrix of the particle
  69517. * @hidden
  69518. */
  69519. getRotationMatrix(m: Matrix): void;
  69520. }
  69521. /**
  69522. * Represents a group of points in a points cloud system
  69523. * * PCS internal tool, don't use it manually.
  69524. */
  69525. export class PointsGroup {
  69526. /**
  69527. * The group id
  69528. * @hidden
  69529. */
  69530. groupID: number;
  69531. /**
  69532. * image data for group (internal use)
  69533. * @hidden
  69534. */
  69535. _groupImageData: Nullable<ArrayBufferView>;
  69536. /**
  69537. * Image Width (internal use)
  69538. * @hidden
  69539. */
  69540. _groupImgWidth: number;
  69541. /**
  69542. * Image Height (internal use)
  69543. * @hidden
  69544. */
  69545. _groupImgHeight: number;
  69546. /**
  69547. * Custom position function (internal use)
  69548. * @hidden
  69549. */
  69550. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69551. /**
  69552. * density per facet for surface points
  69553. * @hidden
  69554. */
  69555. _groupDensity: number[];
  69556. /**
  69557. * Only when points are colored by texture carries pointer to texture list array
  69558. * @hidden
  69559. */
  69560. _textureNb: number;
  69561. /**
  69562. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69563. * PCS internal tool, don't use it manually.
  69564. * @hidden
  69565. */
  69566. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69567. }
  69568. }
  69569. declare module BABYLON {
  69570. interface Scene {
  69571. /** @hidden (Backing field) */
  69572. _physicsEngine: Nullable<IPhysicsEngine>;
  69573. /** @hidden */
  69574. _physicsTimeAccumulator: number;
  69575. /**
  69576. * Gets the current physics engine
  69577. * @returns a IPhysicsEngine or null if none attached
  69578. */
  69579. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69580. /**
  69581. * Enables physics to the current scene
  69582. * @param gravity defines the scene's gravity for the physics engine
  69583. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69584. * @return a boolean indicating if the physics engine was initialized
  69585. */
  69586. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69587. /**
  69588. * Disables and disposes the physics engine associated with the scene
  69589. */
  69590. disablePhysicsEngine(): void;
  69591. /**
  69592. * Gets a boolean indicating if there is an active physics engine
  69593. * @returns a boolean indicating if there is an active physics engine
  69594. */
  69595. isPhysicsEnabled(): boolean;
  69596. /**
  69597. * Deletes a physics compound impostor
  69598. * @param compound defines the compound to delete
  69599. */
  69600. deleteCompoundImpostor(compound: any): void;
  69601. /**
  69602. * An event triggered when physic simulation is about to be run
  69603. */
  69604. onBeforePhysicsObservable: Observable<Scene>;
  69605. /**
  69606. * An event triggered when physic simulation has been done
  69607. */
  69608. onAfterPhysicsObservable: Observable<Scene>;
  69609. }
  69610. interface AbstractMesh {
  69611. /** @hidden */
  69612. _physicsImpostor: Nullable<PhysicsImpostor>;
  69613. /**
  69614. * Gets or sets impostor used for physic simulation
  69615. * @see https://doc.babylonjs.com/features/physics_engine
  69616. */
  69617. physicsImpostor: Nullable<PhysicsImpostor>;
  69618. /**
  69619. * Gets the current physics impostor
  69620. * @see https://doc.babylonjs.com/features/physics_engine
  69621. * @returns a physics impostor or null
  69622. */
  69623. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69624. /** Apply a physic impulse to the mesh
  69625. * @param force defines the force to apply
  69626. * @param contactPoint defines where to apply the force
  69627. * @returns the current mesh
  69628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69629. */
  69630. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69631. /**
  69632. * Creates a physic joint between two meshes
  69633. * @param otherMesh defines the other mesh to use
  69634. * @param pivot1 defines the pivot to use on this mesh
  69635. * @param pivot2 defines the pivot to use on the other mesh
  69636. * @param options defines additional options (can be plugin dependent)
  69637. * @returns the current mesh
  69638. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69639. */
  69640. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69641. /** @hidden */
  69642. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69643. }
  69644. /**
  69645. * Defines the physics engine scene component responsible to manage a physics engine
  69646. */
  69647. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69648. /**
  69649. * The component name helpful to identify the component in the list of scene components.
  69650. */
  69651. readonly name: string;
  69652. /**
  69653. * The scene the component belongs to.
  69654. */
  69655. scene: Scene;
  69656. /**
  69657. * Creates a new instance of the component for the given scene
  69658. * @param scene Defines the scene to register the component in
  69659. */
  69660. constructor(scene: Scene);
  69661. /**
  69662. * Registers the component in a given scene
  69663. */
  69664. register(): void;
  69665. /**
  69666. * Rebuilds the elements related to this component in case of
  69667. * context lost for instance.
  69668. */
  69669. rebuild(): void;
  69670. /**
  69671. * Disposes the component and the associated ressources
  69672. */
  69673. dispose(): void;
  69674. }
  69675. }
  69676. declare module BABYLON {
  69677. /**
  69678. * A helper for physics simulations
  69679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69680. */
  69681. export class PhysicsHelper {
  69682. private _scene;
  69683. private _physicsEngine;
  69684. /**
  69685. * Initializes the Physics helper
  69686. * @param scene Babylon.js scene
  69687. */
  69688. constructor(scene: Scene);
  69689. /**
  69690. * Applies a radial explosion impulse
  69691. * @param origin the origin of the explosion
  69692. * @param radiusOrEventOptions the radius or the options of radial explosion
  69693. * @param strength the explosion strength
  69694. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69695. * @returns A physics radial explosion event, or null
  69696. */
  69697. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69698. /**
  69699. * Applies a radial explosion force
  69700. * @param origin the origin of the explosion
  69701. * @param radiusOrEventOptions the radius or the options of radial explosion
  69702. * @param strength the explosion strength
  69703. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69704. * @returns A physics radial explosion event, or null
  69705. */
  69706. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69707. /**
  69708. * Creates a gravitational field
  69709. * @param origin the origin of the explosion
  69710. * @param radiusOrEventOptions the radius or the options of radial explosion
  69711. * @param strength the explosion strength
  69712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69713. * @returns A physics gravitational field event, or null
  69714. */
  69715. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69716. /**
  69717. * Creates a physics updraft event
  69718. * @param origin the origin of the updraft
  69719. * @param radiusOrEventOptions the radius or the options of the updraft
  69720. * @param strength the strength of the updraft
  69721. * @param height the height of the updraft
  69722. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69723. * @returns A physics updraft event, or null
  69724. */
  69725. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69726. /**
  69727. * Creates a physics vortex event
  69728. * @param origin the of the vortex
  69729. * @param radiusOrEventOptions the radius or the options of the vortex
  69730. * @param strength the strength of the vortex
  69731. * @param height the height of the vortex
  69732. * @returns a Physics vortex event, or null
  69733. * A physics vortex event or null
  69734. */
  69735. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69736. }
  69737. /**
  69738. * Represents a physics radial explosion event
  69739. */
  69740. class PhysicsRadialExplosionEvent {
  69741. private _scene;
  69742. private _options;
  69743. private _sphere;
  69744. private _dataFetched;
  69745. /**
  69746. * Initializes a radial explosioin event
  69747. * @param _scene BabylonJS scene
  69748. * @param _options The options for the vortex event
  69749. */
  69750. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69751. /**
  69752. * Returns the data related to the radial explosion event (sphere).
  69753. * @returns The radial explosion event data
  69754. */
  69755. getData(): PhysicsRadialExplosionEventData;
  69756. /**
  69757. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69758. * @param impostor A physics imposter
  69759. * @param origin the origin of the explosion
  69760. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69761. */
  69762. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69763. /**
  69764. * Triggers affecterd impostors callbacks
  69765. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69766. */
  69767. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69768. /**
  69769. * Disposes the sphere.
  69770. * @param force Specifies if the sphere should be disposed by force
  69771. */
  69772. dispose(force?: boolean): void;
  69773. /*** Helpers ***/
  69774. private _prepareSphere;
  69775. private _intersectsWithSphere;
  69776. }
  69777. /**
  69778. * Represents a gravitational field event
  69779. */
  69780. class PhysicsGravitationalFieldEvent {
  69781. private _physicsHelper;
  69782. private _scene;
  69783. private _origin;
  69784. private _options;
  69785. private _tickCallback;
  69786. private _sphere;
  69787. private _dataFetched;
  69788. /**
  69789. * Initializes the physics gravitational field event
  69790. * @param _physicsHelper A physics helper
  69791. * @param _scene BabylonJS scene
  69792. * @param _origin The origin position of the gravitational field event
  69793. * @param _options The options for the vortex event
  69794. */
  69795. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69796. /**
  69797. * Returns the data related to the gravitational field event (sphere).
  69798. * @returns A gravitational field event
  69799. */
  69800. getData(): PhysicsGravitationalFieldEventData;
  69801. /**
  69802. * Enables the gravitational field.
  69803. */
  69804. enable(): void;
  69805. /**
  69806. * Disables the gravitational field.
  69807. */
  69808. disable(): void;
  69809. /**
  69810. * Disposes the sphere.
  69811. * @param force The force to dispose from the gravitational field event
  69812. */
  69813. dispose(force?: boolean): void;
  69814. private _tick;
  69815. }
  69816. /**
  69817. * Represents a physics updraft event
  69818. */
  69819. class PhysicsUpdraftEvent {
  69820. private _scene;
  69821. private _origin;
  69822. private _options;
  69823. private _physicsEngine;
  69824. private _originTop;
  69825. private _originDirection;
  69826. private _tickCallback;
  69827. private _cylinder;
  69828. private _cylinderPosition;
  69829. private _dataFetched;
  69830. /**
  69831. * Initializes the physics updraft event
  69832. * @param _scene BabylonJS scene
  69833. * @param _origin The origin position of the updraft
  69834. * @param _options The options for the updraft event
  69835. */
  69836. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69837. /**
  69838. * Returns the data related to the updraft event (cylinder).
  69839. * @returns A physics updraft event
  69840. */
  69841. getData(): PhysicsUpdraftEventData;
  69842. /**
  69843. * Enables the updraft.
  69844. */
  69845. enable(): void;
  69846. /**
  69847. * Disables the updraft.
  69848. */
  69849. disable(): void;
  69850. /**
  69851. * Disposes the cylinder.
  69852. * @param force Specifies if the updraft should be disposed by force
  69853. */
  69854. dispose(force?: boolean): void;
  69855. private getImpostorHitData;
  69856. private _tick;
  69857. /*** Helpers ***/
  69858. private _prepareCylinder;
  69859. private _intersectsWithCylinder;
  69860. }
  69861. /**
  69862. * Represents a physics vortex event
  69863. */
  69864. class PhysicsVortexEvent {
  69865. private _scene;
  69866. private _origin;
  69867. private _options;
  69868. private _physicsEngine;
  69869. private _originTop;
  69870. private _tickCallback;
  69871. private _cylinder;
  69872. private _cylinderPosition;
  69873. private _dataFetched;
  69874. /**
  69875. * Initializes the physics vortex event
  69876. * @param _scene The BabylonJS scene
  69877. * @param _origin The origin position of the vortex
  69878. * @param _options The options for the vortex event
  69879. */
  69880. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69881. /**
  69882. * Returns the data related to the vortex event (cylinder).
  69883. * @returns The physics vortex event data
  69884. */
  69885. getData(): PhysicsVortexEventData;
  69886. /**
  69887. * Enables the vortex.
  69888. */
  69889. enable(): void;
  69890. /**
  69891. * Disables the cortex.
  69892. */
  69893. disable(): void;
  69894. /**
  69895. * Disposes the sphere.
  69896. * @param force
  69897. */
  69898. dispose(force?: boolean): void;
  69899. private getImpostorHitData;
  69900. private _tick;
  69901. /*** Helpers ***/
  69902. private _prepareCylinder;
  69903. private _intersectsWithCylinder;
  69904. }
  69905. /**
  69906. * Options fot the radial explosion event
  69907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69908. */
  69909. export class PhysicsRadialExplosionEventOptions {
  69910. /**
  69911. * The radius of the sphere for the radial explosion.
  69912. */
  69913. radius: number;
  69914. /**
  69915. * The strenth of the explosion.
  69916. */
  69917. strength: number;
  69918. /**
  69919. * The strenght of the force in correspondence to the distance of the affected object
  69920. */
  69921. falloff: PhysicsRadialImpulseFalloff;
  69922. /**
  69923. * Sphere options for the radial explosion.
  69924. */
  69925. sphere: {
  69926. segments: number;
  69927. diameter: number;
  69928. };
  69929. /**
  69930. * Sphere options for the radial explosion.
  69931. */
  69932. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69933. }
  69934. /**
  69935. * Options fot the updraft event
  69936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69937. */
  69938. export class PhysicsUpdraftEventOptions {
  69939. /**
  69940. * The radius of the cylinder for the vortex
  69941. */
  69942. radius: number;
  69943. /**
  69944. * The strenth of the updraft.
  69945. */
  69946. strength: number;
  69947. /**
  69948. * The height of the cylinder for the updraft.
  69949. */
  69950. height: number;
  69951. /**
  69952. * The mode for the the updraft.
  69953. */
  69954. updraftMode: PhysicsUpdraftMode;
  69955. }
  69956. /**
  69957. * Options fot the vortex event
  69958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69959. */
  69960. export class PhysicsVortexEventOptions {
  69961. /**
  69962. * The radius of the cylinder for the vortex
  69963. */
  69964. radius: number;
  69965. /**
  69966. * The strenth of the vortex.
  69967. */
  69968. strength: number;
  69969. /**
  69970. * The height of the cylinder for the vortex.
  69971. */
  69972. height: number;
  69973. /**
  69974. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69975. */
  69976. centripetalForceThreshold: number;
  69977. /**
  69978. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69979. */
  69980. centripetalForceMultiplier: number;
  69981. /**
  69982. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69983. */
  69984. centrifugalForceMultiplier: number;
  69985. /**
  69986. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69987. */
  69988. updraftForceMultiplier: number;
  69989. }
  69990. /**
  69991. * The strenght of the force in correspondence to the distance of the affected object
  69992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69993. */
  69994. export enum PhysicsRadialImpulseFalloff {
  69995. /** Defines that impulse is constant in strength across it's whole radius */
  69996. Constant = 0,
  69997. /** Defines that impulse gets weaker if it's further from the origin */
  69998. Linear = 1
  69999. }
  70000. /**
  70001. * The strength of the force in correspondence to the distance of the affected object
  70002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70003. */
  70004. export enum PhysicsUpdraftMode {
  70005. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70006. Center = 0,
  70007. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70008. Perpendicular = 1
  70009. }
  70010. /**
  70011. * Interface for a physics hit data
  70012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70013. */
  70014. export interface PhysicsHitData {
  70015. /**
  70016. * The force applied at the contact point
  70017. */
  70018. force: Vector3;
  70019. /**
  70020. * The contact point
  70021. */
  70022. contactPoint: Vector3;
  70023. /**
  70024. * The distance from the origin to the contact point
  70025. */
  70026. distanceFromOrigin: number;
  70027. }
  70028. /**
  70029. * Interface for radial explosion event data
  70030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70031. */
  70032. export interface PhysicsRadialExplosionEventData {
  70033. /**
  70034. * A sphere used for the radial explosion event
  70035. */
  70036. sphere: Mesh;
  70037. }
  70038. /**
  70039. * Interface for gravitational field event data
  70040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70041. */
  70042. export interface PhysicsGravitationalFieldEventData {
  70043. /**
  70044. * A sphere mesh used for the gravitational field event
  70045. */
  70046. sphere: Mesh;
  70047. }
  70048. /**
  70049. * Interface for updraft event data
  70050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70051. */
  70052. export interface PhysicsUpdraftEventData {
  70053. /**
  70054. * A cylinder used for the updraft event
  70055. */
  70056. cylinder: Mesh;
  70057. }
  70058. /**
  70059. * Interface for vortex event data
  70060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70061. */
  70062. export interface PhysicsVortexEventData {
  70063. /**
  70064. * A cylinder used for the vortex event
  70065. */
  70066. cylinder: Mesh;
  70067. }
  70068. /**
  70069. * Interface for an affected physics impostor
  70070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70071. */
  70072. export interface PhysicsAffectedImpostorWithData {
  70073. /**
  70074. * The impostor affected by the effect
  70075. */
  70076. impostor: PhysicsImpostor;
  70077. /**
  70078. * The data about the hit/horce from the explosion
  70079. */
  70080. hitData: PhysicsHitData;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /** @hidden */
  70085. export var blackAndWhitePixelShader: {
  70086. name: string;
  70087. shader: string;
  70088. };
  70089. }
  70090. declare module BABYLON {
  70091. /**
  70092. * Post process used to render in black and white
  70093. */
  70094. export class BlackAndWhitePostProcess extends PostProcess {
  70095. /**
  70096. * Linear about to convert he result to black and white (default: 1)
  70097. */
  70098. degree: number;
  70099. /**
  70100. * Gets a string identifying the name of the class
  70101. * @returns "BlackAndWhitePostProcess" string
  70102. */
  70103. getClassName(): string;
  70104. /**
  70105. * Creates a black and white post process
  70106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70107. * @param name The name of the effect.
  70108. * @param options The required width/height ratio to downsize to before computing the render pass.
  70109. * @param camera The camera to apply the render pass to.
  70110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70111. * @param engine The engine which the post process will be applied. (default: current engine)
  70112. * @param reusable If the post process can be reused on the same frame. (default: false)
  70113. */
  70114. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70115. /** @hidden */
  70116. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70117. }
  70118. }
  70119. declare module BABYLON {
  70120. /**
  70121. * This represents a set of one or more post processes in Babylon.
  70122. * A post process can be used to apply a shader to a texture after it is rendered.
  70123. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70124. */
  70125. export class PostProcessRenderEffect {
  70126. private _postProcesses;
  70127. private _getPostProcesses;
  70128. private _singleInstance;
  70129. private _cameras;
  70130. private _indicesForCamera;
  70131. /**
  70132. * Name of the effect
  70133. * @hidden
  70134. */
  70135. _name: string;
  70136. /**
  70137. * Instantiates a post process render effect.
  70138. * A post process can be used to apply a shader to a texture after it is rendered.
  70139. * @param engine The engine the effect is tied to
  70140. * @param name The name of the effect
  70141. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70142. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70143. */
  70144. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70145. /**
  70146. * Checks if all the post processes in the effect are supported.
  70147. */
  70148. get isSupported(): boolean;
  70149. /**
  70150. * Updates the current state of the effect
  70151. * @hidden
  70152. */
  70153. _update(): void;
  70154. /**
  70155. * Attaches the effect on cameras
  70156. * @param cameras The camera to attach to.
  70157. * @hidden
  70158. */
  70159. _attachCameras(cameras: Camera): void;
  70160. /**
  70161. * Attaches the effect on cameras
  70162. * @param cameras The camera to attach to.
  70163. * @hidden
  70164. */
  70165. _attachCameras(cameras: Camera[]): void;
  70166. /**
  70167. * Detaches the effect on cameras
  70168. * @param cameras The camera to detatch from.
  70169. * @hidden
  70170. */
  70171. _detachCameras(cameras: Camera): void;
  70172. /**
  70173. * Detatches the effect on cameras
  70174. * @param cameras The camera to detatch from.
  70175. * @hidden
  70176. */
  70177. _detachCameras(cameras: Camera[]): void;
  70178. /**
  70179. * Enables the effect on given cameras
  70180. * @param cameras The camera to enable.
  70181. * @hidden
  70182. */
  70183. _enable(cameras: Camera): void;
  70184. /**
  70185. * Enables the effect on given cameras
  70186. * @param cameras The camera to enable.
  70187. * @hidden
  70188. */
  70189. _enable(cameras: Nullable<Camera[]>): void;
  70190. /**
  70191. * Disables the effect on the given cameras
  70192. * @param cameras The camera to disable.
  70193. * @hidden
  70194. */
  70195. _disable(cameras: Camera): void;
  70196. /**
  70197. * Disables the effect on the given cameras
  70198. * @param cameras The camera to disable.
  70199. * @hidden
  70200. */
  70201. _disable(cameras: Nullable<Camera[]>): void;
  70202. /**
  70203. * Gets a list of the post processes contained in the effect.
  70204. * @param camera The camera to get the post processes on.
  70205. * @returns The list of the post processes in the effect.
  70206. */
  70207. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70208. }
  70209. }
  70210. declare module BABYLON {
  70211. /** @hidden */
  70212. export var extractHighlightsPixelShader: {
  70213. name: string;
  70214. shader: string;
  70215. };
  70216. }
  70217. declare module BABYLON {
  70218. /**
  70219. * 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.
  70220. */
  70221. export class ExtractHighlightsPostProcess extends PostProcess {
  70222. /**
  70223. * The luminance threshold, pixels below this value will be set to black.
  70224. */
  70225. threshold: number;
  70226. /** @hidden */
  70227. _exposure: number;
  70228. /**
  70229. * Post process which has the input texture to be used when performing highlight extraction
  70230. * @hidden
  70231. */
  70232. _inputPostProcess: Nullable<PostProcess>;
  70233. /**
  70234. * Gets a string identifying the name of the class
  70235. * @returns "ExtractHighlightsPostProcess" string
  70236. */
  70237. getClassName(): string;
  70238. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70239. }
  70240. }
  70241. declare module BABYLON {
  70242. /** @hidden */
  70243. export var bloomMergePixelShader: {
  70244. name: string;
  70245. shader: string;
  70246. };
  70247. }
  70248. declare module BABYLON {
  70249. /**
  70250. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70251. */
  70252. export class BloomMergePostProcess extends PostProcess {
  70253. /** Weight of the bloom to be added to the original input. */
  70254. weight: number;
  70255. /**
  70256. * Gets a string identifying the name of the class
  70257. * @returns "BloomMergePostProcess" string
  70258. */
  70259. getClassName(): string;
  70260. /**
  70261. * Creates a new instance of @see BloomMergePostProcess
  70262. * @param name The name of the effect.
  70263. * @param originalFromInput Post process which's input will be used for the merge.
  70264. * @param blurred Blurred highlights post process which's output will be used.
  70265. * @param weight Weight of the bloom to be added to the original input.
  70266. * @param options The required width/height ratio to downsize to before computing the render pass.
  70267. * @param camera The camera to apply the render pass to.
  70268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70269. * @param engine The engine which the post process will be applied. (default: current engine)
  70270. * @param reusable If the post process can be reused on the same frame. (default: false)
  70271. * @param textureType Type of textures used when performing the post process. (default: 0)
  70272. * @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)
  70273. */
  70274. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70275. /** Weight of the bloom to be added to the original input. */
  70276. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70277. }
  70278. }
  70279. declare module BABYLON {
  70280. /**
  70281. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70282. */
  70283. export class BloomEffect extends PostProcessRenderEffect {
  70284. private bloomScale;
  70285. /**
  70286. * @hidden Internal
  70287. */
  70288. _effects: Array<PostProcess>;
  70289. /**
  70290. * @hidden Internal
  70291. */
  70292. _downscale: ExtractHighlightsPostProcess;
  70293. private _blurX;
  70294. private _blurY;
  70295. private _merge;
  70296. /**
  70297. * The luminance threshold to find bright areas of the image to bloom.
  70298. */
  70299. get threshold(): number;
  70300. set threshold(value: number);
  70301. /**
  70302. * The strength of the bloom.
  70303. */
  70304. get weight(): number;
  70305. set weight(value: number);
  70306. /**
  70307. * Specifies the size of the bloom blur kernel, relative to the final output size
  70308. */
  70309. get kernel(): number;
  70310. set kernel(value: number);
  70311. /**
  70312. * Creates a new instance of @see BloomEffect
  70313. * @param scene The scene the effect belongs to.
  70314. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70315. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70316. * @param bloomWeight The the strength of bloom.
  70317. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70318. * @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)
  70319. */
  70320. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70321. /**
  70322. * Disposes each of the internal effects for a given camera.
  70323. * @param camera The camera to dispose the effect on.
  70324. */
  70325. disposeEffects(camera: Camera): void;
  70326. /**
  70327. * @hidden Internal
  70328. */
  70329. _updateEffects(): void;
  70330. /**
  70331. * Internal
  70332. * @returns if all the contained post processes are ready.
  70333. * @hidden
  70334. */
  70335. _isReady(): boolean;
  70336. }
  70337. }
  70338. declare module BABYLON {
  70339. /** @hidden */
  70340. export var chromaticAberrationPixelShader: {
  70341. name: string;
  70342. shader: string;
  70343. };
  70344. }
  70345. declare module BABYLON {
  70346. /**
  70347. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70348. */
  70349. export class ChromaticAberrationPostProcess extends PostProcess {
  70350. /**
  70351. * The amount of seperation of rgb channels (default: 30)
  70352. */
  70353. aberrationAmount: number;
  70354. /**
  70355. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70356. */
  70357. radialIntensity: number;
  70358. /**
  70359. * 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))
  70360. */
  70361. direction: Vector2;
  70362. /**
  70363. * 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))
  70364. */
  70365. centerPosition: Vector2;
  70366. /** The width of the screen to apply the effect on */
  70367. screenWidth: number;
  70368. /** The height of the screen to apply the effect on */
  70369. screenHeight: number;
  70370. /**
  70371. * Gets a string identifying the name of the class
  70372. * @returns "ChromaticAberrationPostProcess" string
  70373. */
  70374. getClassName(): string;
  70375. /**
  70376. * Creates a new instance ChromaticAberrationPostProcess
  70377. * @param name The name of the effect.
  70378. * @param screenWidth The width of the screen to apply the effect on.
  70379. * @param screenHeight The height of the screen to apply the effect on.
  70380. * @param options The required width/height ratio to downsize to before computing the render pass.
  70381. * @param camera The camera to apply the render pass to.
  70382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70383. * @param engine The engine which the post process will be applied. (default: current engine)
  70384. * @param reusable If the post process can be reused on the same frame. (default: false)
  70385. * @param textureType Type of textures used when performing the post process. (default: 0)
  70386. * @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)
  70387. */
  70388. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70389. /** @hidden */
  70390. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70391. }
  70392. }
  70393. declare module BABYLON {
  70394. /** @hidden */
  70395. export var circleOfConfusionPixelShader: {
  70396. name: string;
  70397. shader: string;
  70398. };
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70403. */
  70404. export class CircleOfConfusionPostProcess extends PostProcess {
  70405. /**
  70406. * 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.
  70407. */
  70408. lensSize: number;
  70409. /**
  70410. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70411. */
  70412. fStop: number;
  70413. /**
  70414. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70415. */
  70416. focusDistance: number;
  70417. /**
  70418. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70419. */
  70420. focalLength: number;
  70421. /**
  70422. * Gets a string identifying the name of the class
  70423. * @returns "CircleOfConfusionPostProcess" string
  70424. */
  70425. getClassName(): string;
  70426. private _depthTexture;
  70427. /**
  70428. * Creates a new instance CircleOfConfusionPostProcess
  70429. * @param name The name of the effect.
  70430. * @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.
  70431. * @param options The required width/height ratio to downsize to before computing the render pass.
  70432. * @param camera The camera to apply the render pass to.
  70433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70434. * @param engine The engine which the post process will be applied. (default: current engine)
  70435. * @param reusable If the post process can be reused on the same frame. (default: false)
  70436. * @param textureType Type of textures used when performing the post process. (default: 0)
  70437. * @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)
  70438. */
  70439. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70440. /**
  70441. * 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.
  70442. */
  70443. set depthTexture(value: RenderTargetTexture);
  70444. }
  70445. }
  70446. declare module BABYLON {
  70447. /** @hidden */
  70448. export var colorCorrectionPixelShader: {
  70449. name: string;
  70450. shader: string;
  70451. };
  70452. }
  70453. declare module BABYLON {
  70454. /**
  70455. *
  70456. * This post-process allows the modification of rendered colors by using
  70457. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70458. *
  70459. * The object needs to be provided an url to a texture containing the color
  70460. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70461. * Use an image editing software to tweak the LUT to match your needs.
  70462. *
  70463. * For an example of a color LUT, see here:
  70464. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70465. * For explanations on color grading, see here:
  70466. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70467. *
  70468. */
  70469. export class ColorCorrectionPostProcess extends PostProcess {
  70470. private _colorTableTexture;
  70471. /**
  70472. * Gets the color table url used to create the LUT texture
  70473. */
  70474. colorTableUrl: string;
  70475. /**
  70476. * Gets a string identifying the name of the class
  70477. * @returns "ColorCorrectionPostProcess" string
  70478. */
  70479. getClassName(): string;
  70480. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70481. /** @hidden */
  70482. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70483. }
  70484. }
  70485. declare module BABYLON {
  70486. /** @hidden */
  70487. export var convolutionPixelShader: {
  70488. name: string;
  70489. shader: string;
  70490. };
  70491. }
  70492. declare module BABYLON {
  70493. /**
  70494. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70495. * input texture to perform effects such as edge detection or sharpening
  70496. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70497. */
  70498. export class ConvolutionPostProcess extends PostProcess {
  70499. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70500. kernel: number[];
  70501. /**
  70502. * Gets a string identifying the name of the class
  70503. * @returns "ConvolutionPostProcess" string
  70504. */
  70505. getClassName(): string;
  70506. /**
  70507. * Creates a new instance ConvolutionPostProcess
  70508. * @param name The name of the effect.
  70509. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70510. * @param options The required width/height ratio to downsize to before computing the render pass.
  70511. * @param camera The camera to apply the render pass to.
  70512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70513. * @param engine The engine which the post process will be applied. (default: current engine)
  70514. * @param reusable If the post process can be reused on the same frame. (default: false)
  70515. * @param textureType Type of textures used when performing the post process. (default: 0)
  70516. */
  70517. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70518. /** @hidden */
  70519. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70520. /**
  70521. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70522. */
  70523. static EdgeDetect0Kernel: number[];
  70524. /**
  70525. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70526. */
  70527. static EdgeDetect1Kernel: number[];
  70528. /**
  70529. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70530. */
  70531. static EdgeDetect2Kernel: number[];
  70532. /**
  70533. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70534. */
  70535. static SharpenKernel: number[];
  70536. /**
  70537. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70538. */
  70539. static EmbossKernel: number[];
  70540. /**
  70541. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70542. */
  70543. static GaussianKernel: number[];
  70544. }
  70545. }
  70546. declare module BABYLON {
  70547. /**
  70548. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70549. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70550. * based on samples that have a large difference in distance than the center pixel.
  70551. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70552. */
  70553. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70554. /**
  70555. * The direction the blur should be applied
  70556. */
  70557. direction: Vector2;
  70558. /**
  70559. * Gets a string identifying the name of the class
  70560. * @returns "DepthOfFieldBlurPostProcess" string
  70561. */
  70562. getClassName(): string;
  70563. /**
  70564. * Creates a new instance CircleOfConfusionPostProcess
  70565. * @param name The name of the effect.
  70566. * @param scene The scene the effect belongs to.
  70567. * @param direction The direction the blur should be applied.
  70568. * @param kernel The size of the kernel used to blur.
  70569. * @param options The required width/height ratio to downsize to before computing the render pass.
  70570. * @param camera The camera to apply the render pass to.
  70571. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70572. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70574. * @param engine The engine which the post process will be applied. (default: current engine)
  70575. * @param reusable If the post process can be reused on the same frame. (default: false)
  70576. * @param textureType Type of textures used when performing the post process. (default: 0)
  70577. * @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)
  70578. */
  70579. 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);
  70580. }
  70581. }
  70582. declare module BABYLON {
  70583. /** @hidden */
  70584. export var depthOfFieldMergePixelShader: {
  70585. name: string;
  70586. shader: string;
  70587. };
  70588. }
  70589. declare module BABYLON {
  70590. /**
  70591. * Options to be set when merging outputs from the default pipeline.
  70592. */
  70593. export class DepthOfFieldMergePostProcessOptions {
  70594. /**
  70595. * The original image to merge on top of
  70596. */
  70597. originalFromInput: PostProcess;
  70598. /**
  70599. * Parameters to perform the merge of the depth of field effect
  70600. */
  70601. depthOfField?: {
  70602. circleOfConfusion: PostProcess;
  70603. blurSteps: Array<PostProcess>;
  70604. };
  70605. /**
  70606. * Parameters to perform the merge of bloom effect
  70607. */
  70608. bloom?: {
  70609. blurred: PostProcess;
  70610. weight: number;
  70611. };
  70612. }
  70613. /**
  70614. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70615. */
  70616. export class DepthOfFieldMergePostProcess extends PostProcess {
  70617. private blurSteps;
  70618. /**
  70619. * Gets a string identifying the name of the class
  70620. * @returns "DepthOfFieldMergePostProcess" string
  70621. */
  70622. getClassName(): string;
  70623. /**
  70624. * Creates a new instance of DepthOfFieldMergePostProcess
  70625. * @param name The name of the effect.
  70626. * @param originalFromInput Post process which's input will be used for the merge.
  70627. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70628. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70629. * @param options The required width/height ratio to downsize to before computing the render pass.
  70630. * @param camera The camera to apply the render pass to.
  70631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70632. * @param engine The engine which the post process will be applied. (default: current engine)
  70633. * @param reusable If the post process can be reused on the same frame. (default: false)
  70634. * @param textureType Type of textures used when performing the post process. (default: 0)
  70635. * @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)
  70636. */
  70637. 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);
  70638. /**
  70639. * Updates the effect with the current post process compile time values and recompiles the shader.
  70640. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70641. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70642. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70643. * @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
  70644. * @param onCompiled Called when the shader has been compiled.
  70645. * @param onError Called if there is an error when compiling a shader.
  70646. */
  70647. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70648. }
  70649. }
  70650. declare module BABYLON {
  70651. /**
  70652. * Specifies the level of max blur that should be applied when using the depth of field effect
  70653. */
  70654. export enum DepthOfFieldEffectBlurLevel {
  70655. /**
  70656. * Subtle blur
  70657. */
  70658. Low = 0,
  70659. /**
  70660. * Medium blur
  70661. */
  70662. Medium = 1,
  70663. /**
  70664. * Large blur
  70665. */
  70666. High = 2
  70667. }
  70668. /**
  70669. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70670. */
  70671. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70672. private _circleOfConfusion;
  70673. /**
  70674. * @hidden Internal, blurs from high to low
  70675. */
  70676. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70677. private _depthOfFieldBlurY;
  70678. private _dofMerge;
  70679. /**
  70680. * @hidden Internal post processes in depth of field effect
  70681. */
  70682. _effects: Array<PostProcess>;
  70683. /**
  70684. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70685. */
  70686. set focalLength(value: number);
  70687. get focalLength(): number;
  70688. /**
  70689. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70690. */
  70691. set fStop(value: number);
  70692. get fStop(): number;
  70693. /**
  70694. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70695. */
  70696. set focusDistance(value: number);
  70697. get focusDistance(): number;
  70698. /**
  70699. * 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.
  70700. */
  70701. set lensSize(value: number);
  70702. get lensSize(): number;
  70703. /**
  70704. * Creates a new instance DepthOfFieldEffect
  70705. * @param scene The scene the effect belongs to.
  70706. * @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.
  70707. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70708. * @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)
  70709. */
  70710. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70711. /**
  70712. * Get the current class name of the current effet
  70713. * @returns "DepthOfFieldEffect"
  70714. */
  70715. getClassName(): string;
  70716. /**
  70717. * 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.
  70718. */
  70719. set depthTexture(value: RenderTargetTexture);
  70720. /**
  70721. * Disposes each of the internal effects for a given camera.
  70722. * @param camera The camera to dispose the effect on.
  70723. */
  70724. disposeEffects(camera: Camera): void;
  70725. /**
  70726. * @hidden Internal
  70727. */
  70728. _updateEffects(): void;
  70729. /**
  70730. * Internal
  70731. * @returns if all the contained post processes are ready.
  70732. * @hidden
  70733. */
  70734. _isReady(): boolean;
  70735. }
  70736. }
  70737. declare module BABYLON {
  70738. /** @hidden */
  70739. export var displayPassPixelShader: {
  70740. name: string;
  70741. shader: string;
  70742. };
  70743. }
  70744. declare module BABYLON {
  70745. /**
  70746. * DisplayPassPostProcess which produces an output the same as it's input
  70747. */
  70748. export class DisplayPassPostProcess extends PostProcess {
  70749. /**
  70750. * Gets a string identifying the name of the class
  70751. * @returns "DisplayPassPostProcess" string
  70752. */
  70753. getClassName(): string;
  70754. /**
  70755. * Creates the DisplayPassPostProcess
  70756. * @param name The name of the effect.
  70757. * @param options The required width/height ratio to downsize to before computing the render pass.
  70758. * @param camera The camera to apply the render pass to.
  70759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70760. * @param engine The engine which the post process will be applied. (default: current engine)
  70761. * @param reusable If the post process can be reused on the same frame. (default: false)
  70762. */
  70763. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70764. /** @hidden */
  70765. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70766. }
  70767. }
  70768. declare module BABYLON {
  70769. /** @hidden */
  70770. export var filterPixelShader: {
  70771. name: string;
  70772. shader: string;
  70773. };
  70774. }
  70775. declare module BABYLON {
  70776. /**
  70777. * Applies a kernel filter to the image
  70778. */
  70779. export class FilterPostProcess extends PostProcess {
  70780. /** The matrix to be applied to the image */
  70781. kernelMatrix: Matrix;
  70782. /**
  70783. * Gets a string identifying the name of the class
  70784. * @returns "FilterPostProcess" string
  70785. */
  70786. getClassName(): string;
  70787. /**
  70788. *
  70789. * @param name The name of the effect.
  70790. * @param kernelMatrix The matrix to be applied to the image
  70791. * @param options The required width/height ratio to downsize to before computing the render pass.
  70792. * @param camera The camera to apply the render pass to.
  70793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70794. * @param engine The engine which the post process will be applied. (default: current engine)
  70795. * @param reusable If the post process can be reused on the same frame. (default: false)
  70796. */
  70797. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70798. /** @hidden */
  70799. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70800. }
  70801. }
  70802. declare module BABYLON {
  70803. /** @hidden */
  70804. export var fxaaPixelShader: {
  70805. name: string;
  70806. shader: string;
  70807. };
  70808. }
  70809. declare module BABYLON {
  70810. /** @hidden */
  70811. export var fxaaVertexShader: {
  70812. name: string;
  70813. shader: string;
  70814. };
  70815. }
  70816. declare module BABYLON {
  70817. /**
  70818. * Fxaa post process
  70819. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70820. */
  70821. export class FxaaPostProcess extends PostProcess {
  70822. /**
  70823. * Gets a string identifying the name of the class
  70824. * @returns "FxaaPostProcess" string
  70825. */
  70826. getClassName(): string;
  70827. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70828. private _getDefines;
  70829. /** @hidden */
  70830. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70831. }
  70832. }
  70833. declare module BABYLON {
  70834. /** @hidden */
  70835. export var grainPixelShader: {
  70836. name: string;
  70837. shader: string;
  70838. };
  70839. }
  70840. declare module BABYLON {
  70841. /**
  70842. * The GrainPostProcess adds noise to the image at mid luminance levels
  70843. */
  70844. export class GrainPostProcess extends PostProcess {
  70845. /**
  70846. * The intensity of the grain added (default: 30)
  70847. */
  70848. intensity: number;
  70849. /**
  70850. * If the grain should be randomized on every frame
  70851. */
  70852. animated: boolean;
  70853. /**
  70854. * Gets a string identifying the name of the class
  70855. * @returns "GrainPostProcess" string
  70856. */
  70857. getClassName(): string;
  70858. /**
  70859. * Creates a new instance of @see GrainPostProcess
  70860. * @param name The name of the effect.
  70861. * @param options The required width/height ratio to downsize to before computing the render pass.
  70862. * @param camera The camera to apply the render pass to.
  70863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70864. * @param engine The engine which the post process will be applied. (default: current engine)
  70865. * @param reusable If the post process can be reused on the same frame. (default: false)
  70866. * @param textureType Type of textures used when performing the post process. (default: 0)
  70867. * @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)
  70868. */
  70869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70870. /** @hidden */
  70871. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70872. }
  70873. }
  70874. declare module BABYLON {
  70875. /** @hidden */
  70876. export var highlightsPixelShader: {
  70877. name: string;
  70878. shader: string;
  70879. };
  70880. }
  70881. declare module BABYLON {
  70882. /**
  70883. * Extracts highlights from the image
  70884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70885. */
  70886. export class HighlightsPostProcess extends PostProcess {
  70887. /**
  70888. * Gets a string identifying the name of the class
  70889. * @returns "HighlightsPostProcess" string
  70890. */
  70891. getClassName(): string;
  70892. /**
  70893. * Extracts highlights from the image
  70894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70895. * @param name The name of the effect.
  70896. * @param options The required width/height ratio to downsize to before computing the render pass.
  70897. * @param camera The camera to apply the render pass to.
  70898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70899. * @param engine The engine which the post process will be applied. (default: current engine)
  70900. * @param reusable If the post process can be reused on the same frame. (default: false)
  70901. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70902. */
  70903. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70904. }
  70905. }
  70906. declare module BABYLON {
  70907. /**
  70908. * Contains all parameters needed for the prepass to perform
  70909. * motion blur
  70910. */
  70911. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70912. /**
  70913. * Is motion blur enabled
  70914. */
  70915. enabled: boolean;
  70916. /**
  70917. * Name of the configuration
  70918. */
  70919. name: string;
  70920. /**
  70921. * Textures that should be present in the MRT for this effect to work
  70922. */
  70923. readonly texturesRequired: number[];
  70924. }
  70925. }
  70926. declare module BABYLON {
  70927. interface Scene {
  70928. /** @hidden (Backing field) */
  70929. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70930. /**
  70931. * Gets or Sets the current geometry buffer associated to the scene.
  70932. */
  70933. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70934. /**
  70935. * Enables a GeometryBufferRender and associates it with the scene
  70936. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70937. * @returns the GeometryBufferRenderer
  70938. */
  70939. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70940. /**
  70941. * Disables the GeometryBufferRender associated with the scene
  70942. */
  70943. disableGeometryBufferRenderer(): void;
  70944. }
  70945. /**
  70946. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70947. * in several rendering techniques.
  70948. */
  70949. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70950. /**
  70951. * The component name helpful to identify the component in the list of scene components.
  70952. */
  70953. readonly name: string;
  70954. /**
  70955. * The scene the component belongs to.
  70956. */
  70957. scene: Scene;
  70958. /**
  70959. * Creates a new instance of the component for the given scene
  70960. * @param scene Defines the scene to register the component in
  70961. */
  70962. constructor(scene: Scene);
  70963. /**
  70964. * Registers the component in a given scene
  70965. */
  70966. register(): void;
  70967. /**
  70968. * Rebuilds the elements related to this component in case of
  70969. * context lost for instance.
  70970. */
  70971. rebuild(): void;
  70972. /**
  70973. * Disposes the component and the associated ressources
  70974. */
  70975. dispose(): void;
  70976. private _gatherRenderTargets;
  70977. }
  70978. }
  70979. declare module BABYLON {
  70980. /** @hidden */
  70981. export var motionBlurPixelShader: {
  70982. name: string;
  70983. shader: string;
  70984. };
  70985. }
  70986. declare module BABYLON {
  70987. /**
  70988. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70989. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70990. * As an example, all you have to do is to create the post-process:
  70991. * var mb = new BABYLON.MotionBlurPostProcess(
  70992. * 'mb', // The name of the effect.
  70993. * scene, // The scene containing the objects to blur according to their velocity.
  70994. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70995. * camera // The camera to apply the render pass to.
  70996. * );
  70997. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70998. */
  70999. export class MotionBlurPostProcess extends PostProcess {
  71000. /**
  71001. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71002. */
  71003. motionStrength: number;
  71004. /**
  71005. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71006. */
  71007. get motionBlurSamples(): number;
  71008. /**
  71009. * Sets the number of iterations to be used for motion blur quality
  71010. */
  71011. set motionBlurSamples(samples: number);
  71012. private _motionBlurSamples;
  71013. private _forceGeometryBuffer;
  71014. private _geometryBufferRenderer;
  71015. private _prePassRenderer;
  71016. /**
  71017. * Gets a string identifying the name of the class
  71018. * @returns "MotionBlurPostProcess" string
  71019. */
  71020. getClassName(): string;
  71021. /**
  71022. * Creates a new instance MotionBlurPostProcess
  71023. * @param name The name of the effect.
  71024. * @param scene The scene containing the objects to blur according to their velocity.
  71025. * @param options The required width/height ratio to downsize to before computing the render pass.
  71026. * @param camera The camera to apply the render pass to.
  71027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71028. * @param engine The engine which the post process will be applied. (default: current engine)
  71029. * @param reusable If the post process can be reused on the same frame. (default: false)
  71030. * @param textureType Type of textures used when performing the post process. (default: 0)
  71031. * @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)
  71032. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71033. */
  71034. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71035. /**
  71036. * Excludes the given skinned mesh from computing bones velocities.
  71037. * 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.
  71038. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71039. */
  71040. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71041. /**
  71042. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71043. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71044. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71045. */
  71046. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71047. /**
  71048. * Disposes the post process.
  71049. * @param camera The camera to dispose the post process on.
  71050. */
  71051. dispose(camera?: Camera): void;
  71052. /** @hidden */
  71053. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71054. }
  71055. }
  71056. declare module BABYLON {
  71057. /** @hidden */
  71058. export var refractionPixelShader: {
  71059. name: string;
  71060. shader: string;
  71061. };
  71062. }
  71063. declare module BABYLON {
  71064. /**
  71065. * Post process which applies a refractin texture
  71066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71067. */
  71068. export class RefractionPostProcess extends PostProcess {
  71069. private _refTexture;
  71070. private _ownRefractionTexture;
  71071. /** the base color of the refraction (used to taint the rendering) */
  71072. color: Color3;
  71073. /** simulated refraction depth */
  71074. depth: number;
  71075. /** the coefficient of the base color (0 to remove base color tainting) */
  71076. colorLevel: number;
  71077. /** Gets the url used to load the refraction texture */
  71078. refractionTextureUrl: string;
  71079. /**
  71080. * Gets or sets the refraction texture
  71081. * Please note that you are responsible for disposing the texture if you set it manually
  71082. */
  71083. get refractionTexture(): Texture;
  71084. set refractionTexture(value: Texture);
  71085. /**
  71086. * Gets a string identifying the name of the class
  71087. * @returns "RefractionPostProcess" string
  71088. */
  71089. getClassName(): string;
  71090. /**
  71091. * Initializes the RefractionPostProcess
  71092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71093. * @param name The name of the effect.
  71094. * @param refractionTextureUrl Url of the refraction texture to use
  71095. * @param color the base color of the refraction (used to taint the rendering)
  71096. * @param depth simulated refraction depth
  71097. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71098. * @param camera The camera to apply the render pass to.
  71099. * @param options The required width/height ratio to downsize to before computing the render pass.
  71100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71101. * @param engine The engine which the post process will be applied. (default: current engine)
  71102. * @param reusable If the post process can be reused on the same frame. (default: false)
  71103. */
  71104. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71105. /**
  71106. * Disposes of the post process
  71107. * @param camera Camera to dispose post process on
  71108. */
  71109. dispose(camera: Camera): void;
  71110. /** @hidden */
  71111. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71112. }
  71113. }
  71114. declare module BABYLON {
  71115. /** @hidden */
  71116. export var sharpenPixelShader: {
  71117. name: string;
  71118. shader: string;
  71119. };
  71120. }
  71121. declare module BABYLON {
  71122. /**
  71123. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71125. */
  71126. export class SharpenPostProcess extends PostProcess {
  71127. /**
  71128. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71129. */
  71130. colorAmount: number;
  71131. /**
  71132. * How much sharpness should be applied (default: 0.3)
  71133. */
  71134. edgeAmount: number;
  71135. /**
  71136. * Gets a string identifying the name of the class
  71137. * @returns "SharpenPostProcess" string
  71138. */
  71139. getClassName(): string;
  71140. /**
  71141. * Creates a new instance ConvolutionPostProcess
  71142. * @param name The name of the effect.
  71143. * @param options The required width/height ratio to downsize to before computing the render pass.
  71144. * @param camera The camera to apply the render pass to.
  71145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71146. * @param engine The engine which the post process will be applied. (default: current engine)
  71147. * @param reusable If the post process can be reused on the same frame. (default: false)
  71148. * @param textureType Type of textures used when performing the post process. (default: 0)
  71149. * @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)
  71150. */
  71151. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71152. /** @hidden */
  71153. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71154. }
  71155. }
  71156. declare module BABYLON {
  71157. /**
  71158. * PostProcessRenderPipeline
  71159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71160. */
  71161. export class PostProcessRenderPipeline {
  71162. private engine;
  71163. private _renderEffects;
  71164. private _renderEffectsForIsolatedPass;
  71165. /**
  71166. * List of inspectable custom properties (used by the Inspector)
  71167. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71168. */
  71169. inspectableCustomProperties: IInspectable[];
  71170. /**
  71171. * @hidden
  71172. */
  71173. protected _cameras: Camera[];
  71174. /** @hidden */
  71175. _name: string;
  71176. /**
  71177. * Gets pipeline name
  71178. */
  71179. get name(): string;
  71180. /** Gets the list of attached cameras */
  71181. get cameras(): Camera[];
  71182. /**
  71183. * Initializes a PostProcessRenderPipeline
  71184. * @param engine engine to add the pipeline to
  71185. * @param name name of the pipeline
  71186. */
  71187. constructor(engine: Engine, name: string);
  71188. /**
  71189. * Gets the class name
  71190. * @returns "PostProcessRenderPipeline"
  71191. */
  71192. getClassName(): string;
  71193. /**
  71194. * If all the render effects in the pipeline are supported
  71195. */
  71196. get isSupported(): boolean;
  71197. /**
  71198. * Adds an effect to the pipeline
  71199. * @param renderEffect the effect to add
  71200. */
  71201. addEffect(renderEffect: PostProcessRenderEffect): void;
  71202. /** @hidden */
  71203. _rebuild(): void;
  71204. /** @hidden */
  71205. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71206. /** @hidden */
  71207. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71208. /** @hidden */
  71209. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71210. /** @hidden */
  71211. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71212. /** @hidden */
  71213. _attachCameras(cameras: Camera, unique: boolean): void;
  71214. /** @hidden */
  71215. _attachCameras(cameras: Camera[], unique: boolean): void;
  71216. /** @hidden */
  71217. _detachCameras(cameras: Camera): void;
  71218. /** @hidden */
  71219. _detachCameras(cameras: Nullable<Camera[]>): void;
  71220. /** @hidden */
  71221. _update(): void;
  71222. /** @hidden */
  71223. _reset(): void;
  71224. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71225. /**
  71226. * Sets the required values to the prepass renderer.
  71227. * @param prePassRenderer defines the prepass renderer to setup.
  71228. * @returns true if the pre pass is needed.
  71229. */
  71230. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71231. /**
  71232. * Disposes of the pipeline
  71233. */
  71234. dispose(): void;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * PostProcessRenderPipelineManager class
  71240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71241. */
  71242. export class PostProcessRenderPipelineManager {
  71243. private _renderPipelines;
  71244. /**
  71245. * Initializes a PostProcessRenderPipelineManager
  71246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71247. */
  71248. constructor();
  71249. /**
  71250. * Gets the list of supported render pipelines
  71251. */
  71252. get supportedPipelines(): PostProcessRenderPipeline[];
  71253. /**
  71254. * Adds a pipeline to the manager
  71255. * @param renderPipeline The pipeline to add
  71256. */
  71257. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71258. /**
  71259. * Attaches a camera to the pipeline
  71260. * @param renderPipelineName The name of the pipeline to attach to
  71261. * @param cameras the camera to attach
  71262. * @param unique if the camera can be attached multiple times to the pipeline
  71263. */
  71264. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71265. /**
  71266. * Detaches a camera from the pipeline
  71267. * @param renderPipelineName The name of the pipeline to detach from
  71268. * @param cameras the camera to detach
  71269. */
  71270. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71271. /**
  71272. * Enables an effect by name on a pipeline
  71273. * @param renderPipelineName the name of the pipeline to enable the effect in
  71274. * @param renderEffectName the name of the effect to enable
  71275. * @param cameras the cameras that the effect should be enabled on
  71276. */
  71277. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71278. /**
  71279. * Disables an effect by name on a pipeline
  71280. * @param renderPipelineName the name of the pipeline to disable the effect in
  71281. * @param renderEffectName the name of the effect to disable
  71282. * @param cameras the cameras that the effect should be disabled on
  71283. */
  71284. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71285. /**
  71286. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71287. */
  71288. update(): void;
  71289. /** @hidden */
  71290. _rebuild(): void;
  71291. /**
  71292. * Disposes of the manager and pipelines
  71293. */
  71294. dispose(): void;
  71295. }
  71296. }
  71297. declare module BABYLON {
  71298. interface Scene {
  71299. /** @hidden (Backing field) */
  71300. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71301. /**
  71302. * Gets the postprocess render pipeline manager
  71303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71304. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71305. */
  71306. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71307. }
  71308. /**
  71309. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71310. */
  71311. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71312. /**
  71313. * The component name helpfull to identify the component in the list of scene components.
  71314. */
  71315. readonly name: string;
  71316. /**
  71317. * The scene the component belongs to.
  71318. */
  71319. scene: Scene;
  71320. /**
  71321. * Creates a new instance of the component for the given scene
  71322. * @param scene Defines the scene to register the component in
  71323. */
  71324. constructor(scene: Scene);
  71325. /**
  71326. * Registers the component in a given scene
  71327. */
  71328. register(): void;
  71329. /**
  71330. * Rebuilds the elements related to this component in case of
  71331. * context lost for instance.
  71332. */
  71333. rebuild(): void;
  71334. /**
  71335. * Disposes the component and the associated ressources
  71336. */
  71337. dispose(): void;
  71338. private _gatherRenderTargets;
  71339. }
  71340. }
  71341. declare module BABYLON {
  71342. /**
  71343. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71344. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71345. */
  71346. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71347. private _scene;
  71348. private _camerasToBeAttached;
  71349. /**
  71350. * ID of the sharpen post process,
  71351. */
  71352. private readonly SharpenPostProcessId;
  71353. /**
  71354. * @ignore
  71355. * ID of the image processing post process;
  71356. */
  71357. readonly ImageProcessingPostProcessId: string;
  71358. /**
  71359. * @ignore
  71360. * ID of the Fast Approximate Anti-Aliasing post process;
  71361. */
  71362. readonly FxaaPostProcessId: string;
  71363. /**
  71364. * ID of the chromatic aberration post process,
  71365. */
  71366. private readonly ChromaticAberrationPostProcessId;
  71367. /**
  71368. * ID of the grain post process
  71369. */
  71370. private readonly GrainPostProcessId;
  71371. /**
  71372. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71373. */
  71374. sharpen: SharpenPostProcess;
  71375. private _sharpenEffect;
  71376. private bloom;
  71377. /**
  71378. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71379. */
  71380. depthOfField: DepthOfFieldEffect;
  71381. /**
  71382. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71383. */
  71384. fxaa: FxaaPostProcess;
  71385. /**
  71386. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71387. */
  71388. imageProcessing: ImageProcessingPostProcess;
  71389. /**
  71390. * Chromatic aberration post process which will shift rgb colors in the image
  71391. */
  71392. chromaticAberration: ChromaticAberrationPostProcess;
  71393. private _chromaticAberrationEffect;
  71394. /**
  71395. * Grain post process which add noise to the image
  71396. */
  71397. grain: GrainPostProcess;
  71398. private _grainEffect;
  71399. /**
  71400. * Glow post process which adds a glow to emissive areas of the image
  71401. */
  71402. private _glowLayer;
  71403. /**
  71404. * Animations which can be used to tweak settings over a period of time
  71405. */
  71406. animations: Animation[];
  71407. private _imageProcessingConfigurationObserver;
  71408. private _sharpenEnabled;
  71409. private _bloomEnabled;
  71410. private _depthOfFieldEnabled;
  71411. private _depthOfFieldBlurLevel;
  71412. private _fxaaEnabled;
  71413. private _imageProcessingEnabled;
  71414. private _defaultPipelineTextureType;
  71415. private _bloomScale;
  71416. private _chromaticAberrationEnabled;
  71417. private _grainEnabled;
  71418. private _buildAllowed;
  71419. /**
  71420. * Gets active scene
  71421. */
  71422. get scene(): Scene;
  71423. /**
  71424. * Enable or disable the sharpen process from the pipeline
  71425. */
  71426. set sharpenEnabled(enabled: boolean);
  71427. get sharpenEnabled(): boolean;
  71428. private _resizeObserver;
  71429. private _hardwareScaleLevel;
  71430. private _bloomKernel;
  71431. /**
  71432. * Specifies the size of the bloom blur kernel, relative to the final output size
  71433. */
  71434. get bloomKernel(): number;
  71435. set bloomKernel(value: number);
  71436. /**
  71437. * Specifies the weight of the bloom in the final rendering
  71438. */
  71439. private _bloomWeight;
  71440. /**
  71441. * Specifies the luma threshold for the area that will be blurred by the bloom
  71442. */
  71443. private _bloomThreshold;
  71444. private _hdr;
  71445. /**
  71446. * The strength of the bloom.
  71447. */
  71448. set bloomWeight(value: number);
  71449. get bloomWeight(): number;
  71450. /**
  71451. * The strength of the bloom.
  71452. */
  71453. set bloomThreshold(value: number);
  71454. get bloomThreshold(): number;
  71455. /**
  71456. * The scale of the bloom, lower value will provide better performance.
  71457. */
  71458. set bloomScale(value: number);
  71459. get bloomScale(): number;
  71460. /**
  71461. * Enable or disable the bloom from the pipeline
  71462. */
  71463. set bloomEnabled(enabled: boolean);
  71464. get bloomEnabled(): boolean;
  71465. private _rebuildBloom;
  71466. /**
  71467. * If the depth of field is enabled.
  71468. */
  71469. get depthOfFieldEnabled(): boolean;
  71470. set depthOfFieldEnabled(enabled: boolean);
  71471. /**
  71472. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71473. */
  71474. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71475. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71476. /**
  71477. * If the anti aliasing is enabled.
  71478. */
  71479. set fxaaEnabled(enabled: boolean);
  71480. get fxaaEnabled(): boolean;
  71481. private _samples;
  71482. /**
  71483. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71484. */
  71485. set samples(sampleCount: number);
  71486. get samples(): number;
  71487. /**
  71488. * If image processing is enabled.
  71489. */
  71490. set imageProcessingEnabled(enabled: boolean);
  71491. get imageProcessingEnabled(): boolean;
  71492. /**
  71493. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71494. */
  71495. set glowLayerEnabled(enabled: boolean);
  71496. get glowLayerEnabled(): boolean;
  71497. /**
  71498. * Gets the glow layer (or null if not defined)
  71499. */
  71500. get glowLayer(): Nullable<GlowLayer>;
  71501. /**
  71502. * Enable or disable the chromaticAberration process from the pipeline
  71503. */
  71504. set chromaticAberrationEnabled(enabled: boolean);
  71505. get chromaticAberrationEnabled(): boolean;
  71506. /**
  71507. * Enable or disable the grain process from the pipeline
  71508. */
  71509. set grainEnabled(enabled: boolean);
  71510. get grainEnabled(): boolean;
  71511. /**
  71512. * @constructor
  71513. * @param name - The rendering pipeline name (default: "")
  71514. * @param hdr - If high dynamic range textures should be used (default: true)
  71515. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71516. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71517. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71518. */
  71519. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71520. /**
  71521. * Get the class name
  71522. * @returns "DefaultRenderingPipeline"
  71523. */
  71524. getClassName(): string;
  71525. /**
  71526. * Force the compilation of the entire pipeline.
  71527. */
  71528. prepare(): void;
  71529. private _hasCleared;
  71530. private _prevPostProcess;
  71531. private _prevPrevPostProcess;
  71532. private _setAutoClearAndTextureSharing;
  71533. private _depthOfFieldSceneObserver;
  71534. private _buildPipeline;
  71535. private _disposePostProcesses;
  71536. /**
  71537. * Adds a camera to the pipeline
  71538. * @param camera the camera to be added
  71539. */
  71540. addCamera(camera: Camera): void;
  71541. /**
  71542. * Removes a camera from the pipeline
  71543. * @param camera the camera to remove
  71544. */
  71545. removeCamera(camera: Camera): void;
  71546. /**
  71547. * Dispose of the pipeline and stop all post processes
  71548. */
  71549. dispose(): void;
  71550. /**
  71551. * Serialize the rendering pipeline (Used when exporting)
  71552. * @returns the serialized object
  71553. */
  71554. serialize(): any;
  71555. /**
  71556. * Parse the serialized pipeline
  71557. * @param source Source pipeline.
  71558. * @param scene The scene to load the pipeline to.
  71559. * @param rootUrl The URL of the serialized pipeline.
  71560. * @returns An instantiated pipeline from the serialized object.
  71561. */
  71562. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71563. }
  71564. }
  71565. declare module BABYLON {
  71566. /** @hidden */
  71567. export var lensHighlightsPixelShader: {
  71568. name: string;
  71569. shader: string;
  71570. };
  71571. }
  71572. declare module BABYLON {
  71573. /** @hidden */
  71574. export var depthOfFieldPixelShader: {
  71575. name: string;
  71576. shader: string;
  71577. };
  71578. }
  71579. declare module BABYLON {
  71580. /**
  71581. * BABYLON.JS Chromatic Aberration GLSL Shader
  71582. * Author: Olivier Guyot
  71583. * Separates very slightly R, G and B colors on the edges of the screen
  71584. * Inspired by Francois Tarlier & Martins Upitis
  71585. */
  71586. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71587. /**
  71588. * @ignore
  71589. * The chromatic aberration PostProcess id in the pipeline
  71590. */
  71591. LensChromaticAberrationEffect: string;
  71592. /**
  71593. * @ignore
  71594. * The highlights enhancing PostProcess id in the pipeline
  71595. */
  71596. HighlightsEnhancingEffect: string;
  71597. /**
  71598. * @ignore
  71599. * The depth-of-field PostProcess id in the pipeline
  71600. */
  71601. LensDepthOfFieldEffect: string;
  71602. private _scene;
  71603. private _depthTexture;
  71604. private _grainTexture;
  71605. private _chromaticAberrationPostProcess;
  71606. private _highlightsPostProcess;
  71607. private _depthOfFieldPostProcess;
  71608. private _edgeBlur;
  71609. private _grainAmount;
  71610. private _chromaticAberration;
  71611. private _distortion;
  71612. private _highlightsGain;
  71613. private _highlightsThreshold;
  71614. private _dofDistance;
  71615. private _dofAperture;
  71616. private _dofDarken;
  71617. private _dofPentagon;
  71618. private _blurNoise;
  71619. /**
  71620. * @constructor
  71621. *
  71622. * Effect parameters are as follow:
  71623. * {
  71624. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71625. * edge_blur: number; // from 0 to x (1 for realism)
  71626. * distortion: number; // from 0 to x (1 for realism)
  71627. * grain_amount: number; // from 0 to 1
  71628. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71629. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71630. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71631. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71632. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71633. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71634. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71635. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71636. * }
  71637. * Note: if an effect parameter is unset, effect is disabled
  71638. *
  71639. * @param name The rendering pipeline name
  71640. * @param parameters - An object containing all parameters (see above)
  71641. * @param scene The scene linked to this pipeline
  71642. * @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)
  71643. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71644. */
  71645. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71646. /**
  71647. * Get the class name
  71648. * @returns "LensRenderingPipeline"
  71649. */
  71650. getClassName(): string;
  71651. /**
  71652. * Gets associated scene
  71653. */
  71654. get scene(): Scene;
  71655. /**
  71656. * Gets or sets the edge blur
  71657. */
  71658. get edgeBlur(): number;
  71659. set edgeBlur(value: number);
  71660. /**
  71661. * Gets or sets the grain amount
  71662. */
  71663. get grainAmount(): number;
  71664. set grainAmount(value: number);
  71665. /**
  71666. * Gets or sets the chromatic aberration amount
  71667. */
  71668. get chromaticAberration(): number;
  71669. set chromaticAberration(value: number);
  71670. /**
  71671. * Gets or sets the depth of field aperture
  71672. */
  71673. get dofAperture(): number;
  71674. set dofAperture(value: number);
  71675. /**
  71676. * Gets or sets the edge distortion
  71677. */
  71678. get edgeDistortion(): number;
  71679. set edgeDistortion(value: number);
  71680. /**
  71681. * Gets or sets the depth of field distortion
  71682. */
  71683. get dofDistortion(): number;
  71684. set dofDistortion(value: number);
  71685. /**
  71686. * Gets or sets the darken out of focus amount
  71687. */
  71688. get darkenOutOfFocus(): number;
  71689. set darkenOutOfFocus(value: number);
  71690. /**
  71691. * Gets or sets a boolean indicating if blur noise is enabled
  71692. */
  71693. get blurNoise(): boolean;
  71694. set blurNoise(value: boolean);
  71695. /**
  71696. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71697. */
  71698. get pentagonBokeh(): boolean;
  71699. set pentagonBokeh(value: boolean);
  71700. /**
  71701. * Gets or sets the highlight grain amount
  71702. */
  71703. get highlightsGain(): number;
  71704. set highlightsGain(value: number);
  71705. /**
  71706. * Gets or sets the highlight threshold
  71707. */
  71708. get highlightsThreshold(): number;
  71709. set highlightsThreshold(value: number);
  71710. /**
  71711. * Sets the amount of blur at the edges
  71712. * @param amount blur amount
  71713. */
  71714. setEdgeBlur(amount: number): void;
  71715. /**
  71716. * Sets edge blur to 0
  71717. */
  71718. disableEdgeBlur(): void;
  71719. /**
  71720. * Sets the amout of grain
  71721. * @param amount Amount of grain
  71722. */
  71723. setGrainAmount(amount: number): void;
  71724. /**
  71725. * Set grain amount to 0
  71726. */
  71727. disableGrain(): void;
  71728. /**
  71729. * Sets the chromatic aberration amount
  71730. * @param amount amount of chromatic aberration
  71731. */
  71732. setChromaticAberration(amount: number): void;
  71733. /**
  71734. * Sets chromatic aberration amount to 0
  71735. */
  71736. disableChromaticAberration(): void;
  71737. /**
  71738. * Sets the EdgeDistortion amount
  71739. * @param amount amount of EdgeDistortion
  71740. */
  71741. setEdgeDistortion(amount: number): void;
  71742. /**
  71743. * Sets edge distortion to 0
  71744. */
  71745. disableEdgeDistortion(): void;
  71746. /**
  71747. * Sets the FocusDistance amount
  71748. * @param amount amount of FocusDistance
  71749. */
  71750. setFocusDistance(amount: number): void;
  71751. /**
  71752. * Disables depth of field
  71753. */
  71754. disableDepthOfField(): void;
  71755. /**
  71756. * Sets the Aperture amount
  71757. * @param amount amount of Aperture
  71758. */
  71759. setAperture(amount: number): void;
  71760. /**
  71761. * Sets the DarkenOutOfFocus amount
  71762. * @param amount amount of DarkenOutOfFocus
  71763. */
  71764. setDarkenOutOfFocus(amount: number): void;
  71765. private _pentagonBokehIsEnabled;
  71766. /**
  71767. * Creates a pentagon bokeh effect
  71768. */
  71769. enablePentagonBokeh(): void;
  71770. /**
  71771. * Disables the pentagon bokeh effect
  71772. */
  71773. disablePentagonBokeh(): void;
  71774. /**
  71775. * Enables noise blur
  71776. */
  71777. enableNoiseBlur(): void;
  71778. /**
  71779. * Disables noise blur
  71780. */
  71781. disableNoiseBlur(): void;
  71782. /**
  71783. * Sets the HighlightsGain amount
  71784. * @param amount amount of HighlightsGain
  71785. */
  71786. setHighlightsGain(amount: number): void;
  71787. /**
  71788. * Sets the HighlightsThreshold amount
  71789. * @param amount amount of HighlightsThreshold
  71790. */
  71791. setHighlightsThreshold(amount: number): void;
  71792. /**
  71793. * Disables highlights
  71794. */
  71795. disableHighlights(): void;
  71796. /**
  71797. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71798. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71799. */
  71800. dispose(disableDepthRender?: boolean): void;
  71801. private _createChromaticAberrationPostProcess;
  71802. private _createHighlightsPostProcess;
  71803. private _createDepthOfFieldPostProcess;
  71804. private _createGrainTexture;
  71805. }
  71806. }
  71807. declare module BABYLON {
  71808. /**
  71809. * Contains all parameters needed for the prepass to perform
  71810. * screen space subsurface scattering
  71811. */
  71812. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71813. /**
  71814. * Is subsurface enabled
  71815. */
  71816. enabled: boolean;
  71817. /**
  71818. * Name of the configuration
  71819. */
  71820. name: string;
  71821. /**
  71822. * Textures that should be present in the MRT for this effect to work
  71823. */
  71824. readonly texturesRequired: number[];
  71825. }
  71826. }
  71827. declare module BABYLON {
  71828. /** @hidden */
  71829. export var ssao2PixelShader: {
  71830. name: string;
  71831. shader: string;
  71832. };
  71833. }
  71834. declare module BABYLON {
  71835. /** @hidden */
  71836. export var ssaoCombinePixelShader: {
  71837. name: string;
  71838. shader: string;
  71839. };
  71840. }
  71841. declare module BABYLON {
  71842. /**
  71843. * Render pipeline to produce ssao effect
  71844. */
  71845. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71846. /**
  71847. * @ignore
  71848. * The PassPostProcess id in the pipeline that contains the original scene color
  71849. */
  71850. SSAOOriginalSceneColorEffect: string;
  71851. /**
  71852. * @ignore
  71853. * The SSAO PostProcess id in the pipeline
  71854. */
  71855. SSAORenderEffect: string;
  71856. /**
  71857. * @ignore
  71858. * The horizontal blur PostProcess id in the pipeline
  71859. */
  71860. SSAOBlurHRenderEffect: string;
  71861. /**
  71862. * @ignore
  71863. * The vertical blur PostProcess id in the pipeline
  71864. */
  71865. SSAOBlurVRenderEffect: string;
  71866. /**
  71867. * @ignore
  71868. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71869. */
  71870. SSAOCombineRenderEffect: string;
  71871. /**
  71872. * The output strength of the SSAO post-process. Default value is 1.0.
  71873. */
  71874. totalStrength: number;
  71875. /**
  71876. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71877. */
  71878. maxZ: number;
  71879. /**
  71880. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71881. */
  71882. minZAspect: number;
  71883. private _samples;
  71884. /**
  71885. * Number of samples used for the SSAO calculations. Default value is 8
  71886. */
  71887. set samples(n: number);
  71888. get samples(): number;
  71889. private _textureSamples;
  71890. /**
  71891. * Number of samples to use for antialiasing
  71892. */
  71893. set textureSamples(n: number);
  71894. get textureSamples(): number;
  71895. /**
  71896. * Force rendering the geometry through geometry buffer
  71897. */
  71898. private _forceGeometryBuffer;
  71899. /**
  71900. * Ratio object used for SSAO ratio and blur ratio
  71901. */
  71902. private _ratio;
  71903. /**
  71904. * Dynamically generated sphere sampler.
  71905. */
  71906. private _sampleSphere;
  71907. /**
  71908. * Blur filter offsets
  71909. */
  71910. private _samplerOffsets;
  71911. private _expensiveBlur;
  71912. /**
  71913. * If bilateral blur should be used
  71914. */
  71915. set expensiveBlur(b: boolean);
  71916. get expensiveBlur(): boolean;
  71917. /**
  71918. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71919. */
  71920. radius: number;
  71921. /**
  71922. * The base color of the SSAO post-process
  71923. * The final result is "base + ssao" between [0, 1]
  71924. */
  71925. base: number;
  71926. /**
  71927. * Support test.
  71928. */
  71929. static get IsSupported(): boolean;
  71930. private _scene;
  71931. private _randomTexture;
  71932. private _originalColorPostProcess;
  71933. private _ssaoPostProcess;
  71934. private _blurHPostProcess;
  71935. private _blurVPostProcess;
  71936. private _ssaoCombinePostProcess;
  71937. private _prePassRenderer;
  71938. /**
  71939. * Gets active scene
  71940. */
  71941. get scene(): Scene;
  71942. /**
  71943. * @constructor
  71944. * @param name The rendering pipeline name
  71945. * @param scene The scene linked to this pipeline
  71946. * @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 }
  71947. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71948. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71949. */
  71950. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71951. /**
  71952. * Get the class name
  71953. * @returns "SSAO2RenderingPipeline"
  71954. */
  71955. getClassName(): string;
  71956. /**
  71957. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71958. */
  71959. dispose(disableGeometryBufferRenderer?: boolean): void;
  71960. private _createBlurPostProcess;
  71961. /** @hidden */
  71962. _rebuild(): void;
  71963. private _bits;
  71964. private _radicalInverse_VdC;
  71965. private _hammersley;
  71966. private _hemisphereSample_uniform;
  71967. private _generateHemisphere;
  71968. private _getDefinesForSSAO;
  71969. private _createSSAOPostProcess;
  71970. private _createSSAOCombinePostProcess;
  71971. private _createRandomTexture;
  71972. /**
  71973. * Serialize the rendering pipeline (Used when exporting)
  71974. * @returns the serialized object
  71975. */
  71976. serialize(): any;
  71977. /**
  71978. * Parse the serialized pipeline
  71979. * @param source Source pipeline.
  71980. * @param scene The scene to load the pipeline to.
  71981. * @param rootUrl The URL of the serialized pipeline.
  71982. * @returns An instantiated pipeline from the serialized object.
  71983. */
  71984. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71985. }
  71986. }
  71987. declare module BABYLON {
  71988. /** @hidden */
  71989. export var ssaoPixelShader: {
  71990. name: string;
  71991. shader: string;
  71992. };
  71993. }
  71994. declare module BABYLON {
  71995. /**
  71996. * Render pipeline to produce ssao effect
  71997. */
  71998. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71999. /**
  72000. * @ignore
  72001. * The PassPostProcess id in the pipeline that contains the original scene color
  72002. */
  72003. SSAOOriginalSceneColorEffect: string;
  72004. /**
  72005. * @ignore
  72006. * The SSAO PostProcess id in the pipeline
  72007. */
  72008. SSAORenderEffect: string;
  72009. /**
  72010. * @ignore
  72011. * The horizontal blur PostProcess id in the pipeline
  72012. */
  72013. SSAOBlurHRenderEffect: string;
  72014. /**
  72015. * @ignore
  72016. * The vertical blur PostProcess id in the pipeline
  72017. */
  72018. SSAOBlurVRenderEffect: string;
  72019. /**
  72020. * @ignore
  72021. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72022. */
  72023. SSAOCombineRenderEffect: string;
  72024. /**
  72025. * The output strength of the SSAO post-process. Default value is 1.0.
  72026. */
  72027. totalStrength: number;
  72028. /**
  72029. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72030. */
  72031. radius: number;
  72032. /**
  72033. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72034. * Must not be equal to fallOff and superior to fallOff.
  72035. * Default value is 0.0075
  72036. */
  72037. area: number;
  72038. /**
  72039. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72040. * Must not be equal to area and inferior to area.
  72041. * Default value is 0.000001
  72042. */
  72043. fallOff: number;
  72044. /**
  72045. * The base color of the SSAO post-process
  72046. * The final result is "base + ssao" between [0, 1]
  72047. */
  72048. base: number;
  72049. private _scene;
  72050. private _depthTexture;
  72051. private _randomTexture;
  72052. private _originalColorPostProcess;
  72053. private _ssaoPostProcess;
  72054. private _blurHPostProcess;
  72055. private _blurVPostProcess;
  72056. private _ssaoCombinePostProcess;
  72057. private _firstUpdate;
  72058. /**
  72059. * Gets active scene
  72060. */
  72061. get scene(): Scene;
  72062. /**
  72063. * @constructor
  72064. * @param name - The rendering pipeline name
  72065. * @param scene - The scene linked to this pipeline
  72066. * @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 }
  72067. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72068. */
  72069. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72070. /**
  72071. * Get the class name
  72072. * @returns "SSAORenderingPipeline"
  72073. */
  72074. getClassName(): string;
  72075. /**
  72076. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72077. */
  72078. dispose(disableDepthRender?: boolean): void;
  72079. private _createBlurPostProcess;
  72080. /** @hidden */
  72081. _rebuild(): void;
  72082. private _createSSAOPostProcess;
  72083. private _createSSAOCombinePostProcess;
  72084. private _createRandomTexture;
  72085. }
  72086. }
  72087. declare module BABYLON {
  72088. /**
  72089. * Contains all parameters needed for the prepass to perform
  72090. * screen space reflections
  72091. */
  72092. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72093. /**
  72094. * Is ssr enabled
  72095. */
  72096. enabled: boolean;
  72097. /**
  72098. * Name of the configuration
  72099. */
  72100. name: string;
  72101. /**
  72102. * Textures that should be present in the MRT for this effect to work
  72103. */
  72104. readonly texturesRequired: number[];
  72105. }
  72106. }
  72107. declare module BABYLON {
  72108. /** @hidden */
  72109. export var screenSpaceReflectionPixelShader: {
  72110. name: string;
  72111. shader: string;
  72112. };
  72113. }
  72114. declare module BABYLON {
  72115. /**
  72116. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72117. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72118. */
  72119. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72120. /**
  72121. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72122. */
  72123. threshold: number;
  72124. /**
  72125. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72126. */
  72127. strength: number;
  72128. /**
  72129. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72130. */
  72131. reflectionSpecularFalloffExponent: number;
  72132. /**
  72133. * 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]
  72134. */
  72135. step: number;
  72136. /**
  72137. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72138. */
  72139. roughnessFactor: number;
  72140. private _forceGeometryBuffer;
  72141. private _geometryBufferRenderer;
  72142. private _prePassRenderer;
  72143. private _enableSmoothReflections;
  72144. private _reflectionSamples;
  72145. private _smoothSteps;
  72146. /**
  72147. * Gets a string identifying the name of the class
  72148. * @returns "ScreenSpaceReflectionPostProcess" string
  72149. */
  72150. getClassName(): string;
  72151. /**
  72152. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72153. * @param name The name of the effect.
  72154. * @param scene The scene containing the objects to calculate reflections.
  72155. * @param options The required width/height ratio to downsize to before computing the render pass.
  72156. * @param camera The camera to apply the render pass to.
  72157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72158. * @param engine The engine which the post process will be applied. (default: current engine)
  72159. * @param reusable If the post process can be reused on the same frame. (default: false)
  72160. * @param textureType Type of textures used when performing the post process. (default: 0)
  72161. * @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)
  72162. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72163. */
  72164. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72165. /**
  72166. * Gets wether or not smoothing reflections is enabled.
  72167. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72168. */
  72169. get enableSmoothReflections(): boolean;
  72170. /**
  72171. * Sets wether or not smoothing reflections is enabled.
  72172. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72173. */
  72174. set enableSmoothReflections(enabled: boolean);
  72175. /**
  72176. * Gets the number of samples taken while computing reflections. More samples count is high,
  72177. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72178. */
  72179. get reflectionSamples(): number;
  72180. /**
  72181. * Sets the number of samples taken while computing reflections. More samples count is high,
  72182. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72183. */
  72184. set reflectionSamples(samples: number);
  72185. /**
  72186. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72187. * more the post-process will require GPU power and can generate a drop in FPS.
  72188. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72189. */
  72190. get smoothSteps(): number;
  72191. set smoothSteps(steps: number);
  72192. private _updateEffectDefines;
  72193. /** @hidden */
  72194. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72195. }
  72196. }
  72197. declare module BABYLON {
  72198. /** @hidden */
  72199. export var standardPixelShader: {
  72200. name: string;
  72201. shader: string;
  72202. };
  72203. }
  72204. declare module BABYLON {
  72205. /**
  72206. * Standard rendering pipeline
  72207. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72208. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72209. */
  72210. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72211. /**
  72212. * Public members
  72213. */
  72214. /**
  72215. * Post-process which contains the original scene color before the pipeline applies all the effects
  72216. */
  72217. originalPostProcess: Nullable<PostProcess>;
  72218. /**
  72219. * Post-process used to down scale an image x4
  72220. */
  72221. downSampleX4PostProcess: Nullable<PostProcess>;
  72222. /**
  72223. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72224. */
  72225. brightPassPostProcess: Nullable<PostProcess>;
  72226. /**
  72227. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72228. */
  72229. blurHPostProcesses: PostProcess[];
  72230. /**
  72231. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72232. */
  72233. blurVPostProcesses: PostProcess[];
  72234. /**
  72235. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72236. */
  72237. textureAdderPostProcess: Nullable<PostProcess>;
  72238. /**
  72239. * Post-process used to create volumetric lighting effect
  72240. */
  72241. volumetricLightPostProcess: Nullable<PostProcess>;
  72242. /**
  72243. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72244. */
  72245. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72246. /**
  72247. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72248. */
  72249. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72250. /**
  72251. * Post-process used to merge the volumetric light effect and the real scene color
  72252. */
  72253. volumetricLightMergePostProces: Nullable<PostProcess>;
  72254. /**
  72255. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72256. */
  72257. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72258. /**
  72259. * Base post-process used to calculate the average luminance of the final image for HDR
  72260. */
  72261. luminancePostProcess: Nullable<PostProcess>;
  72262. /**
  72263. * Post-processes used to create down sample post-processes in order to get
  72264. * the average luminance of the final image for HDR
  72265. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72266. */
  72267. luminanceDownSamplePostProcesses: PostProcess[];
  72268. /**
  72269. * Post-process used to create a HDR effect (light adaptation)
  72270. */
  72271. hdrPostProcess: Nullable<PostProcess>;
  72272. /**
  72273. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72274. */
  72275. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72276. /**
  72277. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72278. */
  72279. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72280. /**
  72281. * Post-process used to merge the final HDR post-process and the real scene color
  72282. */
  72283. hdrFinalPostProcess: Nullable<PostProcess>;
  72284. /**
  72285. * Post-process used to create a lens flare effect
  72286. */
  72287. lensFlarePostProcess: Nullable<PostProcess>;
  72288. /**
  72289. * Post-process that merges the result of the lens flare post-process and the real scene color
  72290. */
  72291. lensFlareComposePostProcess: Nullable<PostProcess>;
  72292. /**
  72293. * Post-process used to create a motion blur effect
  72294. */
  72295. motionBlurPostProcess: Nullable<PostProcess>;
  72296. /**
  72297. * Post-process used to create a depth of field effect
  72298. */
  72299. depthOfFieldPostProcess: Nullable<PostProcess>;
  72300. /**
  72301. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72302. */
  72303. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72304. /**
  72305. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72306. */
  72307. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72308. /**
  72309. * Represents the brightness threshold in order to configure the illuminated surfaces
  72310. */
  72311. brightThreshold: number;
  72312. /**
  72313. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72314. */
  72315. blurWidth: number;
  72316. /**
  72317. * Sets if the blur for highlighted surfaces must be only horizontal
  72318. */
  72319. horizontalBlur: boolean;
  72320. /**
  72321. * Gets the overall exposure used by the pipeline
  72322. */
  72323. get exposure(): number;
  72324. /**
  72325. * Sets the overall exposure used by the pipeline
  72326. */
  72327. set exposure(value: number);
  72328. /**
  72329. * Texture used typically to simulate "dirty" on camera lens
  72330. */
  72331. lensTexture: Nullable<Texture>;
  72332. /**
  72333. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72334. */
  72335. volumetricLightCoefficient: number;
  72336. /**
  72337. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72338. */
  72339. volumetricLightPower: number;
  72340. /**
  72341. * Used the set the blur intensity to smooth the volumetric lights
  72342. */
  72343. volumetricLightBlurScale: number;
  72344. /**
  72345. * Light (spot or directional) used to generate the volumetric lights rays
  72346. * The source light must have a shadow generate so the pipeline can get its
  72347. * depth map
  72348. */
  72349. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72350. /**
  72351. * For eye adaptation, represents the minimum luminance the eye can see
  72352. */
  72353. hdrMinimumLuminance: number;
  72354. /**
  72355. * For eye adaptation, represents the decrease luminance speed
  72356. */
  72357. hdrDecreaseRate: number;
  72358. /**
  72359. * For eye adaptation, represents the increase luminance speed
  72360. */
  72361. hdrIncreaseRate: number;
  72362. /**
  72363. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72364. */
  72365. get hdrAutoExposure(): boolean;
  72366. /**
  72367. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72368. */
  72369. set hdrAutoExposure(value: boolean);
  72370. /**
  72371. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72372. */
  72373. lensColorTexture: Nullable<Texture>;
  72374. /**
  72375. * The overall strengh for the lens flare effect
  72376. */
  72377. lensFlareStrength: number;
  72378. /**
  72379. * Dispersion coefficient for lens flare ghosts
  72380. */
  72381. lensFlareGhostDispersal: number;
  72382. /**
  72383. * Main lens flare halo width
  72384. */
  72385. lensFlareHaloWidth: number;
  72386. /**
  72387. * Based on the lens distortion effect, defines how much the lens flare result
  72388. * is distorted
  72389. */
  72390. lensFlareDistortionStrength: number;
  72391. /**
  72392. * Configures the blur intensity used for for lens flare (halo)
  72393. */
  72394. lensFlareBlurWidth: number;
  72395. /**
  72396. * Lens star texture must be used to simulate rays on the flares and is available
  72397. * in the documentation
  72398. */
  72399. lensStarTexture: Nullable<Texture>;
  72400. /**
  72401. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72402. * flare effect by taking account of the dirt texture
  72403. */
  72404. lensFlareDirtTexture: Nullable<Texture>;
  72405. /**
  72406. * Represents the focal length for the depth of field effect
  72407. */
  72408. depthOfFieldDistance: number;
  72409. /**
  72410. * Represents the blur intensity for the blurred part of the depth of field effect
  72411. */
  72412. depthOfFieldBlurWidth: number;
  72413. /**
  72414. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72415. */
  72416. get motionStrength(): number;
  72417. /**
  72418. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72419. */
  72420. set motionStrength(strength: number);
  72421. /**
  72422. * Gets wether or not the motion blur post-process is object based or screen based.
  72423. */
  72424. get objectBasedMotionBlur(): boolean;
  72425. /**
  72426. * Sets wether or not the motion blur post-process should be object based or screen based
  72427. */
  72428. set objectBasedMotionBlur(value: boolean);
  72429. /**
  72430. * List of animations for the pipeline (IAnimatable implementation)
  72431. */
  72432. animations: Animation[];
  72433. /**
  72434. * Private members
  72435. */
  72436. private _scene;
  72437. private _currentDepthOfFieldSource;
  72438. private _basePostProcess;
  72439. private _fixedExposure;
  72440. private _currentExposure;
  72441. private _hdrAutoExposure;
  72442. private _hdrCurrentLuminance;
  72443. private _motionStrength;
  72444. private _isObjectBasedMotionBlur;
  72445. private _floatTextureType;
  72446. private _camerasToBeAttached;
  72447. private _ratio;
  72448. private _bloomEnabled;
  72449. private _depthOfFieldEnabled;
  72450. private _vlsEnabled;
  72451. private _lensFlareEnabled;
  72452. private _hdrEnabled;
  72453. private _motionBlurEnabled;
  72454. private _fxaaEnabled;
  72455. private _screenSpaceReflectionsEnabled;
  72456. private _motionBlurSamples;
  72457. private _volumetricLightStepsCount;
  72458. private _samples;
  72459. /**
  72460. * @ignore
  72461. * Specifies if the bloom pipeline is enabled
  72462. */
  72463. get BloomEnabled(): boolean;
  72464. set BloomEnabled(enabled: boolean);
  72465. /**
  72466. * @ignore
  72467. * Specifies if the depth of field pipeline is enabed
  72468. */
  72469. get DepthOfFieldEnabled(): boolean;
  72470. set DepthOfFieldEnabled(enabled: boolean);
  72471. /**
  72472. * @ignore
  72473. * Specifies if the lens flare pipeline is enabed
  72474. */
  72475. get LensFlareEnabled(): boolean;
  72476. set LensFlareEnabled(enabled: boolean);
  72477. /**
  72478. * @ignore
  72479. * Specifies if the HDR pipeline is enabled
  72480. */
  72481. get HDREnabled(): boolean;
  72482. set HDREnabled(enabled: boolean);
  72483. /**
  72484. * @ignore
  72485. * Specifies if the volumetric lights scattering effect is enabled
  72486. */
  72487. get VLSEnabled(): boolean;
  72488. set VLSEnabled(enabled: boolean);
  72489. /**
  72490. * @ignore
  72491. * Specifies if the motion blur effect is enabled
  72492. */
  72493. get MotionBlurEnabled(): boolean;
  72494. set MotionBlurEnabled(enabled: boolean);
  72495. /**
  72496. * Specifies if anti-aliasing is enabled
  72497. */
  72498. get fxaaEnabled(): boolean;
  72499. set fxaaEnabled(enabled: boolean);
  72500. /**
  72501. * Specifies if screen space reflections are enabled.
  72502. */
  72503. get screenSpaceReflectionsEnabled(): boolean;
  72504. set screenSpaceReflectionsEnabled(enabled: boolean);
  72505. /**
  72506. * Specifies the number of steps used to calculate the volumetric lights
  72507. * Typically in interval [50, 200]
  72508. */
  72509. get volumetricLightStepsCount(): number;
  72510. set volumetricLightStepsCount(count: number);
  72511. /**
  72512. * Specifies the number of samples used for the motion blur effect
  72513. * Typically in interval [16, 64]
  72514. */
  72515. get motionBlurSamples(): number;
  72516. set motionBlurSamples(samples: number);
  72517. /**
  72518. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72519. */
  72520. get samples(): number;
  72521. set samples(sampleCount: number);
  72522. /**
  72523. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72524. * @constructor
  72525. * @param name The rendering pipeline name
  72526. * @param scene The scene linked to this pipeline
  72527. * @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)
  72528. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72530. */
  72531. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72532. private _buildPipeline;
  72533. private _createDownSampleX4PostProcess;
  72534. private _createBrightPassPostProcess;
  72535. private _createBlurPostProcesses;
  72536. private _createTextureAdderPostProcess;
  72537. private _createVolumetricLightPostProcess;
  72538. private _createLuminancePostProcesses;
  72539. private _createHdrPostProcess;
  72540. private _createLensFlarePostProcess;
  72541. private _createDepthOfFieldPostProcess;
  72542. private _createMotionBlurPostProcess;
  72543. private _getDepthTexture;
  72544. private _disposePostProcesses;
  72545. /**
  72546. * Dispose of the pipeline and stop all post processes
  72547. */
  72548. dispose(): void;
  72549. /**
  72550. * Serialize the rendering pipeline (Used when exporting)
  72551. * @returns the serialized object
  72552. */
  72553. serialize(): any;
  72554. /**
  72555. * Parse the serialized pipeline
  72556. * @param source Source pipeline.
  72557. * @param scene The scene to load the pipeline to.
  72558. * @param rootUrl The URL of the serialized pipeline.
  72559. * @returns An instantiated pipeline from the serialized object.
  72560. */
  72561. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72562. /**
  72563. * Luminance steps
  72564. */
  72565. static LuminanceSteps: number;
  72566. }
  72567. }
  72568. declare module BABYLON {
  72569. /** @hidden */
  72570. export var stereoscopicInterlacePixelShader: {
  72571. name: string;
  72572. shader: string;
  72573. };
  72574. }
  72575. declare module BABYLON {
  72576. /**
  72577. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72578. */
  72579. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72580. private _stepSize;
  72581. private _passedProcess;
  72582. /**
  72583. * Gets a string identifying the name of the class
  72584. * @returns "StereoscopicInterlacePostProcessI" string
  72585. */
  72586. getClassName(): string;
  72587. /**
  72588. * Initializes a StereoscopicInterlacePostProcessI
  72589. * @param name The name of the effect.
  72590. * @param rigCameras The rig cameras to be appled to the post process
  72591. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72592. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72594. * @param engine The engine which the post process will be applied. (default: current engine)
  72595. * @param reusable If the post process can be reused on the same frame. (default: false)
  72596. */
  72597. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72598. }
  72599. /**
  72600. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72601. */
  72602. export class StereoscopicInterlacePostProcess extends PostProcess {
  72603. private _stepSize;
  72604. private _passedProcess;
  72605. /**
  72606. * Gets a string identifying the name of the class
  72607. * @returns "StereoscopicInterlacePostProcess" string
  72608. */
  72609. getClassName(): string;
  72610. /**
  72611. * Initializes a StereoscopicInterlacePostProcess
  72612. * @param name The name of the effect.
  72613. * @param rigCameras The rig cameras to be appled to the post process
  72614. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72616. * @param engine The engine which the post process will be applied. (default: current engine)
  72617. * @param reusable If the post process can be reused on the same frame. (default: false)
  72618. */
  72619. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72620. }
  72621. }
  72622. declare module BABYLON {
  72623. /** @hidden */
  72624. export var tonemapPixelShader: {
  72625. name: string;
  72626. shader: string;
  72627. };
  72628. }
  72629. declare module BABYLON {
  72630. /** Defines operator used for tonemapping */
  72631. export enum TonemappingOperator {
  72632. /** Hable */
  72633. Hable = 0,
  72634. /** Reinhard */
  72635. Reinhard = 1,
  72636. /** HejiDawson */
  72637. HejiDawson = 2,
  72638. /** Photographic */
  72639. Photographic = 3
  72640. }
  72641. /**
  72642. * Defines a post process to apply tone mapping
  72643. */
  72644. export class TonemapPostProcess extends PostProcess {
  72645. private _operator;
  72646. /** Defines the required exposure adjustement */
  72647. exposureAdjustment: number;
  72648. /**
  72649. * Gets a string identifying the name of the class
  72650. * @returns "TonemapPostProcess" string
  72651. */
  72652. getClassName(): string;
  72653. /**
  72654. * Creates a new TonemapPostProcess
  72655. * @param name defines the name of the postprocess
  72656. * @param _operator defines the operator to use
  72657. * @param exposureAdjustment defines the required exposure adjustement
  72658. * @param camera defines the camera to use (can be null)
  72659. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72660. * @param engine defines the hosting engine (can be ignore if camera is set)
  72661. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72662. */
  72663. constructor(name: string, _operator: TonemappingOperator,
  72664. /** Defines the required exposure adjustement */
  72665. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72666. }
  72667. }
  72668. declare module BABYLON {
  72669. /** @hidden */
  72670. export var volumetricLightScatteringPixelShader: {
  72671. name: string;
  72672. shader: string;
  72673. };
  72674. }
  72675. declare module BABYLON {
  72676. /** @hidden */
  72677. export var volumetricLightScatteringPassVertexShader: {
  72678. name: string;
  72679. shader: string;
  72680. };
  72681. }
  72682. declare module BABYLON {
  72683. /** @hidden */
  72684. export var volumetricLightScatteringPassPixelShader: {
  72685. name: string;
  72686. shader: string;
  72687. };
  72688. }
  72689. declare module BABYLON {
  72690. /**
  72691. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72692. */
  72693. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72694. private _volumetricLightScatteringPass;
  72695. private _volumetricLightScatteringRTT;
  72696. private _viewPort;
  72697. private _screenCoordinates;
  72698. private _cachedDefines;
  72699. /**
  72700. * If not undefined, the mesh position is computed from the attached node position
  72701. */
  72702. attachedNode: {
  72703. position: Vector3;
  72704. };
  72705. /**
  72706. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72707. */
  72708. customMeshPosition: Vector3;
  72709. /**
  72710. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72711. */
  72712. useCustomMeshPosition: boolean;
  72713. /**
  72714. * If the post-process should inverse the light scattering direction
  72715. */
  72716. invert: boolean;
  72717. /**
  72718. * The internal mesh used by the post-process
  72719. */
  72720. mesh: Mesh;
  72721. /**
  72722. * @hidden
  72723. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72724. */
  72725. get useDiffuseColor(): boolean;
  72726. set useDiffuseColor(useDiffuseColor: boolean);
  72727. /**
  72728. * Array containing the excluded meshes not rendered in the internal pass
  72729. */
  72730. excludedMeshes: AbstractMesh[];
  72731. /**
  72732. * Controls the overall intensity of the post-process
  72733. */
  72734. exposure: number;
  72735. /**
  72736. * Dissipates each sample's contribution in range [0, 1]
  72737. */
  72738. decay: number;
  72739. /**
  72740. * Controls the overall intensity of each sample
  72741. */
  72742. weight: number;
  72743. /**
  72744. * Controls the density of each sample
  72745. */
  72746. density: number;
  72747. /**
  72748. * @constructor
  72749. * @param name The post-process name
  72750. * @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)
  72751. * @param camera The camera that the post-process will be attached to
  72752. * @param mesh The mesh used to create the light scattering
  72753. * @param samples The post-process quality, default 100
  72754. * @param samplingModeThe post-process filtering mode
  72755. * @param engine The babylon engine
  72756. * @param reusable If the post-process is reusable
  72757. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72758. */
  72759. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72760. /**
  72761. * Returns the string "VolumetricLightScatteringPostProcess"
  72762. * @returns "VolumetricLightScatteringPostProcess"
  72763. */
  72764. getClassName(): string;
  72765. private _isReady;
  72766. /**
  72767. * Sets the new light position for light scattering effect
  72768. * @param position The new custom light position
  72769. */
  72770. setCustomMeshPosition(position: Vector3): void;
  72771. /**
  72772. * Returns the light position for light scattering effect
  72773. * @return Vector3 The custom light position
  72774. */
  72775. getCustomMeshPosition(): Vector3;
  72776. /**
  72777. * Disposes the internal assets and detaches the post-process from the camera
  72778. */
  72779. dispose(camera: Camera): void;
  72780. /**
  72781. * Returns the render target texture used by the post-process
  72782. * @return the render target texture used by the post-process
  72783. */
  72784. getPass(): RenderTargetTexture;
  72785. private _meshExcluded;
  72786. private _createPass;
  72787. private _updateMeshScreenCoordinates;
  72788. /**
  72789. * Creates a default mesh for the Volumeric Light Scattering post-process
  72790. * @param name The mesh name
  72791. * @param scene The scene where to create the mesh
  72792. * @return the default mesh
  72793. */
  72794. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72795. }
  72796. }
  72797. declare module BABYLON {
  72798. /** @hidden */
  72799. export var screenSpaceCurvaturePixelShader: {
  72800. name: string;
  72801. shader: string;
  72802. };
  72803. }
  72804. declare module BABYLON {
  72805. /**
  72806. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72807. */
  72808. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72809. /**
  72810. * Defines how much ridge the curvature effect displays.
  72811. */
  72812. ridge: number;
  72813. /**
  72814. * Defines how much valley the curvature effect displays.
  72815. */
  72816. valley: number;
  72817. private _geometryBufferRenderer;
  72818. /**
  72819. * Gets a string identifying the name of the class
  72820. * @returns "ScreenSpaceCurvaturePostProcess" string
  72821. */
  72822. getClassName(): string;
  72823. /**
  72824. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72825. * @param name The name of the effect.
  72826. * @param scene The scene containing the objects to blur according to their velocity.
  72827. * @param options The required width/height ratio to downsize to before computing the render pass.
  72828. * @param camera The camera to apply the render pass to.
  72829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72830. * @param engine The engine which the post process will be applied. (default: current engine)
  72831. * @param reusable If the post process can be reused on the same frame. (default: false)
  72832. * @param textureType Type of textures used when performing the post process. (default: 0)
  72833. * @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)
  72834. */
  72835. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72836. /**
  72837. * Support test.
  72838. */
  72839. static get IsSupported(): boolean;
  72840. /** @hidden */
  72841. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72842. }
  72843. }
  72844. declare module BABYLON {
  72845. interface Scene {
  72846. /** @hidden (Backing field) */
  72847. _boundingBoxRenderer: BoundingBoxRenderer;
  72848. /** @hidden (Backing field) */
  72849. _forceShowBoundingBoxes: boolean;
  72850. /**
  72851. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72852. */
  72853. forceShowBoundingBoxes: boolean;
  72854. /**
  72855. * Gets the bounding box renderer associated with the scene
  72856. * @returns a BoundingBoxRenderer
  72857. */
  72858. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72859. }
  72860. interface AbstractMesh {
  72861. /** @hidden (Backing field) */
  72862. _showBoundingBox: boolean;
  72863. /**
  72864. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72865. */
  72866. showBoundingBox: boolean;
  72867. }
  72868. /**
  72869. * Component responsible of rendering the bounding box of the meshes in a scene.
  72870. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72871. */
  72872. export class BoundingBoxRenderer implements ISceneComponent {
  72873. /**
  72874. * The component name helpfull to identify the component in the list of scene components.
  72875. */
  72876. readonly name: string;
  72877. /**
  72878. * The scene the component belongs to.
  72879. */
  72880. scene: Scene;
  72881. /**
  72882. * Color of the bounding box lines placed in front of an object
  72883. */
  72884. frontColor: Color3;
  72885. /**
  72886. * Color of the bounding box lines placed behind an object
  72887. */
  72888. backColor: Color3;
  72889. /**
  72890. * Defines if the renderer should show the back lines or not
  72891. */
  72892. showBackLines: boolean;
  72893. /**
  72894. * Observable raised before rendering a bounding box
  72895. */
  72896. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72897. /**
  72898. * Observable raised after rendering a bounding box
  72899. */
  72900. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72901. /**
  72902. * Observable raised after resources are created
  72903. */
  72904. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  72905. /**
  72906. * When false, no bounding boxes will be rendered
  72907. */
  72908. enabled: boolean;
  72909. /**
  72910. * @hidden
  72911. */
  72912. renderList: SmartArray<BoundingBox>;
  72913. private _colorShader;
  72914. private _vertexBuffers;
  72915. private _indexBuffer;
  72916. private _fillIndexBuffer;
  72917. private _fillIndexData;
  72918. /**
  72919. * Instantiates a new bounding box renderer in a scene.
  72920. * @param scene the scene the renderer renders in
  72921. */
  72922. constructor(scene: Scene);
  72923. /**
  72924. * Registers the component in a given scene
  72925. */
  72926. register(): void;
  72927. private _evaluateSubMesh;
  72928. private _preActiveMesh;
  72929. private _prepareResources;
  72930. private _createIndexBuffer;
  72931. /**
  72932. * Rebuilds the elements related to this component in case of
  72933. * context lost for instance.
  72934. */
  72935. rebuild(): void;
  72936. /**
  72937. * @hidden
  72938. */
  72939. reset(): void;
  72940. /**
  72941. * Render the bounding boxes of a specific rendering group
  72942. * @param renderingGroupId defines the rendering group to render
  72943. */
  72944. render(renderingGroupId: number): void;
  72945. /**
  72946. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72947. * @param mesh Define the mesh to render the occlusion bounding box for
  72948. */
  72949. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72950. /**
  72951. * Dispose and release the resources attached to this renderer.
  72952. */
  72953. dispose(): void;
  72954. }
  72955. }
  72956. declare module BABYLON {
  72957. interface Scene {
  72958. /** @hidden (Backing field) */
  72959. _depthRenderer: {
  72960. [id: string]: DepthRenderer;
  72961. };
  72962. /**
  72963. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72964. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72965. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72966. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72967. * @returns the created depth renderer
  72968. */
  72969. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72970. /**
  72971. * Disables a depth renderer for a given camera
  72972. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72973. */
  72974. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72975. }
  72976. /**
  72977. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72978. * in several rendering techniques.
  72979. */
  72980. export class DepthRendererSceneComponent implements ISceneComponent {
  72981. /**
  72982. * The component name helpfull to identify the component in the list of scene components.
  72983. */
  72984. readonly name: string;
  72985. /**
  72986. * The scene the component belongs to.
  72987. */
  72988. scene: Scene;
  72989. /**
  72990. * Creates a new instance of the component for the given scene
  72991. * @param scene Defines the scene to register the component in
  72992. */
  72993. constructor(scene: Scene);
  72994. /**
  72995. * Registers the component in a given scene
  72996. */
  72997. register(): void;
  72998. /**
  72999. * Rebuilds the elements related to this component in case of
  73000. * context lost for instance.
  73001. */
  73002. rebuild(): void;
  73003. /**
  73004. * Disposes the component and the associated ressources
  73005. */
  73006. dispose(): void;
  73007. private _gatherRenderTargets;
  73008. private _gatherActiveCameraRenderTargets;
  73009. }
  73010. }
  73011. declare module BABYLON {
  73012. interface AbstractScene {
  73013. /** @hidden (Backing field) */
  73014. _prePassRenderer: Nullable<PrePassRenderer>;
  73015. /**
  73016. * Gets or Sets the current prepass renderer associated to the scene.
  73017. */
  73018. prePassRenderer: Nullable<PrePassRenderer>;
  73019. /**
  73020. * Enables the prepass and associates it with the scene
  73021. * @returns the PrePassRenderer
  73022. */
  73023. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73024. /**
  73025. * Disables the prepass associated with the scene
  73026. */
  73027. disablePrePassRenderer(): void;
  73028. }
  73029. /**
  73030. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73031. * in several rendering techniques.
  73032. */
  73033. export class PrePassRendererSceneComponent implements ISceneComponent {
  73034. /**
  73035. * The component name helpful to identify the component in the list of scene components.
  73036. */
  73037. readonly name: string;
  73038. /**
  73039. * The scene the component belongs to.
  73040. */
  73041. scene: Scene;
  73042. /**
  73043. * Creates a new instance of the component for the given scene
  73044. * @param scene Defines the scene to register the component in
  73045. */
  73046. constructor(scene: Scene);
  73047. /**
  73048. * Registers the component in a given scene
  73049. */
  73050. register(): void;
  73051. private _beforeCameraDraw;
  73052. private _afterCameraDraw;
  73053. private _beforeClearStage;
  73054. /**
  73055. * Rebuilds the elements related to this component in case of
  73056. * context lost for instance.
  73057. */
  73058. rebuild(): void;
  73059. /**
  73060. * Disposes the component and the associated ressources
  73061. */
  73062. dispose(): void;
  73063. }
  73064. }
  73065. declare module BABYLON {
  73066. /** @hidden */
  73067. export var fibonacci: {
  73068. name: string;
  73069. shader: string;
  73070. };
  73071. }
  73072. declare module BABYLON {
  73073. /** @hidden */
  73074. export var diffusionProfile: {
  73075. name: string;
  73076. shader: string;
  73077. };
  73078. }
  73079. declare module BABYLON {
  73080. /** @hidden */
  73081. export var subSurfaceScatteringPixelShader: {
  73082. name: string;
  73083. shader: string;
  73084. };
  73085. }
  73086. declare module BABYLON {
  73087. /**
  73088. * Sub surface scattering post process
  73089. */
  73090. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73091. /**
  73092. * Gets a string identifying the name of the class
  73093. * @returns "SubSurfaceScatteringPostProcess" string
  73094. */
  73095. getClassName(): string;
  73096. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73097. }
  73098. }
  73099. declare module BABYLON {
  73100. /**
  73101. * Contains all parameters needed for the prepass to perform
  73102. * screen space subsurface scattering
  73103. */
  73104. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73105. /** @hidden */
  73106. static _SceneComponentInitialization: (scene: Scene) => void;
  73107. private _ssDiffusionS;
  73108. private _ssFilterRadii;
  73109. private _ssDiffusionD;
  73110. /**
  73111. * Post process to attach for screen space subsurface scattering
  73112. */
  73113. postProcess: SubSurfaceScatteringPostProcess;
  73114. /**
  73115. * Diffusion profile color for subsurface scattering
  73116. */
  73117. get ssDiffusionS(): number[];
  73118. /**
  73119. * Diffusion profile max color channel value for subsurface scattering
  73120. */
  73121. get ssDiffusionD(): number[];
  73122. /**
  73123. * Diffusion profile filter radius for subsurface scattering
  73124. */
  73125. get ssFilterRadii(): number[];
  73126. /**
  73127. * Is subsurface enabled
  73128. */
  73129. enabled: boolean;
  73130. /**
  73131. * Name of the configuration
  73132. */
  73133. name: string;
  73134. /**
  73135. * Diffusion profile colors for subsurface scattering
  73136. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73137. * See ...
  73138. * Note that you can only store up to 5 of them
  73139. */
  73140. ssDiffusionProfileColors: Color3[];
  73141. /**
  73142. * Defines the ratio real world => scene units.
  73143. * Used for subsurface scattering
  73144. */
  73145. metersPerUnit: number;
  73146. /**
  73147. * Textures that should be present in the MRT for this effect to work
  73148. */
  73149. readonly texturesRequired: number[];
  73150. private _scene;
  73151. /**
  73152. * Builds a subsurface configuration object
  73153. * @param scene The scene
  73154. */
  73155. constructor(scene: Scene);
  73156. /**
  73157. * Adds a new diffusion profile.
  73158. * Useful for more realistic subsurface scattering on diverse materials.
  73159. * @param color The color of the diffusion profile. Should be the average color of the material.
  73160. * @return The index of the diffusion profile for the material subsurface configuration
  73161. */
  73162. addDiffusionProfile(color: Color3): number;
  73163. /**
  73164. * Creates the sss post process
  73165. * @return The created post process
  73166. */
  73167. createPostProcess(): SubSurfaceScatteringPostProcess;
  73168. /**
  73169. * Deletes all diffusion profiles.
  73170. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73171. */
  73172. clearAllDiffusionProfiles(): void;
  73173. /**
  73174. * Disposes this object
  73175. */
  73176. dispose(): void;
  73177. /**
  73178. * @hidden
  73179. * https://zero-radiance.github.io/post/sampling-diffusion/
  73180. *
  73181. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73182. * ------------------------------------------------------------------------------------
  73183. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73184. * PDF[r, phi, s] = r * R[r, phi, s]
  73185. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73186. * ------------------------------------------------------------------------------------
  73187. * We importance sample the color channel with the widest scattering distance.
  73188. */
  73189. getDiffusionProfileParameters(color: Color3): number;
  73190. /**
  73191. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73192. * 'u' is the random number (the value of the CDF): [0, 1).
  73193. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73194. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73195. */
  73196. private _sampleBurleyDiffusionProfile;
  73197. }
  73198. }
  73199. declare module BABYLON {
  73200. interface AbstractScene {
  73201. /** @hidden (Backing field) */
  73202. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73203. /**
  73204. * Gets or Sets the current prepass renderer associated to the scene.
  73205. */
  73206. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73207. /**
  73208. * Enables the subsurface effect for prepass
  73209. * @returns the SubSurfaceConfiguration
  73210. */
  73211. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73212. /**
  73213. * Disables the subsurface effect for prepass
  73214. */
  73215. disableSubSurfaceForPrePass(): void;
  73216. }
  73217. /**
  73218. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73219. * in several rendering techniques.
  73220. */
  73221. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73222. /**
  73223. * The component name helpful to identify the component in the list of scene components.
  73224. */
  73225. readonly name: string;
  73226. /**
  73227. * The scene the component belongs to.
  73228. */
  73229. scene: Scene;
  73230. /**
  73231. * Creates a new instance of the component for the given scene
  73232. * @param scene Defines the scene to register the component in
  73233. */
  73234. constructor(scene: Scene);
  73235. /**
  73236. * Registers the component in a given scene
  73237. */
  73238. register(): void;
  73239. /**
  73240. * Serializes the component data to the specified json object
  73241. * @param serializationObject The object to serialize to
  73242. */
  73243. serialize(serializationObject: any): void;
  73244. /**
  73245. * Adds all the elements from the container to the scene
  73246. * @param container the container holding the elements
  73247. */
  73248. addFromContainer(container: AbstractScene): void;
  73249. /**
  73250. * Removes all the elements in the container from the scene
  73251. * @param container contains the elements to remove
  73252. * @param dispose if the removed element should be disposed (default: false)
  73253. */
  73254. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73255. /**
  73256. * Rebuilds the elements related to this component in case of
  73257. * context lost for instance.
  73258. */
  73259. rebuild(): void;
  73260. /**
  73261. * Disposes the component and the associated ressources
  73262. */
  73263. dispose(): void;
  73264. }
  73265. }
  73266. declare module BABYLON {
  73267. /** @hidden */
  73268. export var outlinePixelShader: {
  73269. name: string;
  73270. shader: string;
  73271. };
  73272. }
  73273. declare module BABYLON {
  73274. /** @hidden */
  73275. export var outlineVertexShader: {
  73276. name: string;
  73277. shader: string;
  73278. };
  73279. }
  73280. declare module BABYLON {
  73281. interface Scene {
  73282. /** @hidden */
  73283. _outlineRenderer: OutlineRenderer;
  73284. /**
  73285. * Gets the outline renderer associated with the scene
  73286. * @returns a OutlineRenderer
  73287. */
  73288. getOutlineRenderer(): OutlineRenderer;
  73289. }
  73290. interface AbstractMesh {
  73291. /** @hidden (Backing field) */
  73292. _renderOutline: boolean;
  73293. /**
  73294. * Gets or sets a boolean indicating if the outline must be rendered as well
  73295. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73296. */
  73297. renderOutline: boolean;
  73298. /** @hidden (Backing field) */
  73299. _renderOverlay: boolean;
  73300. /**
  73301. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73302. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73303. */
  73304. renderOverlay: boolean;
  73305. }
  73306. /**
  73307. * This class is responsible to draw bothe outline/overlay of meshes.
  73308. * It should not be used directly but through the available method on mesh.
  73309. */
  73310. export class OutlineRenderer implements ISceneComponent {
  73311. /**
  73312. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73313. */
  73314. private static _StencilReference;
  73315. /**
  73316. * The name of the component. Each component must have a unique name.
  73317. */
  73318. name: string;
  73319. /**
  73320. * The scene the component belongs to.
  73321. */
  73322. scene: Scene;
  73323. /**
  73324. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73325. */
  73326. zOffset: number;
  73327. private _engine;
  73328. private _effect;
  73329. private _cachedDefines;
  73330. private _savedDepthWrite;
  73331. /**
  73332. * Instantiates a new outline renderer. (There could be only one per scene).
  73333. * @param scene Defines the scene it belongs to
  73334. */
  73335. constructor(scene: Scene);
  73336. /**
  73337. * Register the component to one instance of a scene.
  73338. */
  73339. register(): void;
  73340. /**
  73341. * Rebuilds the elements related to this component in case of
  73342. * context lost for instance.
  73343. */
  73344. rebuild(): void;
  73345. /**
  73346. * Disposes the component and the associated ressources.
  73347. */
  73348. dispose(): void;
  73349. /**
  73350. * Renders the outline in the canvas.
  73351. * @param subMesh Defines the sumesh to render
  73352. * @param batch Defines the batch of meshes in case of instances
  73353. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73354. */
  73355. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73356. /**
  73357. * Returns whether or not the outline renderer is ready for a given submesh.
  73358. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73359. * @param subMesh Defines the submesh to check readyness for
  73360. * @param useInstances Defines wheter wee are trying to render instances or not
  73361. * @returns true if ready otherwise false
  73362. */
  73363. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73364. private _beforeRenderingMesh;
  73365. private _afterRenderingMesh;
  73366. }
  73367. }
  73368. declare module BABYLON {
  73369. /**
  73370. * Defines the basic options interface of a Sprite Frame Source Size.
  73371. */
  73372. export interface ISpriteJSONSpriteSourceSize {
  73373. /**
  73374. * number of the original width of the Frame
  73375. */
  73376. w: number;
  73377. /**
  73378. * number of the original height of the Frame
  73379. */
  73380. h: number;
  73381. }
  73382. /**
  73383. * Defines the basic options interface of a Sprite Frame Data.
  73384. */
  73385. export interface ISpriteJSONSpriteFrameData {
  73386. /**
  73387. * number of the x offset of the Frame
  73388. */
  73389. x: number;
  73390. /**
  73391. * number of the y offset of the Frame
  73392. */
  73393. y: number;
  73394. /**
  73395. * number of the width of the Frame
  73396. */
  73397. w: number;
  73398. /**
  73399. * number of the height of the Frame
  73400. */
  73401. h: number;
  73402. }
  73403. /**
  73404. * Defines the basic options interface of a JSON Sprite.
  73405. */
  73406. export interface ISpriteJSONSprite {
  73407. /**
  73408. * string name of the Frame
  73409. */
  73410. filename: string;
  73411. /**
  73412. * ISpriteJSONSpriteFrame basic object of the frame data
  73413. */
  73414. frame: ISpriteJSONSpriteFrameData;
  73415. /**
  73416. * boolean to flag is the frame was rotated.
  73417. */
  73418. rotated: boolean;
  73419. /**
  73420. * boolean to flag is the frame was trimmed.
  73421. */
  73422. trimmed: boolean;
  73423. /**
  73424. * ISpriteJSONSpriteFrame basic object of the source data
  73425. */
  73426. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73427. /**
  73428. * ISpriteJSONSpriteFrame basic object of the source data
  73429. */
  73430. sourceSize: ISpriteJSONSpriteSourceSize;
  73431. }
  73432. /**
  73433. * Defines the basic options interface of a JSON atlas.
  73434. */
  73435. export interface ISpriteJSONAtlas {
  73436. /**
  73437. * Array of objects that contain the frame data.
  73438. */
  73439. frames: Array<ISpriteJSONSprite>;
  73440. /**
  73441. * object basic object containing the sprite meta data.
  73442. */
  73443. meta?: object;
  73444. }
  73445. }
  73446. declare module BABYLON {
  73447. /** @hidden */
  73448. export var spriteMapPixelShader: {
  73449. name: string;
  73450. shader: string;
  73451. };
  73452. }
  73453. declare module BABYLON {
  73454. /** @hidden */
  73455. export var spriteMapVertexShader: {
  73456. name: string;
  73457. shader: string;
  73458. };
  73459. }
  73460. declare module BABYLON {
  73461. /**
  73462. * Defines the basic options interface of a SpriteMap
  73463. */
  73464. export interface ISpriteMapOptions {
  73465. /**
  73466. * Vector2 of the number of cells in the grid.
  73467. */
  73468. stageSize?: Vector2;
  73469. /**
  73470. * Vector2 of the size of the output plane in World Units.
  73471. */
  73472. outputSize?: Vector2;
  73473. /**
  73474. * Vector3 of the position of the output plane in World Units.
  73475. */
  73476. outputPosition?: Vector3;
  73477. /**
  73478. * Vector3 of the rotation of the output plane.
  73479. */
  73480. outputRotation?: Vector3;
  73481. /**
  73482. * number of layers that the system will reserve in resources.
  73483. */
  73484. layerCount?: number;
  73485. /**
  73486. * number of max animation frames a single cell will reserve in resources.
  73487. */
  73488. maxAnimationFrames?: number;
  73489. /**
  73490. * number cell index of the base tile when the system compiles.
  73491. */
  73492. baseTile?: number;
  73493. /**
  73494. * boolean flip the sprite after its been repositioned by the framing data.
  73495. */
  73496. flipU?: boolean;
  73497. /**
  73498. * Vector3 scalar of the global RGB values of the SpriteMap.
  73499. */
  73500. colorMultiply?: Vector3;
  73501. }
  73502. /**
  73503. * Defines the IDisposable interface in order to be cleanable from resources.
  73504. */
  73505. export interface ISpriteMap extends IDisposable {
  73506. /**
  73507. * String name of the SpriteMap.
  73508. */
  73509. name: string;
  73510. /**
  73511. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73512. */
  73513. atlasJSON: ISpriteJSONAtlas;
  73514. /**
  73515. * Texture of the SpriteMap.
  73516. */
  73517. spriteSheet: Texture;
  73518. /**
  73519. * The parameters to initialize the SpriteMap with.
  73520. */
  73521. options: ISpriteMapOptions;
  73522. }
  73523. /**
  73524. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73525. */
  73526. export class SpriteMap implements ISpriteMap {
  73527. /** The Name of the spriteMap */
  73528. name: string;
  73529. /** The JSON file with the frame and meta data */
  73530. atlasJSON: ISpriteJSONAtlas;
  73531. /** The systems Sprite Sheet Texture */
  73532. spriteSheet: Texture;
  73533. /** Arguments passed with the Constructor */
  73534. options: ISpriteMapOptions;
  73535. /** Public Sprite Storage array, parsed from atlasJSON */
  73536. sprites: Array<ISpriteJSONSprite>;
  73537. /** Returns the Number of Sprites in the System */
  73538. get spriteCount(): number;
  73539. /** Returns the Position of Output Plane*/
  73540. get position(): Vector3;
  73541. /** Returns the Position of Output Plane*/
  73542. set position(v: Vector3);
  73543. /** Returns the Rotation of Output Plane*/
  73544. get rotation(): Vector3;
  73545. /** Returns the Rotation of Output Plane*/
  73546. set rotation(v: Vector3);
  73547. /** Sets the AnimationMap*/
  73548. get animationMap(): RawTexture;
  73549. /** Sets the AnimationMap*/
  73550. set animationMap(v: RawTexture);
  73551. /** Scene that the SpriteMap was created in */
  73552. private _scene;
  73553. /** Texture Buffer of Float32 that holds tile frame data*/
  73554. private _frameMap;
  73555. /** Texture Buffers of Float32 that holds tileMap data*/
  73556. private _tileMaps;
  73557. /** Texture Buffer of Float32 that holds Animation Data*/
  73558. private _animationMap;
  73559. /** Custom ShaderMaterial Central to the System*/
  73560. private _material;
  73561. /** Custom ShaderMaterial Central to the System*/
  73562. private _output;
  73563. /** Systems Time Ticker*/
  73564. private _time;
  73565. /**
  73566. * Creates a new SpriteMap
  73567. * @param name defines the SpriteMaps Name
  73568. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73569. * @param spriteSheet is the Texture that the Sprites are on.
  73570. * @param options a basic deployment configuration
  73571. * @param scene The Scene that the map is deployed on
  73572. */
  73573. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73574. /**
  73575. * Returns tileID location
  73576. * @returns Vector2 the cell position ID
  73577. */
  73578. getTileID(): Vector2;
  73579. /**
  73580. * Gets the UV location of the mouse over the SpriteMap.
  73581. * @returns Vector2 the UV position of the mouse interaction
  73582. */
  73583. getMousePosition(): Vector2;
  73584. /**
  73585. * Creates the "frame" texture Buffer
  73586. * -------------------------------------
  73587. * Structure of frames
  73588. * "filename": "Falling-Water-2.png",
  73589. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73590. * "rotated": true,
  73591. * "trimmed": true,
  73592. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73593. * "sourceSize": {"w":32,"h":32}
  73594. * @returns RawTexture of the frameMap
  73595. */
  73596. private _createFrameBuffer;
  73597. /**
  73598. * Creates the tileMap texture Buffer
  73599. * @param buffer normally and array of numbers, or a false to generate from scratch
  73600. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73601. * @returns RawTexture of the tileMap
  73602. */
  73603. private _createTileBuffer;
  73604. /**
  73605. * Modifies the data of the tileMaps
  73606. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73607. * @param pos is the iVector2 Coordinates of the Tile
  73608. * @param tile The SpriteIndex of the new Tile
  73609. */
  73610. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73611. /**
  73612. * Creates the animationMap texture Buffer
  73613. * @param buffer normally and array of numbers, or a false to generate from scratch
  73614. * @returns RawTexture of the animationMap
  73615. */
  73616. private _createTileAnimationBuffer;
  73617. /**
  73618. * Modifies the data of the animationMap
  73619. * @param cellID is the Index of the Sprite
  73620. * @param _frame is the target Animation frame
  73621. * @param toCell is the Target Index of the next frame of the animation
  73622. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73623. * @param speed is a global scalar of the time variable on the map.
  73624. */
  73625. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73626. /**
  73627. * Exports the .tilemaps file
  73628. */
  73629. saveTileMaps(): void;
  73630. /**
  73631. * Imports the .tilemaps file
  73632. * @param url of the .tilemaps file
  73633. */
  73634. loadTileMaps(url: string): void;
  73635. /**
  73636. * Release associated resources
  73637. */
  73638. dispose(): void;
  73639. }
  73640. }
  73641. declare module BABYLON {
  73642. /**
  73643. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73644. * @see https://doc.babylonjs.com/babylon101/sprites
  73645. */
  73646. export class SpritePackedManager extends SpriteManager {
  73647. /** defines the packed manager's name */
  73648. name: string;
  73649. /**
  73650. * Creates a new sprite manager from a packed sprite sheet
  73651. * @param name defines the manager's name
  73652. * @param imgUrl defines the sprite sheet url
  73653. * @param capacity defines the maximum allowed number of sprites
  73654. * @param scene defines the hosting scene
  73655. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73656. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73657. * @param samplingMode defines the smapling mode to use with spritesheet
  73658. * @param fromPacked set to true; do not alter
  73659. */
  73660. constructor(
  73661. /** defines the packed manager's name */
  73662. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73663. }
  73664. }
  73665. declare module BABYLON {
  73666. /**
  73667. * Defines the list of states available for a task inside a AssetsManager
  73668. */
  73669. export enum AssetTaskState {
  73670. /**
  73671. * Initialization
  73672. */
  73673. INIT = 0,
  73674. /**
  73675. * Running
  73676. */
  73677. RUNNING = 1,
  73678. /**
  73679. * Done
  73680. */
  73681. DONE = 2,
  73682. /**
  73683. * Error
  73684. */
  73685. ERROR = 3
  73686. }
  73687. /**
  73688. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73689. */
  73690. export abstract class AbstractAssetTask {
  73691. /**
  73692. * Task name
  73693. */ name: string;
  73694. /**
  73695. * Callback called when the task is successful
  73696. */
  73697. onSuccess: (task: any) => void;
  73698. /**
  73699. * Callback called when the task is not successful
  73700. */
  73701. onError: (task: any, message?: string, exception?: any) => void;
  73702. /**
  73703. * Creates a new AssetsManager
  73704. * @param name defines the name of the task
  73705. */
  73706. constructor(
  73707. /**
  73708. * Task name
  73709. */ name: string);
  73710. private _isCompleted;
  73711. private _taskState;
  73712. private _errorObject;
  73713. /**
  73714. * Get if the task is completed
  73715. */
  73716. get isCompleted(): boolean;
  73717. /**
  73718. * Gets the current state of the task
  73719. */
  73720. get taskState(): AssetTaskState;
  73721. /**
  73722. * Gets the current error object (if task is in error)
  73723. */
  73724. get errorObject(): {
  73725. message?: string;
  73726. exception?: any;
  73727. };
  73728. /**
  73729. * Internal only
  73730. * @hidden
  73731. */
  73732. _setErrorObject(message?: string, exception?: any): void;
  73733. /**
  73734. * Execute the current task
  73735. * @param scene defines the scene where you want your assets to be loaded
  73736. * @param onSuccess is a callback called when the task is successfully executed
  73737. * @param onError is a callback called if an error occurs
  73738. */
  73739. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73740. /**
  73741. * Execute the current task
  73742. * @param scene defines the scene where you want your assets to be loaded
  73743. * @param onSuccess is a callback called when the task is successfully executed
  73744. * @param onError is a callback called if an error occurs
  73745. */
  73746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73747. /**
  73748. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73749. * This can be used with failed tasks that have the reason for failure fixed.
  73750. */
  73751. reset(): void;
  73752. private onErrorCallback;
  73753. private onDoneCallback;
  73754. }
  73755. /**
  73756. * Define the interface used by progress events raised during assets loading
  73757. */
  73758. export interface IAssetsProgressEvent {
  73759. /**
  73760. * Defines the number of remaining tasks to process
  73761. */
  73762. remainingCount: number;
  73763. /**
  73764. * Defines the total number of tasks
  73765. */
  73766. totalCount: number;
  73767. /**
  73768. * Defines the task that was just processed
  73769. */
  73770. task: AbstractAssetTask;
  73771. }
  73772. /**
  73773. * Class used to share progress information about assets loading
  73774. */
  73775. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73776. /**
  73777. * Defines the number of remaining tasks to process
  73778. */
  73779. remainingCount: number;
  73780. /**
  73781. * Defines the total number of tasks
  73782. */
  73783. totalCount: number;
  73784. /**
  73785. * Defines the task that was just processed
  73786. */
  73787. task: AbstractAssetTask;
  73788. /**
  73789. * Creates a AssetsProgressEvent
  73790. * @param remainingCount defines the number of remaining tasks to process
  73791. * @param totalCount defines the total number of tasks
  73792. * @param task defines the task that was just processed
  73793. */
  73794. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73795. }
  73796. /**
  73797. * Define a task used by AssetsManager to load assets into a container
  73798. */
  73799. export class ContainerAssetTask extends AbstractAssetTask {
  73800. /**
  73801. * Defines the name of the task
  73802. */
  73803. name: string;
  73804. /**
  73805. * Defines the list of mesh's names you want to load
  73806. */
  73807. meshesNames: any;
  73808. /**
  73809. * Defines the root url to use as a base to load your meshes and associated resources
  73810. */
  73811. rootUrl: string;
  73812. /**
  73813. * Defines the filename or File of the scene to load from
  73814. */
  73815. sceneFilename: string | File;
  73816. /**
  73817. * Get the loaded asset container
  73818. */
  73819. loadedContainer: AssetContainer;
  73820. /**
  73821. * Gets the list of loaded meshes
  73822. */
  73823. loadedMeshes: Array<AbstractMesh>;
  73824. /**
  73825. * Gets the list of loaded particle systems
  73826. */
  73827. loadedParticleSystems: Array<IParticleSystem>;
  73828. /**
  73829. * Gets the list of loaded skeletons
  73830. */
  73831. loadedSkeletons: Array<Skeleton>;
  73832. /**
  73833. * Gets the list of loaded animation groups
  73834. */
  73835. loadedAnimationGroups: Array<AnimationGroup>;
  73836. /**
  73837. * Callback called when the task is successful
  73838. */
  73839. onSuccess: (task: ContainerAssetTask) => void;
  73840. /**
  73841. * Callback called when the task is successful
  73842. */
  73843. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73844. /**
  73845. * Creates a new ContainerAssetTask
  73846. * @param name defines the name of the task
  73847. * @param meshesNames defines the list of mesh's names you want to load
  73848. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73849. * @param sceneFilename defines the filename or File of the scene to load from
  73850. */
  73851. constructor(
  73852. /**
  73853. * Defines the name of the task
  73854. */
  73855. name: string,
  73856. /**
  73857. * Defines the list of mesh's names you want to load
  73858. */
  73859. meshesNames: any,
  73860. /**
  73861. * Defines the root url to use as a base to load your meshes and associated resources
  73862. */
  73863. rootUrl: string,
  73864. /**
  73865. * Defines the filename or File of the scene to load from
  73866. */
  73867. sceneFilename: string | File);
  73868. /**
  73869. * Execute the current task
  73870. * @param scene defines the scene where you want your assets to be loaded
  73871. * @param onSuccess is a callback called when the task is successfully executed
  73872. * @param onError is a callback called if an error occurs
  73873. */
  73874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73875. }
  73876. /**
  73877. * Define a task used by AssetsManager to load meshes
  73878. */
  73879. export class MeshAssetTask extends AbstractAssetTask {
  73880. /**
  73881. * Defines the name of the task
  73882. */
  73883. name: string;
  73884. /**
  73885. * Defines the list of mesh's names you want to load
  73886. */
  73887. meshesNames: any;
  73888. /**
  73889. * Defines the root url to use as a base to load your meshes and associated resources
  73890. */
  73891. rootUrl: string;
  73892. /**
  73893. * Defines the filename or File of the scene to load from
  73894. */
  73895. sceneFilename: string | File;
  73896. /**
  73897. * Gets the list of loaded meshes
  73898. */
  73899. loadedMeshes: Array<AbstractMesh>;
  73900. /**
  73901. * Gets the list of loaded particle systems
  73902. */
  73903. loadedParticleSystems: Array<IParticleSystem>;
  73904. /**
  73905. * Gets the list of loaded skeletons
  73906. */
  73907. loadedSkeletons: Array<Skeleton>;
  73908. /**
  73909. * Gets the list of loaded animation groups
  73910. */
  73911. loadedAnimationGroups: Array<AnimationGroup>;
  73912. /**
  73913. * Callback called when the task is successful
  73914. */
  73915. onSuccess: (task: MeshAssetTask) => void;
  73916. /**
  73917. * Callback called when the task is successful
  73918. */
  73919. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73920. /**
  73921. * Creates a new MeshAssetTask
  73922. * @param name defines the name of the task
  73923. * @param meshesNames defines the list of mesh's names you want to load
  73924. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73925. * @param sceneFilename defines the filename or File of the scene to load from
  73926. */
  73927. constructor(
  73928. /**
  73929. * Defines the name of the task
  73930. */
  73931. name: string,
  73932. /**
  73933. * Defines the list of mesh's names you want to load
  73934. */
  73935. meshesNames: any,
  73936. /**
  73937. * Defines the root url to use as a base to load your meshes and associated resources
  73938. */
  73939. rootUrl: string,
  73940. /**
  73941. * Defines the filename or File of the scene to load from
  73942. */
  73943. sceneFilename: string | File);
  73944. /**
  73945. * Execute the current task
  73946. * @param scene defines the scene where you want your assets to be loaded
  73947. * @param onSuccess is a callback called when the task is successfully executed
  73948. * @param onError is a callback called if an error occurs
  73949. */
  73950. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73951. }
  73952. /**
  73953. * Define a task used by AssetsManager to load text content
  73954. */
  73955. export class TextFileAssetTask extends AbstractAssetTask {
  73956. /**
  73957. * Defines the name of the task
  73958. */
  73959. name: string;
  73960. /**
  73961. * Defines the location of the file to load
  73962. */
  73963. url: string;
  73964. /**
  73965. * Gets the loaded text string
  73966. */
  73967. text: string;
  73968. /**
  73969. * Callback called when the task is successful
  73970. */
  73971. onSuccess: (task: TextFileAssetTask) => void;
  73972. /**
  73973. * Callback called when the task is successful
  73974. */
  73975. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73976. /**
  73977. * Creates a new TextFileAssetTask object
  73978. * @param name defines the name of the task
  73979. * @param url defines the location of the file to load
  73980. */
  73981. constructor(
  73982. /**
  73983. * Defines the name of the task
  73984. */
  73985. name: string,
  73986. /**
  73987. * Defines the location of the file to load
  73988. */
  73989. url: string);
  73990. /**
  73991. * Execute the current task
  73992. * @param scene defines the scene where you want your assets to be loaded
  73993. * @param onSuccess is a callback called when the task is successfully executed
  73994. * @param onError is a callback called if an error occurs
  73995. */
  73996. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73997. }
  73998. /**
  73999. * Define a task used by AssetsManager to load binary data
  74000. */
  74001. export class BinaryFileAssetTask extends AbstractAssetTask {
  74002. /**
  74003. * Defines the name of the task
  74004. */
  74005. name: string;
  74006. /**
  74007. * Defines the location of the file to load
  74008. */
  74009. url: string;
  74010. /**
  74011. * Gets the lodaded data (as an array buffer)
  74012. */
  74013. data: ArrayBuffer;
  74014. /**
  74015. * Callback called when the task is successful
  74016. */
  74017. onSuccess: (task: BinaryFileAssetTask) => void;
  74018. /**
  74019. * Callback called when the task is successful
  74020. */
  74021. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74022. /**
  74023. * Creates a new BinaryFileAssetTask object
  74024. * @param name defines the name of the new task
  74025. * @param url defines the location of the file to load
  74026. */
  74027. constructor(
  74028. /**
  74029. * Defines the name of the task
  74030. */
  74031. name: string,
  74032. /**
  74033. * Defines the location of the file to load
  74034. */
  74035. url: string);
  74036. /**
  74037. * Execute the current task
  74038. * @param scene defines the scene where you want your assets to be loaded
  74039. * @param onSuccess is a callback called when the task is successfully executed
  74040. * @param onError is a callback called if an error occurs
  74041. */
  74042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74043. }
  74044. /**
  74045. * Define a task used by AssetsManager to load images
  74046. */
  74047. export class ImageAssetTask extends AbstractAssetTask {
  74048. /**
  74049. * Defines the name of the task
  74050. */
  74051. name: string;
  74052. /**
  74053. * Defines the location of the image to load
  74054. */
  74055. url: string;
  74056. /**
  74057. * Gets the loaded images
  74058. */
  74059. image: HTMLImageElement;
  74060. /**
  74061. * Callback called when the task is successful
  74062. */
  74063. onSuccess: (task: ImageAssetTask) => void;
  74064. /**
  74065. * Callback called when the task is successful
  74066. */
  74067. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74068. /**
  74069. * Creates a new ImageAssetTask
  74070. * @param name defines the name of the task
  74071. * @param url defines the location of the image to load
  74072. */
  74073. constructor(
  74074. /**
  74075. * Defines the name of the task
  74076. */
  74077. name: string,
  74078. /**
  74079. * Defines the location of the image to load
  74080. */
  74081. url: string);
  74082. /**
  74083. * Execute the current task
  74084. * @param scene defines the scene where you want your assets to be loaded
  74085. * @param onSuccess is a callback called when the task is successfully executed
  74086. * @param onError is a callback called if an error occurs
  74087. */
  74088. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74089. }
  74090. /**
  74091. * Defines the interface used by texture loading tasks
  74092. */
  74093. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74094. /**
  74095. * Gets the loaded texture
  74096. */
  74097. texture: TEX;
  74098. }
  74099. /**
  74100. * Define a task used by AssetsManager to load 2D textures
  74101. */
  74102. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74103. /**
  74104. * Defines the name of the task
  74105. */
  74106. name: string;
  74107. /**
  74108. * Defines the location of the file to load
  74109. */
  74110. url: string;
  74111. /**
  74112. * Defines if mipmap should not be generated (default is false)
  74113. */
  74114. noMipmap?: boolean | undefined;
  74115. /**
  74116. * Defines if texture must be inverted on Y axis (default is true)
  74117. */
  74118. invertY: boolean;
  74119. /**
  74120. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74121. */
  74122. samplingMode: number;
  74123. /**
  74124. * Gets the loaded texture
  74125. */
  74126. texture: Texture;
  74127. /**
  74128. * Callback called when the task is successful
  74129. */
  74130. onSuccess: (task: TextureAssetTask) => void;
  74131. /**
  74132. * Callback called when the task is successful
  74133. */
  74134. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74135. /**
  74136. * Creates a new TextureAssetTask object
  74137. * @param name defines the name of the task
  74138. * @param url defines the location of the file to load
  74139. * @param noMipmap defines if mipmap should not be generated (default is false)
  74140. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74141. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74142. */
  74143. constructor(
  74144. /**
  74145. * Defines the name of the task
  74146. */
  74147. name: string,
  74148. /**
  74149. * Defines the location of the file to load
  74150. */
  74151. url: string,
  74152. /**
  74153. * Defines if mipmap should not be generated (default is false)
  74154. */
  74155. noMipmap?: boolean | undefined,
  74156. /**
  74157. * Defines if texture must be inverted on Y axis (default is true)
  74158. */
  74159. invertY?: boolean,
  74160. /**
  74161. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74162. */
  74163. samplingMode?: number);
  74164. /**
  74165. * Execute the current task
  74166. * @param scene defines the scene where you want your assets to be loaded
  74167. * @param onSuccess is a callback called when the task is successfully executed
  74168. * @param onError is a callback called if an error occurs
  74169. */
  74170. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74171. }
  74172. /**
  74173. * Define a task used by AssetsManager to load cube textures
  74174. */
  74175. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74176. /**
  74177. * Defines the name of the task
  74178. */
  74179. name: string;
  74180. /**
  74181. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74182. */
  74183. url: string;
  74184. /**
  74185. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74186. */
  74187. extensions?: string[] | undefined;
  74188. /**
  74189. * Defines if mipmaps should not be generated (default is false)
  74190. */
  74191. noMipmap?: boolean | undefined;
  74192. /**
  74193. * Defines the explicit list of files (undefined by default)
  74194. */
  74195. files?: string[] | undefined;
  74196. /**
  74197. * Gets the loaded texture
  74198. */
  74199. texture: CubeTexture;
  74200. /**
  74201. * Callback called when the task is successful
  74202. */
  74203. onSuccess: (task: CubeTextureAssetTask) => void;
  74204. /**
  74205. * Callback called when the task is successful
  74206. */
  74207. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74208. /**
  74209. * Creates a new CubeTextureAssetTask
  74210. * @param name defines the name of the task
  74211. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74212. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74213. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74214. * @param files defines the explicit list of files (undefined by default)
  74215. */
  74216. constructor(
  74217. /**
  74218. * Defines the name of the task
  74219. */
  74220. name: string,
  74221. /**
  74222. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74223. */
  74224. url: string,
  74225. /**
  74226. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74227. */
  74228. extensions?: string[] | undefined,
  74229. /**
  74230. * Defines if mipmaps should not be generated (default is false)
  74231. */
  74232. noMipmap?: boolean | undefined,
  74233. /**
  74234. * Defines the explicit list of files (undefined by default)
  74235. */
  74236. files?: string[] | undefined);
  74237. /**
  74238. * Execute the current task
  74239. * @param scene defines the scene where you want your assets to be loaded
  74240. * @param onSuccess is a callback called when the task is successfully executed
  74241. * @param onError is a callback called if an error occurs
  74242. */
  74243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74244. }
  74245. /**
  74246. * Define a task used by AssetsManager to load HDR cube textures
  74247. */
  74248. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74249. /**
  74250. * Defines the name of the task
  74251. */
  74252. name: string;
  74253. /**
  74254. * Defines the location of the file to load
  74255. */
  74256. url: string;
  74257. /**
  74258. * Defines the desired size (the more it increases the longer the generation will be)
  74259. */
  74260. size: number;
  74261. /**
  74262. * Defines if mipmaps should not be generated (default is false)
  74263. */
  74264. noMipmap: boolean;
  74265. /**
  74266. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74267. */
  74268. generateHarmonics: boolean;
  74269. /**
  74270. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  74271. */
  74272. gammaSpace: boolean;
  74273. /**
  74274. * Internal Use Only
  74275. */
  74276. reserved: boolean;
  74277. /**
  74278. * Gets the loaded texture
  74279. */
  74280. texture: HDRCubeTexture;
  74281. /**
  74282. * Callback called when the task is successful
  74283. */
  74284. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74285. /**
  74286. * Callback called when the task is successful
  74287. */
  74288. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74289. /**
  74290. * Creates a new HDRCubeTextureAssetTask object
  74291. * @param name defines the name of the task
  74292. * @param url defines the location of the file to load
  74293. * @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.
  74294. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74295. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74296. * @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)
  74297. * @param reserved Internal use only
  74298. */
  74299. constructor(
  74300. /**
  74301. * Defines the name of the task
  74302. */
  74303. name: string,
  74304. /**
  74305. * Defines the location of the file to load
  74306. */
  74307. url: string,
  74308. /**
  74309. * Defines the desired size (the more it increases the longer the generation will be)
  74310. */
  74311. size: number,
  74312. /**
  74313. * Defines if mipmaps should not be generated (default is false)
  74314. */
  74315. noMipmap?: boolean,
  74316. /**
  74317. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74318. */
  74319. generateHarmonics?: boolean,
  74320. /**
  74321. * 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)
  74322. */
  74323. gammaSpace?: boolean,
  74324. /**
  74325. * Internal Use Only
  74326. */
  74327. reserved?: boolean);
  74328. /**
  74329. * Execute the current task
  74330. * @param scene defines the scene where you want your assets to be loaded
  74331. * @param onSuccess is a callback called when the task is successfully executed
  74332. * @param onError is a callback called if an error occurs
  74333. */
  74334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74335. }
  74336. /**
  74337. * Define a task used by AssetsManager to load Equirectangular cube textures
  74338. */
  74339. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74340. /**
  74341. * Defines the name of the task
  74342. */
  74343. name: string;
  74344. /**
  74345. * Defines the location of the file to load
  74346. */
  74347. url: string;
  74348. /**
  74349. * Defines the desired size (the more it increases the longer the generation will be)
  74350. */
  74351. size: number;
  74352. /**
  74353. * Defines if mipmaps should not be generated (default is false)
  74354. */
  74355. noMipmap: boolean;
  74356. /**
  74357. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74358. * but the standard material would require them in Gamma space) (default is true)
  74359. */
  74360. gammaSpace: boolean;
  74361. /**
  74362. * Gets the loaded texture
  74363. */
  74364. texture: EquiRectangularCubeTexture;
  74365. /**
  74366. * Callback called when the task is successful
  74367. */
  74368. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74369. /**
  74370. * Callback called when the task is successful
  74371. */
  74372. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74373. /**
  74374. * Creates a new EquiRectangularCubeTextureAssetTask object
  74375. * @param name defines the name of the task
  74376. * @param url defines the location of the file to load
  74377. * @param size defines the desired size (the more it increases the longer the generation will be)
  74378. * If the size is omitted this implies you are using a preprocessed cubemap.
  74379. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74380. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74381. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74382. * (default is true)
  74383. */
  74384. constructor(
  74385. /**
  74386. * Defines the name of the task
  74387. */
  74388. name: string,
  74389. /**
  74390. * Defines the location of the file to load
  74391. */
  74392. url: string,
  74393. /**
  74394. * Defines the desired size (the more it increases the longer the generation will be)
  74395. */
  74396. size: number,
  74397. /**
  74398. * Defines if mipmaps should not be generated (default is false)
  74399. */
  74400. noMipmap?: boolean,
  74401. /**
  74402. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74403. * but the standard material would require them in Gamma space) (default is true)
  74404. */
  74405. gammaSpace?: boolean);
  74406. /**
  74407. * Execute the current task
  74408. * @param scene defines the scene where you want your assets to be loaded
  74409. * @param onSuccess is a callback called when the task is successfully executed
  74410. * @param onError is a callback called if an error occurs
  74411. */
  74412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74413. }
  74414. /**
  74415. * This class can be used to easily import assets into a scene
  74416. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74417. */
  74418. export class AssetsManager {
  74419. private _scene;
  74420. private _isLoading;
  74421. protected _tasks: AbstractAssetTask[];
  74422. protected _waitingTasksCount: number;
  74423. protected _totalTasksCount: number;
  74424. /**
  74425. * Callback called when all tasks are processed
  74426. */
  74427. onFinish: (tasks: AbstractAssetTask[]) => void;
  74428. /**
  74429. * Callback called when a task is successful
  74430. */
  74431. onTaskSuccess: (task: AbstractAssetTask) => void;
  74432. /**
  74433. * Callback called when a task had an error
  74434. */
  74435. onTaskError: (task: AbstractAssetTask) => void;
  74436. /**
  74437. * Callback called when a task is done (whatever the result is)
  74438. */
  74439. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74440. /**
  74441. * Observable called when all tasks are processed
  74442. */
  74443. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74444. /**
  74445. * Observable called when a task had an error
  74446. */
  74447. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74448. /**
  74449. * Observable called when all tasks were executed
  74450. */
  74451. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74452. /**
  74453. * Observable called when a task is done (whatever the result is)
  74454. */
  74455. onProgressObservable: Observable<IAssetsProgressEvent>;
  74456. /**
  74457. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74458. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74459. */
  74460. useDefaultLoadingScreen: boolean;
  74461. /**
  74462. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74463. * when all assets have been downloaded.
  74464. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74465. */
  74466. autoHideLoadingUI: boolean;
  74467. /**
  74468. * Creates a new AssetsManager
  74469. * @param scene defines the scene to work on
  74470. */
  74471. constructor(scene: Scene);
  74472. /**
  74473. * Add a ContainerAssetTask to the list of active tasks
  74474. * @param taskName defines the name of the new task
  74475. * @param meshesNames defines the name of meshes to load
  74476. * @param rootUrl defines the root url to use to locate files
  74477. * @param sceneFilename defines the filename of the scene file
  74478. * @returns a new ContainerAssetTask object
  74479. */
  74480. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74481. /**
  74482. * Add a MeshAssetTask to the list of active tasks
  74483. * @param taskName defines the name of the new task
  74484. * @param meshesNames defines the name of meshes to load
  74485. * @param rootUrl defines the root url to use to locate files
  74486. * @param sceneFilename defines the filename of the scene file
  74487. * @returns a new MeshAssetTask object
  74488. */
  74489. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74490. /**
  74491. * Add a TextFileAssetTask to the list of active tasks
  74492. * @param taskName defines the name of the new task
  74493. * @param url defines the url of the file to load
  74494. * @returns a new TextFileAssetTask object
  74495. */
  74496. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74497. /**
  74498. * Add a BinaryFileAssetTask to the list of active tasks
  74499. * @param taskName defines the name of the new task
  74500. * @param url defines the url of the file to load
  74501. * @returns a new BinaryFileAssetTask object
  74502. */
  74503. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74504. /**
  74505. * Add a ImageAssetTask to the list of active tasks
  74506. * @param taskName defines the name of the new task
  74507. * @param url defines the url of the file to load
  74508. * @returns a new ImageAssetTask object
  74509. */
  74510. addImageTask(taskName: string, url: string): ImageAssetTask;
  74511. /**
  74512. * Add a TextureAssetTask to the list of active tasks
  74513. * @param taskName defines the name of the new task
  74514. * @param url defines the url of the file to load
  74515. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74516. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74517. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74518. * @returns a new TextureAssetTask object
  74519. */
  74520. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74521. /**
  74522. * Add a CubeTextureAssetTask to the list of active tasks
  74523. * @param taskName defines the name of the new task
  74524. * @param url defines the url of the file to load
  74525. * @param extensions defines the extension to use to load the cube map (can be null)
  74526. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74527. * @param files defines the list of files to load (can be null)
  74528. * @returns a new CubeTextureAssetTask object
  74529. */
  74530. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74531. /**
  74532. *
  74533. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74534. * @param taskName defines the name of the new task
  74535. * @param url defines the url of the file to load
  74536. * @param size defines the size you want for the cubemap (can be null)
  74537. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74538. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74539. * @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)
  74540. * @param reserved Internal use only
  74541. * @returns a new HDRCubeTextureAssetTask object
  74542. */
  74543. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74544. /**
  74545. *
  74546. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74547. * @param taskName defines the name of the new task
  74548. * @param url defines the url of the file to load
  74549. * @param size defines the size you want for the cubemap (can be null)
  74550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74551. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74552. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74553. * @returns a new EquiRectangularCubeTextureAssetTask object
  74554. */
  74555. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74556. /**
  74557. * Remove a task from the assets manager.
  74558. * @param task the task to remove
  74559. */
  74560. removeTask(task: AbstractAssetTask): void;
  74561. private _decreaseWaitingTasksCount;
  74562. private _runTask;
  74563. /**
  74564. * Reset the AssetsManager and remove all tasks
  74565. * @return the current instance of the AssetsManager
  74566. */
  74567. reset(): AssetsManager;
  74568. /**
  74569. * Start the loading process
  74570. * @return the current instance of the AssetsManager
  74571. */
  74572. load(): AssetsManager;
  74573. /**
  74574. * Start the loading process as an async operation
  74575. * @return a promise returning the list of failed tasks
  74576. */
  74577. loadAsync(): Promise<void>;
  74578. }
  74579. }
  74580. declare module BABYLON {
  74581. /**
  74582. * Wrapper class for promise with external resolve and reject.
  74583. */
  74584. export class Deferred<T> {
  74585. /**
  74586. * The promise associated with this deferred object.
  74587. */
  74588. readonly promise: Promise<T>;
  74589. private _resolve;
  74590. private _reject;
  74591. /**
  74592. * The resolve method of the promise associated with this deferred object.
  74593. */
  74594. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74595. /**
  74596. * The reject method of the promise associated with this deferred object.
  74597. */
  74598. get reject(): (reason?: any) => void;
  74599. /**
  74600. * Constructor for this deferred object.
  74601. */
  74602. constructor();
  74603. }
  74604. }
  74605. declare module BABYLON {
  74606. /**
  74607. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74608. */
  74609. export class MeshExploder {
  74610. private _centerMesh;
  74611. private _meshes;
  74612. private _meshesOrigins;
  74613. private _toCenterVectors;
  74614. private _scaledDirection;
  74615. private _newPosition;
  74616. private _centerPosition;
  74617. /**
  74618. * Explodes meshes from a center mesh.
  74619. * @param meshes The meshes to explode.
  74620. * @param centerMesh The mesh to be center of explosion.
  74621. */
  74622. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74623. private _setCenterMesh;
  74624. /**
  74625. * Get class name
  74626. * @returns "MeshExploder"
  74627. */
  74628. getClassName(): string;
  74629. /**
  74630. * "Exploded meshes"
  74631. * @returns Array of meshes with the centerMesh at index 0.
  74632. */
  74633. getMeshes(): Array<Mesh>;
  74634. /**
  74635. * Explodes meshes giving a specific direction
  74636. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74637. */
  74638. explode(direction?: number): void;
  74639. }
  74640. }
  74641. declare module BABYLON {
  74642. /**
  74643. * Class used to help managing file picking and drag'n'drop
  74644. */
  74645. export class FilesInput {
  74646. /**
  74647. * List of files ready to be loaded
  74648. */
  74649. static get FilesToLoad(): {
  74650. [key: string]: File;
  74651. };
  74652. /**
  74653. * Callback called when a file is processed
  74654. */
  74655. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74656. private _engine;
  74657. private _currentScene;
  74658. private _sceneLoadedCallback;
  74659. private _progressCallback;
  74660. private _additionalRenderLoopLogicCallback;
  74661. private _textureLoadingCallback;
  74662. private _startingProcessingFilesCallback;
  74663. private _onReloadCallback;
  74664. private _errorCallback;
  74665. private _elementToMonitor;
  74666. private _sceneFileToLoad;
  74667. private _filesToLoad;
  74668. /**
  74669. * Creates a new FilesInput
  74670. * @param engine defines the rendering engine
  74671. * @param scene defines the hosting scene
  74672. * @param sceneLoadedCallback callback called when scene is loaded
  74673. * @param progressCallback callback called to track progress
  74674. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74675. * @param textureLoadingCallback callback called when a texture is loading
  74676. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74677. * @param onReloadCallback callback called when a reload is requested
  74678. * @param errorCallback callback call if an error occurs
  74679. */
  74680. 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>);
  74681. private _dragEnterHandler;
  74682. private _dragOverHandler;
  74683. private _dropHandler;
  74684. /**
  74685. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74686. * @param elementToMonitor defines the DOM element to track
  74687. */
  74688. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74689. /** Gets the current list of files to load */
  74690. get filesToLoad(): File[];
  74691. /**
  74692. * Release all associated resources
  74693. */
  74694. dispose(): void;
  74695. private renderFunction;
  74696. private drag;
  74697. private drop;
  74698. private _traverseFolder;
  74699. private _processFiles;
  74700. /**
  74701. * Load files from a drop event
  74702. * @param event defines the drop event to use as source
  74703. */
  74704. loadFiles(event: any): void;
  74705. private _processReload;
  74706. /**
  74707. * Reload the current scene from the loaded files
  74708. */
  74709. reload(): void;
  74710. }
  74711. }
  74712. declare module BABYLON {
  74713. /**
  74714. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74715. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74716. */
  74717. export class SceneOptimization {
  74718. /**
  74719. * Defines the priority of this optimization (0 by default which means first in the list)
  74720. */
  74721. priority: number;
  74722. /**
  74723. * Gets a string describing the action executed by the current optimization
  74724. * @returns description string
  74725. */
  74726. getDescription(): string;
  74727. /**
  74728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74729. * @param scene defines the current scene where to apply this optimization
  74730. * @param optimizer defines the current optimizer
  74731. * @returns true if everything that can be done was applied
  74732. */
  74733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74734. /**
  74735. * Creates the SceneOptimization object
  74736. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74737. * @param desc defines the description associated with the optimization
  74738. */
  74739. constructor(
  74740. /**
  74741. * Defines the priority of this optimization (0 by default which means first in the list)
  74742. */
  74743. priority?: number);
  74744. }
  74745. /**
  74746. * Defines an optimization used to reduce the size of render target textures
  74747. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74748. */
  74749. export class TextureOptimization extends SceneOptimization {
  74750. /**
  74751. * Defines the priority of this optimization (0 by default which means first in the list)
  74752. */
  74753. priority: number;
  74754. /**
  74755. * 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
  74756. */
  74757. maximumSize: number;
  74758. /**
  74759. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74760. */
  74761. step: number;
  74762. /**
  74763. * Gets a string describing the action executed by the current optimization
  74764. * @returns description string
  74765. */
  74766. getDescription(): string;
  74767. /**
  74768. * Creates the TextureOptimization object
  74769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74770. * @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
  74771. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74772. */
  74773. constructor(
  74774. /**
  74775. * Defines the priority of this optimization (0 by default which means first in the list)
  74776. */
  74777. priority?: number,
  74778. /**
  74779. * 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
  74780. */
  74781. maximumSize?: number,
  74782. /**
  74783. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74784. */
  74785. step?: number);
  74786. /**
  74787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74788. * @param scene defines the current scene where to apply this optimization
  74789. * @param optimizer defines the current optimizer
  74790. * @returns true if everything that can be done was applied
  74791. */
  74792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74793. }
  74794. /**
  74795. * Defines an optimization used to increase or decrease the rendering resolution
  74796. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74797. */
  74798. export class HardwareScalingOptimization extends SceneOptimization {
  74799. /**
  74800. * Defines the priority of this optimization (0 by default which means first in the list)
  74801. */
  74802. priority: number;
  74803. /**
  74804. * Defines the maximum scale to use (2 by default)
  74805. */
  74806. maximumScale: number;
  74807. /**
  74808. * Defines the step to use between two passes (0.5 by default)
  74809. */
  74810. step: number;
  74811. private _currentScale;
  74812. private _directionOffset;
  74813. /**
  74814. * Gets a string describing the action executed by the current optimization
  74815. * @return description string
  74816. */
  74817. getDescription(): string;
  74818. /**
  74819. * Creates the HardwareScalingOptimization object
  74820. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74821. * @param maximumScale defines the maximum scale to use (2 by default)
  74822. * @param step defines the step to use between two passes (0.5 by default)
  74823. */
  74824. constructor(
  74825. /**
  74826. * Defines the priority of this optimization (0 by default which means first in the list)
  74827. */
  74828. priority?: number,
  74829. /**
  74830. * Defines the maximum scale to use (2 by default)
  74831. */
  74832. maximumScale?: number,
  74833. /**
  74834. * Defines the step to use between two passes (0.5 by default)
  74835. */
  74836. step?: number);
  74837. /**
  74838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74839. * @param scene defines the current scene where to apply this optimization
  74840. * @param optimizer defines the current optimizer
  74841. * @returns true if everything that can be done was applied
  74842. */
  74843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74844. }
  74845. /**
  74846. * Defines an optimization used to remove shadows
  74847. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74848. */
  74849. export class ShadowsOptimization extends SceneOptimization {
  74850. /**
  74851. * Gets a string describing the action executed by the current optimization
  74852. * @return description string
  74853. */
  74854. getDescription(): string;
  74855. /**
  74856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74857. * @param scene defines the current scene where to apply this optimization
  74858. * @param optimizer defines the current optimizer
  74859. * @returns true if everything that can be done was applied
  74860. */
  74861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74862. }
  74863. /**
  74864. * Defines an optimization used to turn post-processes off
  74865. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74866. */
  74867. export class PostProcessesOptimization extends SceneOptimization {
  74868. /**
  74869. * Gets a string describing the action executed by the current optimization
  74870. * @return description string
  74871. */
  74872. getDescription(): string;
  74873. /**
  74874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74875. * @param scene defines the current scene where to apply this optimization
  74876. * @param optimizer defines the current optimizer
  74877. * @returns true if everything that can be done was applied
  74878. */
  74879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74880. }
  74881. /**
  74882. * Defines an optimization used to turn lens flares off
  74883. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74884. */
  74885. export class LensFlaresOptimization extends SceneOptimization {
  74886. /**
  74887. * Gets a string describing the action executed by the current optimization
  74888. * @return description string
  74889. */
  74890. getDescription(): string;
  74891. /**
  74892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74893. * @param scene defines the current scene where to apply this optimization
  74894. * @param optimizer defines the current optimizer
  74895. * @returns true if everything that can be done was applied
  74896. */
  74897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74898. }
  74899. /**
  74900. * Defines an optimization based on user defined callback.
  74901. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74902. */
  74903. export class CustomOptimization extends SceneOptimization {
  74904. /**
  74905. * Callback called to apply the custom optimization.
  74906. */
  74907. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74908. /**
  74909. * Callback called to get custom description
  74910. */
  74911. onGetDescription: () => string;
  74912. /**
  74913. * Gets a string describing the action executed by the current optimization
  74914. * @returns description string
  74915. */
  74916. getDescription(): string;
  74917. /**
  74918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74919. * @param scene defines the current scene where to apply this optimization
  74920. * @param optimizer defines the current optimizer
  74921. * @returns true if everything that can be done was applied
  74922. */
  74923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74924. }
  74925. /**
  74926. * Defines an optimization used to turn particles off
  74927. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74928. */
  74929. export class ParticlesOptimization extends SceneOptimization {
  74930. /**
  74931. * Gets a string describing the action executed by the current optimization
  74932. * @return description string
  74933. */
  74934. getDescription(): string;
  74935. /**
  74936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74937. * @param scene defines the current scene where to apply this optimization
  74938. * @param optimizer defines the current optimizer
  74939. * @returns true if everything that can be done was applied
  74940. */
  74941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74942. }
  74943. /**
  74944. * Defines an optimization used to turn render targets off
  74945. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74946. */
  74947. export class RenderTargetsOptimization extends SceneOptimization {
  74948. /**
  74949. * Gets a string describing the action executed by the current optimization
  74950. * @return description string
  74951. */
  74952. getDescription(): string;
  74953. /**
  74954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74955. * @param scene defines the current scene where to apply this optimization
  74956. * @param optimizer defines the current optimizer
  74957. * @returns true if everything that can be done was applied
  74958. */
  74959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74960. }
  74961. /**
  74962. * Defines an optimization used to merge meshes with compatible materials
  74963. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74964. */
  74965. export class MergeMeshesOptimization extends SceneOptimization {
  74966. private static _UpdateSelectionTree;
  74967. /**
  74968. * Gets or sets a boolean which defines if optimization octree has to be updated
  74969. */
  74970. static get UpdateSelectionTree(): boolean;
  74971. /**
  74972. * Gets or sets a boolean which defines if optimization octree has to be updated
  74973. */
  74974. static set UpdateSelectionTree(value: boolean);
  74975. /**
  74976. * Gets a string describing the action executed by the current optimization
  74977. * @return description string
  74978. */
  74979. getDescription(): string;
  74980. private _canBeMerged;
  74981. /**
  74982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74983. * @param scene defines the current scene where to apply this optimization
  74984. * @param optimizer defines the current optimizer
  74985. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74986. * @returns true if everything that can be done was applied
  74987. */
  74988. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74989. }
  74990. /**
  74991. * Defines a list of options used by SceneOptimizer
  74992. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74993. */
  74994. export class SceneOptimizerOptions {
  74995. /**
  74996. * Defines the target frame rate to reach (60 by default)
  74997. */
  74998. targetFrameRate: number;
  74999. /**
  75000. * Defines the interval between two checkes (2000ms by default)
  75001. */
  75002. trackerDuration: number;
  75003. /**
  75004. * Gets the list of optimizations to apply
  75005. */
  75006. optimizations: SceneOptimization[];
  75007. /**
  75008. * Creates a new list of options used by SceneOptimizer
  75009. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75010. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75011. */
  75012. constructor(
  75013. /**
  75014. * Defines the target frame rate to reach (60 by default)
  75015. */
  75016. targetFrameRate?: number,
  75017. /**
  75018. * Defines the interval between two checkes (2000ms by default)
  75019. */
  75020. trackerDuration?: number);
  75021. /**
  75022. * Add a new optimization
  75023. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75024. * @returns the current SceneOptimizerOptions
  75025. */
  75026. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75027. /**
  75028. * Add a new custom optimization
  75029. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75030. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75031. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75032. * @returns the current SceneOptimizerOptions
  75033. */
  75034. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75035. /**
  75036. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75037. * @param targetFrameRate defines the target frame rate (60 by default)
  75038. * @returns a SceneOptimizerOptions object
  75039. */
  75040. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75041. /**
  75042. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75043. * @param targetFrameRate defines the target frame rate (60 by default)
  75044. * @returns a SceneOptimizerOptions object
  75045. */
  75046. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75047. /**
  75048. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75049. * @param targetFrameRate defines the target frame rate (60 by default)
  75050. * @returns a SceneOptimizerOptions object
  75051. */
  75052. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75053. }
  75054. /**
  75055. * Class used to run optimizations in order to reach a target frame rate
  75056. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75057. */
  75058. export class SceneOptimizer implements IDisposable {
  75059. private _isRunning;
  75060. private _options;
  75061. private _scene;
  75062. private _currentPriorityLevel;
  75063. private _targetFrameRate;
  75064. private _trackerDuration;
  75065. private _currentFrameRate;
  75066. private _sceneDisposeObserver;
  75067. private _improvementMode;
  75068. /**
  75069. * Defines an observable called when the optimizer reaches the target frame rate
  75070. */
  75071. onSuccessObservable: Observable<SceneOptimizer>;
  75072. /**
  75073. * Defines an observable called when the optimizer enables an optimization
  75074. */
  75075. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75076. /**
  75077. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75078. */
  75079. onFailureObservable: Observable<SceneOptimizer>;
  75080. /**
  75081. * Gets a boolean indicating if the optimizer is in improvement mode
  75082. */
  75083. get isInImprovementMode(): boolean;
  75084. /**
  75085. * Gets the current priority level (0 at start)
  75086. */
  75087. get currentPriorityLevel(): number;
  75088. /**
  75089. * Gets the current frame rate checked by the SceneOptimizer
  75090. */
  75091. get currentFrameRate(): number;
  75092. /**
  75093. * Gets or sets the current target frame rate (60 by default)
  75094. */
  75095. get targetFrameRate(): number;
  75096. /**
  75097. * Gets or sets the current target frame rate (60 by default)
  75098. */
  75099. set targetFrameRate(value: number);
  75100. /**
  75101. * Gets or sets the current interval between two checks (every 2000ms by default)
  75102. */
  75103. get trackerDuration(): number;
  75104. /**
  75105. * Gets or sets the current interval between two checks (every 2000ms by default)
  75106. */
  75107. set trackerDuration(value: number);
  75108. /**
  75109. * Gets the list of active optimizations
  75110. */
  75111. get optimizations(): SceneOptimization[];
  75112. /**
  75113. * Creates a new SceneOptimizer
  75114. * @param scene defines the scene to work on
  75115. * @param options defines the options to use with the SceneOptimizer
  75116. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75117. * @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)
  75118. */
  75119. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75120. /**
  75121. * Stops the current optimizer
  75122. */
  75123. stop(): void;
  75124. /**
  75125. * Reset the optimizer to initial step (current priority level = 0)
  75126. */
  75127. reset(): void;
  75128. /**
  75129. * Start the optimizer. By default it will try to reach a specific framerate
  75130. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75131. */
  75132. start(): void;
  75133. private _checkCurrentState;
  75134. /**
  75135. * Release all resources
  75136. */
  75137. dispose(): void;
  75138. /**
  75139. * Helper function to create a SceneOptimizer with one single line of code
  75140. * @param scene defines the scene to work on
  75141. * @param options defines the options to use with the SceneOptimizer
  75142. * @param onSuccess defines a callback to call on success
  75143. * @param onFailure defines a callback to call on failure
  75144. * @returns the new SceneOptimizer object
  75145. */
  75146. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75147. }
  75148. }
  75149. declare module BABYLON {
  75150. /**
  75151. * Class used to serialize a scene into a string
  75152. */
  75153. export class SceneSerializer {
  75154. /**
  75155. * Clear cache used by a previous serialization
  75156. */
  75157. static ClearCache(): void;
  75158. /**
  75159. * Serialize a scene into a JSON compatible object
  75160. * @param scene defines the scene to serialize
  75161. * @returns a JSON compatible object
  75162. */
  75163. static Serialize(scene: Scene): any;
  75164. /**
  75165. * Serialize a mesh into a JSON compatible object
  75166. * @param toSerialize defines the mesh to serialize
  75167. * @param withParents defines if parents must be serialized as well
  75168. * @param withChildren defines if children must be serialized as well
  75169. * @returns a JSON compatible object
  75170. */
  75171. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75172. }
  75173. }
  75174. declare module BABYLON {
  75175. /**
  75176. * Class used to host texture specific utilities
  75177. */
  75178. export class TextureTools {
  75179. /**
  75180. * Uses the GPU to create a copy texture rescaled at a given size
  75181. * @param texture Texture to copy from
  75182. * @param width defines the desired width
  75183. * @param height defines the desired height
  75184. * @param useBilinearMode defines if bilinear mode has to be used
  75185. * @return the generated texture
  75186. */
  75187. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75188. }
  75189. }
  75190. declare module BABYLON {
  75191. /**
  75192. * This represents the different options available for the video capture.
  75193. */
  75194. export interface VideoRecorderOptions {
  75195. /** Defines the mime type of the video. */
  75196. mimeType: string;
  75197. /** Defines the FPS the video should be recorded at. */
  75198. fps: number;
  75199. /** Defines the chunk size for the recording data. */
  75200. recordChunckSize: number;
  75201. /** The audio tracks to attach to the recording. */
  75202. audioTracks?: MediaStreamTrack[];
  75203. }
  75204. /**
  75205. * This can help with recording videos from BabylonJS.
  75206. * This is based on the available WebRTC functionalities of the browser.
  75207. *
  75208. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75209. */
  75210. export class VideoRecorder {
  75211. private static readonly _defaultOptions;
  75212. /**
  75213. * Returns whether or not the VideoRecorder is available in your browser.
  75214. * @param engine Defines the Babylon Engine.
  75215. * @returns true if supported otherwise false.
  75216. */
  75217. static IsSupported(engine: Engine): boolean;
  75218. private readonly _options;
  75219. private _canvas;
  75220. private _mediaRecorder;
  75221. private _recordedChunks;
  75222. private _fileName;
  75223. private _resolve;
  75224. private _reject;
  75225. /**
  75226. * True when a recording is already in progress.
  75227. */
  75228. get isRecording(): boolean;
  75229. /**
  75230. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75231. * @param engine Defines the BabylonJS Engine you wish to record.
  75232. * @param options Defines options that can be used to customize the capture.
  75233. */
  75234. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75235. /**
  75236. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75237. */
  75238. stopRecording(): void;
  75239. /**
  75240. * Starts recording the canvas for a max duration specified in parameters.
  75241. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75242. * If null no automatic download will start and you can rely on the promise to get the data back.
  75243. * @param maxDuration Defines the maximum recording time in seconds.
  75244. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75245. * @return A promise callback at the end of the recording with the video data in Blob.
  75246. */
  75247. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75248. /**
  75249. * Releases internal resources used during the recording.
  75250. */
  75251. dispose(): void;
  75252. private _handleDataAvailable;
  75253. private _handleError;
  75254. private _handleStop;
  75255. }
  75256. }
  75257. declare module BABYLON {
  75258. /**
  75259. * Class containing a set of static utilities functions for screenshots
  75260. */
  75261. export class ScreenshotTools {
  75262. /**
  75263. * Captures a screenshot of the current rendering
  75264. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75265. * @param engine defines the rendering engine
  75266. * @param camera defines the source camera
  75267. * @param size This parameter can be set to a single number or to an object with the
  75268. * following (optional) properties: precision, width, height. If a single number is passed,
  75269. * it will be used for both width and height. If an object is passed, the screenshot size
  75270. * will be derived from the parameters. The precision property is a multiplier allowing
  75271. * rendering at a higher or lower resolution
  75272. * @param successCallback defines the callback receives a single parameter which contains the
  75273. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75274. * src parameter of an <img> to display it
  75275. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75276. * Check your browser for supported MIME types
  75277. */
  75278. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75279. /**
  75280. * Captures a screenshot of the current rendering
  75281. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75282. * @param engine defines the rendering engine
  75283. * @param camera defines the source camera
  75284. * @param size This parameter can be set to a single number or to an object with the
  75285. * following (optional) properties: precision, width, height. If a single number is passed,
  75286. * it will be used for both width and height. If an object is passed, the screenshot size
  75287. * will be derived from the parameters. The precision property is a multiplier allowing
  75288. * rendering at a higher or lower resolution
  75289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75290. * Check your browser for supported MIME types
  75291. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75292. * to the src parameter of an <img> to display it
  75293. */
  75294. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75295. /**
  75296. * Generates an image screenshot from the specified camera.
  75297. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75298. * @param engine The engine to use for rendering
  75299. * @param camera The camera to use for rendering
  75300. * @param size This parameter can be set to a single number or to an object with the
  75301. * following (optional) properties: precision, width, height. If a single number is passed,
  75302. * it will be used for both width and height. If an object is passed, the screenshot size
  75303. * will be derived from the parameters. The precision property is a multiplier allowing
  75304. * rendering at a higher or lower resolution
  75305. * @param successCallback The callback receives a single parameter which contains the
  75306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75307. * src parameter of an <img> to display it
  75308. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75309. * Check your browser for supported MIME types
  75310. * @param samples Texture samples (default: 1)
  75311. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75312. * @param fileName A name for for the downloaded file.
  75313. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75314. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75315. */
  75316. 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;
  75317. /**
  75318. * Generates an image screenshot from the specified camera.
  75319. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75320. * @param engine The engine to use for rendering
  75321. * @param camera The camera to use for rendering
  75322. * @param size This parameter can be set to a single number or to an object with the
  75323. * following (optional) properties: precision, width, height. If a single number is passed,
  75324. * it will be used for both width and height. If an object is passed, the screenshot size
  75325. * will be derived from the parameters. The precision property is a multiplier allowing
  75326. * rendering at a higher or lower resolution
  75327. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75328. * Check your browser for supported MIME types
  75329. * @param samples Texture samples (default: 1)
  75330. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75331. * @param fileName A name for for the downloaded file.
  75332. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75333. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75334. * to the src parameter of an <img> to display it
  75335. */
  75336. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75337. /**
  75338. * Gets height and width for screenshot size
  75339. * @private
  75340. */
  75341. private static _getScreenshotSize;
  75342. }
  75343. }
  75344. declare module BABYLON {
  75345. /**
  75346. * Interface for a data buffer
  75347. */
  75348. export interface IDataBuffer {
  75349. /**
  75350. * Reads bytes from the data buffer.
  75351. * @param byteOffset The byte offset to read
  75352. * @param byteLength The byte length to read
  75353. * @returns A promise that resolves when the bytes are read
  75354. */
  75355. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75356. /**
  75357. * The byte length of the buffer.
  75358. */
  75359. readonly byteLength: number;
  75360. }
  75361. /**
  75362. * Utility class for reading from a data buffer
  75363. */
  75364. export class DataReader {
  75365. /**
  75366. * The data buffer associated with this data reader.
  75367. */
  75368. readonly buffer: IDataBuffer;
  75369. /**
  75370. * The current byte offset from the beginning of the data buffer.
  75371. */
  75372. byteOffset: number;
  75373. private _dataView;
  75374. private _dataByteOffset;
  75375. /**
  75376. * Constructor
  75377. * @param buffer The buffer to read
  75378. */
  75379. constructor(buffer: IDataBuffer);
  75380. /**
  75381. * Loads the given byte length.
  75382. * @param byteLength The byte length to load
  75383. * @returns A promise that resolves when the load is complete
  75384. */
  75385. loadAsync(byteLength: number): Promise<void>;
  75386. /**
  75387. * Read a unsigned 32-bit integer from the currently loaded data range.
  75388. * @returns The 32-bit integer read
  75389. */
  75390. readUint32(): number;
  75391. /**
  75392. * Read a byte array from the currently loaded data range.
  75393. * @param byteLength The byte length to read
  75394. * @returns The byte array read
  75395. */
  75396. readUint8Array(byteLength: number): Uint8Array;
  75397. /**
  75398. * Read a string from the currently loaded data range.
  75399. * @param byteLength The byte length to read
  75400. * @returns The string read
  75401. */
  75402. readString(byteLength: number): string;
  75403. /**
  75404. * Skips the given byte length the currently loaded data range.
  75405. * @param byteLength The byte length to skip
  75406. */
  75407. skipBytes(byteLength: number): void;
  75408. }
  75409. }
  75410. declare module BABYLON {
  75411. /**
  75412. * Class for storing data to local storage if available or in-memory storage otherwise
  75413. */
  75414. export class DataStorage {
  75415. private static _Storage;
  75416. private static _GetStorage;
  75417. /**
  75418. * Reads a string from the data storage
  75419. * @param key The key to read
  75420. * @param defaultValue The value if the key doesn't exist
  75421. * @returns The string value
  75422. */
  75423. static ReadString(key: string, defaultValue: string): string;
  75424. /**
  75425. * Writes a string to the data storage
  75426. * @param key The key to write
  75427. * @param value The value to write
  75428. */
  75429. static WriteString(key: string, value: string): void;
  75430. /**
  75431. * Reads a boolean from the data storage
  75432. * @param key The key to read
  75433. * @param defaultValue The value if the key doesn't exist
  75434. * @returns The boolean value
  75435. */
  75436. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75437. /**
  75438. * Writes a boolean to the data storage
  75439. * @param key The key to write
  75440. * @param value The value to write
  75441. */
  75442. static WriteBoolean(key: string, value: boolean): void;
  75443. /**
  75444. * Reads a number from the data storage
  75445. * @param key The key to read
  75446. * @param defaultValue The value if the key doesn't exist
  75447. * @returns The number value
  75448. */
  75449. static ReadNumber(key: string, defaultValue: number): number;
  75450. /**
  75451. * Writes a number to the data storage
  75452. * @param key The key to write
  75453. * @param value The value to write
  75454. */
  75455. static WriteNumber(key: string, value: number): void;
  75456. }
  75457. }
  75458. declare module BABYLON {
  75459. /**
  75460. * Class used to record delta files between 2 scene states
  75461. */
  75462. export class SceneRecorder {
  75463. private _trackedScene;
  75464. private _savedJSON;
  75465. /**
  75466. * Track a given scene. This means the current scene state will be considered the original state
  75467. * @param scene defines the scene to track
  75468. */
  75469. track(scene: Scene): void;
  75470. /**
  75471. * Get the delta between current state and original state
  75472. * @returns a string containing the delta
  75473. */
  75474. getDelta(): any;
  75475. private _compareArray;
  75476. private _compareObjects;
  75477. private _compareCollections;
  75478. private static GetShadowGeneratorById;
  75479. /**
  75480. * Apply a given delta to a given scene
  75481. * @param deltaJSON defines the JSON containing the delta
  75482. * @param scene defines the scene to apply the delta to
  75483. */
  75484. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75485. private static _ApplyPropertiesToEntity;
  75486. private static _ApplyDeltaForEntity;
  75487. }
  75488. }
  75489. declare module BABYLON {
  75490. /**
  75491. * A 3D trajectory consisting of an order list of vectors describing a
  75492. * path of motion through 3D space.
  75493. */
  75494. export class Trajectory {
  75495. private _points;
  75496. private readonly _segmentLength;
  75497. /**
  75498. * Serialize to JSON.
  75499. * @returns serialized JSON string
  75500. */
  75501. serialize(): string;
  75502. /**
  75503. * Deserialize from JSON.
  75504. * @param json serialized JSON string
  75505. * @returns deserialized Trajectory
  75506. */
  75507. static Deserialize(json: string): Trajectory;
  75508. /**
  75509. * Create a new empty Trajectory.
  75510. * @param segmentLength radius of discretization for Trajectory points
  75511. */
  75512. constructor(segmentLength?: number);
  75513. /**
  75514. * Get the length of the Trajectory.
  75515. * @returns length of the Trajectory
  75516. */
  75517. getLength(): number;
  75518. /**
  75519. * Append a new point to the Trajectory.
  75520. * NOTE: This implementation has many allocations.
  75521. * @param point point to append to the Trajectory
  75522. */
  75523. add(point: DeepImmutable<Vector3>): void;
  75524. /**
  75525. * Create a new Trajectory with a segment length chosen to make it
  75526. * probable that the new Trajectory will have a specified number of
  75527. * segments. This operation is imprecise.
  75528. * @param targetResolution number of segments desired
  75529. * @returns new Trajectory with approximately the requested number of segments
  75530. */
  75531. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75532. /**
  75533. * Convert Trajectory segments into tokenized representation. This
  75534. * representation is an array of numbers where each nth number is the
  75535. * index of the token which is most similar to the nth segment of the
  75536. * Trajectory.
  75537. * @param tokens list of vectors which serve as discrete tokens
  75538. * @returns list of indices of most similar token per segment
  75539. */
  75540. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75541. private static _forwardDir;
  75542. private static _inverseFromVec;
  75543. private static _upDir;
  75544. private static _fromToVec;
  75545. private static _lookMatrix;
  75546. /**
  75547. * Transform the rotation (i.e., direction) of a segment to isolate
  75548. * the relative transformation represented by the segment. This operation
  75549. * may or may not succeed due to singularities in the equations that define
  75550. * motion relativity in this context.
  75551. * @param priorVec the origin of the prior segment
  75552. * @param fromVec the origin of the current segment
  75553. * @param toVec the destination of the current segment
  75554. * @param result reference to output variable
  75555. * @returns whether or not transformation was successful
  75556. */
  75557. private static _transformSegmentDirToRef;
  75558. private static _bestMatch;
  75559. private static _score;
  75560. private static _bestScore;
  75561. /**
  75562. * Determine which token vector is most similar to the
  75563. * segment vector.
  75564. * @param segment segment vector
  75565. * @param tokens token vector list
  75566. * @returns index of the most similar token to the segment
  75567. */
  75568. private static _tokenizeSegment;
  75569. }
  75570. /**
  75571. * Class representing a set of known, named trajectories to which Trajectories can be
  75572. * added and using which Trajectories can be recognized.
  75573. */
  75574. export class TrajectoryClassifier {
  75575. private _maximumAllowableMatchCost;
  75576. private _vector3Alphabet;
  75577. private _levenshteinAlphabet;
  75578. private _nameToDescribedTrajectory;
  75579. /**
  75580. * Serialize to JSON.
  75581. * @returns JSON serialization
  75582. */
  75583. serialize(): string;
  75584. /**
  75585. * Deserialize from JSON.
  75586. * @param json JSON serialization
  75587. * @returns deserialized TrajectorySet
  75588. */
  75589. static Deserialize(json: string): TrajectoryClassifier;
  75590. /**
  75591. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75592. * VERY naive, need to be generating these things from known
  75593. * sets. Better version later, probably eliminating this one.
  75594. * @returns auto-generated TrajectorySet
  75595. */
  75596. static Generate(): TrajectoryClassifier;
  75597. private constructor();
  75598. /**
  75599. * Add a new Trajectory to the set with a given name.
  75600. * @param trajectory new Trajectory to be added
  75601. * @param classification name to which to add the Trajectory
  75602. */
  75603. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75604. /**
  75605. * Remove a known named trajectory and all Trajectories associated with it.
  75606. * @param classification name to remove
  75607. * @returns whether anything was removed
  75608. */
  75609. deleteClassification(classification: string): boolean;
  75610. /**
  75611. * Attempt to recognize a Trajectory from among all the classifications
  75612. * already known to the classifier.
  75613. * @param trajectory Trajectory to be recognized
  75614. * @returns classification of Trajectory if recognized, null otherwise
  75615. */
  75616. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75617. }
  75618. }
  75619. declare module BABYLON {
  75620. /**
  75621. * An interface for all Hit test features
  75622. */
  75623. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75624. /**
  75625. * Triggered when new babylon (transformed) hit test results are available
  75626. */
  75627. onHitTestResultObservable: Observable<T[]>;
  75628. }
  75629. /**
  75630. * Options used for hit testing
  75631. */
  75632. export interface IWebXRLegacyHitTestOptions {
  75633. /**
  75634. * Only test when user interacted with the scene. Default - hit test every frame
  75635. */
  75636. testOnPointerDownOnly?: boolean;
  75637. /**
  75638. * The node to use to transform the local results to world coordinates
  75639. */
  75640. worldParentNode?: TransformNode;
  75641. }
  75642. /**
  75643. * Interface defining the babylon result of raycasting/hit-test
  75644. */
  75645. export interface IWebXRLegacyHitResult {
  75646. /**
  75647. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75648. */
  75649. transformationMatrix: Matrix;
  75650. /**
  75651. * The native hit test result
  75652. */
  75653. xrHitResult: XRHitResult | XRHitTestResult;
  75654. }
  75655. /**
  75656. * The currently-working hit-test module.
  75657. * Hit test (or Ray-casting) is used to interact with the real world.
  75658. * For further information read here - https://github.com/immersive-web/hit-test
  75659. */
  75660. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75661. /**
  75662. * options to use when constructing this feature
  75663. */
  75664. readonly options: IWebXRLegacyHitTestOptions;
  75665. private _direction;
  75666. private _mat;
  75667. private _onSelectEnabled;
  75668. private _origin;
  75669. /**
  75670. * The module's name
  75671. */
  75672. static readonly Name: string;
  75673. /**
  75674. * The (Babylon) version of this module.
  75675. * This is an integer representing the implementation version.
  75676. * This number does not correspond to the WebXR specs version
  75677. */
  75678. static readonly Version: number;
  75679. /**
  75680. * Populated with the last native XR Hit Results
  75681. */
  75682. lastNativeXRHitResults: XRHitResult[];
  75683. /**
  75684. * Triggered when new babylon (transformed) hit test results are available
  75685. */
  75686. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75687. /**
  75688. * Creates a new instance of the (legacy version) hit test feature
  75689. * @param _xrSessionManager an instance of WebXRSessionManager
  75690. * @param options options to use when constructing this feature
  75691. */
  75692. constructor(_xrSessionManager: WebXRSessionManager,
  75693. /**
  75694. * options to use when constructing this feature
  75695. */
  75696. options?: IWebXRLegacyHitTestOptions);
  75697. /**
  75698. * execute a hit test with an XR Ray
  75699. *
  75700. * @param xrSession a native xrSession that will execute this hit test
  75701. * @param xrRay the ray (position and direction) to use for ray-casting
  75702. * @param referenceSpace native XR reference space to use for the hit-test
  75703. * @param filter filter function that will filter the results
  75704. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75705. */
  75706. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75707. /**
  75708. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75709. * @param event the (select) event to use to select with
  75710. * @param referenceSpace the reference space to use for this hit test
  75711. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75712. */
  75713. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75714. /**
  75715. * attach this feature
  75716. * Will usually be called by the features manager
  75717. *
  75718. * @returns true if successful.
  75719. */
  75720. attach(): boolean;
  75721. /**
  75722. * detach this feature.
  75723. * Will usually be called by the features manager
  75724. *
  75725. * @returns true if successful.
  75726. */
  75727. detach(): boolean;
  75728. /**
  75729. * Dispose this feature and all of the resources attached
  75730. */
  75731. dispose(): void;
  75732. protected _onXRFrame(frame: XRFrame): void;
  75733. private _onHitTestResults;
  75734. private _onSelect;
  75735. }
  75736. }
  75737. declare module BABYLON {
  75738. /**
  75739. * Options used for hit testing (version 2)
  75740. */
  75741. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75742. /**
  75743. * Do not create a permanent hit test. Will usually be used when only
  75744. * transient inputs are needed.
  75745. */
  75746. disablePermanentHitTest?: boolean;
  75747. /**
  75748. * Enable transient (for example touch-based) hit test inspections
  75749. */
  75750. enableTransientHitTest?: boolean;
  75751. /**
  75752. * Offset ray for the permanent hit test
  75753. */
  75754. offsetRay?: Vector3;
  75755. /**
  75756. * Offset ray for the transient hit test
  75757. */
  75758. transientOffsetRay?: Vector3;
  75759. /**
  75760. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75761. */
  75762. useReferenceSpace?: boolean;
  75763. /**
  75764. * Override the default entity type(s) of the hit-test result
  75765. */
  75766. entityTypes?: XRHitTestTrackableType[];
  75767. }
  75768. /**
  75769. * Interface defining the babylon result of hit-test
  75770. */
  75771. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75772. /**
  75773. * The input source that generated this hit test (if transient)
  75774. */
  75775. inputSource?: XRInputSource;
  75776. /**
  75777. * Is this a transient hit test
  75778. */
  75779. isTransient?: boolean;
  75780. /**
  75781. * Position of the hit test result
  75782. */
  75783. position: Vector3;
  75784. /**
  75785. * Rotation of the hit test result
  75786. */
  75787. rotationQuaternion: Quaternion;
  75788. /**
  75789. * The native hit test result
  75790. */
  75791. xrHitResult: XRHitTestResult;
  75792. }
  75793. /**
  75794. * The currently-working hit-test module.
  75795. * Hit test (or Ray-casting) is used to interact with the real world.
  75796. * For further information read here - https://github.com/immersive-web/hit-test
  75797. *
  75798. * Tested on chrome (mobile) 80.
  75799. */
  75800. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75801. /**
  75802. * options to use when constructing this feature
  75803. */
  75804. readonly options: IWebXRHitTestOptions;
  75805. private _tmpMat;
  75806. private _tmpPos;
  75807. private _tmpQuat;
  75808. private _transientXrHitTestSource;
  75809. private _xrHitTestSource;
  75810. private initHitTestSource;
  75811. /**
  75812. * The module's name
  75813. */
  75814. static readonly Name: string;
  75815. /**
  75816. * The (Babylon) version of this module.
  75817. * This is an integer representing the implementation version.
  75818. * This number does not correspond to the WebXR specs version
  75819. */
  75820. static readonly Version: number;
  75821. /**
  75822. * When set to true, each hit test will have its own position/rotation objects
  75823. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75824. * the developers will clone them or copy them as they see fit.
  75825. */
  75826. autoCloneTransformation: boolean;
  75827. /**
  75828. * Triggered when new babylon (transformed) hit test results are available
  75829. * Note - this will be called when results come back from the device. It can be an empty array!!
  75830. */
  75831. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75832. /**
  75833. * Use this to temporarily pause hit test checks.
  75834. */
  75835. paused: boolean;
  75836. /**
  75837. * Creates a new instance of the hit test feature
  75838. * @param _xrSessionManager an instance of WebXRSessionManager
  75839. * @param options options to use when constructing this feature
  75840. */
  75841. constructor(_xrSessionManager: WebXRSessionManager,
  75842. /**
  75843. * options to use when constructing this feature
  75844. */
  75845. options?: IWebXRHitTestOptions);
  75846. /**
  75847. * attach this feature
  75848. * Will usually be called by the features manager
  75849. *
  75850. * @returns true if successful.
  75851. */
  75852. attach(): boolean;
  75853. /**
  75854. * detach this feature.
  75855. * Will usually be called by the features manager
  75856. *
  75857. * @returns true if successful.
  75858. */
  75859. detach(): boolean;
  75860. /**
  75861. * Dispose this feature and all of the resources attached
  75862. */
  75863. dispose(): void;
  75864. protected _onXRFrame(frame: XRFrame): void;
  75865. private _processWebXRHitTestResult;
  75866. }
  75867. }
  75868. declare module BABYLON {
  75869. /**
  75870. * Configuration options of the anchor system
  75871. */
  75872. export interface IWebXRAnchorSystemOptions {
  75873. /**
  75874. * a node that will be used to convert local to world coordinates
  75875. */
  75876. worldParentNode?: TransformNode;
  75877. /**
  75878. * If set to true a reference of the created anchors will be kept until the next session starts
  75879. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75880. */
  75881. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75882. }
  75883. /**
  75884. * A babylon container for an XR Anchor
  75885. */
  75886. export interface IWebXRAnchor {
  75887. /**
  75888. * A babylon-assigned ID for this anchor
  75889. */
  75890. id: number;
  75891. /**
  75892. * Transformation matrix to apply to an object attached to this anchor
  75893. */
  75894. transformationMatrix: Matrix;
  75895. /**
  75896. * The native anchor object
  75897. */
  75898. xrAnchor: XRAnchor;
  75899. /**
  75900. * if defined, this object will be constantly updated by the anchor's position and rotation
  75901. */
  75902. attachedNode?: TransformNode;
  75903. }
  75904. /**
  75905. * An implementation of the anchor system for WebXR.
  75906. * For further information see https://github.com/immersive-web/anchors/
  75907. */
  75908. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75909. private _options;
  75910. private _lastFrameDetected;
  75911. private _trackedAnchors;
  75912. private _referenceSpaceForFrameAnchors;
  75913. private _futureAnchors;
  75914. /**
  75915. * The module's name
  75916. */
  75917. static readonly Name: string;
  75918. /**
  75919. * The (Babylon) version of this module.
  75920. * This is an integer representing the implementation version.
  75921. * This number does not correspond to the WebXR specs version
  75922. */
  75923. static readonly Version: number;
  75924. /**
  75925. * Observers registered here will be executed when a new anchor was added to the session
  75926. */
  75927. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75928. /**
  75929. * Observers registered here will be executed when an anchor was removed from the session
  75930. */
  75931. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75932. /**
  75933. * Observers registered here will be executed when an existing anchor updates
  75934. * This can execute N times every frame
  75935. */
  75936. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75937. /**
  75938. * Set the reference space to use for anchor creation, when not using a hit test.
  75939. * Will default to the session's reference space if not defined
  75940. */
  75941. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75942. /**
  75943. * constructs a new anchor system
  75944. * @param _xrSessionManager an instance of WebXRSessionManager
  75945. * @param _options configuration object for this feature
  75946. */
  75947. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75948. private _tmpVector;
  75949. private _tmpQuaternion;
  75950. private _populateTmpTransformation;
  75951. /**
  75952. * Create a new anchor point using a hit test result at a specific point in the scene
  75953. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75954. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75955. *
  75956. * @param hitTestResult The hit test result to use for this anchor creation
  75957. * @param position an optional position offset for this anchor
  75958. * @param rotationQuaternion an optional rotation offset for this anchor
  75959. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75960. */
  75961. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75962. /**
  75963. * Add a new anchor at a specific position and rotation
  75964. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75965. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75966. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75967. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75968. *
  75969. * @param position the position in which to add an anchor
  75970. * @param rotationQuaternion an optional rotation for the anchor transformation
  75971. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75972. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75973. */
  75974. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75975. /**
  75976. * detach this feature.
  75977. * Will usually be called by the features manager
  75978. *
  75979. * @returns true if successful.
  75980. */
  75981. detach(): boolean;
  75982. /**
  75983. * Dispose this feature and all of the resources attached
  75984. */
  75985. dispose(): void;
  75986. protected _onXRFrame(frame: XRFrame): void;
  75987. /**
  75988. * avoiding using Array.find for global support.
  75989. * @param xrAnchor the plane to find in the array
  75990. */
  75991. private _findIndexInAnchorArray;
  75992. private _updateAnchorWithXRFrame;
  75993. private _createAnchorAtTransformation;
  75994. }
  75995. }
  75996. declare module BABYLON {
  75997. /**
  75998. * Options used in the plane detector module
  75999. */
  76000. export interface IWebXRPlaneDetectorOptions {
  76001. /**
  76002. * The node to use to transform the local results to world coordinates
  76003. */
  76004. worldParentNode?: TransformNode;
  76005. /**
  76006. * If set to true a reference of the created planes will be kept until the next session starts
  76007. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76008. */
  76009. doNotRemovePlanesOnSessionEnded?: boolean;
  76010. }
  76011. /**
  76012. * A babylon interface for a WebXR plane.
  76013. * A Plane is actually a polygon, built from N points in space
  76014. *
  76015. * Supported in chrome 79, not supported in canary 81 ATM
  76016. */
  76017. export interface IWebXRPlane {
  76018. /**
  76019. * a babylon-assigned ID for this polygon
  76020. */
  76021. id: number;
  76022. /**
  76023. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76024. */
  76025. polygonDefinition: Array<Vector3>;
  76026. /**
  76027. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76028. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76029. */
  76030. transformationMatrix: Matrix;
  76031. /**
  76032. * the native xr-plane object
  76033. */
  76034. xrPlane: XRPlane;
  76035. }
  76036. /**
  76037. * The plane detector is used to detect planes in the real world when in AR
  76038. * For more information see https://github.com/immersive-web/real-world-geometry/
  76039. */
  76040. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76041. private _options;
  76042. private _detectedPlanes;
  76043. private _enabled;
  76044. private _lastFrameDetected;
  76045. /**
  76046. * The module's name
  76047. */
  76048. static readonly Name: string;
  76049. /**
  76050. * The (Babylon) version of this module.
  76051. * This is an integer representing the implementation version.
  76052. * This number does not correspond to the WebXR specs version
  76053. */
  76054. static readonly Version: number;
  76055. /**
  76056. * Observers registered here will be executed when a new plane was added to the session
  76057. */
  76058. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76059. /**
  76060. * Observers registered here will be executed when a plane is no longer detected in the session
  76061. */
  76062. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76063. /**
  76064. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76065. * This can execute N times every frame
  76066. */
  76067. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76068. /**
  76069. * construct a new Plane Detector
  76070. * @param _xrSessionManager an instance of xr Session manager
  76071. * @param _options configuration to use when constructing this feature
  76072. */
  76073. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76074. /**
  76075. * detach this feature.
  76076. * Will usually be called by the features manager
  76077. *
  76078. * @returns true if successful.
  76079. */
  76080. detach(): boolean;
  76081. /**
  76082. * Dispose this feature and all of the resources attached
  76083. */
  76084. dispose(): void;
  76085. /**
  76086. * Check if the needed objects are defined.
  76087. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76088. */
  76089. isCompatible(): boolean;
  76090. protected _onXRFrame(frame: XRFrame): void;
  76091. private _init;
  76092. private _updatePlaneWithXRPlane;
  76093. /**
  76094. * avoiding using Array.find for global support.
  76095. * @param xrPlane the plane to find in the array
  76096. */
  76097. private findIndexInPlaneArray;
  76098. }
  76099. }
  76100. declare module BABYLON {
  76101. /**
  76102. * Options interface for the background remover plugin
  76103. */
  76104. export interface IWebXRBackgroundRemoverOptions {
  76105. /**
  76106. * Further background meshes to disable when entering AR
  76107. */
  76108. backgroundMeshes?: AbstractMesh[];
  76109. /**
  76110. * flags to configure the removal of the environment helper.
  76111. * If not set, the entire background will be removed. If set, flags should be set as well.
  76112. */
  76113. environmentHelperRemovalFlags?: {
  76114. /**
  76115. * Should the skybox be removed (default false)
  76116. */
  76117. skyBox?: boolean;
  76118. /**
  76119. * Should the ground be removed (default false)
  76120. */
  76121. ground?: boolean;
  76122. };
  76123. /**
  76124. * don't disable the environment helper
  76125. */
  76126. ignoreEnvironmentHelper?: boolean;
  76127. }
  76128. /**
  76129. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76130. */
  76131. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76132. /**
  76133. * read-only options to be used in this module
  76134. */
  76135. readonly options: IWebXRBackgroundRemoverOptions;
  76136. /**
  76137. * The module's name
  76138. */
  76139. static readonly Name: string;
  76140. /**
  76141. * The (Babylon) version of this module.
  76142. * This is an integer representing the implementation version.
  76143. * This number does not correspond to the WebXR specs version
  76144. */
  76145. static readonly Version: number;
  76146. /**
  76147. * registered observers will be triggered when the background state changes
  76148. */
  76149. onBackgroundStateChangedObservable: Observable<boolean>;
  76150. /**
  76151. * constructs a new background remover module
  76152. * @param _xrSessionManager the session manager for this module
  76153. * @param options read-only options to be used in this module
  76154. */
  76155. constructor(_xrSessionManager: WebXRSessionManager,
  76156. /**
  76157. * read-only options to be used in this module
  76158. */
  76159. options?: IWebXRBackgroundRemoverOptions);
  76160. /**
  76161. * attach this feature
  76162. * Will usually be called by the features manager
  76163. *
  76164. * @returns true if successful.
  76165. */
  76166. attach(): boolean;
  76167. /**
  76168. * detach this feature.
  76169. * Will usually be called by the features manager
  76170. *
  76171. * @returns true if successful.
  76172. */
  76173. detach(): boolean;
  76174. /**
  76175. * Dispose this feature and all of the resources attached
  76176. */
  76177. dispose(): void;
  76178. protected _onXRFrame(_xrFrame: XRFrame): void;
  76179. private _setBackgroundState;
  76180. }
  76181. }
  76182. declare module BABYLON {
  76183. /**
  76184. * Options for the controller physics feature
  76185. */
  76186. export class IWebXRControllerPhysicsOptions {
  76187. /**
  76188. * Should the headset get its own impostor
  76189. */
  76190. enableHeadsetImpostor?: boolean;
  76191. /**
  76192. * Optional parameters for the headset impostor
  76193. */
  76194. headsetImpostorParams?: {
  76195. /**
  76196. * The type of impostor to create. Default is sphere
  76197. */
  76198. impostorType: number;
  76199. /**
  76200. * the size of the impostor. Defaults to 10cm
  76201. */
  76202. impostorSize?: number | {
  76203. width: number;
  76204. height: number;
  76205. depth: number;
  76206. };
  76207. /**
  76208. * Friction definitions
  76209. */
  76210. friction?: number;
  76211. /**
  76212. * Restitution
  76213. */
  76214. restitution?: number;
  76215. };
  76216. /**
  76217. * The physics properties of the future impostors
  76218. */
  76219. physicsProperties?: {
  76220. /**
  76221. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76222. * Note that this requires a physics engine that supports mesh impostors!
  76223. */
  76224. useControllerMesh?: boolean;
  76225. /**
  76226. * The type of impostor to create. Default is sphere
  76227. */
  76228. impostorType?: number;
  76229. /**
  76230. * the size of the impostor. Defaults to 10cm
  76231. */
  76232. impostorSize?: number | {
  76233. width: number;
  76234. height: number;
  76235. depth: number;
  76236. };
  76237. /**
  76238. * Friction definitions
  76239. */
  76240. friction?: number;
  76241. /**
  76242. * Restitution
  76243. */
  76244. restitution?: number;
  76245. };
  76246. /**
  76247. * the xr input to use with this pointer selection
  76248. */
  76249. xrInput: WebXRInput;
  76250. }
  76251. /**
  76252. * Add physics impostor to your webxr controllers,
  76253. * including naive calculation of their linear and angular velocity
  76254. */
  76255. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76256. private readonly _options;
  76257. private _attachController;
  76258. private _controllers;
  76259. private _debugMode;
  76260. private _delta;
  76261. private _headsetImpostor?;
  76262. private _headsetMesh?;
  76263. private _lastTimestamp;
  76264. private _tmpQuaternion;
  76265. private _tmpVector;
  76266. /**
  76267. * The module's name
  76268. */
  76269. static readonly Name: string;
  76270. /**
  76271. * The (Babylon) version of this module.
  76272. * This is an integer representing the implementation version.
  76273. * This number does not correspond to the webxr specs version
  76274. */
  76275. static readonly Version: number;
  76276. /**
  76277. * Construct a new Controller Physics Feature
  76278. * @param _xrSessionManager the corresponding xr session manager
  76279. * @param _options options to create this feature with
  76280. */
  76281. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76282. /**
  76283. * @hidden
  76284. * enable debugging - will show console outputs and the impostor mesh
  76285. */
  76286. _enablePhysicsDebug(): void;
  76287. /**
  76288. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76289. * @param xrController the controller to add
  76290. */
  76291. addController(xrController: WebXRInputSource): void;
  76292. /**
  76293. * attach this feature
  76294. * Will usually be called by the features manager
  76295. *
  76296. * @returns true if successful.
  76297. */
  76298. attach(): boolean;
  76299. /**
  76300. * detach this feature.
  76301. * Will usually be called by the features manager
  76302. *
  76303. * @returns true if successful.
  76304. */
  76305. detach(): boolean;
  76306. /**
  76307. * Get the headset impostor, if enabled
  76308. * @returns the impostor
  76309. */
  76310. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76311. /**
  76312. * Get the physics impostor of a specific controller.
  76313. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76314. * @param controller the controller or the controller id of which to get the impostor
  76315. * @returns the impostor or null
  76316. */
  76317. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76318. /**
  76319. * Update the physics properties provided in the constructor
  76320. * @param newProperties the new properties object
  76321. */
  76322. setPhysicsProperties(newProperties: {
  76323. impostorType?: number;
  76324. impostorSize?: number | {
  76325. width: number;
  76326. height: number;
  76327. depth: number;
  76328. };
  76329. friction?: number;
  76330. restitution?: number;
  76331. }): void;
  76332. protected _onXRFrame(_xrFrame: any): void;
  76333. private _detachController;
  76334. }
  76335. }
  76336. declare module BABYLON {
  76337. /**
  76338. * A babylon interface for a "WebXR" feature point.
  76339. * Represents the position and confidence value of a given feature point.
  76340. */
  76341. export interface IWebXRFeaturePoint {
  76342. /**
  76343. * Represents the position of the feature point in world space.
  76344. */
  76345. position: Vector3;
  76346. /**
  76347. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76348. */
  76349. confidenceValue: number;
  76350. }
  76351. /**
  76352. * The feature point system is used to detect feature points from real world geometry.
  76353. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76354. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76355. */
  76356. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76357. private _enabled;
  76358. private _featurePointCloud;
  76359. /**
  76360. * The module's name
  76361. */
  76362. static readonly Name: string;
  76363. /**
  76364. * The (Babylon) version of this module.
  76365. * This is an integer representing the implementation version.
  76366. * This number does not correspond to the WebXR specs version
  76367. */
  76368. static readonly Version: number;
  76369. /**
  76370. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76371. * Will notify the observers about which feature points have been added.
  76372. */
  76373. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76374. /**
  76375. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76376. * Will notify the observers about which feature points have been updated.
  76377. */
  76378. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76379. /**
  76380. * The current feature point cloud maintained across frames.
  76381. */
  76382. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76383. /**
  76384. * construct the feature point system
  76385. * @param _xrSessionManager an instance of xr Session manager
  76386. */
  76387. constructor(_xrSessionManager: WebXRSessionManager);
  76388. /**
  76389. * Detach this feature.
  76390. * Will usually be called by the features manager
  76391. *
  76392. * @returns true if successful.
  76393. */
  76394. detach(): boolean;
  76395. /**
  76396. * Dispose this feature and all of the resources attached
  76397. */
  76398. dispose(): void;
  76399. /**
  76400. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76401. */
  76402. protected _onXRFrame(frame: XRFrame): void;
  76403. /**
  76404. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76405. */
  76406. private _init;
  76407. }
  76408. }
  76409. declare module BABYLON {
  76410. /**
  76411. * Configuration interface for the hand tracking feature
  76412. */
  76413. export interface IWebXRHandTrackingOptions {
  76414. /**
  76415. * The xrInput that will be used as source for new hands
  76416. */
  76417. xrInput: WebXRInput;
  76418. /**
  76419. * Configuration object for the joint meshes
  76420. */
  76421. jointMeshes?: {
  76422. /**
  76423. * Should the meshes created be invisible (defaults to false)
  76424. */
  76425. invisible?: boolean;
  76426. /**
  76427. * A source mesh to be used to create instances. Defaults to a sphere.
  76428. * This mesh will be the source for all other (25) meshes.
  76429. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76430. */
  76431. sourceMesh?: Mesh;
  76432. /**
  76433. * This function will be called after a mesh was created for a specific joint.
  76434. * Using this function you can either manipulate the instance or return a new mesh.
  76435. * When returning a new mesh the instance created before will be disposed
  76436. */
  76437. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76438. /**
  76439. * Should the source mesh stay visible. Defaults to false
  76440. */
  76441. keepOriginalVisible?: boolean;
  76442. /**
  76443. * Scale factor for all instances (defaults to 2)
  76444. */
  76445. scaleFactor?: number;
  76446. /**
  76447. * Should each instance have its own physics impostor
  76448. */
  76449. enablePhysics?: boolean;
  76450. /**
  76451. * If enabled, override default physics properties
  76452. */
  76453. physicsProps?: {
  76454. friction?: number;
  76455. restitution?: number;
  76456. impostorType?: number;
  76457. };
  76458. /**
  76459. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76460. */
  76461. handMesh?: AbstractMesh;
  76462. };
  76463. }
  76464. /**
  76465. * Parts of the hands divided to writs and finger names
  76466. */
  76467. export const enum HandPart {
  76468. /**
  76469. * HandPart - Wrist
  76470. */
  76471. WRIST = "wrist",
  76472. /**
  76473. * HandPart - The THumb
  76474. */
  76475. THUMB = "thumb",
  76476. /**
  76477. * HandPart - Index finger
  76478. */
  76479. INDEX = "index",
  76480. /**
  76481. * HandPart - Middle finger
  76482. */
  76483. MIDDLE = "middle",
  76484. /**
  76485. * HandPart - Ring finger
  76486. */
  76487. RING = "ring",
  76488. /**
  76489. * HandPart - Little finger
  76490. */
  76491. LITTLE = "little"
  76492. }
  76493. /**
  76494. * Representing a single hand (with its corresponding native XRHand object)
  76495. */
  76496. export class WebXRHand implements IDisposable {
  76497. /** the controller to which the hand correlates */
  76498. readonly xrController: WebXRInputSource;
  76499. /** the meshes to be used to track the hand joints */
  76500. readonly trackedMeshes: AbstractMesh[];
  76501. /**
  76502. * Hand-parts definition (key is HandPart)
  76503. */
  76504. handPartsDefinition: {
  76505. [key: string]: number[];
  76506. };
  76507. /**
  76508. * Populate the HandPartsDefinition object.
  76509. * This is called as a side effect since certain browsers don't have XRHand defined.
  76510. */
  76511. private generateHandPartsDefinition;
  76512. /**
  76513. * Construct a new hand object
  76514. * @param xrController the controller to which the hand correlates
  76515. * @param trackedMeshes the meshes to be used to track the hand joints
  76516. */
  76517. constructor(
  76518. /** the controller to which the hand correlates */
  76519. xrController: WebXRInputSource,
  76520. /** the meshes to be used to track the hand joints */
  76521. trackedMeshes: AbstractMesh[]);
  76522. /**
  76523. * Update this hand from the latest xr frame
  76524. * @param xrFrame xrFrame to update from
  76525. * @param referenceSpace The current viewer reference space
  76526. * @param scaleFactor optional scale factor for the meshes
  76527. */
  76528. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76529. /**
  76530. * Get meshes of part of the hand
  76531. * @param part the part of hand to get
  76532. * @returns An array of meshes that correlate to the hand part requested
  76533. */
  76534. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76535. /**
  76536. * Dispose this Hand object
  76537. */
  76538. dispose(): void;
  76539. }
  76540. /**
  76541. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76542. */
  76543. export class WebXRHandTracking extends WebXRAbstractFeature {
  76544. /**
  76545. * options to use when constructing this feature
  76546. */
  76547. readonly options: IWebXRHandTrackingOptions;
  76548. private static _idCounter;
  76549. /**
  76550. * The module's name
  76551. */
  76552. static readonly Name: string;
  76553. /**
  76554. * The (Babylon) version of this module.
  76555. * This is an integer representing the implementation version.
  76556. * This number does not correspond to the WebXR specs version
  76557. */
  76558. static readonly Version: number;
  76559. /**
  76560. * This observable will notify registered observers when a new hand object was added and initialized
  76561. */
  76562. onHandAddedObservable: Observable<WebXRHand>;
  76563. /**
  76564. * This observable will notify its observers right before the hand object is disposed
  76565. */
  76566. onHandRemovedObservable: Observable<WebXRHand>;
  76567. private _hands;
  76568. /**
  76569. * Creates a new instance of the hit test feature
  76570. * @param _xrSessionManager an instance of WebXRSessionManager
  76571. * @param options options to use when constructing this feature
  76572. */
  76573. constructor(_xrSessionManager: WebXRSessionManager,
  76574. /**
  76575. * options to use when constructing this feature
  76576. */
  76577. options: IWebXRHandTrackingOptions);
  76578. /**
  76579. * Check if the needed objects are defined.
  76580. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76581. */
  76582. isCompatible(): boolean;
  76583. /**
  76584. * attach this feature
  76585. * Will usually be called by the features manager
  76586. *
  76587. * @returns true if successful.
  76588. */
  76589. attach(): boolean;
  76590. /**
  76591. * detach this feature.
  76592. * Will usually be called by the features manager
  76593. *
  76594. * @returns true if successful.
  76595. */
  76596. detach(): boolean;
  76597. /**
  76598. * Dispose this feature and all of the resources attached
  76599. */
  76600. dispose(): void;
  76601. /**
  76602. * Get the hand object according to the controller id
  76603. * @param controllerId the controller id to which we want to get the hand
  76604. * @returns null if not found or the WebXRHand object if found
  76605. */
  76606. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76607. /**
  76608. * Get a hand object according to the requested handedness
  76609. * @param handedness the handedness to request
  76610. * @returns null if not found or the WebXRHand object if found
  76611. */
  76612. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76613. protected _onXRFrame(_xrFrame: XRFrame): void;
  76614. private _attachHand;
  76615. private _detachHand;
  76616. }
  76617. }
  76618. declare module BABYLON {
  76619. /**
  76620. * The motion controller class for all microsoft mixed reality controllers
  76621. */
  76622. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76623. protected readonly _mapping: {
  76624. defaultButton: {
  76625. valueNodeName: string;
  76626. unpressedNodeName: string;
  76627. pressedNodeName: string;
  76628. };
  76629. defaultAxis: {
  76630. valueNodeName: string;
  76631. minNodeName: string;
  76632. maxNodeName: string;
  76633. };
  76634. buttons: {
  76635. "xr-standard-trigger": {
  76636. rootNodeName: string;
  76637. componentProperty: string;
  76638. states: string[];
  76639. };
  76640. "xr-standard-squeeze": {
  76641. rootNodeName: string;
  76642. componentProperty: string;
  76643. states: string[];
  76644. };
  76645. "xr-standard-touchpad": {
  76646. rootNodeName: string;
  76647. labelAnchorNodeName: string;
  76648. touchPointNodeName: string;
  76649. };
  76650. "xr-standard-thumbstick": {
  76651. rootNodeName: string;
  76652. componentProperty: string;
  76653. states: string[];
  76654. };
  76655. };
  76656. axes: {
  76657. "xr-standard-touchpad": {
  76658. "x-axis": {
  76659. rootNodeName: string;
  76660. };
  76661. "y-axis": {
  76662. rootNodeName: string;
  76663. };
  76664. };
  76665. "xr-standard-thumbstick": {
  76666. "x-axis": {
  76667. rootNodeName: string;
  76668. };
  76669. "y-axis": {
  76670. rootNodeName: string;
  76671. };
  76672. };
  76673. };
  76674. };
  76675. /**
  76676. * The base url used to load the left and right controller models
  76677. */
  76678. static MODEL_BASE_URL: string;
  76679. /**
  76680. * The name of the left controller model file
  76681. */
  76682. static MODEL_LEFT_FILENAME: string;
  76683. /**
  76684. * The name of the right controller model file
  76685. */
  76686. static MODEL_RIGHT_FILENAME: string;
  76687. profileId: string;
  76688. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76689. protected _getFilenameAndPath(): {
  76690. filename: string;
  76691. path: string;
  76692. };
  76693. protected _getModelLoadingConstraints(): boolean;
  76694. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76695. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76696. protected _updateModel(): void;
  76697. }
  76698. }
  76699. declare module BABYLON {
  76700. /**
  76701. * The motion controller class for oculus touch (quest, rift).
  76702. * This class supports legacy mapping as well the standard xr mapping
  76703. */
  76704. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76705. private _forceLegacyControllers;
  76706. private _modelRootNode;
  76707. /**
  76708. * The base url used to load the left and right controller models
  76709. */
  76710. static MODEL_BASE_URL: string;
  76711. /**
  76712. * The name of the left controller model file
  76713. */
  76714. static MODEL_LEFT_FILENAME: string;
  76715. /**
  76716. * The name of the right controller model file
  76717. */
  76718. static MODEL_RIGHT_FILENAME: string;
  76719. /**
  76720. * Base Url for the Quest controller model.
  76721. */
  76722. static QUEST_MODEL_BASE_URL: string;
  76723. profileId: string;
  76724. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76725. protected _getFilenameAndPath(): {
  76726. filename: string;
  76727. path: string;
  76728. };
  76729. protected _getModelLoadingConstraints(): boolean;
  76730. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76731. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76732. protected _updateModel(): void;
  76733. /**
  76734. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76735. * between the touch and touch 2.
  76736. */
  76737. private _isQuest;
  76738. }
  76739. }
  76740. declare module BABYLON {
  76741. /**
  76742. * The motion controller class for the standard HTC-Vive controllers
  76743. */
  76744. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76745. private _modelRootNode;
  76746. /**
  76747. * The base url used to load the left and right controller models
  76748. */
  76749. static MODEL_BASE_URL: string;
  76750. /**
  76751. * File name for the controller model.
  76752. */
  76753. static MODEL_FILENAME: string;
  76754. profileId: string;
  76755. /**
  76756. * Create a new Vive motion controller object
  76757. * @param scene the scene to use to create this controller
  76758. * @param gamepadObject the corresponding gamepad object
  76759. * @param handedness the handedness of the controller
  76760. */
  76761. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76762. protected _getFilenameAndPath(): {
  76763. filename: string;
  76764. path: string;
  76765. };
  76766. protected _getModelLoadingConstraints(): boolean;
  76767. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76768. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76769. protected _updateModel(): void;
  76770. }
  76771. }
  76772. declare module BABYLON {
  76773. /**
  76774. * A cursor which tracks a point on a path
  76775. */
  76776. export class PathCursor {
  76777. private path;
  76778. /**
  76779. * Stores path cursor callbacks for when an onchange event is triggered
  76780. */
  76781. private _onchange;
  76782. /**
  76783. * The value of the path cursor
  76784. */
  76785. value: number;
  76786. /**
  76787. * The animation array of the path cursor
  76788. */
  76789. animations: Animation[];
  76790. /**
  76791. * Initializes the path cursor
  76792. * @param path The path to track
  76793. */
  76794. constructor(path: Path2);
  76795. /**
  76796. * Gets the cursor point on the path
  76797. * @returns A point on the path cursor at the cursor location
  76798. */
  76799. getPoint(): Vector3;
  76800. /**
  76801. * Moves the cursor ahead by the step amount
  76802. * @param step The amount to move the cursor forward
  76803. * @returns This path cursor
  76804. */
  76805. moveAhead(step?: number): PathCursor;
  76806. /**
  76807. * Moves the cursor behind by the step amount
  76808. * @param step The amount to move the cursor back
  76809. * @returns This path cursor
  76810. */
  76811. moveBack(step?: number): PathCursor;
  76812. /**
  76813. * Moves the cursor by the step amount
  76814. * If the step amount is greater than one, an exception is thrown
  76815. * @param step The amount to move the cursor
  76816. * @returns This path cursor
  76817. */
  76818. move(step: number): PathCursor;
  76819. /**
  76820. * Ensures that the value is limited between zero and one
  76821. * @returns This path cursor
  76822. */
  76823. private ensureLimits;
  76824. /**
  76825. * Runs onchange callbacks on change (used by the animation engine)
  76826. * @returns This path cursor
  76827. */
  76828. private raiseOnChange;
  76829. /**
  76830. * Executes a function on change
  76831. * @param f A path cursor onchange callback
  76832. * @returns This path cursor
  76833. */
  76834. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76835. }
  76836. }
  76837. declare module BABYLON {
  76838. /** @hidden */
  76839. export var blurPixelShader: {
  76840. name: string;
  76841. shader: string;
  76842. };
  76843. }
  76844. declare module BABYLON {
  76845. /** @hidden */
  76846. export var pointCloudVertexDeclaration: {
  76847. name: string;
  76848. shader: string;
  76849. };
  76850. }
  76851. // Mixins
  76852. interface Window {
  76853. mozIndexedDB: IDBFactory;
  76854. webkitIndexedDB: IDBFactory;
  76855. msIndexedDB: IDBFactory;
  76856. webkitURL: typeof URL;
  76857. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76858. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76859. WebGLRenderingContext: WebGLRenderingContext;
  76860. MSGesture: MSGesture;
  76861. CANNON: any;
  76862. AudioContext: AudioContext;
  76863. webkitAudioContext: AudioContext;
  76864. PointerEvent: any;
  76865. Math: Math;
  76866. Uint8Array: Uint8ArrayConstructor;
  76867. Float32Array: Float32ArrayConstructor;
  76868. mozURL: typeof URL;
  76869. msURL: typeof URL;
  76870. VRFrameData: any; // WebVR, from specs 1.1
  76871. DracoDecoderModule: any;
  76872. setImmediate(handler: (...args: any[]) => void): number;
  76873. }
  76874. interface HTMLCanvasElement {
  76875. requestPointerLock(): void;
  76876. msRequestPointerLock?(): void;
  76877. mozRequestPointerLock?(): void;
  76878. webkitRequestPointerLock?(): void;
  76879. /** Track wether a record is in progress */
  76880. isRecording: boolean;
  76881. /** Capture Stream method defined by some browsers */
  76882. captureStream(fps?: number): MediaStream;
  76883. }
  76884. interface CanvasRenderingContext2D {
  76885. msImageSmoothingEnabled: boolean;
  76886. }
  76887. interface MouseEvent {
  76888. mozMovementX: number;
  76889. mozMovementY: number;
  76890. webkitMovementX: number;
  76891. webkitMovementY: number;
  76892. msMovementX: number;
  76893. msMovementY: number;
  76894. }
  76895. interface Navigator {
  76896. mozGetVRDevices: (any: any) => any;
  76897. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76898. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76899. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76900. webkitGetGamepads(): Gamepad[];
  76901. msGetGamepads(): Gamepad[];
  76902. webkitGamepads(): Gamepad[];
  76903. }
  76904. interface HTMLVideoElement {
  76905. mozSrcObject: any;
  76906. }
  76907. interface Math {
  76908. fround(x: number): number;
  76909. imul(a: number, b: number): number;
  76910. }
  76911. interface WebGLRenderingContext {
  76912. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76913. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76914. vertexAttribDivisor(index: number, divisor: number): void;
  76915. createVertexArray(): any;
  76916. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76917. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76918. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76919. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76920. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76921. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76922. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76923. // Queries
  76924. createQuery(): WebGLQuery;
  76925. deleteQuery(query: WebGLQuery): void;
  76926. beginQuery(target: number, query: WebGLQuery): void;
  76927. endQuery(target: number): void;
  76928. getQueryParameter(query: WebGLQuery, pname: number): any;
  76929. getQuery(target: number, pname: number): any;
  76930. MAX_SAMPLES: number;
  76931. RGBA8: number;
  76932. READ_FRAMEBUFFER: number;
  76933. DRAW_FRAMEBUFFER: number;
  76934. UNIFORM_BUFFER: number;
  76935. HALF_FLOAT_OES: number;
  76936. RGBA16F: number;
  76937. RGBA32F: number;
  76938. R32F: number;
  76939. RG32F: number;
  76940. RGB32F: number;
  76941. R16F: number;
  76942. RG16F: number;
  76943. RGB16F: number;
  76944. RED: number;
  76945. RG: number;
  76946. R8: number;
  76947. RG8: number;
  76948. UNSIGNED_INT_24_8: number;
  76949. DEPTH24_STENCIL8: number;
  76950. MIN: number;
  76951. MAX: number;
  76952. /* Multiple Render Targets */
  76953. drawBuffers(buffers: number[]): void;
  76954. readBuffer(src: number): void;
  76955. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76956. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76957. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76958. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76959. // Occlusion Query
  76960. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76961. ANY_SAMPLES_PASSED: number;
  76962. QUERY_RESULT_AVAILABLE: number;
  76963. QUERY_RESULT: number;
  76964. }
  76965. interface WebGLProgram {
  76966. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76967. }
  76968. interface EXT_disjoint_timer_query {
  76969. QUERY_COUNTER_BITS_EXT: number;
  76970. TIME_ELAPSED_EXT: number;
  76971. TIMESTAMP_EXT: number;
  76972. GPU_DISJOINT_EXT: number;
  76973. QUERY_RESULT_EXT: number;
  76974. QUERY_RESULT_AVAILABLE_EXT: number;
  76975. queryCounterEXT(query: WebGLQuery, target: number): void;
  76976. createQueryEXT(): WebGLQuery;
  76977. beginQueryEXT(target: number, query: WebGLQuery): void;
  76978. endQueryEXT(target: number): void;
  76979. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76980. deleteQueryEXT(query: WebGLQuery): void;
  76981. }
  76982. interface WebGLUniformLocation {
  76983. _currentState: any;
  76984. }
  76985. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76986. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76987. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76988. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76989. interface WebGLRenderingContext {
  76990. readonly RASTERIZER_DISCARD: number;
  76991. readonly DEPTH_COMPONENT24: number;
  76992. readonly TEXTURE_3D: number;
  76993. readonly TEXTURE_2D_ARRAY: number;
  76994. readonly TEXTURE_COMPARE_FUNC: number;
  76995. readonly TEXTURE_COMPARE_MODE: number;
  76996. readonly COMPARE_REF_TO_TEXTURE: number;
  76997. readonly TEXTURE_WRAP_R: number;
  76998. readonly HALF_FLOAT: number;
  76999. readonly RGB8: number;
  77000. readonly RED_INTEGER: number;
  77001. readonly RG_INTEGER: number;
  77002. readonly RGB_INTEGER: number;
  77003. readonly RGBA_INTEGER: number;
  77004. readonly R8_SNORM: number;
  77005. readonly RG8_SNORM: number;
  77006. readonly RGB8_SNORM: number;
  77007. readonly RGBA8_SNORM: number;
  77008. readonly R8I: number;
  77009. readonly RG8I: number;
  77010. readonly RGB8I: number;
  77011. readonly RGBA8I: number;
  77012. readonly R8UI: number;
  77013. readonly RG8UI: number;
  77014. readonly RGB8UI: number;
  77015. readonly RGBA8UI: number;
  77016. readonly R16I: number;
  77017. readonly RG16I: number;
  77018. readonly RGB16I: number;
  77019. readonly RGBA16I: number;
  77020. readonly R16UI: number;
  77021. readonly RG16UI: number;
  77022. readonly RGB16UI: number;
  77023. readonly RGBA16UI: number;
  77024. readonly R32I: number;
  77025. readonly RG32I: number;
  77026. readonly RGB32I: number;
  77027. readonly RGBA32I: number;
  77028. readonly R32UI: number;
  77029. readonly RG32UI: number;
  77030. readonly RGB32UI: number;
  77031. readonly RGBA32UI: number;
  77032. readonly RGB10_A2UI: number;
  77033. readonly R11F_G11F_B10F: number;
  77034. readonly RGB9_E5: number;
  77035. readonly RGB10_A2: number;
  77036. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77037. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77038. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77039. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77040. readonly DEPTH_COMPONENT32F: number;
  77041. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77042. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77043. 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;
  77044. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77045. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77046. readonly TRANSFORM_FEEDBACK: number;
  77047. readonly INTERLEAVED_ATTRIBS: number;
  77048. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77049. createTransformFeedback(): WebGLTransformFeedback;
  77050. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77051. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77052. beginTransformFeedback(primitiveMode: number): void;
  77053. endTransformFeedback(): void;
  77054. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77055. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77056. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77057. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77058. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77059. }
  77060. interface ImageBitmap {
  77061. readonly width: number;
  77062. readonly height: number;
  77063. close(): void;
  77064. }
  77065. interface WebGLQuery extends WebGLObject {
  77066. }
  77067. declare var WebGLQuery: {
  77068. prototype: WebGLQuery;
  77069. new(): WebGLQuery;
  77070. };
  77071. interface WebGLSampler extends WebGLObject {
  77072. }
  77073. declare var WebGLSampler: {
  77074. prototype: WebGLSampler;
  77075. new(): WebGLSampler;
  77076. };
  77077. interface WebGLSync extends WebGLObject {
  77078. }
  77079. declare var WebGLSync: {
  77080. prototype: WebGLSync;
  77081. new(): WebGLSync;
  77082. };
  77083. interface WebGLTransformFeedback extends WebGLObject {
  77084. }
  77085. declare var WebGLTransformFeedback: {
  77086. prototype: WebGLTransformFeedback;
  77087. new(): WebGLTransformFeedback;
  77088. };
  77089. interface WebGLVertexArrayObject extends WebGLObject {
  77090. }
  77091. declare var WebGLVertexArrayObject: {
  77092. prototype: WebGLVertexArrayObject;
  77093. new(): WebGLVertexArrayObject;
  77094. };
  77095. // Type definitions for WebVR API
  77096. // Project: https://w3c.github.io/webvr/
  77097. // Definitions by: six a <https://github.com/lostfictions>
  77098. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77099. interface VRDisplay extends EventTarget {
  77100. /**
  77101. * Dictionary of capabilities describing the VRDisplay.
  77102. */
  77103. readonly capabilities: VRDisplayCapabilities;
  77104. /**
  77105. * z-depth defining the far plane of the eye view frustum
  77106. * enables mapping of values in the render target depth
  77107. * attachment to scene coordinates. Initially set to 10000.0.
  77108. */
  77109. depthFar: number;
  77110. /**
  77111. * z-depth defining the near plane of the eye view frustum
  77112. * enables mapping of values in the render target depth
  77113. * attachment to scene coordinates. Initially set to 0.01.
  77114. */
  77115. depthNear: number;
  77116. /**
  77117. * An identifier for this distinct VRDisplay. Used as an
  77118. * association point in the Gamepad API.
  77119. */
  77120. readonly displayId: number;
  77121. /**
  77122. * A display name, a user-readable name identifying it.
  77123. */
  77124. readonly displayName: string;
  77125. readonly isConnected: boolean;
  77126. readonly isPresenting: boolean;
  77127. /**
  77128. * If this VRDisplay supports room-scale experiences, the optional
  77129. * stage attribute contains details on the room-scale parameters.
  77130. */
  77131. readonly stageParameters: VRStageParameters | null;
  77132. /**
  77133. * Passing the value returned by `requestAnimationFrame` to
  77134. * `cancelAnimationFrame` will unregister the callback.
  77135. * @param handle Define the hanle of the request to cancel
  77136. */
  77137. cancelAnimationFrame(handle: number): void;
  77138. /**
  77139. * Stops presenting to the VRDisplay.
  77140. * @returns a promise to know when it stopped
  77141. */
  77142. exitPresent(): Promise<void>;
  77143. /**
  77144. * Return the current VREyeParameters for the given eye.
  77145. * @param whichEye Define the eye we want the parameter for
  77146. * @returns the eye parameters
  77147. */
  77148. getEyeParameters(whichEye: string): VREyeParameters;
  77149. /**
  77150. * Populates the passed VRFrameData with the information required to render
  77151. * the current frame.
  77152. * @param frameData Define the data structure to populate
  77153. * @returns true if ok otherwise false
  77154. */
  77155. getFrameData(frameData: VRFrameData): boolean;
  77156. /**
  77157. * Get the layers currently being presented.
  77158. * @returns the list of VR layers
  77159. */
  77160. getLayers(): VRLayer[];
  77161. /**
  77162. * Return a VRPose containing the future predicted pose of the VRDisplay
  77163. * when the current frame will be presented. The value returned will not
  77164. * change until JavaScript has returned control to the browser.
  77165. *
  77166. * The VRPose will contain the position, orientation, velocity,
  77167. * and acceleration of each of these properties.
  77168. * @returns the pose object
  77169. */
  77170. getPose(): VRPose;
  77171. /**
  77172. * Return the current instantaneous pose of the VRDisplay, with no
  77173. * prediction applied.
  77174. * @returns the current instantaneous pose
  77175. */
  77176. getImmediatePose(): VRPose;
  77177. /**
  77178. * The callback passed to `requestAnimationFrame` will be called
  77179. * any time a new frame should be rendered. When the VRDisplay is
  77180. * presenting the callback will be called at the native refresh
  77181. * rate of the HMD. When not presenting this function acts
  77182. * identically to how window.requestAnimationFrame acts. Content should
  77183. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77184. * asynchronously from other displays and at differing refresh rates.
  77185. * @param callback Define the eaction to run next frame
  77186. * @returns the request handle it
  77187. */
  77188. requestAnimationFrame(callback: FrameRequestCallback): number;
  77189. /**
  77190. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77191. * Repeat calls while already presenting will update the VRLayers being displayed.
  77192. * @param layers Define the list of layer to present
  77193. * @returns a promise to know when the request has been fulfilled
  77194. */
  77195. requestPresent(layers: VRLayer[]): Promise<void>;
  77196. /**
  77197. * Reset the pose for this display, treating its current position and
  77198. * orientation as the "origin/zero" values. VRPose.position,
  77199. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77200. * updated when calling resetPose(). This should be called in only
  77201. * sitting-space experiences.
  77202. */
  77203. resetPose(): void;
  77204. /**
  77205. * The VRLayer provided to the VRDisplay will be captured and presented
  77206. * in the HMD. Calling this function has the same effect on the source
  77207. * canvas as any other operation that uses its source image, and canvases
  77208. * created without preserveDrawingBuffer set to true will be cleared.
  77209. * @param pose Define the pose to submit
  77210. */
  77211. submitFrame(pose?: VRPose): void;
  77212. }
  77213. declare var VRDisplay: {
  77214. prototype: VRDisplay;
  77215. new(): VRDisplay;
  77216. };
  77217. interface VRLayer {
  77218. leftBounds?: number[] | Float32Array | null;
  77219. rightBounds?: number[] | Float32Array | null;
  77220. source?: HTMLCanvasElement | null;
  77221. }
  77222. interface VRDisplayCapabilities {
  77223. readonly canPresent: boolean;
  77224. readonly hasExternalDisplay: boolean;
  77225. readonly hasOrientation: boolean;
  77226. readonly hasPosition: boolean;
  77227. readonly maxLayers: number;
  77228. }
  77229. interface VREyeParameters {
  77230. /** @deprecated */
  77231. readonly fieldOfView: VRFieldOfView;
  77232. readonly offset: Float32Array;
  77233. readonly renderHeight: number;
  77234. readonly renderWidth: number;
  77235. }
  77236. interface VRFieldOfView {
  77237. readonly downDegrees: number;
  77238. readonly leftDegrees: number;
  77239. readonly rightDegrees: number;
  77240. readonly upDegrees: number;
  77241. }
  77242. interface VRFrameData {
  77243. readonly leftProjectionMatrix: Float32Array;
  77244. readonly leftViewMatrix: Float32Array;
  77245. readonly pose: VRPose;
  77246. readonly rightProjectionMatrix: Float32Array;
  77247. readonly rightViewMatrix: Float32Array;
  77248. readonly timestamp: number;
  77249. }
  77250. interface VRPose {
  77251. readonly angularAcceleration: Float32Array | null;
  77252. readonly angularVelocity: Float32Array | null;
  77253. readonly linearAcceleration: Float32Array | null;
  77254. readonly linearVelocity: Float32Array | null;
  77255. readonly orientation: Float32Array | null;
  77256. readonly position: Float32Array | null;
  77257. readonly timestamp: number;
  77258. }
  77259. interface VRStageParameters {
  77260. sittingToStandingTransform?: Float32Array;
  77261. sizeX?: number;
  77262. sizeY?: number;
  77263. }
  77264. interface Navigator {
  77265. getVRDisplays(): Promise<VRDisplay[]>;
  77266. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77267. }
  77268. interface Window {
  77269. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77270. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77271. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77272. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77273. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77274. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77275. }
  77276. interface Gamepad {
  77277. readonly displayId: number;
  77278. }
  77279. /**
  77280. * Available session modes
  77281. */
  77282. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77283. /**
  77284. * Reference space types
  77285. */
  77286. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77287. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77288. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77289. /**
  77290. * Handedness types
  77291. */
  77292. type XRHandedness = "none" | "left" | "right";
  77293. /**
  77294. * InputSource target ray modes
  77295. */
  77296. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77297. /**
  77298. * Eye types
  77299. */
  77300. type XREye = "none" | "left" | "right";
  77301. /**
  77302. * Type of XR events available
  77303. */
  77304. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77305. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77306. type XRPlaneSet = Set<XRPlane>;
  77307. type XRAnchorSet = Set<XRAnchor>;
  77308. type XREventHandler = (callback: any) => void;
  77309. interface XRLayer extends EventTarget {}
  77310. interface XRSessionInit {
  77311. optionalFeatures?: string[];
  77312. requiredFeatures?: string[];
  77313. }
  77314. interface XRSessionEvent extends Event {
  77315. readonly session: XRSession;
  77316. }
  77317. interface XRSystem {
  77318. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77319. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77320. }
  77321. interface XRViewport {
  77322. readonly x: number;
  77323. readonly y: number;
  77324. readonly width: number;
  77325. readonly height: number;
  77326. }
  77327. interface XRWebGLLayerInit {
  77328. antialias?: boolean;
  77329. depth?: boolean;
  77330. stencil?: boolean;
  77331. alpha?: boolean;
  77332. multiview?: boolean;
  77333. framebufferScaleFactor?: number;
  77334. }
  77335. declare class XRWebGLLayer {
  77336. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77337. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77338. readonly antialias: boolean;
  77339. readonly framebuffer: WebGLFramebuffer;
  77340. readonly framebufferWidth: number;
  77341. readonly framebufferHeight: number;
  77342. readonly ignoreDepthValues: boolean;
  77343. getViewport: (view: XRView) => XRViewport;
  77344. }
  77345. // tslint:disable-next-line no-empty-interface
  77346. interface XRSpace extends EventTarget {}
  77347. interface XRRenderState {
  77348. readonly baseLayer?: XRWebGLLayer;
  77349. readonly depthFar: number;
  77350. readonly depthNear: number;
  77351. readonly inlineVerticalFieldOfView?: number;
  77352. }
  77353. interface XRRenderStateInit extends XRRenderState {
  77354. baseLayer: XRWebGLLayer;
  77355. depthFar: number;
  77356. depthNear: number;
  77357. inlineVerticalFieldOfView?: number;
  77358. layers?: XRLayer[];
  77359. }
  77360. interface XRReferenceSpace extends XRSpace {
  77361. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77362. onreset: XREventHandler;
  77363. }
  77364. interface XRBoundedReferenceSpace extends XRSpace {
  77365. readonly boundsGeometry: DOMPointReadOnly[];
  77366. }
  77367. interface XRInputSource {
  77368. readonly handedness: XRHandedness;
  77369. readonly targetRayMode: XRTargetRayMode;
  77370. readonly targetRaySpace: XRSpace;
  77371. readonly gripSpace?: XRSpace;
  77372. readonly gamepad?: Gamepad;
  77373. readonly profiles: Array<string>;
  77374. readonly hand?: XRHand;
  77375. }
  77376. interface XRPose {
  77377. readonly transform: XRRigidTransform;
  77378. readonly emulatedPosition: boolean;
  77379. }
  77380. interface XRFrame {
  77381. readonly session: XRSession;
  77382. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77383. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77384. // AR
  77385. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77386. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77387. // Anchors
  77388. trackedAnchors?: XRAnchorSet;
  77389. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77390. // Planes
  77391. worldInformation?: {
  77392. detectedPlanes?: XRPlaneSet;
  77393. };
  77394. // Hand tracking
  77395. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77396. }
  77397. interface XRInputSourceEvent extends Event {
  77398. readonly frame: XRFrame;
  77399. readonly inputSource: XRInputSource;
  77400. }
  77401. type XRInputSourceArray = XRInputSource[];
  77402. interface XRSession {
  77403. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77404. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77405. /**
  77406. * Returns a list of this session's XRInputSources, each representing an input device
  77407. * used to control the camera and/or scene.
  77408. */
  77409. readonly inputSources: Array<XRInputSource>;
  77410. /**
  77411. * object which contains options affecting how the imagery is rendered.
  77412. * This includes things such as the near and far clipping planes
  77413. */
  77414. readonly renderState: XRRenderState;
  77415. readonly visibilityState: XRVisibilityState;
  77416. /**
  77417. * Removes a callback from the animation frame painting callback from
  77418. * XRSession's set of animation frame rendering callbacks, given the
  77419. * identifying handle returned by a previous call to requestAnimationFrame().
  77420. */
  77421. cancelAnimationFrame: (handle: number) => void;
  77422. /**
  77423. * Ends the WebXR session. Returns a promise which resolves when the
  77424. * session has been shut down.
  77425. */
  77426. end(): Promise<void>;
  77427. /**
  77428. * Schedules the specified method to be called the next time the user agent
  77429. * is working on rendering an animation frame for the WebXR device. Returns an
  77430. * integer value which can be used to identify the request for the purposes of
  77431. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77432. * to the Window.requestAnimationFrame() method.
  77433. */
  77434. requestAnimationFrame: XRFrameRequestCallback;
  77435. /**
  77436. * Requests that a new XRReferenceSpace of the specified type be created.
  77437. * Returns a promise which resolves with the XRReferenceSpace or
  77438. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77439. * the requested space type isn't supported by the device.
  77440. */
  77441. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77442. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77443. onend: XREventHandler;
  77444. oninputsourceschange: XREventHandler;
  77445. onselect: XREventHandler;
  77446. onselectstart: XREventHandler;
  77447. onselectend: XREventHandler;
  77448. onsqueeze: XREventHandler;
  77449. onsqueezestart: XREventHandler;
  77450. onsqueezeend: XREventHandler;
  77451. onvisibilitychange: XREventHandler;
  77452. // hit test
  77453. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77454. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77455. // legacy AR hit test
  77456. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77457. // legacy plane detection
  77458. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77459. }
  77460. interface XRViewerPose extends XRPose {
  77461. readonly views: Array<XRView>;
  77462. }
  77463. declare class XRRigidTransform {
  77464. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77465. position: DOMPointReadOnly;
  77466. orientation: DOMPointReadOnly;
  77467. matrix: Float32Array;
  77468. inverse: XRRigidTransform;
  77469. }
  77470. interface XRView {
  77471. readonly eye: XREye;
  77472. readonly projectionMatrix: Float32Array;
  77473. readonly transform: XRRigidTransform;
  77474. readonly recommendedViewportScale?: number;
  77475. requestViewportScale(scale: number): void;
  77476. }
  77477. interface XRInputSourceChangeEvent extends Event {
  77478. session: XRSession;
  77479. removed: Array<XRInputSource>;
  77480. added: Array<XRInputSource>;
  77481. }
  77482. // Experimental/Draft features
  77483. declare class XRRay {
  77484. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77485. origin: DOMPointReadOnly;
  77486. direction: DOMPointReadOnly;
  77487. matrix: Float32Array;
  77488. }
  77489. declare enum XRHitTestTrackableType {
  77490. "point",
  77491. "plane",
  77492. "mesh",
  77493. }
  77494. interface XRHitResult {
  77495. hitMatrix: Float32Array;
  77496. }
  77497. interface XRTransientInputHitTestResult {
  77498. readonly inputSource: XRInputSource;
  77499. readonly results: Array<XRHitTestResult>;
  77500. }
  77501. interface XRHitTestResult {
  77502. getPose(baseSpace: XRSpace): XRPose | undefined;
  77503. // When anchor system is enabled
  77504. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77505. }
  77506. interface XRHitTestSource {
  77507. cancel(): void;
  77508. }
  77509. interface XRTransientInputHitTestSource {
  77510. cancel(): void;
  77511. }
  77512. interface XRHitTestOptionsInit {
  77513. space: XRSpace;
  77514. entityTypes?: Array<XRHitTestTrackableType>;
  77515. offsetRay?: XRRay;
  77516. }
  77517. interface XRTransientInputHitTestOptionsInit {
  77518. profile: string;
  77519. entityTypes?: Array<XRHitTestTrackableType>;
  77520. offsetRay?: XRRay;
  77521. }
  77522. interface XRAnchor {
  77523. anchorSpace: XRSpace;
  77524. delete(): void;
  77525. }
  77526. interface XRPlane {
  77527. orientation: "Horizontal" | "Vertical";
  77528. planeSpace: XRSpace;
  77529. polygon: Array<DOMPointReadOnly>;
  77530. lastChangedTime: number;
  77531. }
  77532. interface XRJointSpace extends XRSpace {}
  77533. interface XRJointPose extends XRPose {
  77534. radius: number | undefined;
  77535. }
  77536. interface XRHand extends Iterable<XRJointSpace> {
  77537. readonly length: number;
  77538. [index: number]: XRJointSpace;
  77539. readonly WRIST: number;
  77540. readonly THUMB_METACARPAL: number;
  77541. readonly THUMB_PHALANX_PROXIMAL: number;
  77542. readonly THUMB_PHALANX_DISTAL: number;
  77543. readonly THUMB_PHALANX_TIP: number;
  77544. readonly INDEX_METACARPAL: number;
  77545. readonly INDEX_PHALANX_PROXIMAL: number;
  77546. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77547. readonly INDEX_PHALANX_DISTAL: number;
  77548. readonly INDEX_PHALANX_TIP: number;
  77549. readonly MIDDLE_METACARPAL: number;
  77550. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77551. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77552. readonly MIDDLE_PHALANX_DISTAL: number;
  77553. readonly MIDDLE_PHALANX_TIP: number;
  77554. readonly RING_METACARPAL: number;
  77555. readonly RING_PHALANX_PROXIMAL: number;
  77556. readonly RING_PHALANX_INTERMEDIATE: number;
  77557. readonly RING_PHALANX_DISTAL: number;
  77558. readonly RING_PHALANX_TIP: number;
  77559. readonly LITTLE_METACARPAL: number;
  77560. readonly LITTLE_PHALANX_PROXIMAL: number;
  77561. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77562. readonly LITTLE_PHALANX_DISTAL: number;
  77563. readonly LITTLE_PHALANX_TIP: number;
  77564. }
  77565. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77566. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77567. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77568. interface XRSession {
  77569. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77570. }
  77571. interface XRFrame {
  77572. featurePointCloud? : Array<number>;
  77573. }
  77574. /**
  77575. * @ignore
  77576. */
  77577. declare module BABYLON.GLTF2.Exporter {
  77578. }
  77579. /**
  77580. * @ignore
  77581. */
  77582. declare module BABYLON.GLTF1 {
  77583. }
  77584. declare module BABYLON.GUI {
  77585. /**
  77586. * Class used to specific a value and its associated unit
  77587. */
  77588. export class ValueAndUnit {
  77589. /** defines the unit to store */
  77590. unit: number;
  77591. /** defines a boolean indicating if the value can be negative */
  77592. negativeValueAllowed: boolean;
  77593. private _value;
  77594. private _originalUnit;
  77595. /**
  77596. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77597. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77598. */
  77599. ignoreAdaptiveScaling: boolean;
  77600. /**
  77601. * Creates a new ValueAndUnit
  77602. * @param value defines the value to store
  77603. * @param unit defines the unit to store
  77604. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77605. */
  77606. constructor(value: number,
  77607. /** defines the unit to store */
  77608. unit?: number,
  77609. /** defines a boolean indicating if the value can be negative */
  77610. negativeValueAllowed?: boolean);
  77611. /** Gets a boolean indicating if the value is a percentage */
  77612. get isPercentage(): boolean;
  77613. /** Gets a boolean indicating if the value is store as pixel */
  77614. get isPixel(): boolean;
  77615. /** Gets direct internal value */
  77616. get internalValue(): number;
  77617. /**
  77618. * Gets value as pixel
  77619. * @param host defines the root host
  77620. * @param refValue defines the reference value for percentages
  77621. * @returns the value as pixel
  77622. */
  77623. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77624. /**
  77625. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77626. * @param value defines the value to store
  77627. * @param unit defines the unit to store
  77628. * @returns the current ValueAndUnit
  77629. */
  77630. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77631. /**
  77632. * Gets the value accordingly to its unit
  77633. * @param host defines the root host
  77634. * @returns the value
  77635. */
  77636. getValue(host: AdvancedDynamicTexture): number;
  77637. /**
  77638. * Gets a string representation of the value
  77639. * @param host defines the root host
  77640. * @param decimals defines an optional number of decimals to display
  77641. * @returns a string
  77642. */
  77643. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77644. /**
  77645. * Store a value parsed from a string
  77646. * @param source defines the source string
  77647. * @returns true if the value was successfully parsed
  77648. */
  77649. fromString(source: string | number): boolean;
  77650. private static _Regex;
  77651. private static _UNITMODE_PERCENTAGE;
  77652. private static _UNITMODE_PIXEL;
  77653. /** UNITMODE_PERCENTAGE */
  77654. static get UNITMODE_PERCENTAGE(): number;
  77655. /** UNITMODE_PIXEL */
  77656. static get UNITMODE_PIXEL(): number;
  77657. }
  77658. }
  77659. declare module BABYLON.GUI {
  77660. /**
  77661. * Define a style used by control to automatically setup properties based on a template.
  77662. * Only support font related properties so far
  77663. */
  77664. export class Style implements BABYLON.IDisposable {
  77665. private _fontFamily;
  77666. private _fontStyle;
  77667. private _fontWeight;
  77668. /** @hidden */
  77669. _host: AdvancedDynamicTexture;
  77670. /** @hidden */
  77671. _fontSize: ValueAndUnit;
  77672. /**
  77673. * BABYLON.Observable raised when the style values are changed
  77674. */
  77675. onChangedObservable: BABYLON.Observable<Style>;
  77676. /**
  77677. * Creates a new style object
  77678. * @param host defines the AdvancedDynamicTexture which hosts this style
  77679. */
  77680. constructor(host: AdvancedDynamicTexture);
  77681. /**
  77682. * Gets or sets the font size
  77683. */
  77684. get fontSize(): string | number;
  77685. set fontSize(value: string | number);
  77686. /**
  77687. * Gets or sets the font family
  77688. */
  77689. get fontFamily(): string;
  77690. set fontFamily(value: string);
  77691. /**
  77692. * Gets or sets the font style
  77693. */
  77694. get fontStyle(): string;
  77695. set fontStyle(value: string);
  77696. /** Gets or sets font weight */
  77697. get fontWeight(): string;
  77698. set fontWeight(value: string);
  77699. /** Dispose all associated resources */
  77700. dispose(): void;
  77701. }
  77702. }
  77703. declare module BABYLON.GUI {
  77704. /**
  77705. * Class used to transport BABYLON.Vector2 information for pointer events
  77706. */
  77707. export class Vector2WithInfo extends BABYLON.Vector2 {
  77708. /** defines the current mouse button index */
  77709. buttonIndex: number;
  77710. /**
  77711. * Creates a new Vector2WithInfo
  77712. * @param source defines the vector2 data to transport
  77713. * @param buttonIndex defines the current mouse button index
  77714. */
  77715. constructor(source: BABYLON.Vector2,
  77716. /** defines the current mouse button index */
  77717. buttonIndex?: number);
  77718. }
  77719. /** Class used to provide 2D matrix features */
  77720. export class Matrix2D {
  77721. /** Gets the internal array of 6 floats used to store matrix data */
  77722. m: Float32Array;
  77723. /**
  77724. * Creates a new matrix
  77725. * @param m00 defines value for (0, 0)
  77726. * @param m01 defines value for (0, 1)
  77727. * @param m10 defines value for (1, 0)
  77728. * @param m11 defines value for (1, 1)
  77729. * @param m20 defines value for (2, 0)
  77730. * @param m21 defines value for (2, 1)
  77731. */
  77732. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77733. /**
  77734. * Fills the matrix from direct values
  77735. * @param m00 defines value for (0, 0)
  77736. * @param m01 defines value for (0, 1)
  77737. * @param m10 defines value for (1, 0)
  77738. * @param m11 defines value for (1, 1)
  77739. * @param m20 defines value for (2, 0)
  77740. * @param m21 defines value for (2, 1)
  77741. * @returns the current modified matrix
  77742. */
  77743. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77744. /**
  77745. * Gets matrix determinant
  77746. * @returns the determinant
  77747. */
  77748. determinant(): number;
  77749. /**
  77750. * Inverses the matrix and stores it in a target matrix
  77751. * @param result defines the target matrix
  77752. * @returns the current matrix
  77753. */
  77754. invertToRef(result: Matrix2D): Matrix2D;
  77755. /**
  77756. * Multiplies the current matrix with another one
  77757. * @param other defines the second operand
  77758. * @param result defines the target matrix
  77759. * @returns the current matrix
  77760. */
  77761. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77762. /**
  77763. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77764. * @param x defines the x coordinate to transform
  77765. * @param y defines the x coordinate to transform
  77766. * @param result defines the target vector2
  77767. * @returns the current matrix
  77768. */
  77769. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77770. /**
  77771. * Creates an identity matrix
  77772. * @returns a new matrix
  77773. */
  77774. static Identity(): Matrix2D;
  77775. /**
  77776. * Creates a translation matrix and stores it in a target matrix
  77777. * @param x defines the x coordinate of the translation
  77778. * @param y defines the y coordinate of the translation
  77779. * @param result defines the target matrix
  77780. */
  77781. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77782. /**
  77783. * Creates a scaling matrix and stores it in a target matrix
  77784. * @param x defines the x coordinate of the scaling
  77785. * @param y defines the y coordinate of the scaling
  77786. * @param result defines the target matrix
  77787. */
  77788. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77789. /**
  77790. * Creates a rotation matrix and stores it in a target matrix
  77791. * @param angle defines the rotation angle
  77792. * @param result defines the target matrix
  77793. */
  77794. static RotationToRef(angle: number, result: Matrix2D): void;
  77795. private static _TempPreTranslationMatrix;
  77796. private static _TempPostTranslationMatrix;
  77797. private static _TempRotationMatrix;
  77798. private static _TempScalingMatrix;
  77799. private static _TempCompose0;
  77800. private static _TempCompose1;
  77801. private static _TempCompose2;
  77802. /**
  77803. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77804. * @param tx defines the x coordinate of the translation
  77805. * @param ty defines the y coordinate of the translation
  77806. * @param angle defines the rotation angle
  77807. * @param scaleX defines the x coordinate of the scaling
  77808. * @param scaleY defines the y coordinate of the scaling
  77809. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77810. * @param result defines the target matrix
  77811. */
  77812. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77813. }
  77814. }
  77815. declare module BABYLON.GUI {
  77816. /**
  77817. * Class used to store 2D control sizes
  77818. */
  77819. export class Measure {
  77820. /** defines left coordinate */
  77821. left: number;
  77822. /** defines top coordinate */
  77823. top: number;
  77824. /** defines width dimension */
  77825. width: number;
  77826. /** defines height dimension */
  77827. height: number;
  77828. /**
  77829. * Creates a new measure
  77830. * @param left defines left coordinate
  77831. * @param top defines top coordinate
  77832. * @param width defines width dimension
  77833. * @param height defines height dimension
  77834. */
  77835. constructor(
  77836. /** defines left coordinate */
  77837. left: number,
  77838. /** defines top coordinate */
  77839. top: number,
  77840. /** defines width dimension */
  77841. width: number,
  77842. /** defines height dimension */
  77843. height: number);
  77844. /**
  77845. * Copy from another measure
  77846. * @param other defines the other measure to copy from
  77847. */
  77848. copyFrom(other: Measure): void;
  77849. /**
  77850. * Copy from a group of 4 floats
  77851. * @param left defines left coordinate
  77852. * @param top defines top coordinate
  77853. * @param width defines width dimension
  77854. * @param height defines height dimension
  77855. */
  77856. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77857. /**
  77858. * Computes the axis aligned bounding box measure for two given measures
  77859. * @param a Input measure
  77860. * @param b Input measure
  77861. * @param result the resulting bounding measure
  77862. */
  77863. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77864. /**
  77865. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77866. * @param transform the matrix to transform the measure before computing the AABB
  77867. * @param addX number to add to left
  77868. * @param addY number to add to top
  77869. * @param addWidth number to add to width
  77870. * @param addHeight number to add to height
  77871. * @param result the resulting AABB
  77872. */
  77873. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77874. /**
  77875. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77876. * @param transform the matrix to transform the measure before computing the AABB
  77877. * @param result the resulting AABB
  77878. */
  77879. transformToRef(transform: Matrix2D, result: Measure): void;
  77880. /**
  77881. * Check equality between this measure and another one
  77882. * @param other defines the other measures
  77883. * @returns true if both measures are equals
  77884. */
  77885. isEqualsTo(other: Measure): boolean;
  77886. /**
  77887. * Creates an empty measure
  77888. * @returns a new measure
  77889. */
  77890. static Empty(): Measure;
  77891. }
  77892. }
  77893. declare module BABYLON.GUI {
  77894. /**
  77895. * Interface used to define a control that can receive focus
  77896. */
  77897. export interface IFocusableControl {
  77898. /**
  77899. * Function called when the control receives the focus
  77900. */
  77901. onFocus(): void;
  77902. /**
  77903. * Function called when the control loses the focus
  77904. */
  77905. onBlur(): void;
  77906. /**
  77907. * Function called to let the control handle keyboard events
  77908. * @param evt defines the current keyboard event
  77909. */
  77910. processKeyboard(evt: KeyboardEvent): void;
  77911. /**
  77912. * Function called to get the list of controls that should not steal the focus from this control
  77913. * @returns an array of controls
  77914. */
  77915. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77916. }
  77917. /**
  77918. * Class used to create texture to support 2D GUI elements
  77919. * @see https://doc.babylonjs.com/how_to/gui
  77920. */
  77921. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77922. private _isDirty;
  77923. private _renderObserver;
  77924. private _resizeObserver;
  77925. private _preKeyboardObserver;
  77926. private _pointerMoveObserver;
  77927. private _pointerObserver;
  77928. private _canvasPointerOutObserver;
  77929. private _canvasBlurObserver;
  77930. private _background;
  77931. /** @hidden */
  77932. _rootContainer: Container;
  77933. /** @hidden */
  77934. _lastPickedControl: Control;
  77935. /** @hidden */
  77936. _lastControlOver: {
  77937. [pointerId: number]: Control;
  77938. };
  77939. /** @hidden */
  77940. _lastControlDown: {
  77941. [pointerId: number]: Control;
  77942. };
  77943. /** @hidden */
  77944. _capturingControl: {
  77945. [pointerId: number]: Control;
  77946. };
  77947. /** @hidden */
  77948. _shouldBlockPointer: boolean;
  77949. /** @hidden */
  77950. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77951. /** @hidden */
  77952. _linkedControls: Control[];
  77953. private _isFullscreen;
  77954. private _fullscreenViewport;
  77955. private _idealWidth;
  77956. private _idealHeight;
  77957. private _useSmallestIdeal;
  77958. private _renderAtIdealSize;
  77959. private _focusedControl;
  77960. private _blockNextFocusCheck;
  77961. private _renderScale;
  77962. private _rootElement;
  77963. private _cursorChanged;
  77964. private _defaultMousePointerId;
  77965. /** @hidden */
  77966. _numLayoutCalls: number;
  77967. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77968. get numLayoutCalls(): number;
  77969. /** @hidden */
  77970. _numRenderCalls: number;
  77971. /** Gets the number of render calls made the last time the ADT has been rendered */
  77972. get numRenderCalls(): number;
  77973. /**
  77974. * Define type to string to ensure compatibility across browsers
  77975. * Safari doesn't support DataTransfer constructor
  77976. */
  77977. private _clipboardData;
  77978. /**
  77979. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77980. */
  77981. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77982. /**
  77983. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77984. */
  77985. onControlPickedObservable: BABYLON.Observable<Control>;
  77986. /**
  77987. * BABYLON.Observable event triggered before layout is evaluated
  77988. */
  77989. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77990. /**
  77991. * BABYLON.Observable event triggered after the layout was evaluated
  77992. */
  77993. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77994. /**
  77995. * BABYLON.Observable event triggered before the texture is rendered
  77996. */
  77997. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77998. /**
  77999. * BABYLON.Observable event triggered after the texture was rendered
  78000. */
  78001. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78002. /**
  78003. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78004. */
  78005. premulAlpha: boolean;
  78006. /**
  78007. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78008. * Useful when you want more antialiasing
  78009. */
  78010. get renderScale(): number;
  78011. set renderScale(value: number);
  78012. /** Gets or sets the background color */
  78013. get background(): string;
  78014. set background(value: string);
  78015. /**
  78016. * Gets or sets the ideal width used to design controls.
  78017. * The GUI will then rescale everything accordingly
  78018. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78019. */
  78020. get idealWidth(): number;
  78021. set idealWidth(value: number);
  78022. /**
  78023. * Gets or sets the ideal height used to design controls.
  78024. * The GUI will then rescale everything accordingly
  78025. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78026. */
  78027. get idealHeight(): number;
  78028. set idealHeight(value: number);
  78029. /**
  78030. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78031. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78032. */
  78033. get useSmallestIdeal(): boolean;
  78034. set useSmallestIdeal(value: boolean);
  78035. /**
  78036. * Gets or sets a boolean indicating if adaptive scaling must be used
  78037. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78038. */
  78039. get renderAtIdealSize(): boolean;
  78040. set renderAtIdealSize(value: boolean);
  78041. /**
  78042. * Gets the ratio used when in "ideal mode"
  78043. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78044. * */
  78045. get idealRatio(): number;
  78046. /**
  78047. * Gets the underlying layer used to render the texture when in fullscreen mode
  78048. */
  78049. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78050. /**
  78051. * Gets the root container control
  78052. */
  78053. get rootContainer(): Container;
  78054. /**
  78055. * Returns an array containing the root container.
  78056. * This is mostly used to let the Inspector introspects the ADT
  78057. * @returns an array containing the rootContainer
  78058. */
  78059. getChildren(): Array<Container>;
  78060. /**
  78061. * Will return all controls that are inside this texture
  78062. * @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
  78063. * @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
  78064. * @return all child controls
  78065. */
  78066. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78067. /**
  78068. * Gets or sets the current focused control
  78069. */
  78070. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78071. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78072. /**
  78073. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78074. */
  78075. get isForeground(): boolean;
  78076. set isForeground(value: boolean);
  78077. /**
  78078. * Gets or set information about clipboardData
  78079. */
  78080. get clipboardData(): string;
  78081. set clipboardData(value: string);
  78082. /**
  78083. * Creates a new AdvancedDynamicTexture
  78084. * @param name defines the name of the texture
  78085. * @param width defines the width of the texture
  78086. * @param height defines the height of the texture
  78087. * @param scene defines the hosting scene
  78088. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78089. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78090. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78091. */
  78092. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78093. /**
  78094. * Get the current class name of the texture useful for serialization or dynamic coding.
  78095. * @returns "AdvancedDynamicTexture"
  78096. */
  78097. getClassName(): string;
  78098. /**
  78099. * Function used to execute a function on all controls
  78100. * @param func defines the function to execute
  78101. * @param container defines the container where controls belong. If null the root container will be used
  78102. */
  78103. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78104. private _useInvalidateRectOptimization;
  78105. /**
  78106. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78107. */
  78108. get useInvalidateRectOptimization(): boolean;
  78109. set useInvalidateRectOptimization(value: boolean);
  78110. private _invalidatedRectangle;
  78111. /**
  78112. * Invalidates a rectangle area on the gui texture
  78113. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78114. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78115. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78116. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78117. */
  78118. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78119. /**
  78120. * Marks the texture as dirty forcing a complete update
  78121. */
  78122. markAsDirty(): void;
  78123. /**
  78124. * Helper function used to create a new style
  78125. * @returns a new style
  78126. * @see https://doc.babylonjs.com/how_to/gui#styles
  78127. */
  78128. createStyle(): Style;
  78129. /**
  78130. * Adds a new control to the root container
  78131. * @param control defines the control to add
  78132. * @returns the current texture
  78133. */
  78134. addControl(control: Control): AdvancedDynamicTexture;
  78135. /**
  78136. * Removes a control from the root container
  78137. * @param control defines the control to remove
  78138. * @returns the current texture
  78139. */
  78140. removeControl(control: Control): AdvancedDynamicTexture;
  78141. /**
  78142. * Release all resources
  78143. */
  78144. dispose(): void;
  78145. private _onResize;
  78146. /** @hidden */
  78147. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78148. /**
  78149. * Get screen coordinates for a vector3
  78150. * @param position defines the position to project
  78151. * @param worldMatrix defines the world matrix to use
  78152. * @returns the projected position
  78153. */
  78154. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78155. private _checkUpdate;
  78156. private _clearMeasure;
  78157. private _render;
  78158. /** @hidden */
  78159. _changeCursor(cursor: string): void;
  78160. /** @hidden */
  78161. _registerLastControlDown(control: Control, pointerId: number): void;
  78162. private _doPicking;
  78163. /** @hidden */
  78164. _cleanControlAfterRemovalFromList(list: {
  78165. [pointerId: number]: Control;
  78166. }, control: Control): void;
  78167. /** @hidden */
  78168. _cleanControlAfterRemoval(control: Control): void;
  78169. /** Attach to all scene events required to support pointer events */
  78170. attach(): void;
  78171. /** @hidden */
  78172. private onClipboardCopy;
  78173. /** @hidden */
  78174. private onClipboardCut;
  78175. /** @hidden */
  78176. private onClipboardPaste;
  78177. /**
  78178. * Register the clipboard Events onto the canvas
  78179. */
  78180. registerClipboardEvents(): void;
  78181. /**
  78182. * Unregister the clipboard Events from the canvas
  78183. */
  78184. unRegisterClipboardEvents(): void;
  78185. /**
  78186. * Connect the texture to a hosting mesh to enable interactions
  78187. * @param mesh defines the mesh to attach to
  78188. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78189. */
  78190. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78191. /**
  78192. * Move the focus to a specific control
  78193. * @param control defines the control which will receive the focus
  78194. */
  78195. moveFocusToControl(control: IFocusableControl): void;
  78196. private _manageFocus;
  78197. private _attachToOnPointerOut;
  78198. private _attachToOnBlur;
  78199. /**
  78200. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78201. * @param mesh defines the mesh which will receive the texture
  78202. * @param width defines the texture width (1024 by default)
  78203. * @param height defines the texture height (1024 by default)
  78204. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78205. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78206. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78207. * @returns a new AdvancedDynamicTexture
  78208. */
  78209. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78210. /**
  78211. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78212. * In this mode the texture will rely on a layer for its rendering.
  78213. * This allows it to be treated like any other layer.
  78214. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78215. * LayerMask is set through advancedTexture.layer.layerMask
  78216. * @param name defines name for the texture
  78217. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78218. * @param scene defines the hsoting scene
  78219. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78220. * @returns a new AdvancedDynamicTexture
  78221. */
  78222. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78223. }
  78224. }
  78225. declare module BABYLON.GUI {
  78226. /**
  78227. * Root class used for all 2D controls
  78228. * @see https://doc.babylonjs.com/how_to/gui#controls
  78229. */
  78230. export class Control {
  78231. /** defines the name of the control */
  78232. name?: string | undefined;
  78233. /**
  78234. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78235. */
  78236. static AllowAlphaInheritance: boolean;
  78237. private _alpha;
  78238. private _alphaSet;
  78239. private _zIndex;
  78240. /** @hidden */
  78241. _host: AdvancedDynamicTexture;
  78242. /** Gets or sets the control parent */
  78243. parent: BABYLON.Nullable<Container>;
  78244. /** @hidden */
  78245. _currentMeasure: Measure;
  78246. private _fontFamily;
  78247. private _fontStyle;
  78248. private _fontWeight;
  78249. private _fontSize;
  78250. private _font;
  78251. /** @hidden */
  78252. _width: ValueAndUnit;
  78253. /** @hidden */
  78254. _height: ValueAndUnit;
  78255. /** @hidden */
  78256. protected _fontOffset: {
  78257. ascent: number;
  78258. height: number;
  78259. descent: number;
  78260. };
  78261. private _color;
  78262. private _style;
  78263. private _styleObserver;
  78264. /** @hidden */
  78265. protected _horizontalAlignment: number;
  78266. /** @hidden */
  78267. protected _verticalAlignment: number;
  78268. /** @hidden */
  78269. protected _isDirty: boolean;
  78270. /** @hidden */
  78271. protected _wasDirty: boolean;
  78272. /** @hidden */
  78273. _tempParentMeasure: Measure;
  78274. /** @hidden */
  78275. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78276. /** @hidden */
  78277. protected _cachedParentMeasure: Measure;
  78278. private _paddingLeft;
  78279. private _paddingRight;
  78280. private _paddingTop;
  78281. private _paddingBottom;
  78282. /** @hidden */
  78283. _left: ValueAndUnit;
  78284. /** @hidden */
  78285. _top: ValueAndUnit;
  78286. private _scaleX;
  78287. private _scaleY;
  78288. private _rotation;
  78289. private _transformCenterX;
  78290. private _transformCenterY;
  78291. /** @hidden */
  78292. _transformMatrix: Matrix2D;
  78293. /** @hidden */
  78294. protected _invertTransformMatrix: Matrix2D;
  78295. /** @hidden */
  78296. protected _transformedPosition: BABYLON.Vector2;
  78297. private _isMatrixDirty;
  78298. private _cachedOffsetX;
  78299. private _cachedOffsetY;
  78300. private _isVisible;
  78301. private _isHighlighted;
  78302. /** @hidden */
  78303. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78304. private _fontSet;
  78305. private _dummyVector2;
  78306. private _downCount;
  78307. private _enterCount;
  78308. private _doNotRender;
  78309. private _downPointerIds;
  78310. protected _isEnabled: boolean;
  78311. protected _disabledColor: string;
  78312. protected _disabledColorItem: string;
  78313. /** @hidden */
  78314. protected _rebuildLayout: boolean;
  78315. /** @hidden */
  78316. _customData: any;
  78317. /** @hidden */
  78318. _isClipped: boolean;
  78319. /** @hidden */
  78320. _automaticSize: boolean;
  78321. /** @hidden */
  78322. _tag: any;
  78323. /**
  78324. * 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
  78325. */
  78326. uniqueId: number;
  78327. /**
  78328. * Gets or sets an object used to store user defined information for the node
  78329. */
  78330. metadata: any;
  78331. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78332. isHitTestVisible: boolean;
  78333. /** Gets or sets a boolean indicating if the control can block pointer events */
  78334. isPointerBlocker: boolean;
  78335. /** Gets or sets a boolean indicating if the control can be focusable */
  78336. isFocusInvisible: boolean;
  78337. /**
  78338. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78339. * 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
  78340. */
  78341. clipChildren: boolean;
  78342. /**
  78343. * Gets or sets a boolean indicating that control content must be clipped
  78344. * 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
  78345. */
  78346. clipContent: boolean;
  78347. /**
  78348. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78349. */
  78350. useBitmapCache: boolean;
  78351. private _cacheData;
  78352. private _shadowOffsetX;
  78353. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78354. get shadowOffsetX(): number;
  78355. set shadowOffsetX(value: number);
  78356. private _shadowOffsetY;
  78357. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78358. get shadowOffsetY(): number;
  78359. set shadowOffsetY(value: number);
  78360. private _shadowBlur;
  78361. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78362. get shadowBlur(): number;
  78363. set shadowBlur(value: number);
  78364. private _shadowColor;
  78365. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78366. get shadowColor(): string;
  78367. set shadowColor(value: string);
  78368. /** Gets or sets the cursor to use when the control is hovered */
  78369. hoverCursor: string;
  78370. /** @hidden */
  78371. protected _linkOffsetX: ValueAndUnit;
  78372. /** @hidden */
  78373. protected _linkOffsetY: ValueAndUnit;
  78374. /** Gets the control type name */
  78375. get typeName(): string;
  78376. /**
  78377. * Get the current class name of the control.
  78378. * @returns current class name
  78379. */
  78380. getClassName(): string;
  78381. /**
  78382. * An event triggered when pointer wheel is scrolled
  78383. */
  78384. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78385. /**
  78386. * An event triggered when the pointer move over the control.
  78387. */
  78388. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78389. /**
  78390. * An event triggered when the pointer move out of the control.
  78391. */
  78392. onPointerOutObservable: BABYLON.Observable<Control>;
  78393. /**
  78394. * An event triggered when the pointer taps the control
  78395. */
  78396. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78397. /**
  78398. * An event triggered when pointer up
  78399. */
  78400. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78401. /**
  78402. * An event triggered when a control is clicked on
  78403. */
  78404. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78405. /**
  78406. * An event triggered when pointer enters the control
  78407. */
  78408. onPointerEnterObservable: BABYLON.Observable<Control>;
  78409. /**
  78410. * An event triggered when the control is marked as dirty
  78411. */
  78412. onDirtyObservable: BABYLON.Observable<Control>;
  78413. /**
  78414. * An event triggered before drawing the control
  78415. */
  78416. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78417. /**
  78418. * An event triggered after the control was drawn
  78419. */
  78420. onAfterDrawObservable: BABYLON.Observable<Control>;
  78421. /**
  78422. * An event triggered when the control has been disposed
  78423. */
  78424. onDisposeObservable: BABYLON.Observable<Control>;
  78425. /**
  78426. * Get the hosting AdvancedDynamicTexture
  78427. */
  78428. get host(): AdvancedDynamicTexture;
  78429. /** Gets or set information about font offsets (used to render and align text) */
  78430. get fontOffset(): {
  78431. ascent: number;
  78432. height: number;
  78433. descent: number;
  78434. };
  78435. set fontOffset(offset: {
  78436. ascent: number;
  78437. height: number;
  78438. descent: number;
  78439. });
  78440. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78441. get alpha(): number;
  78442. set alpha(value: number);
  78443. /**
  78444. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78445. */
  78446. get isHighlighted(): boolean;
  78447. set isHighlighted(value: boolean);
  78448. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78449. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78450. */
  78451. get scaleX(): number;
  78452. set scaleX(value: number);
  78453. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78454. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78455. */
  78456. get scaleY(): number;
  78457. set scaleY(value: number);
  78458. /** Gets or sets the rotation angle (0 by default)
  78459. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78460. */
  78461. get rotation(): number;
  78462. set rotation(value: number);
  78463. /** Gets or sets the transformation center on Y axis (0 by default)
  78464. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78465. */
  78466. get transformCenterY(): number;
  78467. set transformCenterY(value: number);
  78468. /** Gets or sets the transformation center on X axis (0 by default)
  78469. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78470. */
  78471. get transformCenterX(): number;
  78472. set transformCenterX(value: number);
  78473. /**
  78474. * Gets or sets the horizontal alignment
  78475. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78476. */
  78477. get horizontalAlignment(): number;
  78478. set horizontalAlignment(value: number);
  78479. /**
  78480. * Gets or sets the vertical alignment
  78481. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78482. */
  78483. get verticalAlignment(): number;
  78484. set verticalAlignment(value: number);
  78485. /**
  78486. * Gets or sets a fixed ratio for this control.
  78487. * When different from 0, the ratio is used to compute the "second" dimension.
  78488. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78489. * second dimension is computed as first dimension * fixedRatio
  78490. */
  78491. fixedRatio: number;
  78492. private _fixedRatioMasterIsWidth;
  78493. /**
  78494. * Gets or sets control width
  78495. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78496. */
  78497. get width(): string | number;
  78498. set width(value: string | number);
  78499. /**
  78500. * Gets or sets the control width in pixel
  78501. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78502. */
  78503. get widthInPixels(): number;
  78504. set widthInPixels(value: number);
  78505. /**
  78506. * Gets or sets control height
  78507. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78508. */
  78509. get height(): string | number;
  78510. set height(value: string | number);
  78511. /**
  78512. * Gets or sets control height in pixel
  78513. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78514. */
  78515. get heightInPixels(): number;
  78516. set heightInPixels(value: number);
  78517. /** Gets or set font family */
  78518. get fontFamily(): string;
  78519. set fontFamily(value: string);
  78520. /** Gets or sets font style */
  78521. get fontStyle(): string;
  78522. set fontStyle(value: string);
  78523. /** Gets or sets font weight */
  78524. get fontWeight(): string;
  78525. set fontWeight(value: string);
  78526. /**
  78527. * Gets or sets style
  78528. * @see https://doc.babylonjs.com/how_to/gui#styles
  78529. */
  78530. get style(): BABYLON.Nullable<Style>;
  78531. set style(value: BABYLON.Nullable<Style>);
  78532. /** @hidden */
  78533. get _isFontSizeInPercentage(): boolean;
  78534. /** Gets or sets font size in pixels */
  78535. get fontSizeInPixels(): number;
  78536. set fontSizeInPixels(value: number);
  78537. /** Gets or sets font size */
  78538. get fontSize(): string | number;
  78539. set fontSize(value: string | number);
  78540. /** Gets or sets foreground color */
  78541. get color(): string;
  78542. set color(value: string);
  78543. /** Gets or sets z index which is used to reorder controls on the z axis */
  78544. get zIndex(): number;
  78545. set zIndex(value: number);
  78546. /** Gets or sets a boolean indicating if the control can be rendered */
  78547. get notRenderable(): boolean;
  78548. set notRenderable(value: boolean);
  78549. /** Gets or sets a boolean indicating if the control is visible */
  78550. get isVisible(): boolean;
  78551. set isVisible(value: boolean);
  78552. /** Gets a boolean indicating that the control needs to update its rendering */
  78553. get isDirty(): boolean;
  78554. /**
  78555. * Gets the current linked mesh (or null if none)
  78556. */
  78557. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78558. /**
  78559. * Gets or sets a value indicating the padding to use on the left of the control
  78560. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78561. */
  78562. get paddingLeft(): string | number;
  78563. set paddingLeft(value: string | number);
  78564. /**
  78565. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78566. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78567. */
  78568. get paddingLeftInPixels(): number;
  78569. set paddingLeftInPixels(value: number);
  78570. /**
  78571. * Gets or sets a value indicating the padding to use on the right of the control
  78572. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78573. */
  78574. get paddingRight(): string | number;
  78575. set paddingRight(value: string | number);
  78576. /**
  78577. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78578. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78579. */
  78580. get paddingRightInPixels(): number;
  78581. set paddingRightInPixels(value: number);
  78582. /**
  78583. * Gets or sets a value indicating the padding to use on the top of the control
  78584. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78585. */
  78586. get paddingTop(): string | number;
  78587. set paddingTop(value: string | number);
  78588. /**
  78589. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78590. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78591. */
  78592. get paddingTopInPixels(): number;
  78593. set paddingTopInPixels(value: number);
  78594. /**
  78595. * Gets or sets a value indicating the padding to use on the bottom of the control
  78596. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78597. */
  78598. get paddingBottom(): string | number;
  78599. set paddingBottom(value: string | number);
  78600. /**
  78601. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78602. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78603. */
  78604. get paddingBottomInPixels(): number;
  78605. set paddingBottomInPixels(value: number);
  78606. /**
  78607. * Gets or sets a value indicating the left coordinate of the control
  78608. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78609. */
  78610. get left(): string | number;
  78611. set left(value: string | number);
  78612. /**
  78613. * Gets or sets a value indicating the left coordinate in pixels of the control
  78614. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78615. */
  78616. get leftInPixels(): number;
  78617. set leftInPixels(value: number);
  78618. /**
  78619. * Gets or sets a value indicating the top coordinate of the control
  78620. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78621. */
  78622. get top(): string | number;
  78623. set top(value: string | number);
  78624. /**
  78625. * Gets or sets a value indicating the top coordinate in pixels of the control
  78626. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78627. */
  78628. get topInPixels(): number;
  78629. set topInPixels(value: number);
  78630. /**
  78631. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78632. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78633. */
  78634. get linkOffsetX(): string | number;
  78635. set linkOffsetX(value: string | number);
  78636. /**
  78637. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78638. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78639. */
  78640. get linkOffsetXInPixels(): number;
  78641. set linkOffsetXInPixels(value: number);
  78642. /**
  78643. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78644. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78645. */
  78646. get linkOffsetY(): string | number;
  78647. set linkOffsetY(value: string | number);
  78648. /**
  78649. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78650. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78651. */
  78652. get linkOffsetYInPixels(): number;
  78653. set linkOffsetYInPixels(value: number);
  78654. /** Gets the center coordinate on X axis */
  78655. get centerX(): number;
  78656. /** Gets the center coordinate on Y axis */
  78657. get centerY(): number;
  78658. /** Gets or sets if control is Enabled*/
  78659. get isEnabled(): boolean;
  78660. set isEnabled(value: boolean);
  78661. /** Gets or sets background color of control if it's disabled*/
  78662. get disabledColor(): string;
  78663. set disabledColor(value: string);
  78664. /** Gets or sets front color of control if it's disabled*/
  78665. get disabledColorItem(): string;
  78666. set disabledColorItem(value: string);
  78667. /**
  78668. * Creates a new control
  78669. * @param name defines the name of the control
  78670. */
  78671. constructor(
  78672. /** defines the name of the control */
  78673. name?: string | undefined);
  78674. /** @hidden */
  78675. protected _getTypeName(): string;
  78676. /**
  78677. * Gets the first ascendant in the hierarchy of the given type
  78678. * @param className defines the required type
  78679. * @returns the ascendant or null if not found
  78680. */
  78681. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78682. /** @hidden */
  78683. _resetFontCache(): void;
  78684. /**
  78685. * Determines if a container is an ascendant of the current control
  78686. * @param container defines the container to look for
  78687. * @returns true if the container is one of the ascendant of the control
  78688. */
  78689. isAscendant(container: Control): boolean;
  78690. /**
  78691. * Gets coordinates in local control space
  78692. * @param globalCoordinates defines the coordinates to transform
  78693. * @returns the new coordinates in local space
  78694. */
  78695. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78696. /**
  78697. * Gets coordinates in local control space
  78698. * @param globalCoordinates defines the coordinates to transform
  78699. * @param result defines the target vector2 where to store the result
  78700. * @returns the current control
  78701. */
  78702. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78703. /**
  78704. * Gets coordinates in parent local control space
  78705. * @param globalCoordinates defines the coordinates to transform
  78706. * @returns the new coordinates in parent local space
  78707. */
  78708. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78709. /**
  78710. * Move the current control to a vector3 position projected onto the screen.
  78711. * @param position defines the target position
  78712. * @param scene defines the hosting scene
  78713. */
  78714. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78715. /**
  78716. * Will store all controls that have this control as ascendant in a given array
  78717. * @param results defines the array where to store the descendants
  78718. * @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
  78719. * @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
  78720. */
  78721. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78722. /**
  78723. * Will return all controls that have this control as ascendant
  78724. * @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
  78725. * @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
  78726. * @return all child controls
  78727. */
  78728. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78729. /**
  78730. * Link current control with a target mesh
  78731. * @param mesh defines the mesh to link with
  78732. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78733. */
  78734. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78735. /** @hidden */
  78736. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78737. /** @hidden */
  78738. _offsetLeft(offset: number): void;
  78739. /** @hidden */
  78740. _offsetTop(offset: number): void;
  78741. /** @hidden */
  78742. _markMatrixAsDirty(): void;
  78743. /** @hidden */
  78744. _flagDescendantsAsMatrixDirty(): void;
  78745. /** @hidden */
  78746. _intersectsRect(rect: Measure): boolean;
  78747. /** @hidden */
  78748. protected invalidateRect(): void;
  78749. /** @hidden */
  78750. _markAsDirty(force?: boolean): void;
  78751. /** @hidden */
  78752. _markAllAsDirty(): void;
  78753. /** @hidden */
  78754. _link(host: AdvancedDynamicTexture): void;
  78755. /** @hidden */
  78756. protected _transform(context?: CanvasRenderingContext2D): void;
  78757. /** @hidden */
  78758. _renderHighlight(context: CanvasRenderingContext2D): void;
  78759. /** @hidden */
  78760. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78761. /** @hidden */
  78762. protected _applyStates(context: CanvasRenderingContext2D): void;
  78763. /** @hidden */
  78764. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78765. /** @hidden */
  78766. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78767. protected _evaluateClippingState(parentMeasure: Measure): void;
  78768. /** @hidden */
  78769. _measure(): void;
  78770. /** @hidden */
  78771. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78772. /** @hidden */
  78773. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78774. /** @hidden */
  78775. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78776. /** @hidden */
  78777. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78778. private static _ClipMeasure;
  78779. private _tmpMeasureA;
  78780. private _clip;
  78781. /** @hidden */
  78782. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78783. /** @hidden */
  78784. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78785. /**
  78786. * Tests if a given coordinates belong to the current control
  78787. * @param x defines x coordinate to test
  78788. * @param y defines y coordinate to test
  78789. * @returns true if the coordinates are inside the control
  78790. */
  78791. contains(x: number, y: number): boolean;
  78792. /** @hidden */
  78793. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78794. /** @hidden */
  78795. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78796. /** @hidden */
  78797. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78798. /** @hidden */
  78799. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78800. /** @hidden */
  78801. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78802. /** @hidden */
  78803. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78804. /** @hidden */
  78805. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78806. /** @hidden */
  78807. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78808. /** @hidden */
  78809. _onCanvasBlur(): void;
  78810. /** @hidden */
  78811. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78812. private _prepareFont;
  78813. /** Releases associated resources */
  78814. dispose(): void;
  78815. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78816. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78817. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78818. private static _VERTICAL_ALIGNMENT_TOP;
  78819. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78820. private static _VERTICAL_ALIGNMENT_CENTER;
  78821. /** HORIZONTAL_ALIGNMENT_LEFT */
  78822. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78823. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78824. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78825. /** HORIZONTAL_ALIGNMENT_CENTER */
  78826. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78827. /** VERTICAL_ALIGNMENT_TOP */
  78828. static get VERTICAL_ALIGNMENT_TOP(): number;
  78829. /** VERTICAL_ALIGNMENT_BOTTOM */
  78830. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78831. /** VERTICAL_ALIGNMENT_CENTER */
  78832. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78833. private static _FontHeightSizes;
  78834. /** @hidden */
  78835. static _GetFontOffset(font: string): {
  78836. ascent: number;
  78837. height: number;
  78838. descent: number;
  78839. };
  78840. /**
  78841. * Creates a stack panel that can be used to render headers
  78842. * @param control defines the control to associate with the header
  78843. * @param text defines the text of the header
  78844. * @param size defines the size of the header
  78845. * @param options defines options used to configure the header
  78846. * @returns a new StackPanel
  78847. * @ignore
  78848. * @hidden
  78849. */
  78850. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78851. isHorizontal: boolean;
  78852. controlFirst: boolean;
  78853. }) => any;
  78854. /** @hidden */
  78855. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78856. }
  78857. }
  78858. declare module BABYLON.GUI {
  78859. /**
  78860. * Root class for 2D containers
  78861. * @see https://doc.babylonjs.com/how_to/gui#containers
  78862. */
  78863. export class Container extends Control {
  78864. name?: string | undefined;
  78865. /** @hidden */
  78866. _children: Control[];
  78867. /** @hidden */
  78868. protected _measureForChildren: Measure;
  78869. /** @hidden */
  78870. protected _background: string;
  78871. /** @hidden */
  78872. protected _adaptWidthToChildren: boolean;
  78873. /** @hidden */
  78874. protected _adaptHeightToChildren: boolean;
  78875. /**
  78876. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78877. */
  78878. logLayoutCycleErrors: boolean;
  78879. /**
  78880. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78881. */
  78882. maxLayoutCycle: number;
  78883. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78884. get adaptHeightToChildren(): boolean;
  78885. set adaptHeightToChildren(value: boolean);
  78886. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78887. get adaptWidthToChildren(): boolean;
  78888. set adaptWidthToChildren(value: boolean);
  78889. /** Gets or sets background color */
  78890. get background(): string;
  78891. set background(value: string);
  78892. /** Gets the list of children */
  78893. get children(): Control[];
  78894. /**
  78895. * Creates a new Container
  78896. * @param name defines the name of the container
  78897. */
  78898. constructor(name?: string | undefined);
  78899. protected _getTypeName(): string;
  78900. _flagDescendantsAsMatrixDirty(): void;
  78901. /**
  78902. * Gets a child using its name
  78903. * @param name defines the child name to look for
  78904. * @returns the child control if found
  78905. */
  78906. getChildByName(name: string): BABYLON.Nullable<Control>;
  78907. /**
  78908. * Gets a child using its type and its name
  78909. * @param name defines the child name to look for
  78910. * @param type defines the child type to look for
  78911. * @returns the child control if found
  78912. */
  78913. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78914. /**
  78915. * Search for a specific control in children
  78916. * @param control defines the control to look for
  78917. * @returns true if the control is in child list
  78918. */
  78919. containsControl(control: Control): boolean;
  78920. /**
  78921. * Adds a new control to the current container
  78922. * @param control defines the control to add
  78923. * @returns the current container
  78924. */
  78925. addControl(control: BABYLON.Nullable<Control>): Container;
  78926. /**
  78927. * Removes all controls from the current container
  78928. * @returns the current container
  78929. */
  78930. clearControls(): Container;
  78931. /**
  78932. * Removes a control from the current container
  78933. * @param control defines the control to remove
  78934. * @returns the current container
  78935. */
  78936. removeControl(control: Control): Container;
  78937. /** @hidden */
  78938. _reOrderControl(control: Control): void;
  78939. /** @hidden */
  78940. _offsetLeft(offset: number): void;
  78941. /** @hidden */
  78942. _offsetTop(offset: number): void;
  78943. /** @hidden */
  78944. _markAllAsDirty(): void;
  78945. /** @hidden */
  78946. protected _localDraw(context: CanvasRenderingContext2D): void;
  78947. /** @hidden */
  78948. _link(host: AdvancedDynamicTexture): void;
  78949. /** @hidden */
  78950. protected _beforeLayout(): void;
  78951. /** @hidden */
  78952. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78953. /** @hidden */
  78954. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78955. protected _postMeasure(): void;
  78956. /** @hidden */
  78957. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78958. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78959. /** @hidden */
  78960. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78961. /** @hidden */
  78962. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78963. /** Releases associated resources */
  78964. dispose(): void;
  78965. }
  78966. }
  78967. declare module BABYLON.GUI {
  78968. /** Class used to create rectangle container */
  78969. export class Rectangle extends Container {
  78970. name?: string | undefined;
  78971. private _thickness;
  78972. private _cornerRadius;
  78973. /** Gets or sets border thickness */
  78974. get thickness(): number;
  78975. set thickness(value: number);
  78976. /** Gets or sets the corner radius angle */
  78977. get cornerRadius(): number;
  78978. set cornerRadius(value: number);
  78979. /**
  78980. * Creates a new Rectangle
  78981. * @param name defines the control name
  78982. */
  78983. constructor(name?: string | undefined);
  78984. protected _getTypeName(): string;
  78985. protected _localDraw(context: CanvasRenderingContext2D): void;
  78986. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78987. private _drawRoundedRect;
  78988. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78989. }
  78990. }
  78991. declare module BABYLON.GUI {
  78992. /**
  78993. * Enum that determines the text-wrapping mode to use.
  78994. */
  78995. export enum TextWrapping {
  78996. /**
  78997. * Clip the text when it's larger than Control.width; this is the default mode.
  78998. */
  78999. Clip = 0,
  79000. /**
  79001. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79002. */
  79003. WordWrap = 1,
  79004. /**
  79005. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79006. */
  79007. Ellipsis = 2
  79008. }
  79009. /**
  79010. * Class used to create text block control
  79011. */
  79012. export class TextBlock extends Control {
  79013. /**
  79014. * Defines the name of the control
  79015. */
  79016. name?: string | undefined;
  79017. private _text;
  79018. private _textWrapping;
  79019. private _textHorizontalAlignment;
  79020. private _textVerticalAlignment;
  79021. private _lines;
  79022. private _resizeToFit;
  79023. private _lineSpacing;
  79024. private _outlineWidth;
  79025. private _outlineColor;
  79026. private _underline;
  79027. private _lineThrough;
  79028. /**
  79029. * An event triggered after the text is changed
  79030. */
  79031. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79032. /**
  79033. * An event triggered after the text was broken up into lines
  79034. */
  79035. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79036. /**
  79037. * Function used to split a string into words. By default, a string is split at each space character found
  79038. */
  79039. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79040. /**
  79041. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79042. */
  79043. get lines(): any[];
  79044. /**
  79045. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79046. */
  79047. get resizeToFit(): boolean;
  79048. /**
  79049. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79050. */
  79051. set resizeToFit(value: boolean);
  79052. /**
  79053. * Gets or sets a boolean indicating if text must be wrapped
  79054. */
  79055. get textWrapping(): TextWrapping | boolean;
  79056. /**
  79057. * Gets or sets a boolean indicating if text must be wrapped
  79058. */
  79059. set textWrapping(value: TextWrapping | boolean);
  79060. /**
  79061. * Gets or sets text to display
  79062. */
  79063. get text(): string;
  79064. /**
  79065. * Gets or sets text to display
  79066. */
  79067. set text(value: string);
  79068. /**
  79069. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79070. */
  79071. get textHorizontalAlignment(): number;
  79072. /**
  79073. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79074. */
  79075. set textHorizontalAlignment(value: number);
  79076. /**
  79077. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79078. */
  79079. get textVerticalAlignment(): number;
  79080. /**
  79081. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79082. */
  79083. set textVerticalAlignment(value: number);
  79084. /**
  79085. * Gets or sets line spacing value
  79086. */
  79087. set lineSpacing(value: string | number);
  79088. /**
  79089. * Gets or sets line spacing value
  79090. */
  79091. get lineSpacing(): string | number;
  79092. /**
  79093. * Gets or sets outlineWidth of the text to display
  79094. */
  79095. get outlineWidth(): number;
  79096. /**
  79097. * Gets or sets outlineWidth of the text to display
  79098. */
  79099. set outlineWidth(value: number);
  79100. /**
  79101. * Gets or sets a boolean indicating that text must have underline
  79102. */
  79103. get underline(): boolean;
  79104. /**
  79105. * Gets or sets a boolean indicating that text must have underline
  79106. */
  79107. set underline(value: boolean);
  79108. /**
  79109. * Gets or sets an boolean indicating that text must be crossed out
  79110. */
  79111. get lineThrough(): boolean;
  79112. /**
  79113. * Gets or sets an boolean indicating that text must be crossed out
  79114. */
  79115. set lineThrough(value: boolean);
  79116. /**
  79117. * Gets or sets outlineColor of the text to display
  79118. */
  79119. get outlineColor(): string;
  79120. /**
  79121. * Gets or sets outlineColor of the text to display
  79122. */
  79123. set outlineColor(value: string);
  79124. /**
  79125. * Creates a new TextBlock object
  79126. * @param name defines the name of the control
  79127. * @param text defines the text to display (emptry string by default)
  79128. */
  79129. constructor(
  79130. /**
  79131. * Defines the name of the control
  79132. */
  79133. name?: string | undefined, text?: string);
  79134. protected _getTypeName(): string;
  79135. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79136. private _drawText;
  79137. /** @hidden */
  79138. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79139. protected _applyStates(context: CanvasRenderingContext2D): void;
  79140. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79141. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79142. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79143. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79144. protected _renderLines(context: CanvasRenderingContext2D): void;
  79145. /**
  79146. * Given a width constraint applied on the text block, find the expected height
  79147. * @returns expected height
  79148. */
  79149. computeExpectedHeight(): number;
  79150. dispose(): void;
  79151. }
  79152. }
  79153. declare module BABYLON.GUI {
  79154. /**
  79155. * Class used to create 2D images
  79156. */
  79157. export class Image extends Control {
  79158. name?: string | undefined;
  79159. private _workingCanvas;
  79160. private _domImage;
  79161. private _imageWidth;
  79162. private _imageHeight;
  79163. private _loaded;
  79164. private _stretch;
  79165. private _source;
  79166. private _autoScale;
  79167. private _sourceLeft;
  79168. private _sourceTop;
  79169. private _sourceWidth;
  79170. private _sourceHeight;
  79171. private _svgAttributesComputationCompleted;
  79172. private _isSVG;
  79173. private _cellWidth;
  79174. private _cellHeight;
  79175. private _cellId;
  79176. private _populateNinePatchSlicesFromImage;
  79177. private _sliceLeft;
  79178. private _sliceRight;
  79179. private _sliceTop;
  79180. private _sliceBottom;
  79181. private _detectPointerOnOpaqueOnly;
  79182. private _imageDataCache;
  79183. /**
  79184. * BABYLON.Observable notified when the content is loaded
  79185. */
  79186. onImageLoadedObservable: BABYLON.Observable<Image>;
  79187. /**
  79188. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79189. */
  79190. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79191. /**
  79192. * Gets a boolean indicating that the content is loaded
  79193. */
  79194. get isLoaded(): boolean;
  79195. /**
  79196. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79197. */
  79198. get populateNinePatchSlicesFromImage(): boolean;
  79199. set populateNinePatchSlicesFromImage(value: boolean);
  79200. /**
  79201. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79202. * Beware using this as this will comsume more memory as the image has to be stored twice
  79203. */
  79204. get detectPointerOnOpaqueOnly(): boolean;
  79205. set detectPointerOnOpaqueOnly(value: boolean);
  79206. /**
  79207. * Gets or sets the left value for slicing (9-patch)
  79208. */
  79209. get sliceLeft(): number;
  79210. set sliceLeft(value: number);
  79211. /**
  79212. * Gets or sets the right value for slicing (9-patch)
  79213. */
  79214. get sliceRight(): number;
  79215. set sliceRight(value: number);
  79216. /**
  79217. * Gets or sets the top value for slicing (9-patch)
  79218. */
  79219. get sliceTop(): number;
  79220. set sliceTop(value: number);
  79221. /**
  79222. * Gets or sets the bottom value for slicing (9-patch)
  79223. */
  79224. get sliceBottom(): number;
  79225. set sliceBottom(value: number);
  79226. /**
  79227. * Gets or sets the left coordinate in the source image
  79228. */
  79229. get sourceLeft(): number;
  79230. set sourceLeft(value: number);
  79231. /**
  79232. * Gets or sets the top coordinate in the source image
  79233. */
  79234. get sourceTop(): number;
  79235. set sourceTop(value: number);
  79236. /**
  79237. * Gets or sets the width to capture in the source image
  79238. */
  79239. get sourceWidth(): number;
  79240. set sourceWidth(value: number);
  79241. /**
  79242. * Gets or sets the height to capture in the source image
  79243. */
  79244. get sourceHeight(): number;
  79245. set sourceHeight(value: number);
  79246. /** Indicates if the format of the image is SVG */
  79247. get isSVG(): boolean;
  79248. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79249. get svgAttributesComputationCompleted(): boolean;
  79250. /**
  79251. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79252. * @see https://doc.babylonjs.com/how_to/gui#image
  79253. */
  79254. get autoScale(): boolean;
  79255. set autoScale(value: boolean);
  79256. /** Gets or sets the streching mode used by the image */
  79257. get stretch(): number;
  79258. set stretch(value: number);
  79259. /** @hidden */
  79260. _rotate90(n: number, preserveProperties?: boolean): Image;
  79261. private _handleRotationForSVGImage;
  79262. private _rotate90SourceProperties;
  79263. /**
  79264. * Gets or sets the internal DOM image used to render the control
  79265. */
  79266. set domImage(value: HTMLImageElement);
  79267. get domImage(): HTMLImageElement;
  79268. private _onImageLoaded;
  79269. private _extractNinePatchSliceDataFromImage;
  79270. /**
  79271. * Gets or sets image source url
  79272. */
  79273. set source(value: BABYLON.Nullable<string>);
  79274. /**
  79275. * Checks for svg document with icon id present
  79276. */
  79277. private _svgCheck;
  79278. /**
  79279. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79280. * given external svg file and icon id
  79281. */
  79282. private _getSVGAttribs;
  79283. /**
  79284. * Gets or sets the cell width to use when animation sheet is enabled
  79285. * @see https://doc.babylonjs.com/how_to/gui#image
  79286. */
  79287. get cellWidth(): number;
  79288. set cellWidth(value: number);
  79289. /**
  79290. * Gets or sets the cell height to use when animation sheet is enabled
  79291. * @see https://doc.babylonjs.com/how_to/gui#image
  79292. */
  79293. get cellHeight(): number;
  79294. set cellHeight(value: number);
  79295. /**
  79296. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79297. * @see https://doc.babylonjs.com/how_to/gui#image
  79298. */
  79299. get cellId(): number;
  79300. set cellId(value: number);
  79301. /**
  79302. * Creates a new Image
  79303. * @param name defines the control name
  79304. * @param url defines the image url
  79305. */
  79306. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79307. /**
  79308. * Tests if a given coordinates belong to the current control
  79309. * @param x defines x coordinate to test
  79310. * @param y defines y coordinate to test
  79311. * @returns true if the coordinates are inside the control
  79312. */
  79313. contains(x: number, y: number): boolean;
  79314. protected _getTypeName(): string;
  79315. /** Force the control to synchronize with its content */
  79316. synchronizeSizeWithContent(): void;
  79317. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79318. private _prepareWorkingCanvasForOpaqueDetection;
  79319. private _drawImage;
  79320. _draw(context: CanvasRenderingContext2D): void;
  79321. private _renderCornerPatch;
  79322. private _renderNinePatch;
  79323. dispose(): void;
  79324. /** STRETCH_NONE */
  79325. static readonly STRETCH_NONE: number;
  79326. /** STRETCH_FILL */
  79327. static readonly STRETCH_FILL: number;
  79328. /** STRETCH_UNIFORM */
  79329. static readonly STRETCH_UNIFORM: number;
  79330. /** STRETCH_EXTEND */
  79331. static readonly STRETCH_EXTEND: number;
  79332. /** NINE_PATCH */
  79333. static readonly STRETCH_NINE_PATCH: number;
  79334. }
  79335. }
  79336. declare module BABYLON.GUI {
  79337. /**
  79338. * Class used to create 2D buttons
  79339. */
  79340. export class Button extends Rectangle {
  79341. name?: string | undefined;
  79342. /**
  79343. * Function called to generate a pointer enter animation
  79344. */
  79345. pointerEnterAnimation: () => void;
  79346. /**
  79347. * Function called to generate a pointer out animation
  79348. */
  79349. pointerOutAnimation: () => void;
  79350. /**
  79351. * Function called to generate a pointer down animation
  79352. */
  79353. pointerDownAnimation: () => void;
  79354. /**
  79355. * Function called to generate a pointer up animation
  79356. */
  79357. pointerUpAnimation: () => void;
  79358. /**
  79359. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79360. */
  79361. delegatePickingToChildren: boolean;
  79362. private _image;
  79363. /**
  79364. * Returns the image part of the button (if any)
  79365. */
  79366. get image(): BABYLON.Nullable<Image>;
  79367. private _textBlock;
  79368. /**
  79369. * Returns the image part of the button (if any)
  79370. */
  79371. get textBlock(): BABYLON.Nullable<TextBlock>;
  79372. /**
  79373. * Creates a new Button
  79374. * @param name defines the name of the button
  79375. */
  79376. constructor(name?: string | undefined);
  79377. protected _getTypeName(): string;
  79378. /** @hidden */
  79379. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79380. /** @hidden */
  79381. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79382. /** @hidden */
  79383. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79384. /** @hidden */
  79385. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79386. /** @hidden */
  79387. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79388. /**
  79389. * Creates a new button made with an image and a text
  79390. * @param name defines the name of the button
  79391. * @param text defines the text of the button
  79392. * @param imageUrl defines the url of the image
  79393. * @returns a new Button
  79394. */
  79395. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79396. /**
  79397. * Creates a new button made with an image
  79398. * @param name defines the name of the button
  79399. * @param imageUrl defines the url of the image
  79400. * @returns a new Button
  79401. */
  79402. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79403. /**
  79404. * Creates a new button made with a text
  79405. * @param name defines the name of the button
  79406. * @param text defines the text of the button
  79407. * @returns a new Button
  79408. */
  79409. static CreateSimpleButton(name: string, text: string): Button;
  79410. /**
  79411. * Creates a new button made with an image and a centered text
  79412. * @param name defines the name of the button
  79413. * @param text defines the text of the button
  79414. * @param imageUrl defines the url of the image
  79415. * @returns a new Button
  79416. */
  79417. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79418. }
  79419. }
  79420. declare module BABYLON.GUI {
  79421. /**
  79422. * Class used to create a 2D stack panel container
  79423. */
  79424. export class StackPanel extends Container {
  79425. name?: string | undefined;
  79426. private _isVertical;
  79427. private _manualWidth;
  79428. private _manualHeight;
  79429. private _doNotTrackManualChanges;
  79430. /**
  79431. * Gets or sets a boolean indicating that layou warnings should be ignored
  79432. */
  79433. ignoreLayoutWarnings: boolean;
  79434. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79435. get isVertical(): boolean;
  79436. set isVertical(value: boolean);
  79437. /**
  79438. * Gets or sets panel width.
  79439. * This value should not be set when in horizontal mode as it will be computed automatically
  79440. */
  79441. set width(value: string | number);
  79442. get width(): string | number;
  79443. /**
  79444. * Gets or sets panel height.
  79445. * This value should not be set when in vertical mode as it will be computed automatically
  79446. */
  79447. set height(value: string | number);
  79448. get height(): string | number;
  79449. /**
  79450. * Creates a new StackPanel
  79451. * @param name defines control name
  79452. */
  79453. constructor(name?: string | undefined);
  79454. protected _getTypeName(): string;
  79455. /** @hidden */
  79456. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79457. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79458. protected _postMeasure(): void;
  79459. }
  79460. }
  79461. declare module BABYLON.GUI {
  79462. /**
  79463. * Class used to represent a 2D checkbox
  79464. */
  79465. export class Checkbox extends Control {
  79466. name?: string | undefined;
  79467. private _isChecked;
  79468. private _background;
  79469. private _checkSizeRatio;
  79470. private _thickness;
  79471. /** Gets or sets border thickness */
  79472. get thickness(): number;
  79473. set thickness(value: number);
  79474. /**
  79475. * BABYLON.Observable raised when isChecked property changes
  79476. */
  79477. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79478. /** Gets or sets a value indicating the ratio between overall size and check size */
  79479. get checkSizeRatio(): number;
  79480. set checkSizeRatio(value: number);
  79481. /** Gets or sets background color */
  79482. get background(): string;
  79483. set background(value: string);
  79484. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79485. get isChecked(): boolean;
  79486. set isChecked(value: boolean);
  79487. /**
  79488. * Creates a new CheckBox
  79489. * @param name defines the control name
  79490. */
  79491. constructor(name?: string | undefined);
  79492. protected _getTypeName(): string;
  79493. /** @hidden */
  79494. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79495. /** @hidden */
  79496. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79497. /**
  79498. * Utility function to easily create a checkbox with a header
  79499. * @param title defines the label to use for the header
  79500. * @param onValueChanged defines the callback to call when value changes
  79501. * @returns a StackPanel containing the checkbox and a textBlock
  79502. */
  79503. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79504. }
  79505. }
  79506. declare module BABYLON.GUI {
  79507. /**
  79508. * Class used to store key control properties
  79509. */
  79510. export class KeyPropertySet {
  79511. /** Width */
  79512. width?: string;
  79513. /** Height */
  79514. height?: string;
  79515. /** Left padding */
  79516. paddingLeft?: string;
  79517. /** Right padding */
  79518. paddingRight?: string;
  79519. /** Top padding */
  79520. paddingTop?: string;
  79521. /** Bottom padding */
  79522. paddingBottom?: string;
  79523. /** Foreground color */
  79524. color?: string;
  79525. /** Background color */
  79526. background?: string;
  79527. }
  79528. /**
  79529. * Class used to create virtual keyboard
  79530. */
  79531. export class VirtualKeyboard extends StackPanel {
  79532. /** BABYLON.Observable raised when a key is pressed */
  79533. onKeyPressObservable: BABYLON.Observable<string>;
  79534. /** Gets or sets default key button width */
  79535. defaultButtonWidth: string;
  79536. /** Gets or sets default key button height */
  79537. defaultButtonHeight: string;
  79538. /** Gets or sets default key button left padding */
  79539. defaultButtonPaddingLeft: string;
  79540. /** Gets or sets default key button right padding */
  79541. defaultButtonPaddingRight: string;
  79542. /** Gets or sets default key button top padding */
  79543. defaultButtonPaddingTop: string;
  79544. /** Gets or sets default key button bottom padding */
  79545. defaultButtonPaddingBottom: string;
  79546. /** Gets or sets default key button foreground color */
  79547. defaultButtonColor: string;
  79548. /** Gets or sets default key button background color */
  79549. defaultButtonBackground: string;
  79550. /** Gets or sets shift button foreground color */
  79551. shiftButtonColor: string;
  79552. /** Gets or sets shift button thickness*/
  79553. selectedShiftThickness: number;
  79554. /** Gets shift key state */
  79555. shiftState: number;
  79556. protected _getTypeName(): string;
  79557. private _createKey;
  79558. /**
  79559. * Adds a new row of keys
  79560. * @param keys defines the list of keys to add
  79561. * @param propertySets defines the associated property sets
  79562. */
  79563. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79564. /**
  79565. * Set the shift key to a specific state
  79566. * @param shiftState defines the new shift state
  79567. */
  79568. applyShiftState(shiftState: number): void;
  79569. private _currentlyConnectedInputText;
  79570. private _connectedInputTexts;
  79571. private _onKeyPressObserver;
  79572. /** Gets the input text control currently attached to the keyboard */
  79573. get connectedInputText(): BABYLON.Nullable<InputText>;
  79574. /**
  79575. * Connects the keyboard with an input text control
  79576. *
  79577. * @param input defines the target control
  79578. */
  79579. connect(input: InputText): void;
  79580. /**
  79581. * Disconnects the keyboard from connected InputText controls
  79582. *
  79583. * @param input optionally defines a target control, otherwise all are disconnected
  79584. */
  79585. disconnect(input?: InputText): void;
  79586. private _removeConnectedInputObservables;
  79587. /**
  79588. * Release all resources
  79589. */
  79590. dispose(): void;
  79591. /**
  79592. * Creates a new keyboard using a default layout
  79593. *
  79594. * @param name defines control name
  79595. * @returns a new VirtualKeyboard
  79596. */
  79597. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79598. }
  79599. }
  79600. declare module BABYLON.GUI {
  79601. /**
  79602. * Class used to create input text control
  79603. */
  79604. export class InputText extends Control implements IFocusableControl {
  79605. name?: string | undefined;
  79606. private _text;
  79607. private _placeholderText;
  79608. private _background;
  79609. private _focusedBackground;
  79610. private _focusedColor;
  79611. private _placeholderColor;
  79612. private _thickness;
  79613. private _margin;
  79614. private _autoStretchWidth;
  79615. private _maxWidth;
  79616. private _isFocused;
  79617. private _blinkTimeout;
  79618. private _blinkIsEven;
  79619. private _cursorOffset;
  79620. private _scrollLeft;
  79621. private _textWidth;
  79622. private _clickedCoordinate;
  79623. private _deadKey;
  79624. private _addKey;
  79625. private _currentKey;
  79626. private _isTextHighlightOn;
  79627. private _textHighlightColor;
  79628. private _highligherOpacity;
  79629. private _highlightedText;
  79630. private _startHighlightIndex;
  79631. private _endHighlightIndex;
  79632. private _cursorIndex;
  79633. private _onFocusSelectAll;
  79634. private _isPointerDown;
  79635. private _onClipboardObserver;
  79636. private _onPointerDblTapObserver;
  79637. /** @hidden */
  79638. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79639. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79640. promptMessage: string;
  79641. /** Force disable prompt on mobile device */
  79642. disableMobilePrompt: boolean;
  79643. /** BABYLON.Observable raised when the text changes */
  79644. onTextChangedObservable: BABYLON.Observable<InputText>;
  79645. /** BABYLON.Observable raised just before an entered character is to be added */
  79646. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79647. /** BABYLON.Observable raised when the control gets the focus */
  79648. onFocusObservable: BABYLON.Observable<InputText>;
  79649. /** BABYLON.Observable raised when the control loses the focus */
  79650. onBlurObservable: BABYLON.Observable<InputText>;
  79651. /**Observable raised when the text is highlighted */
  79652. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79653. /**Observable raised when copy event is triggered */
  79654. onTextCopyObservable: BABYLON.Observable<InputText>;
  79655. /** BABYLON.Observable raised when cut event is triggered */
  79656. onTextCutObservable: BABYLON.Observable<InputText>;
  79657. /** BABYLON.Observable raised when paste event is triggered */
  79658. onTextPasteObservable: BABYLON.Observable<InputText>;
  79659. /** BABYLON.Observable raised when a key event was processed */
  79660. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79661. /** Gets or sets the maximum width allowed by the control */
  79662. get maxWidth(): string | number;
  79663. /** Gets the maximum width allowed by the control in pixels */
  79664. get maxWidthInPixels(): number;
  79665. set maxWidth(value: string | number);
  79666. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79667. get highligherOpacity(): number;
  79668. set highligherOpacity(value: number);
  79669. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79670. get onFocusSelectAll(): boolean;
  79671. set onFocusSelectAll(value: boolean);
  79672. /** Gets or sets the text hightlight color */
  79673. get textHighlightColor(): string;
  79674. set textHighlightColor(value: string);
  79675. /** Gets or sets control margin */
  79676. get margin(): string;
  79677. /** Gets control margin in pixels */
  79678. get marginInPixels(): number;
  79679. set margin(value: string);
  79680. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79681. get autoStretchWidth(): boolean;
  79682. set autoStretchWidth(value: boolean);
  79683. /** Gets or sets border thickness */
  79684. get thickness(): number;
  79685. set thickness(value: number);
  79686. /** Gets or sets the background color when focused */
  79687. get focusedBackground(): string;
  79688. set focusedBackground(value: string);
  79689. /** Gets or sets the background color when focused */
  79690. get focusedColor(): string;
  79691. set focusedColor(value: string);
  79692. /** Gets or sets the background color */
  79693. get background(): string;
  79694. set background(value: string);
  79695. /** Gets or sets the placeholder color */
  79696. get placeholderColor(): string;
  79697. set placeholderColor(value: string);
  79698. /** Gets or sets the text displayed when the control is empty */
  79699. get placeholderText(): string;
  79700. set placeholderText(value: string);
  79701. /** Gets or sets the dead key flag */
  79702. get deadKey(): boolean;
  79703. set deadKey(flag: boolean);
  79704. /** Gets or sets the highlight text */
  79705. get highlightedText(): string;
  79706. set highlightedText(text: string);
  79707. /** Gets or sets if the current key should be added */
  79708. get addKey(): boolean;
  79709. set addKey(flag: boolean);
  79710. /** Gets or sets the value of the current key being entered */
  79711. get currentKey(): string;
  79712. set currentKey(key: string);
  79713. /** Gets or sets the text displayed in the control */
  79714. get text(): string;
  79715. set text(value: string);
  79716. /** Gets or sets control width */
  79717. get width(): string | number;
  79718. set width(value: string | number);
  79719. /**
  79720. * Creates a new InputText
  79721. * @param name defines the control name
  79722. * @param text defines the text of the control
  79723. */
  79724. constructor(name?: string | undefined, text?: string);
  79725. /** @hidden */
  79726. onBlur(): void;
  79727. /** @hidden */
  79728. onFocus(): void;
  79729. protected _getTypeName(): string;
  79730. /**
  79731. * Function called to get the list of controls that should not steal the focus from this control
  79732. * @returns an array of controls
  79733. */
  79734. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79735. /** @hidden */
  79736. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79737. /** @hidden */
  79738. private _updateValueFromCursorIndex;
  79739. /** @hidden */
  79740. private _processDblClick;
  79741. /** @hidden */
  79742. private _selectAllText;
  79743. /**
  79744. * Handles the keyboard event
  79745. * @param evt Defines the KeyboardEvent
  79746. */
  79747. processKeyboard(evt: KeyboardEvent): void;
  79748. /** @hidden */
  79749. private _onCopyText;
  79750. /** @hidden */
  79751. private _onCutText;
  79752. /** @hidden */
  79753. private _onPasteText;
  79754. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79755. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79756. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79757. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79758. protected _beforeRenderText(text: string): string;
  79759. dispose(): void;
  79760. }
  79761. }
  79762. declare module BABYLON.GUI {
  79763. /**
  79764. * Class used to create a 2D grid container
  79765. */
  79766. export class Grid extends Container {
  79767. name?: string | undefined;
  79768. private _rowDefinitions;
  79769. private _columnDefinitions;
  79770. private _cells;
  79771. private _childControls;
  79772. /**
  79773. * Gets the number of columns
  79774. */
  79775. get columnCount(): number;
  79776. /**
  79777. * Gets the number of rows
  79778. */
  79779. get rowCount(): number;
  79780. /** Gets the list of children */
  79781. get children(): Control[];
  79782. /** Gets the list of cells (e.g. the containers) */
  79783. get cells(): {
  79784. [key: string]: Container;
  79785. };
  79786. /**
  79787. * Gets the definition of a specific row
  79788. * @param index defines the index of the row
  79789. * @returns the row definition
  79790. */
  79791. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79792. /**
  79793. * Gets the definition of a specific column
  79794. * @param index defines the index of the column
  79795. * @returns the column definition
  79796. */
  79797. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79798. /**
  79799. * Adds a new row to the grid
  79800. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79801. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79802. * @returns the current grid
  79803. */
  79804. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79805. /**
  79806. * Adds a new column to the grid
  79807. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79808. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79809. * @returns the current grid
  79810. */
  79811. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79812. /**
  79813. * Update a row definition
  79814. * @param index defines the index of the row to update
  79815. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79816. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79817. * @returns the current grid
  79818. */
  79819. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79820. /**
  79821. * Update a column definition
  79822. * @param index defines the index of the column to update
  79823. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79824. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79825. * @returns the current grid
  79826. */
  79827. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79828. /**
  79829. * Gets the list of children stored in a specific cell
  79830. * @param row defines the row to check
  79831. * @param column defines the column to check
  79832. * @returns the list of controls
  79833. */
  79834. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79835. /**
  79836. * Gets a string representing the child cell info (row x column)
  79837. * @param child defines the control to get info from
  79838. * @returns a string containing the child cell info (row x column)
  79839. */
  79840. getChildCellInfo(child: Control): string;
  79841. private _removeCell;
  79842. private _offsetCell;
  79843. /**
  79844. * Remove a column definition at specified index
  79845. * @param index defines the index of the column to remove
  79846. * @returns the current grid
  79847. */
  79848. removeColumnDefinition(index: number): Grid;
  79849. /**
  79850. * Remove a row definition at specified index
  79851. * @param index defines the index of the row to remove
  79852. * @returns the current grid
  79853. */
  79854. removeRowDefinition(index: number): Grid;
  79855. /**
  79856. * Adds a new control to the current grid
  79857. * @param control defines the control to add
  79858. * @param row defines the row where to add the control (0 by default)
  79859. * @param column defines the column where to add the control (0 by default)
  79860. * @returns the current grid
  79861. */
  79862. addControl(control: Control, row?: number, column?: number): Grid;
  79863. /**
  79864. * Removes a control from the current container
  79865. * @param control defines the control to remove
  79866. * @returns the current container
  79867. */
  79868. removeControl(control: Control): Container;
  79869. /**
  79870. * Creates a new Grid
  79871. * @param name defines control name
  79872. */
  79873. constructor(name?: string | undefined);
  79874. protected _getTypeName(): string;
  79875. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79876. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79877. _flagDescendantsAsMatrixDirty(): void;
  79878. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79879. /** Releases associated resources */
  79880. dispose(): void;
  79881. }
  79882. }
  79883. declare module BABYLON.GUI {
  79884. /** Class used to create color pickers */
  79885. export class ColorPicker extends Control {
  79886. name?: string | undefined;
  79887. private static _Epsilon;
  79888. private _colorWheelCanvas;
  79889. private _value;
  79890. private _tmpColor;
  79891. private _pointerStartedOnSquare;
  79892. private _pointerStartedOnWheel;
  79893. private _squareLeft;
  79894. private _squareTop;
  79895. private _squareSize;
  79896. private _h;
  79897. private _s;
  79898. private _v;
  79899. private _lastPointerDownID;
  79900. /**
  79901. * BABYLON.Observable raised when the value changes
  79902. */
  79903. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79904. /** Gets or sets the color of the color picker */
  79905. get value(): BABYLON.Color3;
  79906. set value(value: BABYLON.Color3);
  79907. /**
  79908. * Gets or sets control width
  79909. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79910. */
  79911. get width(): string | number;
  79912. set width(value: string | number);
  79913. /**
  79914. * Gets or sets control height
  79915. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79916. */
  79917. get height(): string | number;
  79918. /** Gets or sets control height */
  79919. set height(value: string | number);
  79920. /** Gets or sets control size */
  79921. get size(): string | number;
  79922. set size(value: string | number);
  79923. /**
  79924. * Creates a new ColorPicker
  79925. * @param name defines the control name
  79926. */
  79927. constructor(name?: string | undefined);
  79928. protected _getTypeName(): string;
  79929. /** @hidden */
  79930. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79931. private _updateSquareProps;
  79932. private _drawGradientSquare;
  79933. private _drawCircle;
  79934. private _createColorWheelCanvas;
  79935. /** @hidden */
  79936. _draw(context: CanvasRenderingContext2D): void;
  79937. private _pointerIsDown;
  79938. private _updateValueFromPointer;
  79939. private _isPointOnSquare;
  79940. private _isPointOnWheel;
  79941. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79942. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79943. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79944. _onCanvasBlur(): void;
  79945. /**
  79946. * This function expands the color picker by creating a color picker dialog with manual
  79947. * color value input and the ability to save colors into an array to be used later in
  79948. * subsequent launches of the dialogue.
  79949. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79950. * @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.
  79951. * @returns picked color as a hex string and the saved colors array as hex strings.
  79952. */
  79953. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79954. pickerWidth?: string;
  79955. pickerHeight?: string;
  79956. headerHeight?: string;
  79957. lastColor?: string;
  79958. swatchLimit?: number;
  79959. numSwatchesPerLine?: number;
  79960. savedColors?: Array<string>;
  79961. }): Promise<{
  79962. savedColors?: string[];
  79963. pickedColor: string;
  79964. }>;
  79965. }
  79966. }
  79967. declare module BABYLON.GUI {
  79968. /** Class used to create 2D ellipse containers */
  79969. export class Ellipse extends Container {
  79970. name?: string | undefined;
  79971. private _thickness;
  79972. /** Gets or sets border thickness */
  79973. get thickness(): number;
  79974. set thickness(value: number);
  79975. /**
  79976. * Creates a new Ellipse
  79977. * @param name defines the control name
  79978. */
  79979. constructor(name?: string | undefined);
  79980. protected _getTypeName(): string;
  79981. protected _localDraw(context: CanvasRenderingContext2D): void;
  79982. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79983. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79984. }
  79985. }
  79986. declare module BABYLON.GUI {
  79987. /**
  79988. * Class used to create a password control
  79989. */
  79990. export class InputPassword extends InputText {
  79991. protected _beforeRenderText(text: string): string;
  79992. }
  79993. }
  79994. declare module BABYLON.GUI {
  79995. /** Class used to render 2D lines */
  79996. export class Line extends Control {
  79997. name?: string | undefined;
  79998. private _lineWidth;
  79999. private _x1;
  80000. private _y1;
  80001. private _x2;
  80002. private _y2;
  80003. private _dash;
  80004. private _connectedControl;
  80005. private _connectedControlDirtyObserver;
  80006. /** Gets or sets the dash pattern */
  80007. get dash(): Array<number>;
  80008. set dash(value: Array<number>);
  80009. /** Gets or sets the control connected with the line end */
  80010. get connectedControl(): Control;
  80011. set connectedControl(value: Control);
  80012. /** Gets or sets start coordinates on X axis */
  80013. get x1(): string | number;
  80014. set x1(value: string | number);
  80015. /** Gets or sets start coordinates on Y axis */
  80016. get y1(): string | number;
  80017. set y1(value: string | number);
  80018. /** Gets or sets end coordinates on X axis */
  80019. get x2(): string | number;
  80020. set x2(value: string | number);
  80021. /** Gets or sets end coordinates on Y axis */
  80022. get y2(): string | number;
  80023. set y2(value: string | number);
  80024. /** Gets or sets line width */
  80025. get lineWidth(): number;
  80026. set lineWidth(value: number);
  80027. /** Gets or sets horizontal alignment */
  80028. set horizontalAlignment(value: number);
  80029. /** Gets or sets vertical alignment */
  80030. set verticalAlignment(value: number);
  80031. private get _effectiveX2();
  80032. private get _effectiveY2();
  80033. /**
  80034. * Creates a new Line
  80035. * @param name defines the control name
  80036. */
  80037. constructor(name?: string | undefined);
  80038. protected _getTypeName(): string;
  80039. _draw(context: CanvasRenderingContext2D): void;
  80040. _measure(): void;
  80041. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80042. /**
  80043. * Move one end of the line given 3D cartesian coordinates.
  80044. * @param position Targeted world position
  80045. * @param scene BABYLON.Scene
  80046. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80047. */
  80048. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80049. /**
  80050. * Move one end of the line to a position in screen absolute space.
  80051. * @param projectedPosition Position in screen absolute space (X, Y)
  80052. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80053. */
  80054. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80055. }
  80056. }
  80057. declare module BABYLON.GUI {
  80058. /**
  80059. * Class used to store a point for a MultiLine object.
  80060. * The point can be pure 2D coordinates, a mesh or a control
  80061. */
  80062. export class MultiLinePoint {
  80063. private _multiLine;
  80064. private _x;
  80065. private _y;
  80066. private _control;
  80067. private _mesh;
  80068. private _controlObserver;
  80069. private _meshObserver;
  80070. /** @hidden */
  80071. _point: BABYLON.Vector2;
  80072. /**
  80073. * Creates a new MultiLinePoint
  80074. * @param multiLine defines the source MultiLine object
  80075. */
  80076. constructor(multiLine: MultiLine);
  80077. /** Gets or sets x coordinate */
  80078. get x(): string | number;
  80079. set x(value: string | number);
  80080. /** Gets or sets y coordinate */
  80081. get y(): string | number;
  80082. set y(value: string | number);
  80083. /** Gets or sets the control associated with this point */
  80084. get control(): BABYLON.Nullable<Control>;
  80085. set control(value: BABYLON.Nullable<Control>);
  80086. /** Gets or sets the mesh associated with this point */
  80087. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80088. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80089. /** Resets links */
  80090. resetLinks(): void;
  80091. /**
  80092. * Gets a translation vector
  80093. * @returns the translation vector
  80094. */
  80095. translate(): BABYLON.Vector2;
  80096. private _translatePoint;
  80097. /** Release associated resources */
  80098. dispose(): void;
  80099. }
  80100. }
  80101. declare module BABYLON.GUI {
  80102. /**
  80103. * Class used to create multi line control
  80104. */
  80105. export class MultiLine extends Control {
  80106. name?: string | undefined;
  80107. private _lineWidth;
  80108. private _dash;
  80109. private _points;
  80110. private _minX;
  80111. private _minY;
  80112. private _maxX;
  80113. private _maxY;
  80114. /**
  80115. * Creates a new MultiLine
  80116. * @param name defines the control name
  80117. */
  80118. constructor(name?: string | undefined);
  80119. /** Gets or sets dash pattern */
  80120. get dash(): Array<number>;
  80121. set dash(value: Array<number>);
  80122. /**
  80123. * Gets point stored at specified index
  80124. * @param index defines the index to look for
  80125. * @returns the requested point if found
  80126. */
  80127. getAt(index: number): MultiLinePoint;
  80128. /** Function called when a point is updated */
  80129. onPointUpdate: () => void;
  80130. /**
  80131. * Adds new points to the point collection
  80132. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80133. * @returns the list of created MultiLinePoint
  80134. */
  80135. add(...items: (AbstractMesh | Control | {
  80136. x: string | number;
  80137. y: string | number;
  80138. })[]): MultiLinePoint[];
  80139. /**
  80140. * Adds a new point to the point collection
  80141. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80142. * @returns the created MultiLinePoint
  80143. */
  80144. push(item?: (AbstractMesh | Control | {
  80145. x: string | number;
  80146. y: string | number;
  80147. })): MultiLinePoint;
  80148. /**
  80149. * Remove a specific value or point from the active point collection
  80150. * @param value defines the value or point to remove
  80151. */
  80152. remove(value: number | MultiLinePoint): void;
  80153. /**
  80154. * Resets this object to initial state (no point)
  80155. */
  80156. reset(): void;
  80157. /**
  80158. * Resets all links
  80159. */
  80160. resetLinks(): void;
  80161. /** Gets or sets line width */
  80162. get lineWidth(): number;
  80163. set lineWidth(value: number);
  80164. set horizontalAlignment(value: number);
  80165. set verticalAlignment(value: number);
  80166. protected _getTypeName(): string;
  80167. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80168. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80169. _measure(): void;
  80170. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80171. dispose(): void;
  80172. }
  80173. }
  80174. declare module BABYLON.GUI {
  80175. /**
  80176. * Class used to create radio button controls
  80177. */
  80178. export class RadioButton extends Control {
  80179. name?: string | undefined;
  80180. private _isChecked;
  80181. private _background;
  80182. private _checkSizeRatio;
  80183. private _thickness;
  80184. /** Gets or sets border thickness */
  80185. get thickness(): number;
  80186. set thickness(value: number);
  80187. /** Gets or sets group name */
  80188. group: string;
  80189. /** BABYLON.Observable raised when isChecked is changed */
  80190. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80191. /** Gets or sets a value indicating the ratio between overall size and check size */
  80192. get checkSizeRatio(): number;
  80193. set checkSizeRatio(value: number);
  80194. /** Gets or sets background color */
  80195. get background(): string;
  80196. set background(value: string);
  80197. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80198. get isChecked(): boolean;
  80199. set isChecked(value: boolean);
  80200. /**
  80201. * Creates a new RadioButton
  80202. * @param name defines the control name
  80203. */
  80204. constructor(name?: string | undefined);
  80205. protected _getTypeName(): string;
  80206. _draw(context: CanvasRenderingContext2D): void;
  80207. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80208. /**
  80209. * Utility function to easily create a radio button with a header
  80210. * @param title defines the label to use for the header
  80211. * @param group defines the group to use for the radio button
  80212. * @param isChecked defines the initial state of the radio button
  80213. * @param onValueChanged defines the callback to call when value changes
  80214. * @returns a StackPanel containing the radio button and a textBlock
  80215. */
  80216. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80217. }
  80218. }
  80219. declare module BABYLON.GUI {
  80220. /**
  80221. * Class used to create slider controls
  80222. */
  80223. export class BaseSlider extends Control {
  80224. name?: string | undefined;
  80225. protected _thumbWidth: ValueAndUnit;
  80226. private _minimum;
  80227. private _maximum;
  80228. private _value;
  80229. private _isVertical;
  80230. protected _barOffset: ValueAndUnit;
  80231. private _isThumbClamped;
  80232. protected _displayThumb: boolean;
  80233. private _step;
  80234. private _lastPointerDownID;
  80235. protected _effectiveBarOffset: number;
  80236. protected _renderLeft: number;
  80237. protected _renderTop: number;
  80238. protected _renderWidth: number;
  80239. protected _renderHeight: number;
  80240. protected _backgroundBoxLength: number;
  80241. protected _backgroundBoxThickness: number;
  80242. protected _effectiveThumbThickness: number;
  80243. /** BABYLON.Observable raised when the sldier value changes */
  80244. onValueChangedObservable: BABYLON.Observable<number>;
  80245. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80246. get displayThumb(): boolean;
  80247. set displayThumb(value: boolean);
  80248. /** Gets or sets a step to apply to values (0 by default) */
  80249. get step(): number;
  80250. set step(value: number);
  80251. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80252. get barOffset(): string | number;
  80253. /** Gets main bar offset in pixels*/
  80254. get barOffsetInPixels(): number;
  80255. set barOffset(value: string | number);
  80256. /** Gets or sets thumb width */
  80257. get thumbWidth(): string | number;
  80258. /** Gets thumb width in pixels */
  80259. get thumbWidthInPixels(): number;
  80260. set thumbWidth(value: string | number);
  80261. /** Gets or sets minimum value */
  80262. get minimum(): number;
  80263. set minimum(value: number);
  80264. /** Gets or sets maximum value */
  80265. get maximum(): number;
  80266. set maximum(value: number);
  80267. /** Gets or sets current value */
  80268. get value(): number;
  80269. set value(value: number);
  80270. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80271. get isVertical(): boolean;
  80272. set isVertical(value: boolean);
  80273. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80274. get isThumbClamped(): boolean;
  80275. set isThumbClamped(value: boolean);
  80276. /**
  80277. * Creates a new BaseSlider
  80278. * @param name defines the control name
  80279. */
  80280. constructor(name?: string | undefined);
  80281. protected _getTypeName(): string;
  80282. protected _getThumbPosition(): number;
  80283. protected _getThumbThickness(type: string): number;
  80284. protected _prepareRenderingData(type: string): void;
  80285. private _pointerIsDown;
  80286. /** @hidden */
  80287. protected _updateValueFromPointer(x: number, y: number): void;
  80288. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80289. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80290. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80291. _onCanvasBlur(): void;
  80292. }
  80293. }
  80294. declare module BABYLON.GUI {
  80295. /**
  80296. * Class used to create slider controls
  80297. */
  80298. export class Slider extends BaseSlider {
  80299. name?: string | undefined;
  80300. private _background;
  80301. private _borderColor;
  80302. private _thumbColor;
  80303. private _isThumbCircle;
  80304. protected _displayValueBar: boolean;
  80305. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80306. get displayValueBar(): boolean;
  80307. set displayValueBar(value: boolean);
  80308. /** Gets or sets border color */
  80309. get borderColor(): string;
  80310. set borderColor(value: string);
  80311. /** Gets or sets background color */
  80312. get background(): string;
  80313. set background(value: string);
  80314. /** Gets or sets thumb's color */
  80315. get thumbColor(): string;
  80316. set thumbColor(value: string);
  80317. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80318. get isThumbCircle(): boolean;
  80319. set isThumbCircle(value: boolean);
  80320. /**
  80321. * Creates a new Slider
  80322. * @param name defines the control name
  80323. */
  80324. constructor(name?: string | undefined);
  80325. protected _getTypeName(): string;
  80326. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80327. }
  80328. }
  80329. declare module BABYLON.GUI {
  80330. /** Class used to create a RadioGroup
  80331. * which contains groups of radio buttons
  80332. */
  80333. export class SelectorGroup {
  80334. /** name of SelectorGroup */
  80335. name: string;
  80336. private _groupPanel;
  80337. private _selectors;
  80338. private _groupHeader;
  80339. /**
  80340. * Creates a new SelectorGroup
  80341. * @param name of group, used as a group heading
  80342. */
  80343. constructor(
  80344. /** name of SelectorGroup */
  80345. name: string);
  80346. /** Gets the groupPanel of the SelectorGroup */
  80347. get groupPanel(): StackPanel;
  80348. /** Gets the selectors array */
  80349. get selectors(): StackPanel[];
  80350. /** Gets and sets the group header */
  80351. get header(): string;
  80352. set header(label: string);
  80353. /** @hidden */
  80354. private _addGroupHeader;
  80355. /** @hidden*/
  80356. _getSelector(selectorNb: number): StackPanel | undefined;
  80357. /** Removes the selector at the given position
  80358. * @param selectorNb the position of the selector within the group
  80359. */
  80360. removeSelector(selectorNb: number): void;
  80361. }
  80362. /** Class used to create a CheckboxGroup
  80363. * which contains groups of checkbox buttons
  80364. */
  80365. export class CheckboxGroup extends SelectorGroup {
  80366. /** Adds a checkbox as a control
  80367. * @param text is the label for the selector
  80368. * @param func is the function called when the Selector is checked
  80369. * @param checked is true when Selector is checked
  80370. */
  80371. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80372. /** @hidden */
  80373. _setSelectorLabel(selectorNb: number, label: string): void;
  80374. /** @hidden */
  80375. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80376. /** @hidden */
  80377. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80378. /** @hidden */
  80379. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80380. }
  80381. /** Class used to create a RadioGroup
  80382. * which contains groups of radio buttons
  80383. */
  80384. export class RadioGroup extends SelectorGroup {
  80385. private _selectNb;
  80386. /** Adds a radio button as a control
  80387. * @param label is the label for the selector
  80388. * @param func is the function called when the Selector is checked
  80389. * @param checked is true when Selector is checked
  80390. */
  80391. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80392. /** @hidden */
  80393. _setSelectorLabel(selectorNb: number, label: string): void;
  80394. /** @hidden */
  80395. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80396. /** @hidden */
  80397. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80398. /** @hidden */
  80399. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80400. }
  80401. /** Class used to create a SliderGroup
  80402. * which contains groups of slider buttons
  80403. */
  80404. export class SliderGroup extends SelectorGroup {
  80405. /**
  80406. * Adds a slider to the SelectorGroup
  80407. * @param label is the label for the SliderBar
  80408. * @param func is the function called when the Slider moves
  80409. * @param unit is a string describing the units used, eg degrees or metres
  80410. * @param min is the minimum value for the Slider
  80411. * @param max is the maximum value for the Slider
  80412. * @param value is the start value for the Slider between min and max
  80413. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80414. */
  80415. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80416. /** @hidden */
  80417. _setSelectorLabel(selectorNb: number, label: string): void;
  80418. /** @hidden */
  80419. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80420. /** @hidden */
  80421. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80422. /** @hidden */
  80423. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80424. }
  80425. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80426. * @see https://doc.babylonjs.com/how_to/selector
  80427. */
  80428. export class SelectionPanel extends Rectangle {
  80429. /** name of SelectionPanel */
  80430. name: string;
  80431. /** an array of SelectionGroups */
  80432. groups: SelectorGroup[];
  80433. private _panel;
  80434. private _buttonColor;
  80435. private _buttonBackground;
  80436. private _headerColor;
  80437. private _barColor;
  80438. private _barHeight;
  80439. private _spacerHeight;
  80440. private _labelColor;
  80441. private _groups;
  80442. private _bars;
  80443. /**
  80444. * Creates a new SelectionPanel
  80445. * @param name of SelectionPanel
  80446. * @param groups is an array of SelectionGroups
  80447. */
  80448. constructor(
  80449. /** name of SelectionPanel */
  80450. name: string,
  80451. /** an array of SelectionGroups */
  80452. groups?: SelectorGroup[]);
  80453. protected _getTypeName(): string;
  80454. /** Gets the (stack) panel of the SelectionPanel */
  80455. get panel(): StackPanel;
  80456. /** Gets or sets the headerColor */
  80457. get headerColor(): string;
  80458. set headerColor(color: string);
  80459. private _setHeaderColor;
  80460. /** Gets or sets the button color */
  80461. get buttonColor(): string;
  80462. set buttonColor(color: string);
  80463. private _setbuttonColor;
  80464. /** Gets or sets the label color */
  80465. get labelColor(): string;
  80466. set labelColor(color: string);
  80467. private _setLabelColor;
  80468. /** Gets or sets the button background */
  80469. get buttonBackground(): string;
  80470. set buttonBackground(color: string);
  80471. private _setButtonBackground;
  80472. /** Gets or sets the color of separator bar */
  80473. get barColor(): string;
  80474. set barColor(color: string);
  80475. private _setBarColor;
  80476. /** Gets or sets the height of separator bar */
  80477. get barHeight(): string;
  80478. set barHeight(value: string);
  80479. private _setBarHeight;
  80480. /** Gets or sets the height of spacers*/
  80481. get spacerHeight(): string;
  80482. set spacerHeight(value: string);
  80483. private _setSpacerHeight;
  80484. /** Adds a bar between groups */
  80485. private _addSpacer;
  80486. /** Add a group to the selection panel
  80487. * @param group is the selector group to add
  80488. */
  80489. addGroup(group: SelectorGroup): void;
  80490. /** Remove the group from the given position
  80491. * @param groupNb is the position of the group in the list
  80492. */
  80493. removeGroup(groupNb: number): void;
  80494. /** Change a group header label
  80495. * @param label is the new group header label
  80496. * @param groupNb is the number of the group to relabel
  80497. * */
  80498. setHeaderName(label: string, groupNb: number): void;
  80499. /** Change selector label to the one given
  80500. * @param label is the new selector label
  80501. * @param groupNb is the number of the groupcontaining the selector
  80502. * @param selectorNb is the number of the selector within a group to relabel
  80503. * */
  80504. relabel(label: string, groupNb: number, selectorNb: number): void;
  80505. /** For a given group position remove the selector at the given position
  80506. * @param groupNb is the number of the group to remove the selector from
  80507. * @param selectorNb is the number of the selector within the group
  80508. */
  80509. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80510. /** For a given group position of correct type add a checkbox button
  80511. * @param groupNb is the number of the group to remove the selector from
  80512. * @param label is the label for the selector
  80513. * @param func is the function called when the Selector is checked
  80514. * @param checked is true when Selector is checked
  80515. */
  80516. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80517. /** For a given group position of correct type add a radio button
  80518. * @param groupNb is the number of the group to remove the selector from
  80519. * @param label is the label for the selector
  80520. * @param func is the function called when the Selector is checked
  80521. * @param checked is true when Selector is checked
  80522. */
  80523. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80524. /**
  80525. * For a given slider group add a slider
  80526. * @param groupNb is the number of the group to add the slider to
  80527. * @param label is the label for the Slider
  80528. * @param func is the function called when the Slider moves
  80529. * @param unit is a string describing the units used, eg degrees or metres
  80530. * @param min is the minimum value for the Slider
  80531. * @param max is the maximum value for the Slider
  80532. * @param value is the start value for the Slider between min and max
  80533. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80534. */
  80535. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80536. }
  80537. }
  80538. declare module BABYLON.GUI {
  80539. /**
  80540. * Class used to hold a the container for ScrollViewer
  80541. * @hidden
  80542. */
  80543. export class _ScrollViewerWindow extends Container {
  80544. parentClientWidth: number;
  80545. parentClientHeight: number;
  80546. private _freezeControls;
  80547. private _parentMeasure;
  80548. private _oldLeft;
  80549. private _oldTop;
  80550. get freezeControls(): boolean;
  80551. set freezeControls(value: boolean);
  80552. private _bucketWidth;
  80553. private _bucketHeight;
  80554. private _buckets;
  80555. private _bucketLen;
  80556. get bucketWidth(): number;
  80557. get bucketHeight(): number;
  80558. setBucketSizes(width: number, height: number): void;
  80559. private _useBuckets;
  80560. private _makeBuckets;
  80561. private _dispatchInBuckets;
  80562. private _updateMeasures;
  80563. private _updateChildrenMeasures;
  80564. private _restoreMeasures;
  80565. /**
  80566. * Creates a new ScrollViewerWindow
  80567. * @param name of ScrollViewerWindow
  80568. */
  80569. constructor(name?: string);
  80570. protected _getTypeName(): string;
  80571. /** @hidden */
  80572. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80573. /** @hidden */
  80574. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80575. private _scrollChildren;
  80576. private _scrollChildrenWithBuckets;
  80577. /** @hidden */
  80578. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80579. protected _postMeasure(): void;
  80580. }
  80581. }
  80582. declare module BABYLON.GUI {
  80583. /**
  80584. * Class used to create slider controls
  80585. */
  80586. export class ScrollBar extends BaseSlider {
  80587. name?: string | undefined;
  80588. private _background;
  80589. private _borderColor;
  80590. private _tempMeasure;
  80591. /** Gets or sets border color */
  80592. get borderColor(): string;
  80593. set borderColor(value: string);
  80594. /** Gets or sets background color */
  80595. get background(): string;
  80596. set background(value: string);
  80597. /**
  80598. * Creates a new Slider
  80599. * @param name defines the control name
  80600. */
  80601. constructor(name?: string | undefined);
  80602. protected _getTypeName(): string;
  80603. protected _getThumbThickness(): number;
  80604. _draw(context: CanvasRenderingContext2D): void;
  80605. private _first;
  80606. private _originX;
  80607. private _originY;
  80608. /** @hidden */
  80609. protected _updateValueFromPointer(x: number, y: number): void;
  80610. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80611. }
  80612. }
  80613. declare module BABYLON.GUI {
  80614. /**
  80615. * Class used to create slider controls
  80616. */
  80617. export class ImageScrollBar extends BaseSlider {
  80618. name?: string | undefined;
  80619. private _backgroundBaseImage;
  80620. private _backgroundImage;
  80621. private _thumbImage;
  80622. private _thumbBaseImage;
  80623. private _thumbLength;
  80624. private _thumbHeight;
  80625. private _barImageHeight;
  80626. private _tempMeasure;
  80627. /** Number of 90° rotation to apply on the images when in vertical mode */
  80628. num90RotationInVerticalMode: number;
  80629. /**
  80630. * Gets or sets the image used to render the background for horizontal bar
  80631. */
  80632. get backgroundImage(): Image;
  80633. set backgroundImage(value: Image);
  80634. /**
  80635. * Gets or sets the image used to render the thumb
  80636. */
  80637. get thumbImage(): Image;
  80638. set thumbImage(value: Image);
  80639. /**
  80640. * Gets or sets the length of the thumb
  80641. */
  80642. get thumbLength(): number;
  80643. set thumbLength(value: number);
  80644. /**
  80645. * Gets or sets the height of the thumb
  80646. */
  80647. get thumbHeight(): number;
  80648. set thumbHeight(value: number);
  80649. /**
  80650. * Gets or sets the height of the bar image
  80651. */
  80652. get barImageHeight(): number;
  80653. set barImageHeight(value: number);
  80654. /**
  80655. * Creates a new ImageScrollBar
  80656. * @param name defines the control name
  80657. */
  80658. constructor(name?: string | undefined);
  80659. protected _getTypeName(): string;
  80660. protected _getThumbThickness(): number;
  80661. _draw(context: CanvasRenderingContext2D): void;
  80662. private _first;
  80663. private _originX;
  80664. private _originY;
  80665. /** @hidden */
  80666. protected _updateValueFromPointer(x: number, y: number): void;
  80667. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80668. }
  80669. }
  80670. declare module BABYLON.GUI {
  80671. /**
  80672. * Class used to hold a viewer window and sliders in a grid
  80673. */
  80674. export class ScrollViewer extends Rectangle {
  80675. private _grid;
  80676. private _horizontalBarSpace;
  80677. private _verticalBarSpace;
  80678. private _dragSpace;
  80679. private _horizontalBar;
  80680. private _verticalBar;
  80681. private _barColor;
  80682. private _barBackground;
  80683. private _barImage;
  80684. private _horizontalBarImage;
  80685. private _verticalBarImage;
  80686. private _barBackgroundImage;
  80687. private _horizontalBarBackgroundImage;
  80688. private _verticalBarBackgroundImage;
  80689. private _barSize;
  80690. private _window;
  80691. private _pointerIsOver;
  80692. private _wheelPrecision;
  80693. private _onWheelObserver;
  80694. private _clientWidth;
  80695. private _clientHeight;
  80696. private _useImageBar;
  80697. private _thumbLength;
  80698. private _thumbHeight;
  80699. private _barImageHeight;
  80700. private _horizontalBarImageHeight;
  80701. private _verticalBarImageHeight;
  80702. private _oldWindowContentsWidth;
  80703. private _oldWindowContentsHeight;
  80704. /**
  80705. * Gets the horizontal scrollbar
  80706. */
  80707. get horizontalBar(): ScrollBar | ImageScrollBar;
  80708. /**
  80709. * Gets the vertical scrollbar
  80710. */
  80711. get verticalBar(): ScrollBar | ImageScrollBar;
  80712. /**
  80713. * Adds a new control to the current container
  80714. * @param control defines the control to add
  80715. * @returns the current container
  80716. */
  80717. addControl(control: BABYLON.Nullable<Control>): Container;
  80718. /**
  80719. * Removes a control from the current container
  80720. * @param control defines the control to remove
  80721. * @returns the current container
  80722. */
  80723. removeControl(control: Control): Container;
  80724. /** Gets the list of children */
  80725. get children(): Control[];
  80726. _flagDescendantsAsMatrixDirty(): void;
  80727. /**
  80728. * Freezes or unfreezes the controls in the window.
  80729. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80730. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80731. */
  80732. get freezeControls(): boolean;
  80733. set freezeControls(value: boolean);
  80734. /** Gets the bucket width */
  80735. get bucketWidth(): number;
  80736. /** Gets the bucket height */
  80737. get bucketHeight(): number;
  80738. /**
  80739. * Sets the bucket sizes.
  80740. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80741. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80742. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80743. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80744. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80745. * used), that's why it is not enabled by default.
  80746. * @param width width of the bucket
  80747. * @param height height of the bucket
  80748. */
  80749. setBucketSizes(width: number, height: number): void;
  80750. private _forceHorizontalBar;
  80751. private _forceVerticalBar;
  80752. /**
  80753. * Forces the horizontal scroll bar to be displayed
  80754. */
  80755. get forceHorizontalBar(): boolean;
  80756. set forceHorizontalBar(value: boolean);
  80757. /**
  80758. * Forces the vertical scroll bar to be displayed
  80759. */
  80760. get forceVerticalBar(): boolean;
  80761. set forceVerticalBar(value: boolean);
  80762. /**
  80763. * Creates a new ScrollViewer
  80764. * @param name of ScrollViewer
  80765. */
  80766. constructor(name?: string, isImageBased?: boolean);
  80767. /** Reset the scroll viewer window to initial size */
  80768. resetWindow(): void;
  80769. protected _getTypeName(): string;
  80770. private _buildClientSizes;
  80771. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80772. protected _postMeasure(): void;
  80773. /**
  80774. * Gets or sets the mouse wheel precision
  80775. * from 0 to 1 with a default value of 0.05
  80776. * */
  80777. get wheelPrecision(): number;
  80778. set wheelPrecision(value: number);
  80779. /** Gets or sets the scroll bar container background color */
  80780. get scrollBackground(): string;
  80781. set scrollBackground(color: string);
  80782. /** Gets or sets the bar color */
  80783. get barColor(): string;
  80784. set barColor(color: string);
  80785. /** Gets or sets the bar image */
  80786. get thumbImage(): Image;
  80787. set thumbImage(value: Image);
  80788. /** Gets or sets the horizontal bar image */
  80789. get horizontalThumbImage(): Image;
  80790. set horizontalThumbImage(value: Image);
  80791. /** Gets or sets the vertical bar image */
  80792. get verticalThumbImage(): Image;
  80793. set verticalThumbImage(value: Image);
  80794. /** Gets or sets the size of the bar */
  80795. get barSize(): number;
  80796. set barSize(value: number);
  80797. /** Gets or sets the length of the thumb */
  80798. get thumbLength(): number;
  80799. set thumbLength(value: number);
  80800. /** Gets or sets the height of the thumb */
  80801. get thumbHeight(): number;
  80802. set thumbHeight(value: number);
  80803. /** Gets or sets the height of the bar image */
  80804. get barImageHeight(): number;
  80805. set barImageHeight(value: number);
  80806. /** Gets or sets the height of the horizontal bar image */
  80807. get horizontalBarImageHeight(): number;
  80808. set horizontalBarImageHeight(value: number);
  80809. /** Gets or sets the height of the vertical bar image */
  80810. get verticalBarImageHeight(): number;
  80811. set verticalBarImageHeight(value: number);
  80812. /** Gets or sets the bar background */
  80813. get barBackground(): string;
  80814. set barBackground(color: string);
  80815. /** Gets or sets the bar background image */
  80816. get barImage(): Image;
  80817. set barImage(value: Image);
  80818. /** Gets or sets the horizontal bar background image */
  80819. get horizontalBarImage(): Image;
  80820. set horizontalBarImage(value: Image);
  80821. /** Gets or sets the vertical bar background image */
  80822. get verticalBarImage(): Image;
  80823. set verticalBarImage(value: Image);
  80824. private _setWindowPosition;
  80825. /** @hidden */
  80826. private _updateScroller;
  80827. _link(host: AdvancedDynamicTexture): void;
  80828. /** @hidden */
  80829. private _addBar;
  80830. /** @hidden */
  80831. private _attachWheel;
  80832. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80833. /** Releases associated resources */
  80834. dispose(): void;
  80835. }
  80836. }
  80837. declare module BABYLON.GUI {
  80838. /** Class used to render a grid */
  80839. export class DisplayGrid extends Control {
  80840. name?: string | undefined;
  80841. private _cellWidth;
  80842. private _cellHeight;
  80843. private _minorLineTickness;
  80844. private _minorLineColor;
  80845. private _majorLineTickness;
  80846. private _majorLineColor;
  80847. private _majorLineFrequency;
  80848. private _background;
  80849. private _displayMajorLines;
  80850. private _displayMinorLines;
  80851. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80852. get displayMinorLines(): boolean;
  80853. set displayMinorLines(value: boolean);
  80854. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80855. get displayMajorLines(): boolean;
  80856. set displayMajorLines(value: boolean);
  80857. /** Gets or sets background color (Black by default) */
  80858. get background(): string;
  80859. set background(value: string);
  80860. /** Gets or sets the width of each cell (20 by default) */
  80861. get cellWidth(): number;
  80862. set cellWidth(value: number);
  80863. /** Gets or sets the height of each cell (20 by default) */
  80864. get cellHeight(): number;
  80865. set cellHeight(value: number);
  80866. /** Gets or sets the tickness of minor lines (1 by default) */
  80867. get minorLineTickness(): number;
  80868. set minorLineTickness(value: number);
  80869. /** Gets or sets the color of minor lines (DarkGray by default) */
  80870. get minorLineColor(): string;
  80871. set minorLineColor(value: string);
  80872. /** Gets or sets the tickness of major lines (2 by default) */
  80873. get majorLineTickness(): number;
  80874. set majorLineTickness(value: number);
  80875. /** Gets or sets the color of major lines (White by default) */
  80876. get majorLineColor(): string;
  80877. set majorLineColor(value: string);
  80878. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80879. get majorLineFrequency(): number;
  80880. set majorLineFrequency(value: number);
  80881. /**
  80882. * Creates a new GridDisplayRectangle
  80883. * @param name defines the control name
  80884. */
  80885. constructor(name?: string | undefined);
  80886. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80887. protected _getTypeName(): string;
  80888. }
  80889. }
  80890. declare module BABYLON.GUI {
  80891. /**
  80892. * Class used to create slider controls based on images
  80893. */
  80894. export class ImageBasedSlider extends BaseSlider {
  80895. name?: string | undefined;
  80896. private _backgroundImage;
  80897. private _thumbImage;
  80898. private _valueBarImage;
  80899. private _tempMeasure;
  80900. get displayThumb(): boolean;
  80901. set displayThumb(value: boolean);
  80902. /**
  80903. * Gets or sets the image used to render the background
  80904. */
  80905. get backgroundImage(): Image;
  80906. set backgroundImage(value: Image);
  80907. /**
  80908. * Gets or sets the image used to render the value bar
  80909. */
  80910. get valueBarImage(): Image;
  80911. set valueBarImage(value: Image);
  80912. /**
  80913. * Gets or sets the image used to render the thumb
  80914. */
  80915. get thumbImage(): Image;
  80916. set thumbImage(value: Image);
  80917. /**
  80918. * Creates a new ImageBasedSlider
  80919. * @param name defines the control name
  80920. */
  80921. constructor(name?: string | undefined);
  80922. protected _getTypeName(): string;
  80923. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80924. }
  80925. }
  80926. declare module BABYLON.GUI {
  80927. /**
  80928. * Forcing an export so that this code will execute
  80929. * @hidden
  80930. */
  80931. const name = "Statics";
  80932. }
  80933. declare module BABYLON.GUI {
  80934. /**
  80935. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80936. */
  80937. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80938. /**
  80939. * Define the instrumented AdvancedDynamicTexture.
  80940. */
  80941. texture: AdvancedDynamicTexture;
  80942. private _captureRenderTime;
  80943. private _renderTime;
  80944. private _captureLayoutTime;
  80945. private _layoutTime;
  80946. private _onBeginRenderObserver;
  80947. private _onEndRenderObserver;
  80948. private _onBeginLayoutObserver;
  80949. private _onEndLayoutObserver;
  80950. /**
  80951. * Gets the perf counter used to capture render time
  80952. */
  80953. get renderTimeCounter(): BABYLON.PerfCounter;
  80954. /**
  80955. * Gets the perf counter used to capture layout time
  80956. */
  80957. get layoutTimeCounter(): BABYLON.PerfCounter;
  80958. /**
  80959. * Enable or disable the render time capture
  80960. */
  80961. get captureRenderTime(): boolean;
  80962. set captureRenderTime(value: boolean);
  80963. /**
  80964. * Enable or disable the layout time capture
  80965. */
  80966. get captureLayoutTime(): boolean;
  80967. set captureLayoutTime(value: boolean);
  80968. /**
  80969. * Instantiates a new advanced dynamic texture instrumentation.
  80970. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80971. * @param texture Defines the AdvancedDynamicTexture to instrument
  80972. */
  80973. constructor(
  80974. /**
  80975. * Define the instrumented AdvancedDynamicTexture.
  80976. */
  80977. texture: AdvancedDynamicTexture);
  80978. /**
  80979. * Dispose and release associated resources.
  80980. */
  80981. dispose(): void;
  80982. }
  80983. }
  80984. declare module BABYLON.GUI {
  80985. /**
  80986. * Class used to load GUI via XML.
  80987. */
  80988. export class XmlLoader {
  80989. private _nodes;
  80990. private _nodeTypes;
  80991. private _isLoaded;
  80992. private _objectAttributes;
  80993. private _parentClass;
  80994. /**
  80995. * Create a new xml loader
  80996. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80997. */
  80998. constructor(parentClass?: null);
  80999. private _getChainElement;
  81000. private _getClassAttribute;
  81001. private _createGuiElement;
  81002. private _parseGrid;
  81003. private _parseElement;
  81004. private _prepareSourceElement;
  81005. private _parseElementsFromSource;
  81006. private _parseXml;
  81007. /**
  81008. * Gets if the loading has finished.
  81009. * @returns whether the loading has finished or not
  81010. */
  81011. isLoaded(): boolean;
  81012. /**
  81013. * Gets a loaded node / control by id.
  81014. * @param id the Controls id set in the xml
  81015. * @returns element of type Control
  81016. */
  81017. getNodeById(id: string): any;
  81018. /**
  81019. * Gets all loaded nodes / controls
  81020. * @returns Array of controls
  81021. */
  81022. getNodes(): any;
  81023. /**
  81024. * Initiates the xml layout loading
  81025. * @param xmlFile defines the xml layout to load
  81026. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81027. * @param callback defines the callback called on layout load.
  81028. */
  81029. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81030. }
  81031. }
  81032. declare module BABYLON.GUI {
  81033. /**
  81034. * Class used to create containers for controls
  81035. */
  81036. export class Container3D extends Control3D {
  81037. private _blockLayout;
  81038. /**
  81039. * Gets the list of child controls
  81040. */
  81041. protected _children: Control3D[];
  81042. /**
  81043. * Gets the list of child controls
  81044. */
  81045. get children(): Array<Control3D>;
  81046. /**
  81047. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81048. * This is helpful to optimize layout operation when adding multiple children in a row
  81049. */
  81050. get blockLayout(): boolean;
  81051. set blockLayout(value: boolean);
  81052. /**
  81053. * Creates a new container
  81054. * @param name defines the container name
  81055. */
  81056. constructor(name?: string);
  81057. /**
  81058. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81059. * @returns the current container
  81060. */
  81061. updateLayout(): Container3D;
  81062. /**
  81063. * Gets a boolean indicating if the given control is in the children of this control
  81064. * @param control defines the control to check
  81065. * @returns true if the control is in the child list
  81066. */
  81067. containsControl(control: Control3D): boolean;
  81068. /**
  81069. * Adds a control to the children of this control
  81070. * @param control defines the control to add
  81071. * @returns the current container
  81072. */
  81073. addControl(control: Control3D): Container3D;
  81074. /**
  81075. * This function will be called everytime a new control is added
  81076. */
  81077. protected _arrangeChildren(): void;
  81078. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81079. /**
  81080. * Removes a control from the children of this control
  81081. * @param control defines the control to remove
  81082. * @returns the current container
  81083. */
  81084. removeControl(control: Control3D): Container3D;
  81085. protected _getTypeName(): string;
  81086. /**
  81087. * Releases all associated resources
  81088. */
  81089. dispose(): void;
  81090. /** Control rotation will remain unchanged */
  81091. static readonly UNSET_ORIENTATION: number;
  81092. /** Control will rotate to make it look at sphere central axis */
  81093. static readonly FACEORIGIN_ORIENTATION: number;
  81094. /** Control will rotate to make it look back at sphere central axis */
  81095. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81096. /** Control will rotate to look at z axis (0, 0, 1) */
  81097. static readonly FACEFORWARD_ORIENTATION: number;
  81098. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81099. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81100. }
  81101. }
  81102. declare module BABYLON.GUI {
  81103. /**
  81104. * Class used to manage 3D user interface
  81105. * @see https://doc.babylonjs.com/how_to/gui3d
  81106. */
  81107. export class GUI3DManager implements BABYLON.IDisposable {
  81108. private _scene;
  81109. private _sceneDisposeObserver;
  81110. private _utilityLayer;
  81111. private _rootContainer;
  81112. private _pointerObserver;
  81113. private _pointerOutObserver;
  81114. /** @hidden */
  81115. _lastPickedControl: Control3D;
  81116. /** @hidden */
  81117. _lastControlOver: {
  81118. [pointerId: number]: Control3D;
  81119. };
  81120. /** @hidden */
  81121. _lastControlDown: {
  81122. [pointerId: number]: Control3D;
  81123. };
  81124. /**
  81125. * BABYLON.Observable raised when the point picked by the pointer events changed
  81126. */
  81127. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81128. /** @hidden */
  81129. _sharedMaterials: {
  81130. [key: string]: BABYLON.Material;
  81131. };
  81132. /** Gets the hosting scene */
  81133. get scene(): BABYLON.Scene;
  81134. /** Gets associated utility layer */
  81135. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81136. /**
  81137. * Creates a new GUI3DManager
  81138. * @param scene
  81139. */
  81140. constructor(scene?: BABYLON.Scene);
  81141. private _handlePointerOut;
  81142. private _doPicking;
  81143. /**
  81144. * Gets the root container
  81145. */
  81146. get rootContainer(): Container3D;
  81147. /**
  81148. * Gets a boolean indicating if the given control is in the root child list
  81149. * @param control defines the control to check
  81150. * @returns true if the control is in the root child list
  81151. */
  81152. containsControl(control: Control3D): boolean;
  81153. /**
  81154. * Adds a control to the root child list
  81155. * @param control defines the control to add
  81156. * @returns the current manager
  81157. */
  81158. addControl(control: Control3D): GUI3DManager;
  81159. /**
  81160. * Removes a control from the root child list
  81161. * @param control defines the control to remove
  81162. * @returns the current container
  81163. */
  81164. removeControl(control: Control3D): GUI3DManager;
  81165. /**
  81166. * Releases all associated resources
  81167. */
  81168. dispose(): void;
  81169. }
  81170. }
  81171. declare module BABYLON.GUI {
  81172. /**
  81173. * Class used to transport BABYLON.Vector3 information for pointer events
  81174. */
  81175. export class Vector3WithInfo extends BABYLON.Vector3 {
  81176. /** defines the current mouse button index */
  81177. buttonIndex: number;
  81178. /**
  81179. * Creates a new Vector3WithInfo
  81180. * @param source defines the vector3 data to transport
  81181. * @param buttonIndex defines the current mouse button index
  81182. */
  81183. constructor(source: BABYLON.Vector3,
  81184. /** defines the current mouse button index */
  81185. buttonIndex?: number);
  81186. }
  81187. }
  81188. declare module BABYLON.GUI {
  81189. /**
  81190. * Class used as base class for controls
  81191. */
  81192. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81193. /** Defines the control name */
  81194. name?: string | undefined;
  81195. /** @hidden */
  81196. _host: GUI3DManager;
  81197. private _node;
  81198. private _downCount;
  81199. private _enterCount;
  81200. private _downPointerIds;
  81201. private _isVisible;
  81202. /** Gets or sets the control position in world space */
  81203. get position(): BABYLON.Vector3;
  81204. set position(value: BABYLON.Vector3);
  81205. /** Gets or sets the control scaling in world space */
  81206. get scaling(): BABYLON.Vector3;
  81207. set scaling(value: BABYLON.Vector3);
  81208. /** Callback used to start pointer enter animation */
  81209. pointerEnterAnimation: () => void;
  81210. /** Callback used to start pointer out animation */
  81211. pointerOutAnimation: () => void;
  81212. /** Callback used to start pointer down animation */
  81213. pointerDownAnimation: () => void;
  81214. /** Callback used to start pointer up animation */
  81215. pointerUpAnimation: () => void;
  81216. /**
  81217. * An event triggered when the pointer move over the control
  81218. */
  81219. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81220. /**
  81221. * An event triggered when the pointer move out of the control
  81222. */
  81223. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81224. /**
  81225. * An event triggered when the pointer taps the control
  81226. */
  81227. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81228. /**
  81229. * An event triggered when pointer is up
  81230. */
  81231. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81232. /**
  81233. * An event triggered when a control is clicked on (with a mouse)
  81234. */
  81235. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81236. /**
  81237. * An event triggered when pointer enters the control
  81238. */
  81239. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81240. /**
  81241. * Gets or sets the parent container
  81242. */
  81243. parent: BABYLON.Nullable<Container3D>;
  81244. private _behaviors;
  81245. /**
  81246. * Gets the list of attached behaviors
  81247. * @see https://doc.babylonjs.com/features/behaviour
  81248. */
  81249. get behaviors(): BABYLON.Behavior<Control3D>[];
  81250. /**
  81251. * Attach a behavior to the control
  81252. * @see https://doc.babylonjs.com/features/behaviour
  81253. * @param behavior defines the behavior to attach
  81254. * @returns the current control
  81255. */
  81256. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81257. /**
  81258. * Remove an attached behavior
  81259. * @see https://doc.babylonjs.com/features/behaviour
  81260. * @param behavior defines the behavior to attach
  81261. * @returns the current control
  81262. */
  81263. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81264. /**
  81265. * Gets an attached behavior by name
  81266. * @param name defines the name of the behavior to look for
  81267. * @see https://doc.babylonjs.com/features/behaviour
  81268. * @returns null if behavior was not found else the requested behavior
  81269. */
  81270. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81271. /** Gets or sets a boolean indicating if the control is visible */
  81272. get isVisible(): boolean;
  81273. set isVisible(value: boolean);
  81274. /**
  81275. * Creates a new control
  81276. * @param name defines the control name
  81277. */
  81278. constructor(
  81279. /** Defines the control name */
  81280. name?: string | undefined);
  81281. /**
  81282. * Gets a string representing the class name
  81283. */
  81284. get typeName(): string;
  81285. /**
  81286. * Get the current class name of the control.
  81287. * @returns current class name
  81288. */
  81289. getClassName(): string;
  81290. protected _getTypeName(): string;
  81291. /**
  81292. * Gets the transform node used by this control
  81293. */
  81294. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81295. /**
  81296. * Gets the mesh used to render this control
  81297. */
  81298. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81299. /**
  81300. * Link the control as child of the given node
  81301. * @param node defines the node to link to. Use null to unlink the control
  81302. * @returns the current control
  81303. */
  81304. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81305. /** @hidden **/
  81306. _prepareNode(scene: BABYLON.Scene): void;
  81307. /**
  81308. * Node creation.
  81309. * Can be overriden by children
  81310. * @param scene defines the scene where the node must be attached
  81311. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81312. */
  81313. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81314. /**
  81315. * Affect a material to the given mesh
  81316. * @param mesh defines the mesh which will represent the control
  81317. */
  81318. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81319. /** @hidden */
  81320. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81321. /** @hidden */
  81322. _onPointerEnter(target: Control3D): boolean;
  81323. /** @hidden */
  81324. _onPointerOut(target: Control3D): void;
  81325. /** @hidden */
  81326. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81327. /** @hidden */
  81328. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81329. /** @hidden */
  81330. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81331. /** @hidden */
  81332. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81333. /** @hidden */
  81334. _disposeNode(): void;
  81335. /**
  81336. * Releases all associated resources
  81337. */
  81338. dispose(): void;
  81339. }
  81340. }
  81341. declare module BABYLON.GUI {
  81342. /**
  81343. * Class used as a root to all buttons
  81344. */
  81345. export class AbstractButton3D extends Control3D {
  81346. /**
  81347. * Creates a new button
  81348. * @param name defines the control name
  81349. */
  81350. constructor(name?: string);
  81351. protected _getTypeName(): string;
  81352. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81353. }
  81354. }
  81355. declare module BABYLON.GUI {
  81356. /**
  81357. * Class used to create a button in 3D
  81358. */
  81359. export class Button3D extends AbstractButton3D {
  81360. /** @hidden */
  81361. protected _currentMaterial: BABYLON.Material;
  81362. private _facadeTexture;
  81363. private _content;
  81364. private _contentResolution;
  81365. private _contentScaleRatio;
  81366. /**
  81367. * Gets or sets the texture resolution used to render content (512 by default)
  81368. */
  81369. get contentResolution(): BABYLON.int;
  81370. set contentResolution(value: BABYLON.int);
  81371. /**
  81372. * Gets or sets the texture scale ratio used to render content (2 by default)
  81373. */
  81374. get contentScaleRatio(): number;
  81375. set contentScaleRatio(value: number);
  81376. protected _disposeFacadeTexture(): void;
  81377. protected _resetContent(): void;
  81378. /**
  81379. * Creates a new button
  81380. * @param name defines the control name
  81381. */
  81382. constructor(name?: string);
  81383. /**
  81384. * Gets or sets the GUI 2D content used to display the button's facade
  81385. */
  81386. get content(): Control;
  81387. set content(value: Control);
  81388. /**
  81389. * Apply the facade texture (created from the content property).
  81390. * This function can be overloaded by child classes
  81391. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81392. */
  81393. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81394. protected _getTypeName(): string;
  81395. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81396. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81397. /**
  81398. * Releases all associated resources
  81399. */
  81400. dispose(): void;
  81401. }
  81402. }
  81403. declare module BABYLON.GUI {
  81404. /**
  81405. * Abstract class used to create a container panel deployed on the surface of a volume
  81406. */
  81407. export abstract class VolumeBasedPanel extends Container3D {
  81408. private _columns;
  81409. private _rows;
  81410. private _rowThenColum;
  81411. private _orientation;
  81412. protected _cellWidth: number;
  81413. protected _cellHeight: number;
  81414. /**
  81415. * Gets or sets the distance between elements
  81416. */
  81417. margin: number;
  81418. /**
  81419. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81420. * | Value | Type | Description |
  81421. * | ----- | ----------------------------------- | ----------- |
  81422. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81423. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81424. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81425. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81426. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81427. */
  81428. get orientation(): number;
  81429. set orientation(value: number);
  81430. /**
  81431. * Gets or sets the number of columns requested (10 by default).
  81432. * The panel will automatically compute the number of rows based on number of child controls.
  81433. */
  81434. get columns(): BABYLON.int;
  81435. set columns(value: BABYLON.int);
  81436. /**
  81437. * Gets or sets a the number of rows requested.
  81438. * The panel will automatically compute the number of columns based on number of child controls.
  81439. */
  81440. get rows(): BABYLON.int;
  81441. set rows(value: BABYLON.int);
  81442. /**
  81443. * Creates new VolumeBasedPanel
  81444. */
  81445. constructor();
  81446. protected _arrangeChildren(): void;
  81447. /** Child classes must implement this function to provide correct control positioning */
  81448. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81449. /** Child classes can implement this function to provide additional processing */
  81450. protected _finalProcessing(): void;
  81451. }
  81452. }
  81453. declare module BABYLON.GUI {
  81454. /**
  81455. * Class used to create a container panel deployed on the surface of a cylinder
  81456. */
  81457. export class CylinderPanel extends VolumeBasedPanel {
  81458. private _radius;
  81459. /**
  81460. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81461. */
  81462. get radius(): BABYLON.float;
  81463. set radius(value: BABYLON.float);
  81464. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81465. private _cylindricalMapping;
  81466. }
  81467. }
  81468. declare module BABYLON.GUI {
  81469. /** @hidden */
  81470. export var fluentVertexShader: {
  81471. name: string;
  81472. shader: string;
  81473. };
  81474. }
  81475. declare module BABYLON.GUI {
  81476. /** @hidden */
  81477. export var fluentPixelShader: {
  81478. name: string;
  81479. shader: string;
  81480. };
  81481. }
  81482. declare module BABYLON.GUI {
  81483. /** @hidden */
  81484. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81485. INNERGLOW: boolean;
  81486. BORDER: boolean;
  81487. HOVERLIGHT: boolean;
  81488. TEXTURE: boolean;
  81489. constructor();
  81490. }
  81491. /**
  81492. * Class used to render controls with fluent desgin
  81493. */
  81494. export class FluentMaterial extends BABYLON.PushMaterial {
  81495. /**
  81496. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81497. */
  81498. innerGlowColorIntensity: number;
  81499. /**
  81500. * Gets or sets the inner glow color (white by default)
  81501. */
  81502. innerGlowColor: BABYLON.Color3;
  81503. /**
  81504. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81505. */
  81506. albedoColor: BABYLON.Color3;
  81507. /**
  81508. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81509. */
  81510. renderBorders: boolean;
  81511. /**
  81512. * Gets or sets border width (default is 0.5)
  81513. */
  81514. borderWidth: number;
  81515. /**
  81516. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81517. */
  81518. edgeSmoothingValue: number;
  81519. /**
  81520. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81521. */
  81522. borderMinValue: number;
  81523. /**
  81524. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81525. */
  81526. renderHoverLight: boolean;
  81527. /**
  81528. * Gets or sets the radius used to render the hover light (default is 1.0)
  81529. */
  81530. hoverRadius: number;
  81531. /**
  81532. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81533. */
  81534. hoverColor: BABYLON.Color4;
  81535. /**
  81536. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81537. */
  81538. hoverPosition: BABYLON.Vector3;
  81539. private _albedoTexture;
  81540. /** Gets or sets the texture to use for albedo color */
  81541. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81542. /**
  81543. * Creates a new Fluent material
  81544. * @param name defines the name of the material
  81545. * @param scene defines the hosting scene
  81546. */
  81547. constructor(name: string, scene: BABYLON.Scene);
  81548. needAlphaBlending(): boolean;
  81549. needAlphaTesting(): boolean;
  81550. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81551. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81552. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81553. getActiveTextures(): BABYLON.BaseTexture[];
  81554. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81555. dispose(forceDisposeEffect?: boolean): void;
  81556. clone(name: string): FluentMaterial;
  81557. serialize(): any;
  81558. getClassName(): string;
  81559. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81560. }
  81561. }
  81562. declare module BABYLON.GUI {
  81563. /**
  81564. * Class used to create a holographic button in 3D
  81565. */
  81566. export class HolographicButton extends Button3D {
  81567. private _backPlate;
  81568. private _textPlate;
  81569. private _frontPlate;
  81570. private _text;
  81571. private _imageUrl;
  81572. private _shareMaterials;
  81573. private _frontMaterial;
  81574. private _backMaterial;
  81575. private _plateMaterial;
  81576. private _pickedPointObserver;
  81577. private _tooltipFade;
  81578. private _tooltipTextBlock;
  81579. private _tooltipTexture;
  81580. private _tooltipMesh;
  81581. private _tooltipHoverObserver;
  81582. private _tooltipOutObserver;
  81583. private _disposeTooltip;
  81584. /**
  81585. * Rendering ground id of all the mesh in the button
  81586. */
  81587. set renderingGroupId(id: number);
  81588. get renderingGroupId(): number;
  81589. /**
  81590. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81591. */
  81592. set tooltipText(text: BABYLON.Nullable<string>);
  81593. get tooltipText(): BABYLON.Nullable<string>;
  81594. /**
  81595. * Gets or sets text for the button
  81596. */
  81597. get text(): string;
  81598. set text(value: string);
  81599. /**
  81600. * Gets or sets the image url for the button
  81601. */
  81602. get imageUrl(): string;
  81603. set imageUrl(value: string);
  81604. /**
  81605. * Gets the back material used by this button
  81606. */
  81607. get backMaterial(): FluentMaterial;
  81608. /**
  81609. * Gets the front material used by this button
  81610. */
  81611. get frontMaterial(): FluentMaterial;
  81612. /**
  81613. * Gets the plate material used by this button
  81614. */
  81615. get plateMaterial(): BABYLON.StandardMaterial;
  81616. /**
  81617. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81618. */
  81619. get shareMaterials(): boolean;
  81620. /**
  81621. * Creates a new button
  81622. * @param name defines the control name
  81623. */
  81624. constructor(name?: string, shareMaterials?: boolean);
  81625. protected _getTypeName(): string;
  81626. private _rebuildContent;
  81627. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81628. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81629. private _createBackMaterial;
  81630. private _createFrontMaterial;
  81631. private _createPlateMaterial;
  81632. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81633. /**
  81634. * Releases all associated resources
  81635. */
  81636. dispose(): void;
  81637. }
  81638. }
  81639. declare module BABYLON.GUI {
  81640. /**
  81641. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81642. */
  81643. export class MeshButton3D extends Button3D {
  81644. /** @hidden */
  81645. protected _currentMesh: BABYLON.Mesh;
  81646. /**
  81647. * Creates a new 3D button based on a mesh
  81648. * @param mesh mesh to become a 3D button
  81649. * @param name defines the control name
  81650. */
  81651. constructor(mesh: BABYLON.Mesh, name?: string);
  81652. protected _getTypeName(): string;
  81653. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81654. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81655. }
  81656. }
  81657. declare module BABYLON.GUI {
  81658. /**
  81659. * Class used to create a container panel deployed on the surface of a plane
  81660. */
  81661. export class PlanePanel extends VolumeBasedPanel {
  81662. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81663. }
  81664. }
  81665. declare module BABYLON.GUI {
  81666. /**
  81667. * Class used to create a container panel where items get randomized planar mapping
  81668. */
  81669. export class ScatterPanel extends VolumeBasedPanel {
  81670. private _iteration;
  81671. /**
  81672. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81673. */
  81674. get iteration(): BABYLON.float;
  81675. set iteration(value: BABYLON.float);
  81676. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81677. private _scatterMapping;
  81678. protected _finalProcessing(): void;
  81679. }
  81680. }
  81681. declare module BABYLON.GUI {
  81682. /**
  81683. * Class used to create a container panel deployed on the surface of a sphere
  81684. */
  81685. export class SpherePanel extends VolumeBasedPanel {
  81686. private _radius;
  81687. /**
  81688. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81689. */
  81690. get radius(): BABYLON.float;
  81691. set radius(value: BABYLON.float);
  81692. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81693. private _sphericalMapping;
  81694. }
  81695. }
  81696. declare module BABYLON.GUI {
  81697. /**
  81698. * Class used to create a stack panel in 3D on XY plane
  81699. */
  81700. export class StackPanel3D extends Container3D {
  81701. private _isVertical;
  81702. /**
  81703. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81704. */
  81705. get isVertical(): boolean;
  81706. set isVertical(value: boolean);
  81707. /**
  81708. * Gets or sets the distance between elements
  81709. */
  81710. margin: number;
  81711. /**
  81712. * Creates new StackPanel
  81713. * @param isVertical
  81714. */
  81715. constructor(isVertical?: boolean);
  81716. protected _arrangeChildren(): void;
  81717. }
  81718. }
  81719. declare module BABYLON {
  81720. /**
  81721. * Configuration for glTF validation
  81722. */
  81723. export interface IGLTFValidationConfiguration {
  81724. /**
  81725. * The url of the glTF validator.
  81726. */
  81727. url: string;
  81728. }
  81729. /**
  81730. * glTF validation
  81731. */
  81732. export class GLTFValidation {
  81733. /**
  81734. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81735. */
  81736. static Configuration: IGLTFValidationConfiguration;
  81737. private static _LoadScriptPromise;
  81738. /**
  81739. * Validate a glTF asset using the glTF-Validator.
  81740. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81741. * @param rootUrl The root url for the glTF
  81742. * @param fileName The file name for the glTF
  81743. * @param getExternalResource The callback to get external resources for the glTF validator
  81744. * @returns A promise that resolves with the glTF validation results once complete
  81745. */
  81746. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81747. }
  81748. }
  81749. declare module BABYLON {
  81750. /**
  81751. * Mode that determines the coordinate system to use.
  81752. */
  81753. export enum GLTFLoaderCoordinateSystemMode {
  81754. /**
  81755. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81756. */
  81757. AUTO = 0,
  81758. /**
  81759. * Sets the useRightHandedSystem flag on the scene.
  81760. */
  81761. FORCE_RIGHT_HANDED = 1
  81762. }
  81763. /**
  81764. * Mode that determines what animations will start.
  81765. */
  81766. export enum GLTFLoaderAnimationStartMode {
  81767. /**
  81768. * No animation will start.
  81769. */
  81770. NONE = 0,
  81771. /**
  81772. * The first animation will start.
  81773. */
  81774. FIRST = 1,
  81775. /**
  81776. * All animations will start.
  81777. */
  81778. ALL = 2
  81779. }
  81780. /**
  81781. * Interface that contains the data for the glTF asset.
  81782. */
  81783. export interface IGLTFLoaderData {
  81784. /**
  81785. * The object that represents the glTF JSON.
  81786. */
  81787. json: Object;
  81788. /**
  81789. * The BIN chunk of a binary glTF.
  81790. */
  81791. bin: Nullable<IDataBuffer>;
  81792. }
  81793. /**
  81794. * Interface for extending the loader.
  81795. */
  81796. export interface IGLTFLoaderExtension {
  81797. /**
  81798. * The name of this extension.
  81799. */
  81800. readonly name: string;
  81801. /**
  81802. * Defines whether this extension is enabled.
  81803. */
  81804. enabled: boolean;
  81805. /**
  81806. * Defines the order of this extension.
  81807. * The loader sorts the extensions using these values when loading.
  81808. */
  81809. order?: number;
  81810. }
  81811. /**
  81812. * Loader state.
  81813. */
  81814. export enum GLTFLoaderState {
  81815. /**
  81816. * The asset is loading.
  81817. */
  81818. LOADING = 0,
  81819. /**
  81820. * The asset is ready for rendering.
  81821. */
  81822. READY = 1,
  81823. /**
  81824. * The asset is completely loaded.
  81825. */
  81826. COMPLETE = 2
  81827. }
  81828. /** @hidden */
  81829. export interface IImportMeshAsyncOutput {
  81830. meshes: AbstractMesh[];
  81831. geometries: Geometry[];
  81832. particleSystems: IParticleSystem[];
  81833. skeletons: Skeleton[];
  81834. animationGroups: AnimationGroup[];
  81835. lights: Light[];
  81836. transformNodes: TransformNode[];
  81837. }
  81838. /** @hidden */
  81839. export interface IGLTFLoader extends IDisposable {
  81840. readonly state: Nullable<GLTFLoaderState>;
  81841. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81842. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81843. }
  81844. /**
  81845. * File loader for loading glTF files into a scene.
  81846. */
  81847. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81848. /** @hidden */
  81849. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81850. /** @hidden */
  81851. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81852. /**
  81853. * Raised when the asset has been parsed
  81854. */
  81855. onParsedObservable: Observable<IGLTFLoaderData>;
  81856. private _onParsedObserver;
  81857. /**
  81858. * Raised when the asset has been parsed
  81859. */
  81860. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81861. /**
  81862. * 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.
  81863. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81864. * Defaults to true.
  81865. * @hidden
  81866. */
  81867. static IncrementalLoading: boolean;
  81868. /**
  81869. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81870. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81871. * @hidden
  81872. */
  81873. static HomogeneousCoordinates: boolean;
  81874. /**
  81875. * The coordinate system mode. Defaults to AUTO.
  81876. */
  81877. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81878. /**
  81879. * The animation start mode. Defaults to FIRST.
  81880. */
  81881. animationStartMode: GLTFLoaderAnimationStartMode;
  81882. /**
  81883. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81884. */
  81885. compileMaterials: boolean;
  81886. /**
  81887. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81888. */
  81889. useClipPlane: boolean;
  81890. /**
  81891. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81892. */
  81893. compileShadowGenerators: boolean;
  81894. /**
  81895. * Defines if the Alpha blended materials are only applied as coverage.
  81896. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81897. * If true, no extra effects are applied to transparent pixels.
  81898. */
  81899. transparencyAsCoverage: boolean;
  81900. /**
  81901. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81902. * Enabling will disable offline support and glTF validator.
  81903. * Defaults to false.
  81904. */
  81905. useRangeRequests: boolean;
  81906. /**
  81907. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81908. */
  81909. createInstances: boolean;
  81910. /**
  81911. * 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.
  81912. */
  81913. alwaysComputeBoundingBox: boolean;
  81914. /**
  81915. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81916. */
  81917. loadAllMaterials: boolean;
  81918. /**
  81919. * Function called before loading a url referenced by the asset.
  81920. */
  81921. preprocessUrlAsync: (url: string) => Promise<string>;
  81922. /**
  81923. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81924. * 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, ...)
  81925. */
  81926. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81927. private _onMeshLoadedObserver;
  81928. /**
  81929. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81930. * 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, ...)
  81931. */
  81932. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81933. /**
  81934. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81935. */
  81936. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81937. private _onTextureLoadedObserver;
  81938. /**
  81939. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81940. */
  81941. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81942. /**
  81943. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81944. */
  81945. readonly onMaterialLoadedObservable: Observable<Material>;
  81946. private _onMaterialLoadedObserver;
  81947. /**
  81948. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81949. */
  81950. set onMaterialLoaded(callback: (material: Material) => void);
  81951. /**
  81952. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81953. */
  81954. readonly onCameraLoadedObservable: Observable<Camera>;
  81955. private _onCameraLoadedObserver;
  81956. /**
  81957. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81958. */
  81959. set onCameraLoaded(callback: (camera: Camera) => void);
  81960. /**
  81961. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81962. * For assets with LODs, raised when all of the LODs are complete.
  81963. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81964. */
  81965. readonly onCompleteObservable: Observable<void>;
  81966. private _onCompleteObserver;
  81967. /**
  81968. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81969. * For assets with LODs, raised when all of the LODs are complete.
  81970. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81971. */
  81972. set onComplete(callback: () => void);
  81973. /**
  81974. * Observable raised when an error occurs.
  81975. */
  81976. readonly onErrorObservable: Observable<any>;
  81977. private _onErrorObserver;
  81978. /**
  81979. * Callback raised when an error occurs.
  81980. */
  81981. set onError(callback: (reason: any) => void);
  81982. /**
  81983. * Observable raised after the loader is disposed.
  81984. */
  81985. readonly onDisposeObservable: Observable<void>;
  81986. private _onDisposeObserver;
  81987. /**
  81988. * Callback raised after the loader is disposed.
  81989. */
  81990. set onDispose(callback: () => void);
  81991. /**
  81992. * Observable raised after a loader extension is created.
  81993. * Set additional options for a loader extension in this event.
  81994. */
  81995. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81996. private _onExtensionLoadedObserver;
  81997. /**
  81998. * Callback raised after a loader extension is created.
  81999. */
  82000. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82001. /**
  82002. * Defines if the loader logging is enabled.
  82003. */
  82004. get loggingEnabled(): boolean;
  82005. set loggingEnabled(value: boolean);
  82006. /**
  82007. * Defines if the loader should capture performance counters.
  82008. */
  82009. get capturePerformanceCounters(): boolean;
  82010. set capturePerformanceCounters(value: boolean);
  82011. /**
  82012. * Defines if the loader should validate the asset.
  82013. */
  82014. validate: boolean;
  82015. /**
  82016. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82017. */
  82018. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82019. private _onValidatedObserver;
  82020. /**
  82021. * Callback raised after a loader extension is created.
  82022. */
  82023. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82024. private _loader;
  82025. private _progressCallback?;
  82026. private _requests;
  82027. private static magicBase64Encoded;
  82028. /**
  82029. * Name of the loader ("gltf")
  82030. */
  82031. name: string;
  82032. /** @hidden */
  82033. extensions: ISceneLoaderPluginExtensions;
  82034. /**
  82035. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82036. */
  82037. dispose(): void;
  82038. /** @hidden */
  82039. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82040. /** @hidden */
  82041. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82042. /** @hidden */
  82043. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82044. meshes: AbstractMesh[];
  82045. particleSystems: IParticleSystem[];
  82046. skeletons: Skeleton[];
  82047. animationGroups: AnimationGroup[];
  82048. }>;
  82049. /** @hidden */
  82050. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82051. /** @hidden */
  82052. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82053. /** @hidden */
  82054. canDirectLoad(data: string): boolean;
  82055. /** @hidden */
  82056. directLoad(scene: Scene, data: string): Promise<any>;
  82057. /**
  82058. * The callback that allows custom handling of the root url based on the response url.
  82059. * @param rootUrl the original root url
  82060. * @param responseURL the response url if available
  82061. * @returns the new root url
  82062. */
  82063. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82064. /** @hidden */
  82065. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82066. /**
  82067. * The loader state or null if the loader is not active.
  82068. */
  82069. get loaderState(): Nullable<GLTFLoaderState>;
  82070. /**
  82071. * Returns a promise that resolves when the asset is completely loaded.
  82072. * @returns a promise that resolves when the asset is completely loaded.
  82073. */
  82074. whenCompleteAsync(): Promise<void>;
  82075. /** @hidden */
  82076. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82077. /** @hidden */
  82078. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82079. private _onProgress;
  82080. private _validate;
  82081. private _getLoader;
  82082. private _parseJson;
  82083. private _unpackBinaryAsync;
  82084. private _unpackBinaryV1Async;
  82085. private _unpackBinaryV2Async;
  82086. private static _parseVersion;
  82087. private static _compareVersion;
  82088. private static readonly _logSpaces;
  82089. private _logIndentLevel;
  82090. private _loggingEnabled;
  82091. /** @hidden */
  82092. _log: (message: string) => void;
  82093. /** @hidden */
  82094. _logOpen(message: string): void;
  82095. /** @hidden */
  82096. _logClose(): void;
  82097. private _logEnabled;
  82098. private _logDisabled;
  82099. private _capturePerformanceCounters;
  82100. /** @hidden */
  82101. _startPerformanceCounter: (counterName: string) => void;
  82102. /** @hidden */
  82103. _endPerformanceCounter: (counterName: string) => void;
  82104. private _startPerformanceCounterEnabled;
  82105. private _startPerformanceCounterDisabled;
  82106. private _endPerformanceCounterEnabled;
  82107. private _endPerformanceCounterDisabled;
  82108. }
  82109. }
  82110. declare module BABYLON.GLTF1 {
  82111. /**
  82112. * Enums
  82113. * @hidden
  82114. */
  82115. export enum EComponentType {
  82116. BYTE = 5120,
  82117. UNSIGNED_BYTE = 5121,
  82118. SHORT = 5122,
  82119. UNSIGNED_SHORT = 5123,
  82120. FLOAT = 5126
  82121. }
  82122. /** @hidden */
  82123. export enum EShaderType {
  82124. FRAGMENT = 35632,
  82125. VERTEX = 35633
  82126. }
  82127. /** @hidden */
  82128. export enum EParameterType {
  82129. BYTE = 5120,
  82130. UNSIGNED_BYTE = 5121,
  82131. SHORT = 5122,
  82132. UNSIGNED_SHORT = 5123,
  82133. INT = 5124,
  82134. UNSIGNED_INT = 5125,
  82135. FLOAT = 5126,
  82136. FLOAT_VEC2 = 35664,
  82137. FLOAT_VEC3 = 35665,
  82138. FLOAT_VEC4 = 35666,
  82139. INT_VEC2 = 35667,
  82140. INT_VEC3 = 35668,
  82141. INT_VEC4 = 35669,
  82142. BOOL = 35670,
  82143. BOOL_VEC2 = 35671,
  82144. BOOL_VEC3 = 35672,
  82145. BOOL_VEC4 = 35673,
  82146. FLOAT_MAT2 = 35674,
  82147. FLOAT_MAT3 = 35675,
  82148. FLOAT_MAT4 = 35676,
  82149. SAMPLER_2D = 35678
  82150. }
  82151. /** @hidden */
  82152. export enum ETextureWrapMode {
  82153. CLAMP_TO_EDGE = 33071,
  82154. MIRRORED_REPEAT = 33648,
  82155. REPEAT = 10497
  82156. }
  82157. /** @hidden */
  82158. export enum ETextureFilterType {
  82159. NEAREST = 9728,
  82160. LINEAR = 9728,
  82161. NEAREST_MIPMAP_NEAREST = 9984,
  82162. LINEAR_MIPMAP_NEAREST = 9985,
  82163. NEAREST_MIPMAP_LINEAR = 9986,
  82164. LINEAR_MIPMAP_LINEAR = 9987
  82165. }
  82166. /** @hidden */
  82167. export enum ETextureFormat {
  82168. ALPHA = 6406,
  82169. RGB = 6407,
  82170. RGBA = 6408,
  82171. LUMINANCE = 6409,
  82172. LUMINANCE_ALPHA = 6410
  82173. }
  82174. /** @hidden */
  82175. export enum ECullingType {
  82176. FRONT = 1028,
  82177. BACK = 1029,
  82178. FRONT_AND_BACK = 1032
  82179. }
  82180. /** @hidden */
  82181. export enum EBlendingFunction {
  82182. ZERO = 0,
  82183. ONE = 1,
  82184. SRC_COLOR = 768,
  82185. ONE_MINUS_SRC_COLOR = 769,
  82186. DST_COLOR = 774,
  82187. ONE_MINUS_DST_COLOR = 775,
  82188. SRC_ALPHA = 770,
  82189. ONE_MINUS_SRC_ALPHA = 771,
  82190. DST_ALPHA = 772,
  82191. ONE_MINUS_DST_ALPHA = 773,
  82192. CONSTANT_COLOR = 32769,
  82193. ONE_MINUS_CONSTANT_COLOR = 32770,
  82194. CONSTANT_ALPHA = 32771,
  82195. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82196. SRC_ALPHA_SATURATE = 776
  82197. }
  82198. /** @hidden */
  82199. export interface IGLTFProperty {
  82200. extensions?: {
  82201. [key: string]: any;
  82202. };
  82203. extras?: Object;
  82204. }
  82205. /** @hidden */
  82206. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82207. name?: string;
  82208. }
  82209. /** @hidden */
  82210. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82211. bufferView: string;
  82212. byteOffset: number;
  82213. byteStride: number;
  82214. count: number;
  82215. type: string;
  82216. componentType: EComponentType;
  82217. max?: number[];
  82218. min?: number[];
  82219. name?: string;
  82220. }
  82221. /** @hidden */
  82222. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82223. buffer: string;
  82224. byteOffset: number;
  82225. byteLength: number;
  82226. byteStride: number;
  82227. target?: number;
  82228. }
  82229. /** @hidden */
  82230. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82231. uri: string;
  82232. byteLength?: number;
  82233. type?: string;
  82234. }
  82235. /** @hidden */
  82236. export interface IGLTFShader extends IGLTFChildRootProperty {
  82237. uri: string;
  82238. type: EShaderType;
  82239. }
  82240. /** @hidden */
  82241. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82242. attributes: string[];
  82243. fragmentShader: string;
  82244. vertexShader: string;
  82245. }
  82246. /** @hidden */
  82247. export interface IGLTFTechniqueParameter {
  82248. type: number;
  82249. count?: number;
  82250. semantic?: string;
  82251. node?: string;
  82252. value?: number | boolean | string | Array<any>;
  82253. source?: string;
  82254. babylonValue?: any;
  82255. }
  82256. /** @hidden */
  82257. export interface IGLTFTechniqueCommonProfile {
  82258. lightingModel: string;
  82259. texcoordBindings: Object;
  82260. parameters?: Array<any>;
  82261. }
  82262. /** @hidden */
  82263. export interface IGLTFTechniqueStatesFunctions {
  82264. blendColor?: number[];
  82265. blendEquationSeparate?: number[];
  82266. blendFuncSeparate?: number[];
  82267. colorMask: boolean[];
  82268. cullFace: number[];
  82269. }
  82270. /** @hidden */
  82271. export interface IGLTFTechniqueStates {
  82272. enable: number[];
  82273. functions: IGLTFTechniqueStatesFunctions;
  82274. }
  82275. /** @hidden */
  82276. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82277. parameters: {
  82278. [key: string]: IGLTFTechniqueParameter;
  82279. };
  82280. program: string;
  82281. attributes: {
  82282. [key: string]: string;
  82283. };
  82284. uniforms: {
  82285. [key: string]: string;
  82286. };
  82287. states: IGLTFTechniqueStates;
  82288. }
  82289. /** @hidden */
  82290. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82291. technique?: string;
  82292. values: string[];
  82293. }
  82294. /** @hidden */
  82295. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82296. attributes: {
  82297. [key: string]: string;
  82298. };
  82299. indices: string;
  82300. material: string;
  82301. mode?: number;
  82302. }
  82303. /** @hidden */
  82304. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82305. primitives: IGLTFMeshPrimitive[];
  82306. }
  82307. /** @hidden */
  82308. export interface IGLTFImage extends IGLTFChildRootProperty {
  82309. uri: string;
  82310. }
  82311. /** @hidden */
  82312. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82313. magFilter?: number;
  82314. minFilter?: number;
  82315. wrapS?: number;
  82316. wrapT?: number;
  82317. }
  82318. /** @hidden */
  82319. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82320. sampler: string;
  82321. source: string;
  82322. format?: ETextureFormat;
  82323. internalFormat?: ETextureFormat;
  82324. target?: number;
  82325. type?: number;
  82326. babylonTexture?: Texture;
  82327. }
  82328. /** @hidden */
  82329. export interface IGLTFAmbienLight {
  82330. color?: number[];
  82331. }
  82332. /** @hidden */
  82333. export interface IGLTFDirectionalLight {
  82334. color?: number[];
  82335. }
  82336. /** @hidden */
  82337. export interface IGLTFPointLight {
  82338. color?: number[];
  82339. constantAttenuation?: number;
  82340. linearAttenuation?: number;
  82341. quadraticAttenuation?: number;
  82342. }
  82343. /** @hidden */
  82344. export interface IGLTFSpotLight {
  82345. color?: number[];
  82346. constantAttenuation?: number;
  82347. fallOfAngle?: number;
  82348. fallOffExponent?: number;
  82349. linearAttenuation?: number;
  82350. quadraticAttenuation?: number;
  82351. }
  82352. /** @hidden */
  82353. export interface IGLTFLight extends IGLTFChildRootProperty {
  82354. type: string;
  82355. }
  82356. /** @hidden */
  82357. export interface IGLTFCameraOrthographic {
  82358. xmag: number;
  82359. ymag: number;
  82360. zfar: number;
  82361. znear: number;
  82362. }
  82363. /** @hidden */
  82364. export interface IGLTFCameraPerspective {
  82365. aspectRatio: number;
  82366. yfov: number;
  82367. zfar: number;
  82368. znear: number;
  82369. }
  82370. /** @hidden */
  82371. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82372. type: string;
  82373. }
  82374. /** @hidden */
  82375. export interface IGLTFAnimationChannelTarget {
  82376. id: string;
  82377. path: string;
  82378. }
  82379. /** @hidden */
  82380. export interface IGLTFAnimationChannel {
  82381. sampler: string;
  82382. target: IGLTFAnimationChannelTarget;
  82383. }
  82384. /** @hidden */
  82385. export interface IGLTFAnimationSampler {
  82386. input: string;
  82387. output: string;
  82388. interpolation?: string;
  82389. }
  82390. /** @hidden */
  82391. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82392. channels?: IGLTFAnimationChannel[];
  82393. parameters?: {
  82394. [key: string]: string;
  82395. };
  82396. samplers?: {
  82397. [key: string]: IGLTFAnimationSampler;
  82398. };
  82399. }
  82400. /** @hidden */
  82401. export interface IGLTFNodeInstanceSkin {
  82402. skeletons: string[];
  82403. skin: string;
  82404. meshes: string[];
  82405. }
  82406. /** @hidden */
  82407. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82408. bindShapeMatrix: number[];
  82409. inverseBindMatrices: string;
  82410. jointNames: string[];
  82411. babylonSkeleton?: Skeleton;
  82412. }
  82413. /** @hidden */
  82414. export interface IGLTFNode extends IGLTFChildRootProperty {
  82415. camera?: string;
  82416. children: string[];
  82417. skin?: string;
  82418. jointName?: string;
  82419. light?: string;
  82420. matrix: number[];
  82421. mesh?: string;
  82422. meshes?: string[];
  82423. rotation?: number[];
  82424. scale?: number[];
  82425. translation?: number[];
  82426. babylonNode?: Node;
  82427. }
  82428. /** @hidden */
  82429. export interface IGLTFScene extends IGLTFChildRootProperty {
  82430. nodes: string[];
  82431. }
  82432. /** @hidden */
  82433. export interface IGLTFRuntime {
  82434. extensions: {
  82435. [key: string]: any;
  82436. };
  82437. accessors: {
  82438. [key: string]: IGLTFAccessor;
  82439. };
  82440. buffers: {
  82441. [key: string]: IGLTFBuffer;
  82442. };
  82443. bufferViews: {
  82444. [key: string]: IGLTFBufferView;
  82445. };
  82446. meshes: {
  82447. [key: string]: IGLTFMesh;
  82448. };
  82449. lights: {
  82450. [key: string]: IGLTFLight;
  82451. };
  82452. cameras: {
  82453. [key: string]: IGLTFCamera;
  82454. };
  82455. nodes: {
  82456. [key: string]: IGLTFNode;
  82457. };
  82458. images: {
  82459. [key: string]: IGLTFImage;
  82460. };
  82461. textures: {
  82462. [key: string]: IGLTFTexture;
  82463. };
  82464. shaders: {
  82465. [key: string]: IGLTFShader;
  82466. };
  82467. programs: {
  82468. [key: string]: IGLTFProgram;
  82469. };
  82470. samplers: {
  82471. [key: string]: IGLTFSampler;
  82472. };
  82473. techniques: {
  82474. [key: string]: IGLTFTechnique;
  82475. };
  82476. materials: {
  82477. [key: string]: IGLTFMaterial;
  82478. };
  82479. animations: {
  82480. [key: string]: IGLTFAnimation;
  82481. };
  82482. skins: {
  82483. [key: string]: IGLTFSkins;
  82484. };
  82485. currentScene?: Object;
  82486. scenes: {
  82487. [key: string]: IGLTFScene;
  82488. };
  82489. extensionsUsed: string[];
  82490. extensionsRequired?: string[];
  82491. buffersCount: number;
  82492. shaderscount: number;
  82493. scene: Scene;
  82494. rootUrl: string;
  82495. loadedBufferCount: number;
  82496. loadedBufferViews: {
  82497. [name: string]: ArrayBufferView;
  82498. };
  82499. loadedShaderCount: number;
  82500. importOnlyMeshes: boolean;
  82501. importMeshesNames?: string[];
  82502. dummyNodes: Node[];
  82503. forAssetContainer: boolean;
  82504. }
  82505. /** @hidden */
  82506. export interface INodeToRoot {
  82507. bone: Bone;
  82508. node: IGLTFNode;
  82509. id: string;
  82510. }
  82511. /** @hidden */
  82512. export interface IJointNode {
  82513. node: IGLTFNode;
  82514. id: string;
  82515. }
  82516. }
  82517. declare module BABYLON.GLTF1 {
  82518. /**
  82519. * Utils functions for GLTF
  82520. * @hidden
  82521. */
  82522. export class GLTFUtils {
  82523. /**
  82524. * Sets the given "parameter" matrix
  82525. * @param scene: the Scene object
  82526. * @param source: the source node where to pick the matrix
  82527. * @param parameter: the GLTF technique parameter
  82528. * @param uniformName: the name of the shader's uniform
  82529. * @param shaderMaterial: the shader material
  82530. */
  82531. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82532. /**
  82533. * Sets the given "parameter" matrix
  82534. * @param shaderMaterial: the shader material
  82535. * @param uniform: the name of the shader's uniform
  82536. * @param value: the value of the uniform
  82537. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82538. */
  82539. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82540. /**
  82541. * Returns the wrap mode of the texture
  82542. * @param mode: the mode value
  82543. */
  82544. static GetWrapMode(mode: number): number;
  82545. /**
  82546. * Returns the byte stride giving an accessor
  82547. * @param accessor: the GLTF accessor objet
  82548. */
  82549. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82550. /**
  82551. * Returns the texture filter mode giving a mode value
  82552. * @param mode: the filter mode value
  82553. */
  82554. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82555. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82556. /**
  82557. * Returns a buffer from its accessor
  82558. * @param gltfRuntime: the GLTF runtime
  82559. * @param accessor: the GLTF accessor
  82560. */
  82561. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82562. /**
  82563. * Decodes a buffer view into a string
  82564. * @param view: the buffer view
  82565. */
  82566. static DecodeBufferToText(view: ArrayBufferView): string;
  82567. /**
  82568. * Returns the default material of gltf. Related to
  82569. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82570. * @param scene: the Babylon.js scene
  82571. */
  82572. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82573. private static _DefaultMaterial;
  82574. }
  82575. }
  82576. declare module BABYLON.GLTF1 {
  82577. /**
  82578. * Implementation of the base glTF spec
  82579. * @hidden
  82580. */
  82581. export class GLTFLoaderBase {
  82582. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82583. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82584. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82585. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82586. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82587. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82588. }
  82589. /**
  82590. * glTF V1 Loader
  82591. * @hidden
  82592. */
  82593. export class GLTFLoader implements IGLTFLoader {
  82594. static Extensions: {
  82595. [name: string]: GLTFLoaderExtension;
  82596. };
  82597. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82598. state: Nullable<GLTFLoaderState>;
  82599. dispose(): void;
  82600. private _importMeshAsync;
  82601. /**
  82602. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82603. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82604. * @param scene the scene the meshes should be added to
  82605. * @param forAssetContainer defines if the entities must be stored in the scene
  82606. * @param data gltf data containing information of the meshes in a loaded file
  82607. * @param rootUrl root url to load from
  82608. * @param onProgress event that fires when loading progress has occured
  82609. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82610. */
  82611. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82612. private _loadAsync;
  82613. /**
  82614. * Imports all objects from a loaded gltf file and adds them to the scene
  82615. * @param scene the scene the objects should be added to
  82616. * @param data gltf data containing information of the meshes in a loaded file
  82617. * @param rootUrl root url to load from
  82618. * @param onProgress event that fires when loading progress has occured
  82619. * @returns a promise which completes when objects have been loaded to the scene
  82620. */
  82621. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82622. private _loadShadersAsync;
  82623. private _loadBuffersAsync;
  82624. private _createNodes;
  82625. }
  82626. /** @hidden */
  82627. export abstract class GLTFLoaderExtension {
  82628. private _name;
  82629. constructor(name: string);
  82630. get name(): string;
  82631. /**
  82632. * Defines an override for loading the runtime
  82633. * Return true to stop further extensions from loading the runtime
  82634. */
  82635. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82636. /**
  82637. * Defines an onverride for creating gltf runtime
  82638. * Return true to stop further extensions from creating the runtime
  82639. */
  82640. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82641. /**
  82642. * Defines an override for loading buffers
  82643. * Return true to stop further extensions from loading this buffer
  82644. */
  82645. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82646. /**
  82647. * Defines an override for loading texture buffers
  82648. * Return true to stop further extensions from loading this texture data
  82649. */
  82650. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82651. /**
  82652. * Defines an override for creating textures
  82653. * Return true to stop further extensions from loading this texture
  82654. */
  82655. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82656. /**
  82657. * Defines an override for loading shader strings
  82658. * Return true to stop further extensions from loading this shader data
  82659. */
  82660. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82661. /**
  82662. * Defines an override for loading materials
  82663. * Return true to stop further extensions from loading this material
  82664. */
  82665. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82666. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82667. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82668. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82669. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82670. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82671. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82672. private static LoadTextureBufferAsync;
  82673. private static CreateTextureAsync;
  82674. private static ApplyExtensions;
  82675. }
  82676. }
  82677. declare module BABYLON.GLTF1 {
  82678. /** @hidden */
  82679. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82680. private _bin;
  82681. constructor();
  82682. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82683. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82684. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82685. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82686. }
  82687. }
  82688. declare module BABYLON.GLTF1 {
  82689. /** @hidden */
  82690. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82691. constructor();
  82692. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82693. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82694. private _loadTexture;
  82695. }
  82696. }
  82697. declare module BABYLON.GLTF2.Loader {
  82698. /**
  82699. * Loader interface with an index field.
  82700. */
  82701. export interface IArrayItem {
  82702. /**
  82703. * The index of this item in the array.
  82704. */
  82705. index: number;
  82706. }
  82707. /**
  82708. * Loader interface with additional members.
  82709. */
  82710. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82711. /** @hidden */
  82712. _data?: Promise<ArrayBufferView>;
  82713. /** @hidden */
  82714. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82715. }
  82716. /**
  82717. * Loader interface with additional members.
  82718. */
  82719. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82720. }
  82721. /** @hidden */
  82722. export interface _IAnimationSamplerData {
  82723. input: Float32Array;
  82724. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82725. output: Float32Array;
  82726. }
  82727. /**
  82728. * Loader interface with additional members.
  82729. */
  82730. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82731. /** @hidden */
  82732. _data?: Promise<_IAnimationSamplerData>;
  82733. }
  82734. /**
  82735. * Loader interface with additional members.
  82736. */
  82737. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82738. channels: IAnimationChannel[];
  82739. samplers: IAnimationSampler[];
  82740. /** @hidden */
  82741. _babylonAnimationGroup?: AnimationGroup;
  82742. }
  82743. /**
  82744. * Loader interface with additional members.
  82745. */
  82746. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82747. /** @hidden */
  82748. _data?: Promise<ArrayBufferView>;
  82749. }
  82750. /**
  82751. * Loader interface with additional members.
  82752. */
  82753. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82754. /** @hidden */
  82755. _data?: Promise<ArrayBufferView>;
  82756. /** @hidden */
  82757. _babylonBuffer?: Promise<Buffer>;
  82758. }
  82759. /**
  82760. * Loader interface with additional members.
  82761. */
  82762. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82763. }
  82764. /**
  82765. * Loader interface with additional members.
  82766. */
  82767. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82768. /** @hidden */
  82769. _data?: Promise<ArrayBufferView>;
  82770. }
  82771. /**
  82772. * Loader interface with additional members.
  82773. */
  82774. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82775. }
  82776. /**
  82777. * Loader interface with additional members.
  82778. */
  82779. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82780. }
  82781. /**
  82782. * Loader interface with additional members.
  82783. */
  82784. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82785. baseColorTexture?: ITextureInfo;
  82786. metallicRoughnessTexture?: ITextureInfo;
  82787. }
  82788. /**
  82789. * Loader interface with additional members.
  82790. */
  82791. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82792. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82793. normalTexture?: IMaterialNormalTextureInfo;
  82794. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82795. emissiveTexture?: ITextureInfo;
  82796. /** @hidden */
  82797. _data?: {
  82798. [babylonDrawMode: number]: {
  82799. babylonMaterial: Material;
  82800. babylonMeshes: AbstractMesh[];
  82801. promise: Promise<void>;
  82802. };
  82803. };
  82804. }
  82805. /**
  82806. * Loader interface with additional members.
  82807. */
  82808. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82809. primitives: IMeshPrimitive[];
  82810. }
  82811. /**
  82812. * Loader interface with additional members.
  82813. */
  82814. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82815. /** @hidden */
  82816. _instanceData?: {
  82817. babylonSourceMesh: Mesh;
  82818. promise: Promise<any>;
  82819. };
  82820. }
  82821. /**
  82822. * Loader interface with additional members.
  82823. */
  82824. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82825. /**
  82826. * The parent glTF node.
  82827. */
  82828. parent?: INode;
  82829. /** @hidden */
  82830. _babylonTransformNode?: TransformNode;
  82831. /** @hidden */
  82832. _primitiveBabylonMeshes?: AbstractMesh[];
  82833. /** @hidden */
  82834. _babylonBones?: Bone[];
  82835. /** @hidden */
  82836. _numMorphTargets?: number;
  82837. }
  82838. /** @hidden */
  82839. export interface _ISamplerData {
  82840. noMipMaps: boolean;
  82841. samplingMode: number;
  82842. wrapU: number;
  82843. wrapV: number;
  82844. }
  82845. /**
  82846. * Loader interface with additional members.
  82847. */
  82848. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82849. /** @hidden */
  82850. _data?: _ISamplerData;
  82851. }
  82852. /**
  82853. * Loader interface with additional members.
  82854. */
  82855. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82856. }
  82857. /**
  82858. * Loader interface with additional members.
  82859. */
  82860. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82861. /** @hidden */
  82862. _data?: {
  82863. babylonSkeleton: Skeleton;
  82864. promise: Promise<void>;
  82865. };
  82866. }
  82867. /**
  82868. * Loader interface with additional members.
  82869. */
  82870. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82871. /** @hidden */
  82872. _textureInfo: ITextureInfo;
  82873. }
  82874. /**
  82875. * Loader interface with additional members.
  82876. */
  82877. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82878. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  82879. nonColorData?: boolean;
  82880. }
  82881. /**
  82882. * Loader interface with additional members.
  82883. */
  82884. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82885. accessors?: IAccessor[];
  82886. animations?: IAnimation[];
  82887. buffers?: IBuffer[];
  82888. bufferViews?: IBufferView[];
  82889. cameras?: ICamera[];
  82890. images?: IImage[];
  82891. materials?: IMaterial[];
  82892. meshes?: IMesh[];
  82893. nodes?: INode[];
  82894. samplers?: ISampler[];
  82895. scenes?: IScene[];
  82896. skins?: ISkin[];
  82897. textures?: ITexture[];
  82898. }
  82899. }
  82900. declare module BABYLON.GLTF2 {
  82901. /**
  82902. * Interface for a glTF loader extension.
  82903. */
  82904. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82905. /**
  82906. * Called after the loader state changes to LOADING.
  82907. */
  82908. onLoading?(): void;
  82909. /**
  82910. * Called after the loader state changes to READY.
  82911. */
  82912. onReady?(): void;
  82913. /**
  82914. * Define this method to modify the default behavior when loading scenes.
  82915. * @param context The context when loading the asset
  82916. * @param scene The glTF scene property
  82917. * @returns A promise that resolves when the load is complete or null if not handled
  82918. */
  82919. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82920. /**
  82921. * Define this method to modify the default behavior when loading nodes.
  82922. * @param context The context when loading the asset
  82923. * @param node The glTF node property
  82924. * @param assign A function called synchronously after parsing the glTF properties
  82925. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82926. */
  82927. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82928. /**
  82929. * Define this method to modify the default behavior when loading cameras.
  82930. * @param context The context when loading the asset
  82931. * @param camera The glTF camera property
  82932. * @param assign A function called synchronously after parsing the glTF properties
  82933. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82934. */
  82935. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82936. /**
  82937. * @hidden
  82938. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82939. * @param context The context when loading the asset
  82940. * @param primitive The glTF mesh primitive property
  82941. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82942. */
  82943. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82944. /**
  82945. * @hidden
  82946. * Define this method to modify the default behavior when loading data for mesh primitives.
  82947. * @param context The context when loading the asset
  82948. * @param name The mesh name when loading the asset
  82949. * @param node The glTF node when loading the asset
  82950. * @param mesh The glTF mesh when loading the asset
  82951. * @param primitive The glTF mesh primitive property
  82952. * @param assign A function called synchronously after parsing the glTF properties
  82953. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82954. */
  82955. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82956. /**
  82957. * @hidden
  82958. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82959. * @param context The context when loading the asset
  82960. * @param material The glTF material property
  82961. * @param assign A function called synchronously after parsing the glTF properties
  82962. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82963. */
  82964. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82965. /**
  82966. * Define this method to modify the default behavior when creating materials.
  82967. * @param context The context when loading the asset
  82968. * @param material The glTF material property
  82969. * @param babylonDrawMode The draw mode for the Babylon material
  82970. * @returns The Babylon material or null if not handled
  82971. */
  82972. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82973. /**
  82974. * Define this method to modify the default behavior when loading material properties.
  82975. * @param context The context when loading the asset
  82976. * @param material The glTF material property
  82977. * @param babylonMaterial The Babylon material
  82978. * @returns A promise that resolves when the load is complete or null if not handled
  82979. */
  82980. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82981. /**
  82982. * Define this method to modify the default behavior when loading texture infos.
  82983. * @param context The context when loading the asset
  82984. * @param textureInfo The glTF texture info property
  82985. * @param assign A function called synchronously after parsing the glTF properties
  82986. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82987. */
  82988. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82989. /**
  82990. * @hidden
  82991. * Define this method to modify the default behavior when loading textures.
  82992. * @param context The context when loading the asset
  82993. * @param texture The glTF texture property
  82994. * @param assign A function called synchronously after parsing the glTF properties
  82995. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82996. */
  82997. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82998. /**
  82999. * Define this method to modify the default behavior when loading animations.
  83000. * @param context The context when loading the asset
  83001. * @param animation The glTF animation property
  83002. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83003. */
  83004. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83005. /**
  83006. * @hidden
  83007. * Define this method to modify the default behavior when loading skins.
  83008. * @param context The context when loading the asset
  83009. * @param node The glTF node property
  83010. * @param skin The glTF skin property
  83011. * @returns A promise that resolves when the load is complete or null if not handled
  83012. */
  83013. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83014. /**
  83015. * @hidden
  83016. * Define this method to modify the default behavior when loading uris.
  83017. * @param context The context when loading the asset
  83018. * @param property The glTF property associated with the uri
  83019. * @param uri The uri to load
  83020. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83021. */
  83022. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83023. /**
  83024. * Define this method to modify the default behavior when loading buffer views.
  83025. * @param context The context when loading the asset
  83026. * @param bufferView The glTF buffer view property
  83027. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83028. */
  83029. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83030. /**
  83031. * Define this method to modify the default behavior when loading buffers.
  83032. * @param context The context when loading the asset
  83033. * @param buffer The glTF buffer property
  83034. * @param byteOffset The byte offset to load
  83035. * @param byteLength The byte length to load
  83036. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83037. */
  83038. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83039. }
  83040. }
  83041. declare module BABYLON.GLTF2 {
  83042. /**
  83043. * Helper class for working with arrays when loading the glTF asset
  83044. */
  83045. export class ArrayItem {
  83046. /**
  83047. * Gets an item from the given array.
  83048. * @param context The context when loading the asset
  83049. * @param array The array to get the item from
  83050. * @param index The index to the array
  83051. * @returns The array item
  83052. */
  83053. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83054. /**
  83055. * Assign an `index` field to each item of the given array.
  83056. * @param array The array of items
  83057. */
  83058. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83059. }
  83060. /**
  83061. * The glTF 2.0 loader
  83062. */
  83063. export class GLTFLoader implements IGLTFLoader {
  83064. /** @hidden */
  83065. _completePromises: Promise<any>[];
  83066. /** @hidden */
  83067. _forAssetContainer: boolean;
  83068. /** Storage */
  83069. _babylonLights: Light[];
  83070. /** @hidden */
  83071. _disableInstancedMesh: number;
  83072. private _disposed;
  83073. private _parent;
  83074. private _state;
  83075. private _extensions;
  83076. private _rootUrl;
  83077. private _fileName;
  83078. private _uniqueRootUrl;
  83079. private _gltf;
  83080. private _bin;
  83081. private _babylonScene;
  83082. private _rootBabylonMesh;
  83083. private _defaultBabylonMaterialData;
  83084. private static _RegisteredExtensions;
  83085. /**
  83086. * The default glTF sampler.
  83087. */
  83088. static readonly DefaultSampler: ISampler;
  83089. /**
  83090. * Registers a loader extension.
  83091. * @param name The name of the loader extension.
  83092. * @param factory The factory function that creates the loader extension.
  83093. */
  83094. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83095. /**
  83096. * Unregisters a loader extension.
  83097. * @param name The name of the loader extension.
  83098. * @returns A boolean indicating whether the extension has been unregistered
  83099. */
  83100. static UnregisterExtension(name: string): boolean;
  83101. /**
  83102. * The loader state.
  83103. */
  83104. get state(): Nullable<GLTFLoaderState>;
  83105. /**
  83106. * The object that represents the glTF JSON.
  83107. */
  83108. get gltf(): IGLTF;
  83109. /**
  83110. * The BIN chunk of a binary glTF.
  83111. */
  83112. get bin(): Nullable<IDataBuffer>;
  83113. /**
  83114. * The parent file loader.
  83115. */
  83116. get parent(): GLTFFileLoader;
  83117. /**
  83118. * The Babylon scene when loading the asset.
  83119. */
  83120. get babylonScene(): Scene;
  83121. /**
  83122. * The root Babylon mesh when loading the asset.
  83123. */
  83124. get rootBabylonMesh(): Mesh;
  83125. /** @hidden */
  83126. constructor(parent: GLTFFileLoader);
  83127. /** @hidden */
  83128. dispose(): void;
  83129. /** @hidden */
  83130. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83131. /** @hidden */
  83132. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83133. private _loadAsync;
  83134. private _loadData;
  83135. private _setupData;
  83136. private _loadExtensions;
  83137. private _checkExtensions;
  83138. private _setState;
  83139. private _createRootNode;
  83140. /**
  83141. * Loads a glTF scene.
  83142. * @param context The context when loading the asset
  83143. * @param scene The glTF scene property
  83144. * @returns A promise that resolves when the load is complete
  83145. */
  83146. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83147. private _forEachPrimitive;
  83148. private _getGeometries;
  83149. private _getMeshes;
  83150. private _getTransformNodes;
  83151. private _getSkeletons;
  83152. private _getAnimationGroups;
  83153. private _startAnimations;
  83154. /**
  83155. * Loads a glTF node.
  83156. * @param context The context when loading the asset
  83157. * @param node The glTF node property
  83158. * @param assign A function called synchronously after parsing the glTF properties
  83159. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83160. */
  83161. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83162. private _loadMeshAsync;
  83163. /**
  83164. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83165. * @param context The context when loading the asset
  83166. * @param name The mesh name when loading the asset
  83167. * @param node The glTF node when loading the asset
  83168. * @param mesh The glTF mesh when loading the asset
  83169. * @param primitive The glTF mesh primitive property
  83170. * @param assign A function called synchronously after parsing the glTF properties
  83171. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83172. */
  83173. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83174. private _loadVertexDataAsync;
  83175. private _createMorphTargets;
  83176. private _loadMorphTargetsAsync;
  83177. private _loadMorphTargetVertexDataAsync;
  83178. private static _LoadTransform;
  83179. private _loadSkinAsync;
  83180. private _loadBones;
  83181. private _loadBone;
  83182. private _loadSkinInverseBindMatricesDataAsync;
  83183. private _updateBoneMatrices;
  83184. private _getNodeMatrix;
  83185. /**
  83186. * Loads a glTF camera.
  83187. * @param context The context when loading the asset
  83188. * @param camera The glTF camera property
  83189. * @param assign A function called synchronously after parsing the glTF properties
  83190. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83191. */
  83192. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83193. private _loadAnimationsAsync;
  83194. /**
  83195. * Loads a glTF animation.
  83196. * @param context The context when loading the asset
  83197. * @param animation The glTF animation property
  83198. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83199. */
  83200. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83201. /**
  83202. * @hidden Loads a glTF animation channel.
  83203. * @param context The context when loading the asset
  83204. * @param animationContext The context of the animation when loading the asset
  83205. * @param animation The glTF animation property
  83206. * @param channel The glTF animation channel property
  83207. * @param babylonAnimationGroup The babylon animation group property
  83208. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83209. * @returns A void promise when the channel load is complete
  83210. */
  83211. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83212. private _loadAnimationSamplerAsync;
  83213. private _loadBufferAsync;
  83214. /**
  83215. * Loads a glTF buffer view.
  83216. * @param context The context when loading the asset
  83217. * @param bufferView The glTF buffer view property
  83218. * @returns A promise that resolves with the loaded data when the load is complete
  83219. */
  83220. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83221. private _loadAccessorAsync;
  83222. /** @hidden */
  83223. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83224. private _loadIndicesAccessorAsync;
  83225. private _loadVertexBufferViewAsync;
  83226. private _loadVertexAccessorAsync;
  83227. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83228. /** @hidden */
  83229. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83230. private _createDefaultMaterial;
  83231. /**
  83232. * Creates a Babylon material from a glTF material.
  83233. * @param context The context when loading the asset
  83234. * @param material The glTF material property
  83235. * @param babylonDrawMode The draw mode for the Babylon material
  83236. * @returns The Babylon material
  83237. */
  83238. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83239. /**
  83240. * Loads properties from a glTF material into a Babylon material.
  83241. * @param context The context when loading the asset
  83242. * @param material The glTF material property
  83243. * @param babylonMaterial The Babylon material
  83244. * @returns A promise that resolves when the load is complete
  83245. */
  83246. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83247. /**
  83248. * Loads the normal, occlusion, and emissive 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. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83255. /**
  83256. * Loads the alpha properties from a glTF material into a Babylon material.
  83257. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83258. * @param context The context when loading the asset
  83259. * @param material The glTF material property
  83260. * @param babylonMaterial The Babylon material
  83261. */
  83262. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83263. /**
  83264. * Loads a glTF texture info.
  83265. * @param context The context when loading the asset
  83266. * @param textureInfo The glTF texture info property
  83267. * @param assign A function called synchronously after parsing the glTF properties
  83268. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83269. */
  83270. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83271. /** @hidden */
  83272. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83273. /** @hidden */
  83274. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83275. private _loadSampler;
  83276. /**
  83277. * Loads a glTF image.
  83278. * @param context The context when loading the asset
  83279. * @param image The glTF image property
  83280. * @returns A promise that resolves with the loaded data when the load is complete
  83281. */
  83282. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83283. /**
  83284. * Loads a glTF uri.
  83285. * @param context The context when loading the asset
  83286. * @param property The glTF property associated with the uri
  83287. * @param uri The base64 or relative uri
  83288. * @returns A promise that resolves with the loaded data when the load is complete
  83289. */
  83290. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83291. /**
  83292. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83293. * @param babylonObject the Babylon object with metadata
  83294. * @param pointer the JSON pointer
  83295. */
  83296. static AddPointerMetadata(babylonObject: {
  83297. metadata: any;
  83298. }, pointer: string): void;
  83299. private static _GetTextureWrapMode;
  83300. private static _GetTextureSamplingMode;
  83301. private static _GetTypedArrayConstructor;
  83302. private static _GetTypedArray;
  83303. private static _GetNumComponents;
  83304. private static _ValidateUri;
  83305. /** @hidden */
  83306. static _GetDrawMode(context: string, mode: number | undefined): number;
  83307. private _compileMaterialsAsync;
  83308. private _compileShadowGeneratorsAsync;
  83309. private _forEachExtensions;
  83310. private _applyExtensions;
  83311. private _extensionsOnLoading;
  83312. private _extensionsOnReady;
  83313. private _extensionsLoadSceneAsync;
  83314. private _extensionsLoadNodeAsync;
  83315. private _extensionsLoadCameraAsync;
  83316. private _extensionsLoadVertexDataAsync;
  83317. private _extensionsLoadMeshPrimitiveAsync;
  83318. private _extensionsLoadMaterialAsync;
  83319. private _extensionsCreateMaterial;
  83320. private _extensionsLoadMaterialPropertiesAsync;
  83321. private _extensionsLoadTextureInfoAsync;
  83322. private _extensionsLoadTextureAsync;
  83323. private _extensionsLoadAnimationAsync;
  83324. private _extensionsLoadSkinAsync;
  83325. private _extensionsLoadUriAsync;
  83326. private _extensionsLoadBufferViewAsync;
  83327. private _extensionsLoadBufferAsync;
  83328. /**
  83329. * Helper method called by a loader extension to load an glTF extension.
  83330. * @param context The context when loading the asset
  83331. * @param property The glTF property to load the extension from
  83332. * @param extensionName The name of the extension to load
  83333. * @param actionAsync The action to run
  83334. * @returns The promise returned by actionAsync or null if the extension does not exist
  83335. */
  83336. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83337. /**
  83338. * Helper method called by a loader extension to load a glTF extra.
  83339. * @param context The context when loading the asset
  83340. * @param property The glTF property to load the extra from
  83341. * @param extensionName The name of the extension to load
  83342. * @param actionAsync The action to run
  83343. * @returns The promise returned by actionAsync or null if the extra does not exist
  83344. */
  83345. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83346. /**
  83347. * Checks for presence of an extension.
  83348. * @param name The name of the extension to check
  83349. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83350. */
  83351. isExtensionUsed(name: string): boolean;
  83352. /**
  83353. * Increments the indentation level and logs a message.
  83354. * @param message The message to log
  83355. */
  83356. logOpen(message: string): void;
  83357. /**
  83358. * Decrements the indentation level.
  83359. */
  83360. logClose(): void;
  83361. /**
  83362. * Logs a message
  83363. * @param message The message to log
  83364. */
  83365. log(message: string): void;
  83366. /**
  83367. * Starts a performance counter.
  83368. * @param counterName The name of the performance counter
  83369. */
  83370. startPerformanceCounter(counterName: string): void;
  83371. /**
  83372. * Ends a performance counter.
  83373. * @param counterName The name of the performance counter
  83374. */
  83375. endPerformanceCounter(counterName: string): void;
  83376. }
  83377. }
  83378. declare module BABYLON.GLTF2.Loader.Extensions {
  83379. /** @hidden */
  83380. interface IEXTLightsImageBased_LightImageBased {
  83381. _babylonTexture?: BaseTexture;
  83382. _loaded?: Promise<void>;
  83383. }
  83384. /**
  83385. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83386. */
  83387. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83388. /**
  83389. * The name of this extension.
  83390. */
  83391. readonly name: string;
  83392. /**
  83393. * Defines whether this extension is enabled.
  83394. */
  83395. enabled: boolean;
  83396. private _loader;
  83397. private _lights?;
  83398. /** @hidden */
  83399. constructor(loader: GLTFLoader);
  83400. /** @hidden */
  83401. dispose(): void;
  83402. /** @hidden */
  83403. onLoading(): void;
  83404. /** @hidden */
  83405. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83406. private _loadLightAsync;
  83407. }
  83408. }
  83409. declare module BABYLON.GLTF2.Loader.Extensions {
  83410. /**
  83411. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83412. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83413. * !!! Experimental Extension Subject to Changes !!!
  83414. */
  83415. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83416. /**
  83417. * The name of this extension.
  83418. */
  83419. readonly name: string;
  83420. /**
  83421. * Defines whether this extension is enabled.
  83422. */
  83423. enabled: boolean;
  83424. private _loader;
  83425. /** @hidden */
  83426. constructor(loader: GLTFLoader);
  83427. /** @hidden */
  83428. dispose(): void;
  83429. /** @hidden */
  83430. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83431. }
  83432. }
  83433. declare module BABYLON.GLTF2.Loader.Extensions {
  83434. /**
  83435. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83436. */
  83437. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83438. /** The name of this extension. */
  83439. readonly name: string;
  83440. /** Defines whether this extension is enabled. */
  83441. enabled: boolean;
  83442. private _loader;
  83443. /** @hidden */
  83444. constructor(loader: GLTFLoader);
  83445. /** @hidden */
  83446. dispose(): void;
  83447. /** @hidden */
  83448. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83449. }
  83450. }
  83451. declare module BABYLON.GLTF2.Loader.Extensions {
  83452. /**
  83453. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83454. */
  83455. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83456. /**
  83457. * The name of this extension.
  83458. */
  83459. readonly name: string;
  83460. /**
  83461. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83462. */
  83463. dracoCompression?: DracoCompression;
  83464. /**
  83465. * Defines whether this extension is enabled.
  83466. */
  83467. enabled: boolean;
  83468. private _loader;
  83469. /** @hidden */
  83470. constructor(loader: GLTFLoader);
  83471. /** @hidden */
  83472. dispose(): void;
  83473. /** @hidden */
  83474. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83475. }
  83476. }
  83477. declare module BABYLON.GLTF2.Loader.Extensions {
  83478. /**
  83479. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83480. */
  83481. export class KHR_lights implements IGLTFLoaderExtension {
  83482. /**
  83483. * The name of this extension.
  83484. */
  83485. readonly name: string;
  83486. /**
  83487. * Defines whether this extension is enabled.
  83488. */
  83489. enabled: boolean;
  83490. private _loader;
  83491. private _lights?;
  83492. /** @hidden */
  83493. constructor(loader: GLTFLoader);
  83494. /** @hidden */
  83495. dispose(): void;
  83496. /** @hidden */
  83497. onLoading(): void;
  83498. /** @hidden */
  83499. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83500. }
  83501. }
  83502. declare module BABYLON.GLTF2.Loader.Extensions {
  83503. /**
  83504. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83505. */
  83506. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83507. /**
  83508. * The name of this extension.
  83509. */
  83510. readonly name: string;
  83511. /**
  83512. * Defines whether this extension is enabled.
  83513. */
  83514. enabled: boolean;
  83515. /**
  83516. * Defines a number that determines the order the extensions are applied.
  83517. */
  83518. order: number;
  83519. private _loader;
  83520. /** @hidden */
  83521. constructor(loader: GLTFLoader);
  83522. /** @hidden */
  83523. dispose(): void;
  83524. /** @hidden */
  83525. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83526. private _loadSpecularGlossinessPropertiesAsync;
  83527. }
  83528. }
  83529. declare module BABYLON.GLTF2.Loader.Extensions {
  83530. /**
  83531. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83532. */
  83533. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83534. /**
  83535. * The name of this extension.
  83536. */
  83537. readonly name: string;
  83538. /**
  83539. * Defines whether this extension is enabled.
  83540. */
  83541. enabled: boolean;
  83542. /**
  83543. * Defines a number that determines the order the extensions are applied.
  83544. */
  83545. order: number;
  83546. private _loader;
  83547. /** @hidden */
  83548. constructor(loader: GLTFLoader);
  83549. /** @hidden */
  83550. dispose(): void;
  83551. /** @hidden */
  83552. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83553. private _loadUnlitPropertiesAsync;
  83554. }
  83555. }
  83556. declare module BABYLON.GLTF2.Loader.Extensions {
  83557. /**
  83558. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83559. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83560. */
  83561. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83562. /**
  83563. * The name of this extension.
  83564. */
  83565. readonly name: string;
  83566. /**
  83567. * Defines whether this extension is enabled.
  83568. */
  83569. enabled: boolean;
  83570. /**
  83571. * Defines a number that determines the order the extensions are applied.
  83572. */
  83573. order: number;
  83574. private _loader;
  83575. /** @hidden */
  83576. constructor(loader: GLTFLoader);
  83577. /** @hidden */
  83578. dispose(): void;
  83579. /** @hidden */
  83580. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83581. private _loadClearCoatPropertiesAsync;
  83582. }
  83583. }
  83584. declare module BABYLON.GLTF2.Loader.Extensions {
  83585. /**
  83586. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83587. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83588. * !!! Experimental Extension Subject to Changes !!!
  83589. */
  83590. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83591. /**
  83592. * The name of this extension.
  83593. */
  83594. readonly name: string;
  83595. /**
  83596. * Defines whether this extension is enabled.
  83597. */
  83598. enabled: boolean;
  83599. /**
  83600. * Defines a number that determines the order the extensions are applied.
  83601. */
  83602. order: number;
  83603. private _loader;
  83604. /** @hidden */
  83605. constructor(loader: GLTFLoader);
  83606. /** @hidden */
  83607. dispose(): void;
  83608. /** @hidden */
  83609. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83610. private _loadSheenPropertiesAsync;
  83611. }
  83612. }
  83613. declare module BABYLON.GLTF2.Loader.Extensions {
  83614. /**
  83615. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83616. * !!! Experimental Extension Subject to Changes !!!
  83617. */
  83618. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83619. /**
  83620. * The name of this extension.
  83621. */
  83622. readonly name: string;
  83623. /**
  83624. * Defines whether this extension is enabled.
  83625. */
  83626. enabled: boolean;
  83627. /**
  83628. * Defines a number that determines the order the extensions are applied.
  83629. */
  83630. order: number;
  83631. private _loader;
  83632. /** @hidden */
  83633. constructor(loader: GLTFLoader);
  83634. /** @hidden */
  83635. dispose(): void;
  83636. /** @hidden */
  83637. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83638. private _loadSpecularPropertiesAsync;
  83639. }
  83640. }
  83641. declare module BABYLON.GLTF2.Loader.Extensions {
  83642. /**
  83643. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83644. * !!! Experimental Extension Subject to Changes !!!
  83645. */
  83646. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83647. /**
  83648. * Default ior Value from the spec.
  83649. */
  83650. private static readonly _DEFAULT_IOR;
  83651. /**
  83652. * The name of this extension.
  83653. */
  83654. readonly name: string;
  83655. /**
  83656. * Defines whether this extension is enabled.
  83657. */
  83658. enabled: boolean;
  83659. /**
  83660. * Defines a number that determines the order the extensions are applied.
  83661. */
  83662. order: number;
  83663. private _loader;
  83664. /** @hidden */
  83665. constructor(loader: GLTFLoader);
  83666. /** @hidden */
  83667. dispose(): void;
  83668. /** @hidden */
  83669. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83670. private _loadIorPropertiesAsync;
  83671. }
  83672. }
  83673. declare module BABYLON.GLTF2.Loader.Extensions {
  83674. /**
  83675. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83676. * !!! Experimental Extension Subject to Changes !!!
  83677. */
  83678. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83679. /**
  83680. * The name of this extension.
  83681. */
  83682. readonly name: string;
  83683. /**
  83684. * Defines whether this extension is enabled.
  83685. */
  83686. enabled: boolean;
  83687. private _loader;
  83688. private _variants?;
  83689. /** @hidden */
  83690. constructor(loader: GLTFLoader);
  83691. /** @hidden */
  83692. dispose(): void;
  83693. /**
  83694. * Gets the list of available variant names for this asset.
  83695. * @param rootMesh The glTF root mesh
  83696. * @returns the list of all the variant names for this model
  83697. */
  83698. static GetAvailableVariants(rootMesh: Mesh): string[];
  83699. /**
  83700. * Gets the list of available variant names for this asset.
  83701. * @param rootMesh The glTF root mesh
  83702. * @returns the list of all the variant names for this model
  83703. */
  83704. getAvailableVariants(rootMesh: Mesh): string[];
  83705. /**
  83706. * Select a variant given a variant name or a list of variant names.
  83707. * @param rootMesh The glTF root mesh
  83708. * @param variantName The variant name(s) to select.
  83709. */
  83710. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83711. /**
  83712. * Select a variant given a variant name or a list of variant names.
  83713. * @param rootMesh The glTF root mesh
  83714. * @param variantName The variant name(s) to select.
  83715. */
  83716. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83717. /**
  83718. * Reset back to the original before selecting a variant.
  83719. * @param rootMesh The glTF root mesh
  83720. */
  83721. static Reset(rootMesh: Mesh): void;
  83722. /**
  83723. * Reset back to the original before selecting a variant.
  83724. * @param rootMesh The glTF root mesh
  83725. */
  83726. reset(rootMesh: Mesh): void;
  83727. /**
  83728. * Gets the last selected variant name(s) or null if original.
  83729. * @param rootMesh The glTF root mesh
  83730. * @returns The selected variant name(s).
  83731. */
  83732. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83733. /**
  83734. * Gets the last selected variant name(s) or null if original.
  83735. * @param rootMesh The glTF root mesh
  83736. * @returns The selected variant name(s).
  83737. */
  83738. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83739. private static _GetExtensionMetadata;
  83740. /** @hidden */
  83741. onLoading(): void;
  83742. /** @hidden */
  83743. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83744. }
  83745. }
  83746. declare module BABYLON.GLTF2.Loader.Extensions {
  83747. /**
  83748. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83749. * !!! Experimental Extension Subject to Changes !!!
  83750. */
  83751. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83752. /**
  83753. * The name of this extension.
  83754. */
  83755. readonly name: string;
  83756. /**
  83757. * Defines whether this extension is enabled.
  83758. */
  83759. enabled: boolean;
  83760. /**
  83761. * Defines a number that determines the order the extensions are applied.
  83762. */
  83763. order: number;
  83764. private _loader;
  83765. /** @hidden */
  83766. constructor(loader: GLTFLoader);
  83767. /** @hidden */
  83768. dispose(): void;
  83769. /** @hidden */
  83770. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83771. private _loadTransparentPropertiesAsync;
  83772. }
  83773. }
  83774. declare module BABYLON.GLTF2.Loader.Extensions {
  83775. /**
  83776. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83777. */
  83778. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83779. /**
  83780. * The name of this extension.
  83781. */
  83782. readonly name: string;
  83783. /**
  83784. * Defines whether this extension is enabled.
  83785. */
  83786. enabled: boolean;
  83787. /** @hidden */
  83788. constructor(loader: GLTFLoader);
  83789. /** @hidden */
  83790. dispose(): void;
  83791. }
  83792. }
  83793. declare module BABYLON.GLTF2.Loader.Extensions {
  83794. /**
  83795. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83796. * !!! Experimental Extension Subject to Changes !!!
  83797. */
  83798. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83799. /** The name of this extension. */
  83800. readonly name: string;
  83801. /** Defines whether this extension is enabled. */
  83802. enabled: boolean;
  83803. private _loader;
  83804. /** @hidden */
  83805. constructor(loader: GLTFLoader);
  83806. /** @hidden */
  83807. dispose(): void;
  83808. /** @hidden */
  83809. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83810. }
  83811. }
  83812. declare module BABYLON.GLTF2.Loader.Extensions {
  83813. /**
  83814. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83815. */
  83816. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83817. /**
  83818. * The name of this extension.
  83819. */
  83820. readonly name: string;
  83821. /**
  83822. * Defines whether this extension is enabled.
  83823. */
  83824. enabled: boolean;
  83825. private _loader;
  83826. /** @hidden */
  83827. constructor(loader: GLTFLoader);
  83828. /** @hidden */
  83829. dispose(): void;
  83830. /** @hidden */
  83831. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83832. }
  83833. }
  83834. declare module BABYLON.GLTF2.Loader.Extensions {
  83835. /**
  83836. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83837. * !!! Experimental Extension Subject to Changes !!!
  83838. */
  83839. export class KHR_xmp implements IGLTFLoaderExtension {
  83840. /**
  83841. * The name of this extension.
  83842. */
  83843. readonly name: string;
  83844. /**
  83845. * Defines whether this extension is enabled.
  83846. */
  83847. enabled: boolean;
  83848. /**
  83849. * Defines a number that determines the order the extensions are applied.
  83850. */
  83851. order: number;
  83852. private _loader;
  83853. /** @hidden */
  83854. constructor(loader: GLTFLoader);
  83855. /** @hidden */
  83856. dispose(): void;
  83857. /**
  83858. * Called after the loader state changes to LOADING.
  83859. */
  83860. onLoading(): void;
  83861. }
  83862. }
  83863. declare module BABYLON.GLTF2.Loader.Extensions {
  83864. /**
  83865. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83866. */
  83867. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83868. /**
  83869. * The name of this extension.
  83870. */
  83871. readonly name: string;
  83872. /**
  83873. * Defines whether this extension is enabled.
  83874. */
  83875. enabled: boolean;
  83876. private _loader;
  83877. private _clips;
  83878. private _emitters;
  83879. /** @hidden */
  83880. constructor(loader: GLTFLoader);
  83881. /** @hidden */
  83882. dispose(): void;
  83883. /** @hidden */
  83884. onLoading(): void;
  83885. /** @hidden */
  83886. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83887. /** @hidden */
  83888. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83889. /** @hidden */
  83890. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83891. private _loadClipAsync;
  83892. private _loadEmitterAsync;
  83893. private _getEventAction;
  83894. private _loadAnimationEventAsync;
  83895. }
  83896. }
  83897. declare module BABYLON.GLTF2.Loader.Extensions {
  83898. /**
  83899. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83900. */
  83901. export class MSFT_lod implements IGLTFLoaderExtension {
  83902. /**
  83903. * The name of this extension.
  83904. */
  83905. readonly name: string;
  83906. /**
  83907. * Defines whether this extension is enabled.
  83908. */
  83909. enabled: boolean;
  83910. /**
  83911. * Defines a number that determines the order the extensions are applied.
  83912. */
  83913. order: number;
  83914. /**
  83915. * Maximum number of LODs to load, starting from the lowest LOD.
  83916. */
  83917. maxLODsToLoad: number;
  83918. /**
  83919. * Observable raised when all node LODs of one level are loaded.
  83920. * The event data is the index of the loaded LOD starting from zero.
  83921. * Dispose the loader to cancel the loading of the next level of LODs.
  83922. */
  83923. onNodeLODsLoadedObservable: Observable<number>;
  83924. /**
  83925. * Observable raised when all material LODs of one level are loaded.
  83926. * The event data is the index of the loaded LOD starting from zero.
  83927. * Dispose the loader to cancel the loading of the next level of LODs.
  83928. */
  83929. onMaterialLODsLoadedObservable: Observable<number>;
  83930. private _loader;
  83931. private _bufferLODs;
  83932. private _nodeIndexLOD;
  83933. private _nodeSignalLODs;
  83934. private _nodePromiseLODs;
  83935. private _nodeBufferLODs;
  83936. private _materialIndexLOD;
  83937. private _materialSignalLODs;
  83938. private _materialPromiseLODs;
  83939. private _materialBufferLODs;
  83940. /** @hidden */
  83941. constructor(loader: GLTFLoader);
  83942. /** @hidden */
  83943. dispose(): void;
  83944. /** @hidden */
  83945. onReady(): void;
  83946. /** @hidden */
  83947. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83948. /** @hidden */
  83949. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83950. /** @hidden */
  83951. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83952. /** @hidden */
  83953. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83954. /** @hidden */
  83955. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83956. private _loadBufferLOD;
  83957. /**
  83958. * Gets an array of LOD properties from lowest to highest.
  83959. */
  83960. private _getLODs;
  83961. private _disposeTransformNode;
  83962. private _disposeMaterials;
  83963. }
  83964. }
  83965. declare module BABYLON.GLTF2.Loader.Extensions {
  83966. /** @hidden */
  83967. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83968. readonly name: string;
  83969. enabled: boolean;
  83970. private _loader;
  83971. constructor(loader: GLTFLoader);
  83972. dispose(): void;
  83973. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83974. }
  83975. }
  83976. declare module BABYLON.GLTF2.Loader.Extensions {
  83977. /** @hidden */
  83978. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83979. readonly name: string;
  83980. enabled: boolean;
  83981. private _loader;
  83982. constructor(loader: GLTFLoader);
  83983. dispose(): void;
  83984. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83985. }
  83986. }
  83987. declare module BABYLON.GLTF2.Loader.Extensions {
  83988. /**
  83989. * Store glTF extras (if present) in BJS objects' metadata
  83990. */
  83991. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83992. /**
  83993. * The name of this extension.
  83994. */
  83995. readonly name: string;
  83996. /**
  83997. * Defines whether this extension is enabled.
  83998. */
  83999. enabled: boolean;
  84000. private _loader;
  84001. private _assignExtras;
  84002. /** @hidden */
  84003. constructor(loader: GLTFLoader);
  84004. /** @hidden */
  84005. dispose(): void;
  84006. /** @hidden */
  84007. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84008. /** @hidden */
  84009. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84010. /** @hidden */
  84011. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84012. }
  84013. }
  84014. declare module BABYLON {
  84015. /**
  84016. * Class reading and parsing the MTL file bundled with the obj file.
  84017. */
  84018. export class MTLFileLoader {
  84019. /**
  84020. * Invert Y-Axis of referenced textures on load
  84021. */
  84022. static INVERT_TEXTURE_Y: boolean;
  84023. /**
  84024. * All material loaded from the mtl will be set here
  84025. */
  84026. materials: StandardMaterial[];
  84027. /**
  84028. * This function will read the mtl file and create each material described inside
  84029. * This function could be improve by adding :
  84030. * -some component missing (Ni, Tf...)
  84031. * -including the specific options available
  84032. *
  84033. * @param scene defines the scene the material will be created in
  84034. * @param data defines the mtl data to parse
  84035. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84036. * @param forAssetContainer defines if the material should be registered in the scene
  84037. */
  84038. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84039. /**
  84040. * Gets the texture for the material.
  84041. *
  84042. * If the material is imported from input file,
  84043. * We sanitize the url to ensure it takes the textre from aside the material.
  84044. *
  84045. * @param rootUrl The root url to load from
  84046. * @param value The value stored in the mtl
  84047. * @return The Texture
  84048. */
  84049. private static _getTexture;
  84050. }
  84051. }
  84052. declare module BABYLON {
  84053. /**
  84054. * Options for loading OBJ/MTL files
  84055. */
  84056. type MeshLoadOptions = {
  84057. /**
  84058. * Defines if UVs are optimized by default during load.
  84059. */
  84060. OptimizeWithUV: boolean;
  84061. /**
  84062. * Defines custom scaling of UV coordinates of loaded meshes.
  84063. */
  84064. UVScaling: Vector2;
  84065. /**
  84066. * Invert model on y-axis (does a model scaling inversion)
  84067. */
  84068. InvertY: boolean;
  84069. /**
  84070. * Invert Y-Axis of referenced textures on load
  84071. */
  84072. InvertTextureY: boolean;
  84073. /**
  84074. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84075. */
  84076. ImportVertexColors: boolean;
  84077. /**
  84078. * Compute the normals for the model, even if normals are present in the file.
  84079. */
  84080. ComputeNormals: boolean;
  84081. /**
  84082. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84083. */
  84084. SkipMaterials: boolean;
  84085. /**
  84086. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84087. */
  84088. MaterialLoadingFailsSilently: boolean;
  84089. };
  84090. /**
  84091. * OBJ file type loader.
  84092. * This is a babylon scene loader plugin.
  84093. */
  84094. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84095. /**
  84096. * Defines if UVs are optimized by default during load.
  84097. */
  84098. static OPTIMIZE_WITH_UV: boolean;
  84099. /**
  84100. * Invert model on y-axis (does a model scaling inversion)
  84101. */
  84102. static INVERT_Y: boolean;
  84103. /**
  84104. * Invert Y-Axis of referenced textures on load
  84105. */
  84106. static get INVERT_TEXTURE_Y(): boolean;
  84107. static set INVERT_TEXTURE_Y(value: boolean);
  84108. /**
  84109. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84110. */
  84111. static IMPORT_VERTEX_COLORS: boolean;
  84112. /**
  84113. * Compute the normals for the model, even if normals are present in the file.
  84114. */
  84115. static COMPUTE_NORMALS: boolean;
  84116. /**
  84117. * Defines custom scaling of UV coordinates of loaded meshes.
  84118. */
  84119. static UV_SCALING: Vector2;
  84120. /**
  84121. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84122. */
  84123. static SKIP_MATERIALS: boolean;
  84124. /**
  84125. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84126. *
  84127. * Defaults to true for backwards compatibility.
  84128. */
  84129. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84130. /**
  84131. * Defines the name of the plugin.
  84132. */
  84133. name: string;
  84134. /**
  84135. * Defines the extension the plugin is able to load.
  84136. */
  84137. extensions: string;
  84138. /** @hidden */
  84139. obj: RegExp;
  84140. /** @hidden */
  84141. group: RegExp;
  84142. /** @hidden */
  84143. mtllib: RegExp;
  84144. /** @hidden */
  84145. usemtl: RegExp;
  84146. /** @hidden */
  84147. smooth: RegExp;
  84148. /** @hidden */
  84149. vertexPattern: RegExp;
  84150. /** @hidden */
  84151. normalPattern: RegExp;
  84152. /** @hidden */
  84153. uvPattern: RegExp;
  84154. /** @hidden */
  84155. facePattern1: RegExp;
  84156. /** @hidden */
  84157. facePattern2: RegExp;
  84158. /** @hidden */
  84159. facePattern3: RegExp;
  84160. /** @hidden */
  84161. facePattern4: RegExp;
  84162. /** @hidden */
  84163. facePattern5: RegExp;
  84164. private _forAssetContainer;
  84165. private _meshLoadOptions;
  84166. /**
  84167. * Creates loader for .OBJ files
  84168. *
  84169. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84170. */
  84171. constructor(meshLoadOptions?: MeshLoadOptions);
  84172. private static get currentMeshLoadOptions();
  84173. /**
  84174. * Calls synchronously the MTL file attached to this obj.
  84175. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84176. * Without this function materials are not displayed in the first frame (but displayed after).
  84177. * In consequence it is impossible to get material information in your HTML file
  84178. *
  84179. * @param url The URL of the MTL file
  84180. * @param rootUrl
  84181. * @param onSuccess Callback function to be called when the MTL file is loaded
  84182. * @private
  84183. */
  84184. private _loadMTL;
  84185. /**
  84186. * Instantiates a OBJ file loader plugin.
  84187. * @returns the created plugin
  84188. */
  84189. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84190. /**
  84191. * If the data string can be loaded directly.
  84192. *
  84193. * @param data string containing the file data
  84194. * @returns if the data can be loaded directly
  84195. */
  84196. canDirectLoad(data: string): boolean;
  84197. /**
  84198. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84199. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84200. * @param scene the scene the meshes should be added to
  84201. * @param data the OBJ data to load
  84202. * @param rootUrl root url to load from
  84203. * @param onProgress event that fires when loading progress has occured
  84204. * @param fileName Defines the name of the file to load
  84205. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84206. */
  84207. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84208. meshes: AbstractMesh[];
  84209. particleSystems: IParticleSystem[];
  84210. skeletons: Skeleton[];
  84211. animationGroups: AnimationGroup[];
  84212. }>;
  84213. /**
  84214. * Imports all objects from the loaded OBJ data and adds them to the scene
  84215. * @param scene the scene the objects should be added to
  84216. * @param data the OBJ data to load
  84217. * @param rootUrl root url to load from
  84218. * @param onProgress event that fires when loading progress has occured
  84219. * @param fileName Defines the name of the file to load
  84220. * @returns a promise which completes when objects have been loaded to the scene
  84221. */
  84222. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84223. /**
  84224. * Load into an asset container.
  84225. * @param scene The scene to load into
  84226. * @param data The data to import
  84227. * @param rootUrl The root url for scene and resources
  84228. * @param onProgress The callback when the load progresses
  84229. * @param fileName Defines the name of the file to load
  84230. * @returns The loaded asset container
  84231. */
  84232. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84233. /**
  84234. * Read the OBJ file and create an Array of meshes.
  84235. * Each mesh contains all information given by the OBJ and the MTL file.
  84236. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84237. *
  84238. * @param meshesNames
  84239. * @param scene Scene The scene where are displayed the data
  84240. * @param data String The content of the obj file
  84241. * @param rootUrl String The path to the folder
  84242. * @returns Array<AbstractMesh>
  84243. * @private
  84244. */
  84245. private _parseSolid;
  84246. }
  84247. }
  84248. declare module BABYLON {
  84249. /**
  84250. * STL file type loader.
  84251. * This is a babylon scene loader plugin.
  84252. */
  84253. export class STLFileLoader implements ISceneLoaderPlugin {
  84254. /** @hidden */
  84255. solidPattern: RegExp;
  84256. /** @hidden */
  84257. facetsPattern: RegExp;
  84258. /** @hidden */
  84259. normalPattern: RegExp;
  84260. /** @hidden */
  84261. vertexPattern: RegExp;
  84262. /**
  84263. * Defines the name of the plugin.
  84264. */
  84265. name: string;
  84266. /**
  84267. * Defines the extensions the stl loader is able to load.
  84268. * force data to come in as an ArrayBuffer
  84269. * we'll convert to string if it looks like it's an ASCII .stl
  84270. */
  84271. extensions: ISceneLoaderPluginExtensions;
  84272. /**
  84273. * Import meshes into a scene.
  84274. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84275. * @param scene The scene to import into
  84276. * @param data The data to import
  84277. * @param rootUrl The root url for scene and resources
  84278. * @param meshes The meshes array to import into
  84279. * @param particleSystems The particle systems array to import into
  84280. * @param skeletons The skeletons array to import into
  84281. * @param onError The callback when import fails
  84282. * @returns True if successful or false otherwise
  84283. */
  84284. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84285. /**
  84286. * Load into a scene.
  84287. * @param scene The scene to load into
  84288. * @param data The data to import
  84289. * @param rootUrl The root url for scene and resources
  84290. * @param onError The callback when import fails
  84291. * @returns true if successful or false otherwise
  84292. */
  84293. load(scene: Scene, data: any, rootUrl: string): boolean;
  84294. /**
  84295. * Load into an asset container.
  84296. * @param scene The scene to load into
  84297. * @param data The data to import
  84298. * @param rootUrl The root url for scene and resources
  84299. * @param onError The callback when import fails
  84300. * @returns The loaded asset container
  84301. */
  84302. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84303. private _isBinary;
  84304. private _parseBinary;
  84305. private _parseASCII;
  84306. }
  84307. }
  84308. declare module BABYLON {
  84309. /**
  84310. * Class for generating OBJ data from a Babylon scene.
  84311. */
  84312. export class OBJExport {
  84313. /**
  84314. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84315. * @param mesh defines the list of meshes to serialize
  84316. * @param materials defines if materials should be exported
  84317. * @param matlibname defines the name of the associated mtl file
  84318. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84319. * @returns the OBJ content
  84320. */
  84321. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84322. /**
  84323. * Exports the material(s) of a mesh in .MTL file format (text)
  84324. * @param mesh defines the mesh to extract the material from
  84325. * @returns the mtl content
  84326. */
  84327. static MTL(mesh: Mesh): string;
  84328. }
  84329. }
  84330. declare module BABYLON {
  84331. /** @hidden */
  84332. export var __IGLTFExporterExtension: number;
  84333. /**
  84334. * Interface for extending the exporter
  84335. * @hidden
  84336. */
  84337. export interface IGLTFExporterExtension {
  84338. /**
  84339. * The name of this extension
  84340. */
  84341. readonly name: string;
  84342. /**
  84343. * Defines whether this extension is enabled
  84344. */
  84345. enabled: boolean;
  84346. /**
  84347. * Defines whether this extension is required
  84348. */
  84349. required: boolean;
  84350. }
  84351. }
  84352. declare module BABYLON.GLTF2.Exporter {
  84353. /** @hidden */
  84354. export var __IGLTFExporterExtensionV2: number;
  84355. /**
  84356. * Interface for a glTF exporter extension
  84357. * @hidden
  84358. */
  84359. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84360. /**
  84361. * Define this method to modify the default behavior before exporting a texture
  84362. * @param context The context when loading the asset
  84363. * @param babylonTexture The Babylon.js texture
  84364. * @param mimeType The mime-type of the generated image
  84365. * @returns A promise that resolves with the exported texture
  84366. */
  84367. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84368. /**
  84369. * Define this method to get notified when a texture info is created
  84370. * @param context The context when loading the asset
  84371. * @param textureInfo The glTF texture info
  84372. * @param babylonTexture The Babylon.js texture
  84373. */
  84374. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84375. /**
  84376. * Define this method to modify the default behavior when exporting texture info
  84377. * @param context The context when loading the asset
  84378. * @param meshPrimitive glTF mesh primitive
  84379. * @param babylonSubMesh Babylon submesh
  84380. * @param binaryWriter glTF serializer binary writer instance
  84381. * @returns nullable IMeshPrimitive promise
  84382. */
  84383. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84384. /**
  84385. * Define this method to modify the default behavior when exporting a node
  84386. * @param context The context when exporting the node
  84387. * @param node glTF node
  84388. * @param babylonNode BabylonJS node
  84389. * @returns nullable INode promise
  84390. */
  84391. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84392. [key: number]: number;
  84393. }): Promise<Nullable<INode>>;
  84394. /**
  84395. * Define this method to modify the default behavior when exporting a material
  84396. * @param material glTF material
  84397. * @param babylonMaterial BabylonJS material
  84398. * @returns nullable IMaterial promise
  84399. */
  84400. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84401. /**
  84402. * Define this method to return additional textures to export from a material
  84403. * @param material glTF material
  84404. * @param babylonMaterial BabylonJS material
  84405. * @returns List of textures
  84406. */
  84407. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84408. /** Gets a boolean indicating that this extension was used */
  84409. wasUsed: boolean;
  84410. /** Gets a boolean indicating that this extension is required for the file to work */
  84411. required: boolean;
  84412. /**
  84413. * Called after the exporter state changes to EXPORTING
  84414. */
  84415. onExporting?(): void;
  84416. }
  84417. }
  84418. declare module BABYLON.GLTF2.Exporter {
  84419. /**
  84420. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84421. * @hidden
  84422. */
  84423. export class _GLTFMaterialExporter {
  84424. /**
  84425. * Represents the dielectric specular values for R, G and B
  84426. */
  84427. private static readonly _DielectricSpecular;
  84428. /**
  84429. * Allows the maximum specular power to be defined for material calculations
  84430. */
  84431. private static readonly _MaxSpecularPower;
  84432. /**
  84433. * Mapping to store textures
  84434. */
  84435. private _textureMap;
  84436. /**
  84437. * Numeric tolerance value
  84438. */
  84439. private static readonly _Epsilon;
  84440. /**
  84441. * Reference to the glTF Exporter
  84442. */
  84443. private _exporter;
  84444. constructor(exporter: _Exporter);
  84445. /**
  84446. * Specifies if two colors are approximately equal in value
  84447. * @param color1 first color to compare to
  84448. * @param color2 second color to compare to
  84449. * @param epsilon threshold value
  84450. */
  84451. private static FuzzyEquals;
  84452. /**
  84453. * Gets the materials from a Babylon scene and converts them to glTF materials
  84454. * @param scene babylonjs scene
  84455. * @param mimeType texture mime type
  84456. * @param images array of images
  84457. * @param textures array of textures
  84458. * @param materials array of materials
  84459. * @param imageData mapping of texture names to base64 textures
  84460. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84461. */
  84462. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84463. /**
  84464. * Makes a copy of the glTF material without the texture parameters
  84465. * @param originalMaterial original glTF material
  84466. * @returns glTF material without texture parameters
  84467. */
  84468. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84469. /**
  84470. * Specifies if the material has any texture parameters present
  84471. * @param material glTF Material
  84472. * @returns boolean specifying if texture parameters are present
  84473. */
  84474. _hasTexturesPresent(material: IMaterial): boolean;
  84475. /**
  84476. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84477. * @param babylonStandardMaterial
  84478. * @returns glTF Metallic Roughness Material representation
  84479. */
  84480. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84481. /**
  84482. * Computes the metallic factor
  84483. * @param diffuse diffused value
  84484. * @param specular specular value
  84485. * @param oneMinusSpecularStrength one minus the specular strength
  84486. * @returns metallic value
  84487. */
  84488. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84489. /**
  84490. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84491. * @param glTFMaterial glTF material
  84492. * @param babylonMaterial Babylon material
  84493. */
  84494. private static _SetAlphaMode;
  84495. /**
  84496. * Converts a Babylon Standard Material to a glTF Material
  84497. * @param babylonStandardMaterial BJS Standard Material
  84498. * @param mimeType mime type to use for the textures
  84499. * @param images array of glTF image interfaces
  84500. * @param textures array of glTF texture interfaces
  84501. * @param materials array of glTF material interfaces
  84502. * @param imageData map of image file name to data
  84503. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84504. */
  84505. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84506. private _finishMaterial;
  84507. /**
  84508. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84509. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84510. * @param mimeType mime type to use for the textures
  84511. * @param images array of glTF image interfaces
  84512. * @param textures array of glTF texture interfaces
  84513. * @param materials array of glTF material interfaces
  84514. * @param imageData map of image file name to data
  84515. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84516. */
  84517. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84518. /**
  84519. * Converts an image typed array buffer to a base64 image
  84520. * @param buffer typed array buffer
  84521. * @param width width of the image
  84522. * @param height height of the image
  84523. * @param mimeType mimetype of the image
  84524. * @returns base64 image string
  84525. */
  84526. private _createBase64FromCanvasAsync;
  84527. /**
  84528. * Generates a white texture based on the specified width and height
  84529. * @param width width of the texture in pixels
  84530. * @param height height of the texture in pixels
  84531. * @param scene babylonjs scene
  84532. * @returns white texture
  84533. */
  84534. private _createWhiteTexture;
  84535. /**
  84536. * 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
  84537. * @param texture1 first texture to resize
  84538. * @param texture2 second texture to resize
  84539. * @param scene babylonjs scene
  84540. * @returns resized textures or null
  84541. */
  84542. private _resizeTexturesToSameDimensions;
  84543. /**
  84544. * Converts an array of pixels to a Float32Array
  84545. * Throws an error if the pixel format is not supported
  84546. * @param pixels - array buffer containing pixel values
  84547. * @returns Float32 of pixels
  84548. */
  84549. private _convertPixelArrayToFloat32;
  84550. /**
  84551. * Convert Specular Glossiness Textures to Metallic Roughness
  84552. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84553. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84554. * @param diffuseTexture texture used to store diffuse information
  84555. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84556. * @param factors specular glossiness material factors
  84557. * @param mimeType the mime type to use for the texture
  84558. * @returns pbr metallic roughness interface or null
  84559. */
  84560. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84561. /**
  84562. * Converts specular glossiness material properties to metallic roughness
  84563. * @param specularGlossiness interface with specular glossiness material properties
  84564. * @returns interface with metallic roughness material properties
  84565. */
  84566. private _convertSpecularGlossinessToMetallicRoughness;
  84567. /**
  84568. * Calculates the surface reflectance, independent of lighting conditions
  84569. * @param color Color source to calculate brightness from
  84570. * @returns number representing the perceived brightness, or zero if color is undefined
  84571. */
  84572. private _getPerceivedBrightness;
  84573. /**
  84574. * Returns the maximum color component value
  84575. * @param color
  84576. * @returns maximum color component value, or zero if color is null or undefined
  84577. */
  84578. private _getMaxComponent;
  84579. /**
  84580. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84581. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84582. * @param mimeType mime type to use for the textures
  84583. * @param images array of glTF image interfaces
  84584. * @param textures array of glTF texture interfaces
  84585. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84586. * @param imageData map of image file name to data
  84587. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84588. * @returns glTF PBR Metallic Roughness factors
  84589. */
  84590. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84591. private _getGLTFTextureSampler;
  84592. private _getGLTFTextureWrapMode;
  84593. private _getGLTFTextureWrapModesSampler;
  84594. /**
  84595. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84596. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84597. * @param mimeType mime type to use for the textures
  84598. * @param images array of glTF image interfaces
  84599. * @param textures array of glTF texture interfaces
  84600. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84601. * @param imageData map of image file name to data
  84602. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84603. * @returns glTF PBR Metallic Roughness factors
  84604. */
  84605. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84606. /**
  84607. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84608. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84609. * @param mimeType mime type to use for the textures
  84610. * @param images array of glTF image interfaces
  84611. * @param textures array of glTF texture interfaces
  84612. * @param materials array of glTF material interfaces
  84613. * @param imageData map of image file name to data
  84614. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84615. */
  84616. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84617. private setMetallicRoughnessPbrMaterial;
  84618. private getPixelsFromTexture;
  84619. /**
  84620. * Extracts a texture from a Babylon texture into file data and glTF data
  84621. * @param babylonTexture Babylon texture to extract
  84622. * @param mimeType Mime Type of the babylonTexture
  84623. * @return glTF texture info, or null if the texture format is not supported
  84624. */
  84625. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84626. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84627. /**
  84628. * Builds a texture from base64 string
  84629. * @param base64Texture base64 texture string
  84630. * @param baseTextureName Name to use for the texture
  84631. * @param mimeType image mime type for the texture
  84632. * @param images array of images
  84633. * @param textures array of textures
  84634. * @param imageData map of image data
  84635. * @returns glTF texture info, or null if the texture format is not supported
  84636. */
  84637. private _getTextureInfoFromBase64;
  84638. }
  84639. }
  84640. declare module BABYLON {
  84641. /**
  84642. * Class for holding and downloading glTF file data
  84643. */
  84644. export class GLTFData {
  84645. /**
  84646. * Object which contains the file name as the key and its data as the value
  84647. */
  84648. glTFFiles: {
  84649. [fileName: string]: string | Blob;
  84650. };
  84651. /**
  84652. * Initializes the glTF file object
  84653. */
  84654. constructor();
  84655. /**
  84656. * Downloads the glTF data as files based on their names and data
  84657. */
  84658. downloadFiles(): void;
  84659. }
  84660. }
  84661. declare module BABYLON {
  84662. /**
  84663. * Holds a collection of exporter options and parameters
  84664. */
  84665. export interface IExportOptions {
  84666. /**
  84667. * Function which indicates whether a babylon node should be exported or not
  84668. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84669. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84670. */
  84671. shouldExportNode?(node: Node): boolean;
  84672. /**
  84673. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84674. * @param metadata source metadata to read from
  84675. * @returns the data to store to glTF node extras
  84676. */
  84677. metadataSelector?(metadata: any): any;
  84678. /**
  84679. * The sample rate to bake animation curves
  84680. */
  84681. animationSampleRate?: number;
  84682. /**
  84683. * Begin serialization without waiting for the scene to be ready
  84684. */
  84685. exportWithoutWaitingForScene?: boolean;
  84686. /**
  84687. * Indicates if coordinate system swapping root nodes should be included in export
  84688. */
  84689. includeCoordinateSystemConversionNodes?: boolean;
  84690. }
  84691. /**
  84692. * Class for generating glTF data from a Babylon scene.
  84693. */
  84694. export class GLTF2Export {
  84695. /**
  84696. * Exports the geometry of the scene to .gltf file format asynchronously
  84697. * @param scene Babylon scene with scene hierarchy information
  84698. * @param filePrefix File prefix to use when generating the glTF file
  84699. * @param options Exporter options
  84700. * @returns Returns an object with a .gltf file and associates texture names
  84701. * as keys and their data and paths as values
  84702. */
  84703. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84704. private static _PreExportAsync;
  84705. private static _PostExportAsync;
  84706. /**
  84707. * Exports the geometry of the scene to .glb file format asychronously
  84708. * @param scene Babylon scene with scene hierarchy information
  84709. * @param filePrefix File prefix to use when generating glb file
  84710. * @param options Exporter options
  84711. * @returns Returns an object with a .glb filename as key and data as value
  84712. */
  84713. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84714. }
  84715. }
  84716. declare module BABYLON.GLTF2.Exporter {
  84717. /**
  84718. * @hidden
  84719. */
  84720. export class _GLTFUtilities {
  84721. /**
  84722. * Creates a buffer view based on the supplied arguments
  84723. * @param bufferIndex index value of the specified buffer
  84724. * @param byteOffset byte offset value
  84725. * @param byteLength byte length of the bufferView
  84726. * @param byteStride byte distance between conequential elements
  84727. * @param name name of the buffer view
  84728. * @returns bufferView for glTF
  84729. */
  84730. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84731. /**
  84732. * Creates an accessor based on the supplied arguments
  84733. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84734. * @param name The name of the accessor
  84735. * @param type The type of the accessor
  84736. * @param componentType The datatype of components in the attribute
  84737. * @param count The number of attributes referenced by this accessor
  84738. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84739. * @param min Minimum value of each component in this attribute
  84740. * @param max Maximum value of each component in this attribute
  84741. * @returns accessor for glTF
  84742. */
  84743. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84744. /**
  84745. * Calculates the minimum and maximum values of an array of position floats
  84746. * @param positions Positions array of a mesh
  84747. * @param vertexStart Starting vertex offset to calculate min and max values
  84748. * @param vertexCount Number of vertices to check for min and max values
  84749. * @returns min number array and max number array
  84750. */
  84751. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84752. min: number[];
  84753. max: number[];
  84754. };
  84755. /**
  84756. * Converts a new right-handed Vector3
  84757. * @param vector vector3 array
  84758. * @returns right-handed Vector3
  84759. */
  84760. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84761. /**
  84762. * Converts a Vector3 to right-handed
  84763. * @param vector Vector3 to convert to right-handed
  84764. */
  84765. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84766. /**
  84767. * Converts a three element number array to right-handed
  84768. * @param vector number array to convert to right-handed
  84769. */
  84770. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84771. /**
  84772. * Converts a new right-handed Vector3
  84773. * @param vector vector3 array
  84774. * @returns right-handed Vector3
  84775. */
  84776. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84777. /**
  84778. * Converts a Vector3 to right-handed
  84779. * @param vector Vector3 to convert to right-handed
  84780. */
  84781. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84782. /**
  84783. * Converts a three element number array to right-handed
  84784. * @param vector number array to convert to right-handed
  84785. */
  84786. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84787. /**
  84788. * Converts a Vector4 to right-handed
  84789. * @param vector Vector4 to convert to right-handed
  84790. */
  84791. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84792. /**
  84793. * Converts a Vector4 to right-handed
  84794. * @param vector Vector4 to convert to right-handed
  84795. */
  84796. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84797. /**
  84798. * Converts a Quaternion to right-handed
  84799. * @param quaternion Source quaternion to convert to right-handed
  84800. */
  84801. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84802. /**
  84803. * Converts a Quaternion to right-handed
  84804. * @param quaternion Source quaternion to convert to right-handed
  84805. */
  84806. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84807. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84808. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84809. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84810. }
  84811. }
  84812. declare module BABYLON.GLTF2.Exporter {
  84813. /**
  84814. * Converts Babylon Scene into glTF 2.0.
  84815. * @hidden
  84816. */
  84817. export class _Exporter {
  84818. /**
  84819. * Stores the glTF to export
  84820. */
  84821. _glTF: IGLTF;
  84822. /**
  84823. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84824. */
  84825. _bufferViews: IBufferView[];
  84826. /**
  84827. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84828. */
  84829. _accessors: IAccessor[];
  84830. /**
  84831. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84832. */
  84833. _nodes: INode[];
  84834. /**
  84835. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84836. */
  84837. private _scenes;
  84838. /**
  84839. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84840. */
  84841. private _meshes;
  84842. /**
  84843. * Stores all the generated material information, which represents the appearance of each primitive
  84844. */
  84845. _materials: IMaterial[];
  84846. _materialMap: {
  84847. [materialID: number]: number;
  84848. };
  84849. /**
  84850. * Stores all the generated texture information, which is referenced by glTF materials
  84851. */
  84852. _textures: ITexture[];
  84853. /**
  84854. * Stores all the generated image information, which is referenced by glTF textures
  84855. */
  84856. _images: IImage[];
  84857. /**
  84858. * Stores all the texture samplers
  84859. */
  84860. _samplers: ISampler[];
  84861. /**
  84862. * Stores all the generated glTF skins
  84863. */
  84864. _skins: ISkin[];
  84865. /**
  84866. * Stores all the generated animation samplers, which is referenced by glTF animations
  84867. */
  84868. /**
  84869. * Stores the animations for glTF models
  84870. */
  84871. private _animations;
  84872. /**
  84873. * Stores the total amount of bytes stored in the glTF buffer
  84874. */
  84875. private _totalByteLength;
  84876. /**
  84877. * Stores a reference to the Babylon scene containing the source geometry and material information
  84878. */
  84879. _babylonScene: Scene;
  84880. /**
  84881. * Stores a map of the image data, where the key is the file name and the value
  84882. * is the image data
  84883. */
  84884. _imageData: {
  84885. [fileName: string]: {
  84886. data: Uint8Array;
  84887. mimeType: ImageMimeType;
  84888. };
  84889. };
  84890. protected _orderedImageData: Array<{
  84891. data: Uint8Array;
  84892. mimeType: ImageMimeType;
  84893. }>;
  84894. /**
  84895. * Stores a map of the unique id of a node to its index in the node array
  84896. */
  84897. _nodeMap: {
  84898. [key: number]: number;
  84899. };
  84900. /**
  84901. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84902. */
  84903. _convertToRightHandedSystem: boolean;
  84904. /**
  84905. * Specifies if a Babylon node should be converted to right-handed on export
  84906. */
  84907. _convertToRightHandedSystemMap: {
  84908. [nodeId: number]: boolean;
  84909. };
  84910. _includeCoordinateSystemConversionNodes: boolean;
  84911. /**
  84912. * Baked animation sample rate
  84913. */
  84914. private _animationSampleRate;
  84915. private _options;
  84916. private _localEngine;
  84917. _glTFMaterialExporter: _GLTFMaterialExporter;
  84918. private _extensions;
  84919. private static _ExtensionNames;
  84920. private static _ExtensionFactories;
  84921. private _applyExtension;
  84922. private _applyExtensions;
  84923. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84924. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84925. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84926. [key: number]: number;
  84927. }): Promise<Nullable<INode>>;
  84928. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84929. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84930. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84931. private _forEachExtensions;
  84932. private _extensionsOnExporting;
  84933. /**
  84934. * Load glTF serializer extensions
  84935. */
  84936. private _loadExtensions;
  84937. /**
  84938. * Creates a glTF Exporter instance, which can accept optional exporter options
  84939. * @param babylonScene Babylon scene object
  84940. * @param options Options to modify the behavior of the exporter
  84941. */
  84942. constructor(babylonScene: Scene, options?: IExportOptions);
  84943. dispose(): void;
  84944. /**
  84945. * Registers a glTF exporter extension
  84946. * @param name Name of the extension to export
  84947. * @param factory The factory function that creates the exporter extension
  84948. */
  84949. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84950. /**
  84951. * Un-registers an exporter extension
  84952. * @param name The name fo the exporter extension
  84953. * @returns A boolean indicating whether the extension has been un-registered
  84954. */
  84955. static UnregisterExtension(name: string): boolean;
  84956. /**
  84957. * Lazy load a local engine
  84958. */
  84959. _getLocalEngine(): Engine;
  84960. private reorderIndicesBasedOnPrimitiveMode;
  84961. /**
  84962. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84963. * clock-wise during export to glTF
  84964. * @param submesh BabylonJS submesh
  84965. * @param primitiveMode Primitive mode of the mesh
  84966. * @param sideOrientation the winding order of the submesh
  84967. * @param vertexBufferKind The type of vertex attribute
  84968. * @param meshAttributeArray The vertex attribute data
  84969. * @param byteOffset The offset to the binary data
  84970. * @param binaryWriter The binary data for the glTF file
  84971. * @param convertToRightHandedSystem Converts the values to right-handed
  84972. */
  84973. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84974. /**
  84975. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84976. * clock-wise during export to glTF
  84977. * @param submesh BabylonJS submesh
  84978. * @param primitiveMode Primitive mode of the mesh
  84979. * @param sideOrientation the winding order of the submesh
  84980. * @param vertexBufferKind The type of vertex attribute
  84981. * @param meshAttributeArray The vertex attribute data
  84982. * @param byteOffset The offset to the binary data
  84983. * @param binaryWriter The binary data for the glTF file
  84984. * @param convertToRightHandedSystem Converts the values to right-handed
  84985. */
  84986. private reorderTriangleFillMode;
  84987. /**
  84988. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84989. * clock-wise during export to glTF
  84990. * @param submesh BabylonJS submesh
  84991. * @param primitiveMode Primitive mode of the mesh
  84992. * @param sideOrientation the winding order of the submesh
  84993. * @param vertexBufferKind The type of vertex attribute
  84994. * @param meshAttributeArray The vertex attribute data
  84995. * @param byteOffset The offset to the binary data
  84996. * @param binaryWriter The binary data for the glTF file
  84997. * @param convertToRightHandedSystem Converts the values to right-handed
  84998. */
  84999. private reorderTriangleStripDrawMode;
  85000. /**
  85001. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85002. * clock-wise during export to glTF
  85003. * @param submesh BabylonJS submesh
  85004. * @param primitiveMode Primitive mode of the mesh
  85005. * @param sideOrientation the winding order of the submesh
  85006. * @param vertexBufferKind The type of vertex attribute
  85007. * @param meshAttributeArray The vertex attribute data
  85008. * @param byteOffset The offset to the binary data
  85009. * @param binaryWriter The binary data for the glTF file
  85010. * @param convertToRightHandedSystem Converts the values to right-handed
  85011. */
  85012. private reorderTriangleFanMode;
  85013. /**
  85014. * Writes the vertex attribute data to binary
  85015. * @param vertices The vertices to write to the binary writer
  85016. * @param byteOffset The offset into the binary writer to overwrite binary data
  85017. * @param vertexAttributeKind The vertex attribute type
  85018. * @param meshAttributeArray The vertex attribute data
  85019. * @param binaryWriter The writer containing the binary data
  85020. * @param convertToRightHandedSystem Converts the values to right-handed
  85021. */
  85022. private writeVertexAttributeData;
  85023. /**
  85024. * Writes mesh attribute data to a data buffer
  85025. * Returns the bytelength of the data
  85026. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85027. * @param meshAttributeArray Array containing the attribute data
  85028. * @param byteStride Specifies the space between data
  85029. * @param binaryWriter The buffer to write the binary data to
  85030. * @param convertToRightHandedSystem Converts the values to right-handed
  85031. */
  85032. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85033. /**
  85034. * Writes mesh attribute data to a data buffer
  85035. * Returns the bytelength of the data
  85036. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85037. * @param meshAttributeArray Array containing the attribute data
  85038. * @param byteStride Specifies the space between data
  85039. * @param binaryWriter The buffer to write the binary data to
  85040. * @param convertToRightHandedSystem Converts the values to right-handed
  85041. */
  85042. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85043. /**
  85044. * Generates glTF json data
  85045. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85046. * @param glTFPrefix Text to use when prefixing a glTF file
  85047. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85048. * @returns json data as string
  85049. */
  85050. private generateJSON;
  85051. /**
  85052. * Generates data for .gltf and .bin files based on the glTF prefix string
  85053. * @param glTFPrefix Text to use when prefixing a glTF file
  85054. * @param dispose Dispose the exporter
  85055. * @returns GLTFData with glTF file data
  85056. */
  85057. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85058. /**
  85059. * Creates a binary buffer for glTF
  85060. * @returns array buffer for binary data
  85061. */
  85062. private _generateBinaryAsync;
  85063. /**
  85064. * Pads the number to a multiple of 4
  85065. * @param num number to pad
  85066. * @returns padded number
  85067. */
  85068. private _getPadding;
  85069. /**
  85070. * @hidden
  85071. */
  85072. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85073. /**
  85074. * Sets the TRS for each node
  85075. * @param node glTF Node for storing the transformation data
  85076. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85077. * @param convertToRightHandedSystem Converts the values to right-handed
  85078. */
  85079. private setNodeTransformation;
  85080. private getVertexBufferFromMesh;
  85081. /**
  85082. * Creates a bufferview based on the vertices type for the Babylon mesh
  85083. * @param kind Indicates the type of vertices data
  85084. * @param componentType Indicates the numerical type used to store the data
  85085. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85086. * @param binaryWriter The buffer to write the bufferview data to
  85087. * @param convertToRightHandedSystem Converts the values to right-handed
  85088. */
  85089. private createBufferViewKind;
  85090. /**
  85091. * Creates a bufferview based on the vertices type for the Babylon mesh
  85092. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85093. * @param babylonMorphTarget the morph target to be exported
  85094. * @param binaryWriter The buffer to write the bufferview data to
  85095. * @param convertToRightHandedSystem Converts the values to right-handed
  85096. */
  85097. private setMorphTargetAttributes;
  85098. /**
  85099. * The primitive mode of the Babylon mesh
  85100. * @param babylonMesh The BabylonJS mesh
  85101. */
  85102. private getMeshPrimitiveMode;
  85103. /**
  85104. * Sets the primitive mode of the glTF mesh primitive
  85105. * @param meshPrimitive glTF mesh primitive
  85106. * @param primitiveMode The primitive mode
  85107. */
  85108. private setPrimitiveMode;
  85109. /**
  85110. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85111. * @param meshPrimitive glTF mesh primitive
  85112. * @param attributeKind vertex attribute
  85113. * @returns boolean specifying if uv coordinates are present
  85114. */
  85115. private setAttributeKind;
  85116. /**
  85117. * Sets data for the primitive attributes of each submesh
  85118. * @param mesh glTF Mesh object to store the primitive attribute information
  85119. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85120. * @param binaryWriter Buffer to write the attribute data to
  85121. * @param convertToRightHandedSystem Converts the values to right-handed
  85122. */
  85123. private setPrimitiveAttributesAsync;
  85124. /**
  85125. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85126. * @param node The node to check
  85127. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85128. */
  85129. private isBabylonCoordinateSystemConvertingNode;
  85130. /**
  85131. * Creates a glTF scene based on the array of meshes
  85132. * Returns the the total byte offset
  85133. * @param babylonScene Babylon scene to get the mesh data from
  85134. * @param binaryWriter Buffer to write binary data to
  85135. */
  85136. private createSceneAsync;
  85137. /**
  85138. * Creates a mapping of Node unique id to node index and handles animations
  85139. * @param babylonScene Babylon Scene
  85140. * @param nodes Babylon transform nodes
  85141. * @param binaryWriter Buffer to write binary data to
  85142. * @returns Node mapping of unique id to index
  85143. */
  85144. private createNodeMapAndAnimationsAsync;
  85145. /**
  85146. * Creates a glTF node from a Babylon mesh
  85147. * @param babylonMesh Source Babylon mesh
  85148. * @param binaryWriter Buffer for storing geometry data
  85149. * @param convertToRightHandedSystem Converts the values to right-handed
  85150. * @param nodeMap Node mapping of unique id to glTF node index
  85151. * @returns glTF node
  85152. */
  85153. private createNodeAsync;
  85154. /**
  85155. * Creates a glTF skin from a Babylon skeleton
  85156. * @param babylonScene Babylon Scene
  85157. * @param nodes Babylon transform nodes
  85158. * @param binaryWriter Buffer to write binary data to
  85159. * @returns Node mapping of unique id to index
  85160. */
  85161. private createSkinsAsync;
  85162. }
  85163. /**
  85164. * @hidden
  85165. *
  85166. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85167. */
  85168. export class _BinaryWriter {
  85169. /**
  85170. * Array buffer which stores all binary data
  85171. */
  85172. private _arrayBuffer;
  85173. /**
  85174. * View of the array buffer
  85175. */
  85176. private _dataView;
  85177. /**
  85178. * byte offset of data in array buffer
  85179. */
  85180. private _byteOffset;
  85181. /**
  85182. * Initialize binary writer with an initial byte length
  85183. * @param byteLength Initial byte length of the array buffer
  85184. */
  85185. constructor(byteLength: number);
  85186. /**
  85187. * Resize the array buffer to the specified byte length
  85188. * @param byteLength
  85189. */
  85190. private resizeBuffer;
  85191. /**
  85192. * Get an array buffer with the length of the byte offset
  85193. * @returns ArrayBuffer resized to the byte offset
  85194. */
  85195. getArrayBuffer(): ArrayBuffer;
  85196. /**
  85197. * Get the byte offset of the array buffer
  85198. * @returns byte offset
  85199. */
  85200. getByteOffset(): number;
  85201. /**
  85202. * Stores an UInt8 in the array buffer
  85203. * @param entry
  85204. * @param byteOffset If defined, specifies where to set the value as an offset.
  85205. */
  85206. setUInt8(entry: number, byteOffset?: number): void;
  85207. /**
  85208. * Stores an UInt16 in the array buffer
  85209. * @param entry
  85210. * @param byteOffset If defined, specifies where to set the value as an offset.
  85211. */
  85212. setUInt16(entry: number, byteOffset?: number): void;
  85213. /**
  85214. * Gets an UInt32 in the array buffer
  85215. * @param entry
  85216. * @param byteOffset If defined, specifies where to set the value as an offset.
  85217. */
  85218. getUInt32(byteOffset: number): number;
  85219. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85220. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85221. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85222. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85223. /**
  85224. * Stores a Float32 in the array buffer
  85225. * @param entry
  85226. */
  85227. setFloat32(entry: number, byteOffset?: number): void;
  85228. /**
  85229. * Stores an UInt32 in the array buffer
  85230. * @param entry
  85231. * @param byteOffset If defined, specifies where to set the value as an offset.
  85232. */
  85233. setUInt32(entry: number, byteOffset?: number): void;
  85234. }
  85235. }
  85236. declare module BABYLON.GLTF2.Exporter {
  85237. /**
  85238. * @hidden
  85239. * Interface to store animation data.
  85240. */
  85241. export interface _IAnimationData {
  85242. /**
  85243. * Keyframe data.
  85244. */
  85245. inputs: number[];
  85246. /**
  85247. * Value data.
  85248. */
  85249. outputs: number[][];
  85250. /**
  85251. * Animation interpolation data.
  85252. */
  85253. samplerInterpolation: AnimationSamplerInterpolation;
  85254. /**
  85255. * Minimum keyframe value.
  85256. */
  85257. inputsMin: number;
  85258. /**
  85259. * Maximum keyframe value.
  85260. */
  85261. inputsMax: number;
  85262. }
  85263. /**
  85264. * @hidden
  85265. */
  85266. export interface _IAnimationInfo {
  85267. /**
  85268. * The target channel for the animation
  85269. */
  85270. animationChannelTargetPath: AnimationChannelTargetPath;
  85271. /**
  85272. * The glTF accessor type for the data.
  85273. */
  85274. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85275. /**
  85276. * Specifies if quaternions should be used.
  85277. */
  85278. useQuaternion: boolean;
  85279. }
  85280. /**
  85281. * @hidden
  85282. * Utility class for generating glTF animation data from BabylonJS.
  85283. */
  85284. export class _GLTFAnimation {
  85285. /**
  85286. * @ignore
  85287. *
  85288. * Creates glTF channel animation from BabylonJS animation.
  85289. * @param babylonTransformNode - BabylonJS mesh.
  85290. * @param animation - animation.
  85291. * @param animationChannelTargetPath - The target animation channel.
  85292. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85293. * @param useQuaternion - Specifies if quaternions are used.
  85294. * @returns nullable IAnimationData
  85295. */
  85296. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85297. private static _DeduceAnimationInfo;
  85298. /**
  85299. * @ignore
  85300. * Create node animations from the transform node animations
  85301. * @param babylonNode
  85302. * @param runtimeGLTFAnimation
  85303. * @param idleGLTFAnimations
  85304. * @param nodeMap
  85305. * @param nodes
  85306. * @param binaryWriter
  85307. * @param bufferViews
  85308. * @param accessors
  85309. * @param convertToRightHandedSystem
  85310. * @param animationSampleRate
  85311. */
  85312. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85313. [key: number]: number;
  85314. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85315. /**
  85316. * @ignore
  85317. * Create individual morph animations from the mesh's morph target animation tracks
  85318. * @param babylonNode
  85319. * @param runtimeGLTFAnimation
  85320. * @param idleGLTFAnimations
  85321. * @param nodeMap
  85322. * @param nodes
  85323. * @param binaryWriter
  85324. * @param bufferViews
  85325. * @param accessors
  85326. * @param convertToRightHandedSystem
  85327. * @param animationSampleRate
  85328. */
  85329. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85330. [key: number]: number;
  85331. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85332. /**
  85333. * @ignore
  85334. * Create node and morph animations from the animation groups
  85335. * @param babylonScene
  85336. * @param glTFAnimations
  85337. * @param nodeMap
  85338. * @param nodes
  85339. * @param binaryWriter
  85340. * @param bufferViews
  85341. * @param accessors
  85342. * @param convertToRightHandedSystemMap
  85343. * @param animationSampleRate
  85344. */
  85345. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85346. [key: number]: number;
  85347. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85348. [nodeId: number]: boolean;
  85349. }, animationSampleRate: number): void;
  85350. private static AddAnimation;
  85351. /**
  85352. * Create a baked animation
  85353. * @param babylonTransformNode BabylonJS mesh
  85354. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85355. * @param animationChannelTargetPath animation target channel
  85356. * @param minFrame minimum animation frame
  85357. * @param maxFrame maximum animation frame
  85358. * @param fps frames per second of the animation
  85359. * @param inputs input key frames of the animation
  85360. * @param outputs output key frame data of the animation
  85361. * @param convertToRightHandedSystem converts the values to right-handed
  85362. * @param useQuaternion specifies if quaternions should be used
  85363. */
  85364. private static _CreateBakedAnimation;
  85365. private static _ConvertFactorToVector3OrQuaternion;
  85366. private static _SetInterpolatedValue;
  85367. /**
  85368. * Creates linear animation from the animation key frames
  85369. * @param babylonTransformNode BabylonJS mesh
  85370. * @param animation BabylonJS animation
  85371. * @param animationChannelTargetPath The target animation channel
  85372. * @param frameDelta The difference between the last and first frame of the animation
  85373. * @param inputs Array to store the key frame times
  85374. * @param outputs Array to store the key frame data
  85375. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85376. * @param useQuaternion Specifies if quaternions are used in the animation
  85377. */
  85378. private static _CreateLinearOrStepAnimation;
  85379. /**
  85380. * Creates cubic spline animation from the animation key frames
  85381. * @param babylonTransformNode BabylonJS mesh
  85382. * @param animation BabylonJS animation
  85383. * @param animationChannelTargetPath The target animation channel
  85384. * @param frameDelta The difference between the last and first frame of the animation
  85385. * @param inputs Array to store the key frame times
  85386. * @param outputs Array to store the key frame data
  85387. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85388. * @param useQuaternion Specifies if quaternions are used in the animation
  85389. */
  85390. private static _CreateCubicSplineAnimation;
  85391. private static _GetBasePositionRotationOrScale;
  85392. /**
  85393. * Adds a key frame value
  85394. * @param keyFrame
  85395. * @param animation
  85396. * @param outputs
  85397. * @param animationChannelTargetPath
  85398. * @param basePositionRotationOrScale
  85399. * @param convertToRightHandedSystem
  85400. * @param useQuaternion
  85401. */
  85402. private static _AddKeyframeValue;
  85403. /**
  85404. * Determine the interpolation based on the key frames
  85405. * @param keyFrames
  85406. * @param animationChannelTargetPath
  85407. * @param useQuaternion
  85408. */
  85409. private static _DeduceInterpolation;
  85410. /**
  85411. * Adds an input tangent or output tangent to the output data
  85412. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85413. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85414. * @param outputs The animation data by keyframe
  85415. * @param animationChannelTargetPath The target animation channel
  85416. * @param interpolation The interpolation type
  85417. * @param keyFrame The key frame with the animation data
  85418. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85419. * @param useQuaternion Specifies if quaternions are used
  85420. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85421. */
  85422. private static AddSplineTangent;
  85423. /**
  85424. * Get the minimum and maximum key frames' frame values
  85425. * @param keyFrames animation key frames
  85426. * @returns the minimum and maximum key frame value
  85427. */
  85428. private static calculateMinMaxKeyFrames;
  85429. }
  85430. }
  85431. declare module BABYLON.GLTF2.Exporter {
  85432. /** @hidden */
  85433. export var textureTransformPixelShader: {
  85434. name: string;
  85435. shader: string;
  85436. };
  85437. }
  85438. declare module BABYLON.GLTF2.Exporter.Extensions {
  85439. /**
  85440. * @hidden
  85441. */
  85442. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85443. private _recordedTextures;
  85444. /** Name of this extension */
  85445. readonly name: string;
  85446. /** Defines whether this extension is enabled */
  85447. enabled: boolean;
  85448. /** Defines whether this extension is required */
  85449. required: boolean;
  85450. /** Reference to the glTF exporter */
  85451. private _wasUsed;
  85452. constructor(exporter: _Exporter);
  85453. dispose(): void;
  85454. /** @hidden */
  85455. get wasUsed(): boolean;
  85456. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85457. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85458. /**
  85459. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85460. * @param babylonTexture
  85461. * @param offset
  85462. * @param rotation
  85463. * @param scale
  85464. * @param scene
  85465. */
  85466. private _textureTransformTextureAsync;
  85467. }
  85468. }
  85469. declare module BABYLON.GLTF2.Exporter.Extensions {
  85470. /**
  85471. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85472. */
  85473. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85474. /** The name of this extension. */
  85475. readonly name: string;
  85476. /** Defines whether this extension is enabled. */
  85477. enabled: boolean;
  85478. /** Defines whether this extension is required */
  85479. required: boolean;
  85480. /** Reference to the glTF exporter */
  85481. private _exporter;
  85482. private _lights;
  85483. /** @hidden */
  85484. constructor(exporter: _Exporter);
  85485. /** @hidden */
  85486. dispose(): void;
  85487. /** @hidden */
  85488. get wasUsed(): boolean;
  85489. /** @hidden */
  85490. onExporting(): void;
  85491. /**
  85492. * Define this method to modify the default behavior when exporting a node
  85493. * @param context The context when exporting the node
  85494. * @param node glTF node
  85495. * @param babylonNode BabylonJS node
  85496. * @param nodeMap Node mapping of unique id to glTF node index
  85497. * @returns nullable INode promise
  85498. */
  85499. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85500. [key: number]: number;
  85501. }): Promise<Nullable<INode>>;
  85502. }
  85503. }
  85504. declare module BABYLON.GLTF2.Exporter.Extensions {
  85505. /**
  85506. * @hidden
  85507. */
  85508. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85509. /** Name of this extension */
  85510. readonly name: string;
  85511. /** Defines whether this extension is enabled */
  85512. enabled: boolean;
  85513. /** Defines whether this extension is required */
  85514. required: boolean;
  85515. /** Reference to the glTF exporter */
  85516. private _textureInfos;
  85517. private _exportedTextures;
  85518. private _wasUsed;
  85519. constructor(exporter: _Exporter);
  85520. dispose(): void;
  85521. /** @hidden */
  85522. get wasUsed(): boolean;
  85523. private _getTextureIndex;
  85524. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85525. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85526. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85527. }
  85528. }
  85529. declare module BABYLON.GLTF2.Exporter.Extensions {
  85530. /**
  85531. * @hidden
  85532. */
  85533. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85534. /** Name of this extension */
  85535. readonly name: string;
  85536. /** Defines whether this extension is enabled */
  85537. enabled: boolean;
  85538. /** Defines whether this extension is required */
  85539. required: boolean;
  85540. private _wasUsed;
  85541. constructor(exporter: _Exporter);
  85542. /** @hidden */
  85543. get wasUsed(): boolean;
  85544. dispose(): void;
  85545. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85546. }
  85547. }
  85548. declare module BABYLON {
  85549. /**
  85550. * Class for generating STL data from a Babylon scene.
  85551. */
  85552. export class STLExport {
  85553. /**
  85554. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85555. * @param meshes list defines the mesh to serialize
  85556. * @param download triggers the automatic download of the file.
  85557. * @param fileName changes the downloads fileName.
  85558. * @param binary changes the STL to a binary type.
  85559. * @param isLittleEndian toggle for binary type exporter.
  85560. * @returns the STL as UTF8 string
  85561. */
  85562. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85563. }
  85564. }
  85565. declare module "babylonjs-gltf2interface" {
  85566. export = BABYLON.GLTF2;
  85567. }
  85568. /**
  85569. * Module for glTF 2.0 Interface
  85570. */
  85571. declare module BABYLON.GLTF2 {
  85572. /**
  85573. * The datatype of the components in the attribute
  85574. */
  85575. const enum AccessorComponentType {
  85576. /**
  85577. * Byte
  85578. */
  85579. BYTE = 5120,
  85580. /**
  85581. * Unsigned Byte
  85582. */
  85583. UNSIGNED_BYTE = 5121,
  85584. /**
  85585. * Short
  85586. */
  85587. SHORT = 5122,
  85588. /**
  85589. * Unsigned Short
  85590. */
  85591. UNSIGNED_SHORT = 5123,
  85592. /**
  85593. * Unsigned Int
  85594. */
  85595. UNSIGNED_INT = 5125,
  85596. /**
  85597. * Float
  85598. */
  85599. FLOAT = 5126,
  85600. }
  85601. /**
  85602. * Specifies if the attirbute is a scalar, vector, or matrix
  85603. */
  85604. const enum AccessorType {
  85605. /**
  85606. * Scalar
  85607. */
  85608. SCALAR = "SCALAR",
  85609. /**
  85610. * Vector2
  85611. */
  85612. VEC2 = "VEC2",
  85613. /**
  85614. * Vector3
  85615. */
  85616. VEC3 = "VEC3",
  85617. /**
  85618. * Vector4
  85619. */
  85620. VEC4 = "VEC4",
  85621. /**
  85622. * Matrix2x2
  85623. */
  85624. MAT2 = "MAT2",
  85625. /**
  85626. * Matrix3x3
  85627. */
  85628. MAT3 = "MAT3",
  85629. /**
  85630. * Matrix4x4
  85631. */
  85632. MAT4 = "MAT4",
  85633. }
  85634. /**
  85635. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85636. */
  85637. const enum AnimationChannelTargetPath {
  85638. /**
  85639. * Translation
  85640. */
  85641. TRANSLATION = "translation",
  85642. /**
  85643. * Rotation
  85644. */
  85645. ROTATION = "rotation",
  85646. /**
  85647. * Scale
  85648. */
  85649. SCALE = "scale",
  85650. /**
  85651. * Weights
  85652. */
  85653. WEIGHTS = "weights",
  85654. }
  85655. /**
  85656. * Interpolation algorithm
  85657. */
  85658. const enum AnimationSamplerInterpolation {
  85659. /**
  85660. * The animated values are linearly interpolated between keyframes
  85661. */
  85662. LINEAR = "LINEAR",
  85663. /**
  85664. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85665. */
  85666. STEP = "STEP",
  85667. /**
  85668. * The animation's interpolation is computed using a cubic spline with specified tangents
  85669. */
  85670. CUBICSPLINE = "CUBICSPLINE",
  85671. }
  85672. /**
  85673. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85674. */
  85675. const enum CameraType {
  85676. /**
  85677. * A perspective camera containing properties to create a perspective projection matrix
  85678. */
  85679. PERSPECTIVE = "perspective",
  85680. /**
  85681. * An orthographic camera containing properties to create an orthographic projection matrix
  85682. */
  85683. ORTHOGRAPHIC = "orthographic",
  85684. }
  85685. /**
  85686. * The mime-type of the image
  85687. */
  85688. const enum ImageMimeType {
  85689. /**
  85690. * JPEG Mime-type
  85691. */
  85692. JPEG = "image/jpeg",
  85693. /**
  85694. * PNG Mime-type
  85695. */
  85696. PNG = "image/png",
  85697. }
  85698. /**
  85699. * The alpha rendering mode of the material
  85700. */
  85701. const enum MaterialAlphaMode {
  85702. /**
  85703. * The alpha value is ignored and the rendered output is fully opaque
  85704. */
  85705. OPAQUE = "OPAQUE",
  85706. /**
  85707. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85708. */
  85709. MASK = "MASK",
  85710. /**
  85711. * 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)
  85712. */
  85713. BLEND = "BLEND",
  85714. }
  85715. /**
  85716. * The type of the primitives to render
  85717. */
  85718. const enum MeshPrimitiveMode {
  85719. /**
  85720. * Points
  85721. */
  85722. POINTS = 0,
  85723. /**
  85724. * Lines
  85725. */
  85726. LINES = 1,
  85727. /**
  85728. * Line Loop
  85729. */
  85730. LINE_LOOP = 2,
  85731. /**
  85732. * Line Strip
  85733. */
  85734. LINE_STRIP = 3,
  85735. /**
  85736. * Triangles
  85737. */
  85738. TRIANGLES = 4,
  85739. /**
  85740. * Triangle Strip
  85741. */
  85742. TRIANGLE_STRIP = 5,
  85743. /**
  85744. * Triangle Fan
  85745. */
  85746. TRIANGLE_FAN = 6,
  85747. }
  85748. /**
  85749. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85750. */
  85751. const enum TextureMagFilter {
  85752. /**
  85753. * Nearest
  85754. */
  85755. NEAREST = 9728,
  85756. /**
  85757. * Linear
  85758. */
  85759. LINEAR = 9729,
  85760. }
  85761. /**
  85762. * Minification filter. All valid values correspond to WebGL enums
  85763. */
  85764. const enum TextureMinFilter {
  85765. /**
  85766. * Nearest
  85767. */
  85768. NEAREST = 9728,
  85769. /**
  85770. * Linear
  85771. */
  85772. LINEAR = 9729,
  85773. /**
  85774. * Nearest Mip-Map Nearest
  85775. */
  85776. NEAREST_MIPMAP_NEAREST = 9984,
  85777. /**
  85778. * Linear Mipmap Nearest
  85779. */
  85780. LINEAR_MIPMAP_NEAREST = 9985,
  85781. /**
  85782. * Nearest Mipmap Linear
  85783. */
  85784. NEAREST_MIPMAP_LINEAR = 9986,
  85785. /**
  85786. * Linear Mipmap Linear
  85787. */
  85788. LINEAR_MIPMAP_LINEAR = 9987,
  85789. }
  85790. /**
  85791. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85792. */
  85793. const enum TextureWrapMode {
  85794. /**
  85795. * Clamp to Edge
  85796. */
  85797. CLAMP_TO_EDGE = 33071,
  85798. /**
  85799. * Mirrored Repeat
  85800. */
  85801. MIRRORED_REPEAT = 33648,
  85802. /**
  85803. * Repeat
  85804. */
  85805. REPEAT = 10497,
  85806. }
  85807. /**
  85808. * glTF Property
  85809. */
  85810. interface IProperty {
  85811. /**
  85812. * Dictionary object with extension-specific objects
  85813. */
  85814. extensions?: {
  85815. [key: string]: any;
  85816. };
  85817. /**
  85818. * Application-Specific data
  85819. */
  85820. extras?: any;
  85821. }
  85822. /**
  85823. * glTF Child of Root Property
  85824. */
  85825. interface IChildRootProperty extends IProperty {
  85826. /**
  85827. * The user-defined name of this object
  85828. */
  85829. name?: string;
  85830. }
  85831. /**
  85832. * Indices of those attributes that deviate from their initialization value
  85833. */
  85834. interface IAccessorSparseIndices extends IProperty {
  85835. /**
  85836. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85837. */
  85838. bufferView: number;
  85839. /**
  85840. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85841. */
  85842. byteOffset?: number;
  85843. /**
  85844. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85845. */
  85846. componentType: AccessorComponentType;
  85847. }
  85848. /**
  85849. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85850. */
  85851. interface IAccessorSparseValues extends IProperty {
  85852. /**
  85853. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85854. */
  85855. bufferView: number;
  85856. /**
  85857. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85858. */
  85859. byteOffset?: number;
  85860. }
  85861. /**
  85862. * Sparse storage of attributes that deviate from their initialization value
  85863. */
  85864. interface IAccessorSparse extends IProperty {
  85865. /**
  85866. * The number of attributes encoded in this sparse accessor
  85867. */
  85868. count: number;
  85869. /**
  85870. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85871. */
  85872. indices: IAccessorSparseIndices;
  85873. /**
  85874. * 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
  85875. */
  85876. values: IAccessorSparseValues;
  85877. }
  85878. /**
  85879. * 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
  85880. */
  85881. interface IAccessor extends IChildRootProperty {
  85882. /**
  85883. * The index of the bufferview
  85884. */
  85885. bufferView?: number;
  85886. /**
  85887. * The offset relative to the start of the bufferView in bytes
  85888. */
  85889. byteOffset?: number;
  85890. /**
  85891. * The datatype of components in the attribute
  85892. */
  85893. componentType: AccessorComponentType;
  85894. /**
  85895. * Specifies whether integer data values should be normalized
  85896. */
  85897. normalized?: boolean;
  85898. /**
  85899. * The number of attributes referenced by this accessor
  85900. */
  85901. count: number;
  85902. /**
  85903. * Specifies if the attribute is a scalar, vector, or matrix
  85904. */
  85905. type: AccessorType;
  85906. /**
  85907. * Maximum value of each component in this attribute
  85908. */
  85909. max?: number[];
  85910. /**
  85911. * Minimum value of each component in this attribute
  85912. */
  85913. min?: number[];
  85914. /**
  85915. * Sparse storage of attributes that deviate from their initialization value
  85916. */
  85917. sparse?: IAccessorSparse;
  85918. }
  85919. /**
  85920. * Targets an animation's sampler at a node's property
  85921. */
  85922. interface IAnimationChannel extends IProperty {
  85923. /**
  85924. * The index of a sampler in this animation used to compute the value for the target
  85925. */
  85926. sampler: number;
  85927. /**
  85928. * The index of the node and TRS property to target
  85929. */
  85930. target: IAnimationChannelTarget;
  85931. }
  85932. /**
  85933. * The index of the node and TRS property that an animation channel targets
  85934. */
  85935. interface IAnimationChannelTarget extends IProperty {
  85936. /**
  85937. * The index of the node to target
  85938. */
  85939. node: number;
  85940. /**
  85941. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85942. */
  85943. path: AnimationChannelTargetPath;
  85944. }
  85945. /**
  85946. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85947. */
  85948. interface IAnimationSampler extends IProperty {
  85949. /**
  85950. * The index of an accessor containing keyframe input values, e.g., time
  85951. */
  85952. input: number;
  85953. /**
  85954. * Interpolation algorithm
  85955. */
  85956. interpolation?: AnimationSamplerInterpolation;
  85957. /**
  85958. * The index of an accessor, containing keyframe output values
  85959. */
  85960. output: number;
  85961. }
  85962. /**
  85963. * A keyframe animation
  85964. */
  85965. interface IAnimation extends IChildRootProperty {
  85966. /**
  85967. * An array of channels, each of which targets an animation's sampler at a node's property
  85968. */
  85969. channels: IAnimationChannel[];
  85970. /**
  85971. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85972. */
  85973. samplers: IAnimationSampler[];
  85974. }
  85975. /**
  85976. * Metadata about the glTF asset
  85977. */
  85978. interface IAsset extends IChildRootProperty {
  85979. /**
  85980. * A copyright message suitable for display to credit the content creator
  85981. */
  85982. copyright?: string;
  85983. /**
  85984. * Tool that generated this glTF model. Useful for debugging
  85985. */
  85986. generator?: string;
  85987. /**
  85988. * The glTF version that this asset targets
  85989. */
  85990. version: string;
  85991. /**
  85992. * The minimum glTF version that this asset targets
  85993. */
  85994. minVersion?: string;
  85995. }
  85996. /**
  85997. * A buffer points to binary geometry, animation, or skins
  85998. */
  85999. interface IBuffer extends IChildRootProperty {
  86000. /**
  86001. * 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
  86002. */
  86003. uri?: string;
  86004. /**
  86005. * The length of the buffer in bytes
  86006. */
  86007. byteLength: number;
  86008. }
  86009. /**
  86010. * A view into a buffer generally representing a subset of the buffer
  86011. */
  86012. interface IBufferView extends IChildRootProperty {
  86013. /**
  86014. * The index of the buffer
  86015. */
  86016. buffer: number;
  86017. /**
  86018. * The offset into the buffer in bytes
  86019. */
  86020. byteOffset?: number;
  86021. /**
  86022. * The lenth of the bufferView in bytes
  86023. */
  86024. byteLength: number;
  86025. /**
  86026. * The stride, in bytes
  86027. */
  86028. byteStride?: number;
  86029. }
  86030. /**
  86031. * An orthographic camera containing properties to create an orthographic projection matrix
  86032. */
  86033. interface ICameraOrthographic extends IProperty {
  86034. /**
  86035. * The floating-point horizontal magnification of the view. Must not be zero
  86036. */
  86037. xmag: number;
  86038. /**
  86039. * The floating-point vertical magnification of the view. Must not be zero
  86040. */
  86041. ymag: number;
  86042. /**
  86043. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86044. */
  86045. zfar: number;
  86046. /**
  86047. * The floating-point distance to the near clipping plane
  86048. */
  86049. znear: number;
  86050. }
  86051. /**
  86052. * A perspective camera containing properties to create a perspective projection matrix
  86053. */
  86054. interface ICameraPerspective extends IProperty {
  86055. /**
  86056. * The floating-point aspect ratio of the field of view
  86057. */
  86058. aspectRatio?: number;
  86059. /**
  86060. * The floating-point vertical field of view in radians
  86061. */
  86062. yfov: number;
  86063. /**
  86064. * The floating-point distance to the far clipping plane
  86065. */
  86066. zfar?: number;
  86067. /**
  86068. * The floating-point distance to the near clipping plane
  86069. */
  86070. znear: number;
  86071. }
  86072. /**
  86073. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86074. */
  86075. interface ICamera extends IChildRootProperty {
  86076. /**
  86077. * An orthographic camera containing properties to create an orthographic projection matrix
  86078. */
  86079. orthographic?: ICameraOrthographic;
  86080. /**
  86081. * A perspective camera containing properties to create a perspective projection matrix
  86082. */
  86083. perspective?: ICameraPerspective;
  86084. /**
  86085. * Specifies if the camera uses a perspective or orthographic projection
  86086. */
  86087. type: CameraType;
  86088. }
  86089. /**
  86090. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86091. */
  86092. interface IImage extends IChildRootProperty {
  86093. /**
  86094. * 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
  86095. */
  86096. uri?: string;
  86097. /**
  86098. * The image's MIME type
  86099. */
  86100. mimeType?: ImageMimeType;
  86101. /**
  86102. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86103. */
  86104. bufferView?: number;
  86105. }
  86106. /**
  86107. * Material Normal Texture Info
  86108. */
  86109. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86110. /**
  86111. * The scalar multiplier applied to each normal vector of the normal texture
  86112. */
  86113. scale?: number;
  86114. }
  86115. /**
  86116. * Material Occlusion Texture Info
  86117. */
  86118. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86119. /**
  86120. * A scalar multiplier controlling the amount of occlusion applied
  86121. */
  86122. strength?: number;
  86123. }
  86124. /**
  86125. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86126. */
  86127. interface IMaterialPbrMetallicRoughness {
  86128. /**
  86129. * The material's base color factor
  86130. */
  86131. baseColorFactor?: number[];
  86132. /**
  86133. * The base color texture
  86134. */
  86135. baseColorTexture?: ITextureInfo;
  86136. /**
  86137. * The metalness of the material
  86138. */
  86139. metallicFactor?: number;
  86140. /**
  86141. * The roughness of the material
  86142. */
  86143. roughnessFactor?: number;
  86144. /**
  86145. * The metallic-roughness texture
  86146. */
  86147. metallicRoughnessTexture?: ITextureInfo;
  86148. }
  86149. /**
  86150. * The material appearance of a primitive
  86151. */
  86152. interface IMaterial extends IChildRootProperty {
  86153. /**
  86154. * 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
  86155. */
  86156. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86157. /**
  86158. * The normal map texture
  86159. */
  86160. normalTexture?: IMaterialNormalTextureInfo;
  86161. /**
  86162. * The occlusion map texture
  86163. */
  86164. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86165. /**
  86166. * The emissive map texture
  86167. */
  86168. emissiveTexture?: ITextureInfo;
  86169. /**
  86170. * 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
  86171. */
  86172. emissiveFactor?: number[];
  86173. /**
  86174. * The alpha rendering mode of the material
  86175. */
  86176. alphaMode?: MaterialAlphaMode;
  86177. /**
  86178. * The alpha cutoff value of the material
  86179. */
  86180. alphaCutoff?: number;
  86181. /**
  86182. * Specifies whether the material is double sided
  86183. */
  86184. doubleSided?: boolean;
  86185. }
  86186. /**
  86187. * Geometry to be rendered with the given material
  86188. */
  86189. interface IMeshPrimitive extends IProperty {
  86190. /**
  86191. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86192. */
  86193. attributes: {
  86194. [name: string]: number;
  86195. };
  86196. /**
  86197. * The index of the accessor that contains the indices
  86198. */
  86199. indices?: number;
  86200. /**
  86201. * The index of the material to apply to this primitive when rendering
  86202. */
  86203. material?: number;
  86204. /**
  86205. * The type of primitives to render. All valid values correspond to WebGL enums
  86206. */
  86207. mode?: MeshPrimitiveMode;
  86208. /**
  86209. * 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
  86210. */
  86211. targets?: {
  86212. [name: string]: number;
  86213. }[];
  86214. }
  86215. /**
  86216. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86217. */
  86218. interface IMesh extends IChildRootProperty {
  86219. /**
  86220. * An array of primitives, each defining geometry to be rendered with a material
  86221. */
  86222. primitives: IMeshPrimitive[];
  86223. /**
  86224. * Array of weights to be applied to the Morph Targets
  86225. */
  86226. weights?: number[];
  86227. }
  86228. /**
  86229. * A node in the node hierarchy
  86230. */
  86231. interface INode extends IChildRootProperty {
  86232. /**
  86233. * The index of the camera referenced by this node
  86234. */
  86235. camera?: number;
  86236. /**
  86237. * The indices of this node's children
  86238. */
  86239. children?: number[];
  86240. /**
  86241. * The index of the skin referenced by this node
  86242. */
  86243. skin?: number;
  86244. /**
  86245. * A floating-point 4x4 transformation matrix stored in column-major order
  86246. */
  86247. matrix?: number[];
  86248. /**
  86249. * The index of the mesh in this node
  86250. */
  86251. mesh?: number;
  86252. /**
  86253. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86254. */
  86255. rotation?: number[];
  86256. /**
  86257. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86258. */
  86259. scale?: number[];
  86260. /**
  86261. * The node's translation along the x, y, and z axes
  86262. */
  86263. translation?: number[];
  86264. /**
  86265. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86266. */
  86267. weights?: number[];
  86268. }
  86269. /**
  86270. * Texture sampler properties for filtering and wrapping modes
  86271. */
  86272. interface ISampler extends IChildRootProperty {
  86273. /**
  86274. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86275. */
  86276. magFilter?: TextureMagFilter;
  86277. /**
  86278. * Minification filter. All valid values correspond to WebGL enums
  86279. */
  86280. minFilter?: TextureMinFilter;
  86281. /**
  86282. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86283. */
  86284. wrapS?: TextureWrapMode;
  86285. /**
  86286. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86287. */
  86288. wrapT?: TextureWrapMode;
  86289. }
  86290. /**
  86291. * The root nodes of a scene
  86292. */
  86293. interface IScene extends IChildRootProperty {
  86294. /**
  86295. * The indices of each root node
  86296. */
  86297. nodes: number[];
  86298. }
  86299. /**
  86300. * Joints and matrices defining a skin
  86301. */
  86302. interface ISkin extends IChildRootProperty {
  86303. /**
  86304. * 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
  86305. */
  86306. inverseBindMatrices?: number;
  86307. /**
  86308. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86309. */
  86310. skeleton?: number;
  86311. /**
  86312. * 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)
  86313. */
  86314. joints: number[];
  86315. }
  86316. /**
  86317. * A texture and its sampler
  86318. */
  86319. interface ITexture extends IChildRootProperty {
  86320. /**
  86321. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86322. */
  86323. sampler?: number;
  86324. /**
  86325. * The index of the image used by this texture
  86326. */
  86327. source: number;
  86328. }
  86329. /**
  86330. * Reference to a texture
  86331. */
  86332. interface ITextureInfo extends IProperty {
  86333. /**
  86334. * The index of the texture
  86335. */
  86336. index: number;
  86337. /**
  86338. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86339. */
  86340. texCoord?: number;
  86341. }
  86342. /**
  86343. * The root object for a glTF asset
  86344. */
  86345. interface IGLTF extends IProperty {
  86346. /**
  86347. * An array of accessors. An accessor is a typed view into a bufferView
  86348. */
  86349. accessors?: IAccessor[];
  86350. /**
  86351. * An array of keyframe animations
  86352. */
  86353. animations?: IAnimation[];
  86354. /**
  86355. * Metadata about the glTF asset
  86356. */
  86357. asset: IAsset;
  86358. /**
  86359. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86360. */
  86361. buffers?: IBuffer[];
  86362. /**
  86363. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86364. */
  86365. bufferViews?: IBufferView[];
  86366. /**
  86367. * An array of cameras
  86368. */
  86369. cameras?: ICamera[];
  86370. /**
  86371. * Names of glTF extensions used somewhere in this asset
  86372. */
  86373. extensionsUsed?: string[];
  86374. /**
  86375. * Names of glTF extensions required to properly load this asset
  86376. */
  86377. extensionsRequired?: string[];
  86378. /**
  86379. * An array of images. An image defines data used to create a texture
  86380. */
  86381. images?: IImage[];
  86382. /**
  86383. * An array of materials. A material defines the appearance of a primitive
  86384. */
  86385. materials?: IMaterial[];
  86386. /**
  86387. * An array of meshes. A mesh is a set of primitives to be rendered
  86388. */
  86389. meshes?: IMesh[];
  86390. /**
  86391. * An array of nodes
  86392. */
  86393. nodes?: INode[];
  86394. /**
  86395. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86396. */
  86397. samplers?: ISampler[];
  86398. /**
  86399. * The index of the default scene
  86400. */
  86401. scene?: number;
  86402. /**
  86403. * An array of scenes
  86404. */
  86405. scenes?: IScene[];
  86406. /**
  86407. * An array of skins. A skin is defined by joints and matrices
  86408. */
  86409. skins?: ISkin[];
  86410. /**
  86411. * An array of textures
  86412. */
  86413. textures?: ITexture[];
  86414. }
  86415. /**
  86416. * The glTF validation results
  86417. * @ignore
  86418. */
  86419. interface IGLTFValidationResults {
  86420. info: {
  86421. generator: string;
  86422. hasAnimations: boolean;
  86423. hasDefaultScene: boolean;
  86424. hasMaterials: boolean;
  86425. hasMorphTargets: boolean;
  86426. hasSkins: boolean;
  86427. hasTextures: boolean;
  86428. maxAttributesUsed: number;
  86429. primitivesCount: number
  86430. };
  86431. issues: {
  86432. messages: Array<string>;
  86433. numErrors: number;
  86434. numHints: number;
  86435. numInfos: number;
  86436. numWarnings: number;
  86437. truncated: boolean
  86438. };
  86439. mimeType: string;
  86440. uri: string;
  86441. validatedAt: string;
  86442. validatorVersion: string;
  86443. }
  86444. /**
  86445. * The glTF validation options
  86446. */
  86447. interface IGLTFValidationOptions {
  86448. /** Uri to use */
  86449. uri?: string;
  86450. /** Function used to load external resources */
  86451. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86452. /** Boolean indicating that we need to validate accessor data */
  86453. validateAccessorData?: boolean;
  86454. /** max number of issues allowed */
  86455. maxIssues?: number;
  86456. /** Ignored issues */
  86457. ignoredIssues?: Array<string>;
  86458. /** Value to override severy settings */
  86459. severityOverrides?: Object;
  86460. }
  86461. /**
  86462. * The glTF validator object
  86463. * @ignore
  86464. */
  86465. interface IGLTFValidator {
  86466. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86467. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86468. }
  86469. /**
  86470. * Interfaces from the EXT_lights_image_based extension
  86471. */
  86472. /** @hidden */
  86473. interface IEXTLightsImageBased_LightReferenceImageBased {
  86474. light: number;
  86475. }
  86476. /** @hidden */
  86477. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86478. intensity: number;
  86479. rotation: number[];
  86480. specularImageSize: number;
  86481. specularImages: number[][];
  86482. irradianceCoefficients: number[][];
  86483. }
  86484. /** @hidden */
  86485. interface IEXTLightsImageBased {
  86486. lights: IEXTLightsImageBased_LightImageBased[];
  86487. }
  86488. /**
  86489. * Interfaces from the EXT_mesh_gpu_instancing extension
  86490. * !!! Experimental Extension Subject to Changes !!!
  86491. */
  86492. /** @hidden */
  86493. interface IEXTMeshGpuInstancing {
  86494. mesh?: number;
  86495. attributes: { [name: string]: number };
  86496. }
  86497. /**
  86498. * Interfaces from the KHR_draco_mesh_compression extension
  86499. */
  86500. /** @hidden */
  86501. interface IKHRDracoMeshCompression {
  86502. bufferView: number;
  86503. attributes: { [name: string]: number };
  86504. }
  86505. /**
  86506. * Interfaces from the KHR_lights_punctual extension
  86507. */
  86508. /** @hidden */
  86509. const enum IKHRLightsPunctual_LightType {
  86510. DIRECTIONAL = "directional",
  86511. POINT = "point",
  86512. SPOT = "spot"
  86513. }
  86514. /** @hidden */
  86515. interface IKHRLightsPunctual_LightReference {
  86516. light: number;
  86517. }
  86518. /** @hidden */
  86519. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86520. type: IKHRLightsPunctual_LightType;
  86521. color?: number[];
  86522. intensity?: number;
  86523. range?: number;
  86524. spot?: {
  86525. innerConeAngle?: number;
  86526. outerConeAngle?: number;
  86527. };
  86528. }
  86529. /** @hidden */
  86530. interface IKHRLightsPunctual {
  86531. lights: IKHRLightsPunctual_Light[];
  86532. }
  86533. /**
  86534. * Interfaces from the KHR_materials_clearcoat extension
  86535. * !!! Experimental Extension Subject to Changes !!!
  86536. */
  86537. /** @hidden */
  86538. interface IKHRMaterialsClearcoat {
  86539. clearcoatFactor: number;
  86540. clearcoatTexture: ITextureInfo;
  86541. clearcoatRoughnessFactor: number;
  86542. clearcoatRoughnessTexture: ITextureInfo;
  86543. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86544. }
  86545. /**
  86546. * Interfaces from the KHR_materials_ior extension
  86547. * !!! Experimental Extension Subject to Changes !!!
  86548. */
  86549. /** @hidden */
  86550. interface IKHRMaterialsIor {
  86551. ior: number;
  86552. }
  86553. /**
  86554. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86555. */
  86556. /** @hidden */
  86557. interface IKHRMaterialsPbrSpecularGlossiness {
  86558. diffuseFactor: number[];
  86559. diffuseTexture: ITextureInfo;
  86560. specularFactor: number[];
  86561. glossinessFactor: number;
  86562. specularGlossinessTexture: ITextureInfo;
  86563. }
  86564. /**
  86565. * Interfaces from the KHR_materials_sheen extension
  86566. * !!! Experimental Extension Subject to Changes !!!
  86567. */
  86568. /** @hidden */
  86569. interface IKHRMaterialsSheen {
  86570. sheenColorFactor?: number[];
  86571. sheenColorTexture?: ITextureInfo;
  86572. sheenRoughnessFactor?: number;
  86573. sheenRoughnessTexture?: ITextureInfo;
  86574. }
  86575. /**
  86576. * Interfaces from the KHR_materials_specular extension
  86577. * !!! Experimental Extension Subject to Changes !!!
  86578. */
  86579. /** @hidden */
  86580. interface IKHRMaterialsSpecular {
  86581. specularFactor: number;
  86582. specularColorFactor: number[];
  86583. specularTexture: ITextureInfo;
  86584. }
  86585. /**
  86586. * Interfaces from the KHR_materials_transmission extension
  86587. * !!! Experimental Extension Subject to Changes !!!
  86588. */
  86589. /** @hidden */
  86590. interface IKHRMaterialsTransmission {
  86591. transmissionFactor?: number;
  86592. transmissionTexture?: ITextureInfo;
  86593. }
  86594. /**
  86595. * Interfaces from the KHR_materials_variants extension
  86596. * !!! Experimental Extension Subject to Changes !!!
  86597. */
  86598. /** @hidden */
  86599. interface IKHRMaterialVariants_Mapping extends IProperty {
  86600. mappings: Array<{
  86601. variants: number[];
  86602. material: number;
  86603. }>;
  86604. }
  86605. /** @hidden */
  86606. interface IKHRMaterialVariants_Variant extends IProperty {
  86607. name: string;
  86608. }
  86609. /** @hidden */
  86610. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86611. variants: Array<IKHRMaterialVariants_Variant>;
  86612. }
  86613. /**
  86614. * Interfaces from the KHR_texture_basisu extension
  86615. * !!! Experimental Extension Subject to Changes !!!
  86616. */
  86617. /** @hidden */
  86618. interface IKHRTextureBasisU {
  86619. source: number;
  86620. }
  86621. /**
  86622. * Interfaces from the EXT_texture_webp extension
  86623. */
  86624. /** @hidden */
  86625. interface IEXTTextureWebP {
  86626. source: number;
  86627. }
  86628. /**
  86629. * Interfaces from the KHR_texture_transform extension
  86630. */
  86631. /** @hidden */
  86632. interface IKHRTextureTransform {
  86633. offset?: number[];
  86634. rotation?: number;
  86635. scale?: number[];
  86636. texCoord?: number;
  86637. }
  86638. /**
  86639. * Interfaces from the KHR_xmp extension
  86640. * !!! Experimental Extension Subject to Changes !!!
  86641. */
  86642. /** @hidden */
  86643. interface IKHRXmp_Data {
  86644. [key: string]: unknown;
  86645. }
  86646. /** @hidden */
  86647. interface IKHRXmp_Gltf {
  86648. packets: IKHRXmp_Data[];
  86649. }
  86650. /** @hidden */
  86651. interface IKHRXmp_Node {
  86652. packet: number;
  86653. }
  86654. /**
  86655. * Interfaces from the MSFT_audio_emitter extension
  86656. */
  86657. /** @hidden */
  86658. interface IMSFTAudioEmitter_ClipReference {
  86659. clip: number;
  86660. weight?: number;
  86661. }
  86662. /** @hidden */
  86663. interface IMSFTAudioEmitter_EmittersReference {
  86664. emitters: number[];
  86665. }
  86666. /** @hidden */
  86667. const enum IMSFTAudioEmitter_DistanceModel {
  86668. linear = "linear",
  86669. inverse = "inverse",
  86670. exponential = "exponential",
  86671. }
  86672. /** @hidden */
  86673. interface IMSFTAudioEmitter_Emitter {
  86674. name?: string;
  86675. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86676. refDistance?: number;
  86677. maxDistance?: number;
  86678. rolloffFactor?: number;
  86679. innerAngle?: number;
  86680. outerAngle?: number;
  86681. loop?: boolean;
  86682. volume?: number;
  86683. clips: IMSFTAudioEmitter_ClipReference[];
  86684. }
  86685. /** @hidden */
  86686. const enum IMSFTAudioEmitter_AudioMimeType {
  86687. WAV = "audio/wav",
  86688. }
  86689. /** @hidden */
  86690. interface IMSFTAudioEmitter_Clip extends IProperty {
  86691. uri?: string;
  86692. bufferView?: number;
  86693. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86694. }
  86695. /** @hidden */
  86696. const enum IMSFTAudioEmitter_AnimationEventAction {
  86697. play = "play",
  86698. pause = "pause",
  86699. stop = "stop",
  86700. }
  86701. /** @hidden */
  86702. interface IMSFTAudioEmitter_AnimationEvent {
  86703. action: IMSFTAudioEmitter_AnimationEventAction;
  86704. emitter: number;
  86705. time: number;
  86706. startOffset?: number;
  86707. }
  86708. /**
  86709. * Interfaces from the MSFT_lod extension
  86710. */
  86711. /** @hidden */
  86712. interface IMSFTLOD {
  86713. ids: number[];
  86714. }
  86715. }
  86716. declare module BABYLON {
  86717. /** @hidden */
  86718. export var cellPixelShader: {
  86719. name: string;
  86720. shader: string;
  86721. };
  86722. }
  86723. declare module BABYLON {
  86724. /** @hidden */
  86725. export var cellVertexShader: {
  86726. name: string;
  86727. shader: string;
  86728. };
  86729. }
  86730. declare module BABYLON {
  86731. export class CellMaterial extends BABYLON.PushMaterial {
  86732. private _diffuseTexture;
  86733. diffuseTexture: BABYLON.BaseTexture;
  86734. diffuseColor: BABYLON.Color3;
  86735. _computeHighLevel: boolean;
  86736. computeHighLevel: boolean;
  86737. private _disableLighting;
  86738. disableLighting: boolean;
  86739. private _maxSimultaneousLights;
  86740. maxSimultaneousLights: number;
  86741. constructor(name: string, scene: BABYLON.Scene);
  86742. needAlphaBlending(): boolean;
  86743. needAlphaTesting(): boolean;
  86744. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86745. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86746. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86747. getAnimatables(): BABYLON.IAnimatable[];
  86748. getActiveTextures(): BABYLON.BaseTexture[];
  86749. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86750. dispose(forceDisposeEffect?: boolean): void;
  86751. getClassName(): string;
  86752. clone(name: string): CellMaterial;
  86753. serialize(): any;
  86754. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86755. }
  86756. }
  86757. declare module BABYLON {
  86758. export class CustomShaderStructure {
  86759. FragmentStore: string;
  86760. VertexStore: string;
  86761. constructor();
  86762. }
  86763. export class ShaderSpecialParts {
  86764. constructor();
  86765. Fragment_Begin: string;
  86766. Fragment_Definitions: string;
  86767. Fragment_MainBegin: string;
  86768. Fragment_Custom_Diffuse: string;
  86769. Fragment_Before_Lights: string;
  86770. Fragment_Before_Fog: string;
  86771. Fragment_Custom_Alpha: string;
  86772. Fragment_Before_FragColor: string;
  86773. Vertex_Begin: string;
  86774. Vertex_Definitions: string;
  86775. Vertex_MainBegin: string;
  86776. Vertex_Before_PositionUpdated: string;
  86777. Vertex_Before_NormalUpdated: string;
  86778. Vertex_After_WorldPosComputed: string;
  86779. Vertex_MainEnd: string;
  86780. }
  86781. export class CustomMaterial extends BABYLON.StandardMaterial {
  86782. static ShaderIndexer: number;
  86783. CustomParts: ShaderSpecialParts;
  86784. _isCreatedShader: boolean;
  86785. _createdShaderName: string;
  86786. _customUniform: string[];
  86787. _newUniforms: string[];
  86788. _newUniformInstances: {
  86789. [name: string]: any;
  86790. };
  86791. _newSamplerInstances: {
  86792. [name: string]: BABYLON.Texture;
  86793. };
  86794. _customAttributes: string[];
  86795. FragmentShader: string;
  86796. VertexShader: string;
  86797. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86798. ReviewUniform(name: string, arr: string[]): string[];
  86799. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86800. constructor(name: string, scene: BABYLON.Scene);
  86801. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86802. AddAttribute(name: string): CustomMaterial;
  86803. Fragment_Begin(shaderPart: string): CustomMaterial;
  86804. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86805. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86806. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86807. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86808. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86809. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86810. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86811. Vertex_Begin(shaderPart: string): CustomMaterial;
  86812. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86813. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86814. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86815. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86816. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86817. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86818. }
  86819. }
  86820. declare module BABYLON {
  86821. export class ShaderAlebdoParts {
  86822. constructor();
  86823. Fragment_Begin: string;
  86824. Fragment_Definitions: string;
  86825. Fragment_MainBegin: string;
  86826. Fragment_Custom_Albedo: string;
  86827. Fragment_Before_Lights: string;
  86828. Fragment_Custom_MetallicRoughness: string;
  86829. Fragment_Custom_MicroSurface: string;
  86830. Fragment_Before_Fog: string;
  86831. Fragment_Custom_Alpha: string;
  86832. Fragment_Before_FragColor: string;
  86833. Vertex_Begin: string;
  86834. Vertex_Definitions: string;
  86835. Vertex_MainBegin: string;
  86836. Vertex_Before_PositionUpdated: string;
  86837. Vertex_Before_NormalUpdated: string;
  86838. Vertex_After_WorldPosComputed: string;
  86839. Vertex_MainEnd: string;
  86840. }
  86841. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86842. static ShaderIndexer: number;
  86843. CustomParts: ShaderAlebdoParts;
  86844. _isCreatedShader: boolean;
  86845. _createdShaderName: string;
  86846. _customUniform: string[];
  86847. _newUniforms: string[];
  86848. _newUniformInstances: {
  86849. [name: string]: any;
  86850. };
  86851. _newSamplerInstances: {
  86852. [name: string]: BABYLON.Texture;
  86853. };
  86854. _customAttributes: string[];
  86855. FragmentShader: string;
  86856. VertexShader: string;
  86857. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86858. ReviewUniform(name: string, arr: string[]): string[];
  86859. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86860. constructor(name: string, scene: BABYLON.Scene);
  86861. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86862. AddAttribute(name: string): PBRCustomMaterial;
  86863. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86864. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86865. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86866. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86867. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86868. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86869. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86870. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86871. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86872. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86873. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86874. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86875. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86876. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86877. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86878. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86879. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86880. }
  86881. }
  86882. declare module BABYLON {
  86883. /** @hidden */
  86884. export var firePixelShader: {
  86885. name: string;
  86886. shader: string;
  86887. };
  86888. }
  86889. declare module BABYLON {
  86890. /** @hidden */
  86891. export var fireVertexShader: {
  86892. name: string;
  86893. shader: string;
  86894. };
  86895. }
  86896. declare module BABYLON {
  86897. export class FireMaterial extends BABYLON.PushMaterial {
  86898. private _diffuseTexture;
  86899. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86900. private _distortionTexture;
  86901. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86902. private _opacityTexture;
  86903. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86904. diffuseColor: BABYLON.Color3;
  86905. speed: number;
  86906. private _scaledDiffuse;
  86907. private _lastTime;
  86908. constructor(name: string, scene: BABYLON.Scene);
  86909. needAlphaBlending(): boolean;
  86910. needAlphaTesting(): boolean;
  86911. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86912. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86913. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86914. getAnimatables(): BABYLON.IAnimatable[];
  86915. getActiveTextures(): BABYLON.BaseTexture[];
  86916. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86917. getClassName(): string;
  86918. dispose(forceDisposeEffect?: boolean): void;
  86919. clone(name: string): FireMaterial;
  86920. serialize(): any;
  86921. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86922. }
  86923. }
  86924. declare module BABYLON {
  86925. /** @hidden */
  86926. export var furPixelShader: {
  86927. name: string;
  86928. shader: string;
  86929. };
  86930. }
  86931. declare module BABYLON {
  86932. /** @hidden */
  86933. export var furVertexShader: {
  86934. name: string;
  86935. shader: string;
  86936. };
  86937. }
  86938. declare module BABYLON {
  86939. export class FurMaterial extends BABYLON.PushMaterial {
  86940. private _diffuseTexture;
  86941. diffuseTexture: BABYLON.BaseTexture;
  86942. private _heightTexture;
  86943. heightTexture: BABYLON.BaseTexture;
  86944. diffuseColor: BABYLON.Color3;
  86945. furLength: number;
  86946. furAngle: number;
  86947. furColor: BABYLON.Color3;
  86948. furOffset: number;
  86949. furSpacing: number;
  86950. furGravity: BABYLON.Vector3;
  86951. furSpeed: number;
  86952. furDensity: number;
  86953. furOcclusion: number;
  86954. furTexture: BABYLON.DynamicTexture;
  86955. private _disableLighting;
  86956. disableLighting: boolean;
  86957. private _maxSimultaneousLights;
  86958. maxSimultaneousLights: number;
  86959. highLevelFur: boolean;
  86960. _meshes: BABYLON.AbstractMesh[];
  86961. private _furTime;
  86962. constructor(name: string, scene: BABYLON.Scene);
  86963. get furTime(): number;
  86964. set furTime(furTime: number);
  86965. needAlphaBlending(): boolean;
  86966. needAlphaTesting(): boolean;
  86967. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86968. updateFur(): void;
  86969. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86970. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86971. getAnimatables(): BABYLON.IAnimatable[];
  86972. getActiveTextures(): BABYLON.BaseTexture[];
  86973. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86974. dispose(forceDisposeEffect?: boolean): void;
  86975. clone(name: string): FurMaterial;
  86976. serialize(): any;
  86977. getClassName(): string;
  86978. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86979. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86980. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86981. }
  86982. }
  86983. declare module BABYLON {
  86984. /** @hidden */
  86985. export var gradientPixelShader: {
  86986. name: string;
  86987. shader: string;
  86988. };
  86989. }
  86990. declare module BABYLON {
  86991. /** @hidden */
  86992. export var gradientVertexShader: {
  86993. name: string;
  86994. shader: string;
  86995. };
  86996. }
  86997. declare module BABYLON {
  86998. export class GradientMaterial extends BABYLON.PushMaterial {
  86999. private _maxSimultaneousLights;
  87000. maxSimultaneousLights: number;
  87001. topColor: BABYLON.Color3;
  87002. topColorAlpha: number;
  87003. bottomColor: BABYLON.Color3;
  87004. bottomColorAlpha: number;
  87005. offset: number;
  87006. scale: number;
  87007. smoothness: number;
  87008. private _disableLighting;
  87009. disableLighting: boolean;
  87010. constructor(name: string, scene: BABYLON.Scene);
  87011. needAlphaBlending(): boolean;
  87012. needAlphaTesting(): boolean;
  87013. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87014. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87015. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87016. getAnimatables(): BABYLON.IAnimatable[];
  87017. dispose(forceDisposeEffect?: boolean): void;
  87018. clone(name: string): GradientMaterial;
  87019. serialize(): any;
  87020. getClassName(): string;
  87021. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87022. }
  87023. }
  87024. declare module BABYLON {
  87025. /** @hidden */
  87026. export var gridPixelShader: {
  87027. name: string;
  87028. shader: string;
  87029. };
  87030. }
  87031. declare module BABYLON {
  87032. /** @hidden */
  87033. export var gridVertexShader: {
  87034. name: string;
  87035. shader: string;
  87036. };
  87037. }
  87038. declare module BABYLON {
  87039. /**
  87040. * The grid materials allows you to wrap any shape with a grid.
  87041. * Colors are customizable.
  87042. */
  87043. export class GridMaterial extends BABYLON.PushMaterial {
  87044. /**
  87045. * Main color of the grid (e.g. between lines)
  87046. */
  87047. mainColor: BABYLON.Color3;
  87048. /**
  87049. * Color of the grid lines.
  87050. */
  87051. lineColor: BABYLON.Color3;
  87052. /**
  87053. * The scale of the grid compared to unit.
  87054. */
  87055. gridRatio: number;
  87056. /**
  87057. * Allows setting an offset for the grid lines.
  87058. */
  87059. gridOffset: BABYLON.Vector3;
  87060. /**
  87061. * The frequency of thicker lines.
  87062. */
  87063. majorUnitFrequency: number;
  87064. /**
  87065. * The visibility of minor units in the grid.
  87066. */
  87067. minorUnitVisibility: number;
  87068. /**
  87069. * The grid opacity outside of the lines.
  87070. */
  87071. opacity: number;
  87072. /**
  87073. * Determine RBG output is premultiplied by alpha value.
  87074. */
  87075. preMultiplyAlpha: boolean;
  87076. private _opacityTexture;
  87077. opacityTexture: BABYLON.BaseTexture;
  87078. private _gridControl;
  87079. /**
  87080. * constructor
  87081. * @param name The name given to the material in order to identify it afterwards.
  87082. * @param scene The scene the material is used in.
  87083. */
  87084. constructor(name: string, scene: BABYLON.Scene);
  87085. /**
  87086. * Returns wehter or not the grid requires alpha blending.
  87087. */
  87088. needAlphaBlending(): boolean;
  87089. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87090. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87091. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87092. /**
  87093. * Dispose the material and its associated resources.
  87094. * @param forceDisposeEffect will also dispose the used effect when true
  87095. */
  87096. dispose(forceDisposeEffect?: boolean): void;
  87097. clone(name: string): GridMaterial;
  87098. serialize(): any;
  87099. getClassName(): string;
  87100. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87101. }
  87102. }
  87103. declare module BABYLON {
  87104. /** @hidden */
  87105. export var lavaPixelShader: {
  87106. name: string;
  87107. shader: string;
  87108. };
  87109. }
  87110. declare module BABYLON {
  87111. /** @hidden */
  87112. export var lavaVertexShader: {
  87113. name: string;
  87114. shader: string;
  87115. };
  87116. }
  87117. declare module BABYLON {
  87118. export class LavaMaterial extends BABYLON.PushMaterial {
  87119. private _diffuseTexture;
  87120. diffuseTexture: BABYLON.BaseTexture;
  87121. noiseTexture: BABYLON.BaseTexture;
  87122. fogColor: BABYLON.Color3;
  87123. speed: number;
  87124. movingSpeed: number;
  87125. lowFrequencySpeed: number;
  87126. fogDensity: number;
  87127. private _lastTime;
  87128. diffuseColor: BABYLON.Color3;
  87129. private _disableLighting;
  87130. disableLighting: boolean;
  87131. private _unlit;
  87132. unlit: boolean;
  87133. private _maxSimultaneousLights;
  87134. maxSimultaneousLights: number;
  87135. private _scaledDiffuse;
  87136. constructor(name: string, scene: BABYLON.Scene);
  87137. needAlphaBlending(): boolean;
  87138. needAlphaTesting(): boolean;
  87139. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87140. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87141. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87142. getAnimatables(): BABYLON.IAnimatable[];
  87143. getActiveTextures(): BABYLON.BaseTexture[];
  87144. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87145. dispose(forceDisposeEffect?: boolean): void;
  87146. clone(name: string): LavaMaterial;
  87147. serialize(): any;
  87148. getClassName(): string;
  87149. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87150. }
  87151. }
  87152. declare module BABYLON {
  87153. /** @hidden */
  87154. export var mixPixelShader: {
  87155. name: string;
  87156. shader: string;
  87157. };
  87158. }
  87159. declare module BABYLON {
  87160. /** @hidden */
  87161. export var mixVertexShader: {
  87162. name: string;
  87163. shader: string;
  87164. };
  87165. }
  87166. declare module BABYLON {
  87167. export class MixMaterial extends BABYLON.PushMaterial {
  87168. /**
  87169. * Mix textures
  87170. */
  87171. private _mixTexture1;
  87172. mixTexture1: BABYLON.BaseTexture;
  87173. private _mixTexture2;
  87174. mixTexture2: BABYLON.BaseTexture;
  87175. /**
  87176. * Diffuse textures
  87177. */
  87178. private _diffuseTexture1;
  87179. diffuseTexture1: BABYLON.Texture;
  87180. private _diffuseTexture2;
  87181. diffuseTexture2: BABYLON.Texture;
  87182. private _diffuseTexture3;
  87183. diffuseTexture3: BABYLON.Texture;
  87184. private _diffuseTexture4;
  87185. diffuseTexture4: BABYLON.Texture;
  87186. private _diffuseTexture5;
  87187. diffuseTexture5: BABYLON.Texture;
  87188. private _diffuseTexture6;
  87189. diffuseTexture6: BABYLON.Texture;
  87190. private _diffuseTexture7;
  87191. diffuseTexture7: BABYLON.Texture;
  87192. private _diffuseTexture8;
  87193. diffuseTexture8: BABYLON.Texture;
  87194. /**
  87195. * Uniforms
  87196. */
  87197. diffuseColor: BABYLON.Color3;
  87198. specularColor: BABYLON.Color3;
  87199. specularPower: number;
  87200. private _disableLighting;
  87201. disableLighting: boolean;
  87202. private _maxSimultaneousLights;
  87203. maxSimultaneousLights: number;
  87204. constructor(name: string, scene: BABYLON.Scene);
  87205. needAlphaBlending(): boolean;
  87206. needAlphaTesting(): boolean;
  87207. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87208. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87209. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87210. getAnimatables(): BABYLON.IAnimatable[];
  87211. getActiveTextures(): BABYLON.BaseTexture[];
  87212. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87213. dispose(forceDisposeEffect?: boolean): void;
  87214. clone(name: string): MixMaterial;
  87215. serialize(): any;
  87216. getClassName(): string;
  87217. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87218. }
  87219. }
  87220. declare module BABYLON {
  87221. /** @hidden */
  87222. export var normalPixelShader: {
  87223. name: string;
  87224. shader: string;
  87225. };
  87226. }
  87227. declare module BABYLON {
  87228. /** @hidden */
  87229. export var normalVertexShader: {
  87230. name: string;
  87231. shader: string;
  87232. };
  87233. }
  87234. declare module BABYLON {
  87235. export class NormalMaterial extends BABYLON.PushMaterial {
  87236. private _diffuseTexture;
  87237. diffuseTexture: BABYLON.BaseTexture;
  87238. diffuseColor: BABYLON.Color3;
  87239. private _disableLighting;
  87240. disableLighting: boolean;
  87241. private _maxSimultaneousLights;
  87242. maxSimultaneousLights: number;
  87243. constructor(name: string, scene: BABYLON.Scene);
  87244. needAlphaBlending(): boolean;
  87245. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87246. needAlphaTesting(): boolean;
  87247. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87248. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87249. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87250. getAnimatables(): BABYLON.IAnimatable[];
  87251. getActiveTextures(): BABYLON.BaseTexture[];
  87252. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87253. dispose(forceDisposeEffect?: boolean): void;
  87254. clone(name: string): NormalMaterial;
  87255. serialize(): any;
  87256. getClassName(): string;
  87257. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87258. }
  87259. }
  87260. declare module BABYLON {
  87261. /** @hidden */
  87262. export var shadowOnlyPixelShader: {
  87263. name: string;
  87264. shader: string;
  87265. };
  87266. }
  87267. declare module BABYLON {
  87268. /** @hidden */
  87269. export var shadowOnlyVertexShader: {
  87270. name: string;
  87271. shader: string;
  87272. };
  87273. }
  87274. declare module BABYLON {
  87275. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87276. private _activeLight;
  87277. private _needAlphaBlending;
  87278. constructor(name: string, scene: BABYLON.Scene);
  87279. shadowColor: BABYLON.Color3;
  87280. needAlphaBlending(): boolean;
  87281. needAlphaTesting(): boolean;
  87282. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87283. get activeLight(): BABYLON.IShadowLight;
  87284. set activeLight(light: BABYLON.IShadowLight);
  87285. private _getFirstShadowLightForMesh;
  87286. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87287. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87288. clone(name: string): ShadowOnlyMaterial;
  87289. serialize(): any;
  87290. getClassName(): string;
  87291. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87292. }
  87293. }
  87294. declare module BABYLON {
  87295. /** @hidden */
  87296. export var simplePixelShader: {
  87297. name: string;
  87298. shader: string;
  87299. };
  87300. }
  87301. declare module BABYLON {
  87302. /** @hidden */
  87303. export var simpleVertexShader: {
  87304. name: string;
  87305. shader: string;
  87306. };
  87307. }
  87308. declare module BABYLON {
  87309. export class SimpleMaterial extends BABYLON.PushMaterial {
  87310. private _diffuseTexture;
  87311. diffuseTexture: BABYLON.BaseTexture;
  87312. diffuseColor: BABYLON.Color3;
  87313. private _disableLighting;
  87314. disableLighting: boolean;
  87315. private _maxSimultaneousLights;
  87316. maxSimultaneousLights: number;
  87317. constructor(name: string, scene: BABYLON.Scene);
  87318. needAlphaBlending(): boolean;
  87319. needAlphaTesting(): boolean;
  87320. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87321. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87322. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87323. getAnimatables(): BABYLON.IAnimatable[];
  87324. getActiveTextures(): BABYLON.BaseTexture[];
  87325. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87326. dispose(forceDisposeEffect?: boolean): void;
  87327. clone(name: string): SimpleMaterial;
  87328. serialize(): any;
  87329. getClassName(): string;
  87330. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87331. }
  87332. }
  87333. declare module BABYLON {
  87334. /** @hidden */
  87335. export var skyPixelShader: {
  87336. name: string;
  87337. shader: string;
  87338. };
  87339. }
  87340. declare module BABYLON {
  87341. /** @hidden */
  87342. export var skyVertexShader: {
  87343. name: string;
  87344. shader: string;
  87345. };
  87346. }
  87347. declare module BABYLON {
  87348. /**
  87349. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87350. * @see https://doc.babylonjs.com/extensions/sky
  87351. */
  87352. export class SkyMaterial extends BABYLON.PushMaterial {
  87353. /**
  87354. * Defines the overall luminance of sky in interval ]0, 1[.
  87355. */
  87356. luminance: number;
  87357. /**
  87358. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87359. */
  87360. turbidity: number;
  87361. /**
  87362. * Defines the sky appearance (light intensity).
  87363. */
  87364. rayleigh: number;
  87365. /**
  87366. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87367. */
  87368. mieCoefficient: number;
  87369. /**
  87370. * Defines the amount of haze particles following the Mie scattering theory.
  87371. */
  87372. mieDirectionalG: number;
  87373. /**
  87374. * Defines the distance of the sun according to the active scene camera.
  87375. */
  87376. distance: number;
  87377. /**
  87378. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87379. * "inclined".
  87380. */
  87381. inclination: number;
  87382. /**
  87383. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87384. * an object direction and a reference direction.
  87385. */
  87386. azimuth: number;
  87387. /**
  87388. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87389. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87390. */
  87391. sunPosition: BABYLON.Vector3;
  87392. /**
  87393. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87394. * .sunPosition property.
  87395. */
  87396. useSunPosition: boolean;
  87397. /**
  87398. * Defines an offset vector used to get a horizon offset.
  87399. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87400. */
  87401. cameraOffset: BABYLON.Vector3;
  87402. private _cameraPosition;
  87403. /**
  87404. * Instantiates a new sky material.
  87405. * This material allows to create dynamic and texture free
  87406. * effects for skyboxes by taking care of the atmosphere state.
  87407. * @see https://doc.babylonjs.com/extensions/sky
  87408. * @param name Define the name of the material in the scene
  87409. * @param scene Define the scene the material belong to
  87410. */
  87411. constructor(name: string, scene: BABYLON.Scene);
  87412. /**
  87413. * Specifies if the material will require alpha blending
  87414. * @returns a boolean specifying if alpha blending is needed
  87415. */
  87416. needAlphaBlending(): boolean;
  87417. /**
  87418. * Specifies if this material should be rendered in alpha test mode
  87419. * @returns false as the sky material doesn't need alpha testing.
  87420. */
  87421. needAlphaTesting(): boolean;
  87422. /**
  87423. * Get the texture used for alpha test purpose.
  87424. * @returns null as the sky material has no texture.
  87425. */
  87426. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87427. /**
  87428. * Get if the submesh is ready to be used and all its information available.
  87429. * Child classes can use it to update shaders
  87430. * @param mesh defines the mesh to check
  87431. * @param subMesh defines which submesh to check
  87432. * @param useInstances specifies that instances should be used
  87433. * @returns a boolean indicating that the submesh is ready or not
  87434. */
  87435. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87436. /**
  87437. * Binds the submesh to this material by preparing the effect and shader to draw
  87438. * @param world defines the world transformation matrix
  87439. * @param mesh defines the mesh containing the submesh
  87440. * @param subMesh defines the submesh to bind the material to
  87441. */
  87442. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87443. /**
  87444. * Get the list of animatables in the material.
  87445. * @returns the list of animatables object used in the material
  87446. */
  87447. getAnimatables(): BABYLON.IAnimatable[];
  87448. /**
  87449. * Disposes the material
  87450. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87451. */
  87452. dispose(forceDisposeEffect?: boolean): void;
  87453. /**
  87454. * Makes a duplicate of the material, and gives it a new name
  87455. * @param name defines the new name for the duplicated material
  87456. * @returns the cloned material
  87457. */
  87458. clone(name: string): SkyMaterial;
  87459. /**
  87460. * Serializes this material in a JSON representation
  87461. * @returns the serialized material object
  87462. */
  87463. serialize(): any;
  87464. /**
  87465. * Gets the current class name of the material e.g. "SkyMaterial"
  87466. * Mainly use in serialization.
  87467. * @returns the class name
  87468. */
  87469. getClassName(): string;
  87470. /**
  87471. * Creates a sky material from parsed material data
  87472. * @param source defines the JSON representation of the material
  87473. * @param scene defines the hosting scene
  87474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87475. * @returns a new sky material
  87476. */
  87477. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87478. }
  87479. }
  87480. declare module BABYLON {
  87481. /** @hidden */
  87482. export var terrainPixelShader: {
  87483. name: string;
  87484. shader: string;
  87485. };
  87486. }
  87487. declare module BABYLON {
  87488. /** @hidden */
  87489. export var terrainVertexShader: {
  87490. name: string;
  87491. shader: string;
  87492. };
  87493. }
  87494. declare module BABYLON {
  87495. export class TerrainMaterial extends BABYLON.PushMaterial {
  87496. private _mixTexture;
  87497. mixTexture: BABYLON.BaseTexture;
  87498. private _diffuseTexture1;
  87499. diffuseTexture1: BABYLON.Texture;
  87500. private _diffuseTexture2;
  87501. diffuseTexture2: BABYLON.Texture;
  87502. private _diffuseTexture3;
  87503. diffuseTexture3: BABYLON.Texture;
  87504. private _bumpTexture1;
  87505. bumpTexture1: BABYLON.Texture;
  87506. private _bumpTexture2;
  87507. bumpTexture2: BABYLON.Texture;
  87508. private _bumpTexture3;
  87509. bumpTexture3: BABYLON.Texture;
  87510. diffuseColor: BABYLON.Color3;
  87511. specularColor: BABYLON.Color3;
  87512. specularPower: number;
  87513. private _disableLighting;
  87514. disableLighting: boolean;
  87515. private _maxSimultaneousLights;
  87516. maxSimultaneousLights: number;
  87517. constructor(name: string, scene: BABYLON.Scene);
  87518. needAlphaBlending(): boolean;
  87519. needAlphaTesting(): boolean;
  87520. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87521. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87522. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87523. getAnimatables(): BABYLON.IAnimatable[];
  87524. getActiveTextures(): BABYLON.BaseTexture[];
  87525. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87526. dispose(forceDisposeEffect?: boolean): void;
  87527. clone(name: string): TerrainMaterial;
  87528. serialize(): any;
  87529. getClassName(): string;
  87530. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87531. }
  87532. }
  87533. declare module BABYLON {
  87534. /** @hidden */
  87535. export var triplanarPixelShader: {
  87536. name: string;
  87537. shader: string;
  87538. };
  87539. }
  87540. declare module BABYLON {
  87541. /** @hidden */
  87542. export var triplanarVertexShader: {
  87543. name: string;
  87544. shader: string;
  87545. };
  87546. }
  87547. declare module BABYLON {
  87548. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87549. mixTexture: BABYLON.BaseTexture;
  87550. private _diffuseTextureX;
  87551. diffuseTextureX: BABYLON.BaseTexture;
  87552. private _diffuseTextureY;
  87553. diffuseTextureY: BABYLON.BaseTexture;
  87554. private _diffuseTextureZ;
  87555. diffuseTextureZ: BABYLON.BaseTexture;
  87556. private _normalTextureX;
  87557. normalTextureX: BABYLON.BaseTexture;
  87558. private _normalTextureY;
  87559. normalTextureY: BABYLON.BaseTexture;
  87560. private _normalTextureZ;
  87561. normalTextureZ: BABYLON.BaseTexture;
  87562. tileSize: number;
  87563. diffuseColor: BABYLON.Color3;
  87564. specularColor: BABYLON.Color3;
  87565. specularPower: number;
  87566. private _disableLighting;
  87567. disableLighting: boolean;
  87568. private _maxSimultaneousLights;
  87569. maxSimultaneousLights: number;
  87570. constructor(name: string, scene: BABYLON.Scene);
  87571. needAlphaBlending(): boolean;
  87572. needAlphaTesting(): boolean;
  87573. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87574. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87575. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87576. getAnimatables(): BABYLON.IAnimatable[];
  87577. getActiveTextures(): BABYLON.BaseTexture[];
  87578. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87579. dispose(forceDisposeEffect?: boolean): void;
  87580. clone(name: string): TriPlanarMaterial;
  87581. serialize(): any;
  87582. getClassName(): string;
  87583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87584. }
  87585. }
  87586. declare module BABYLON {
  87587. /** @hidden */
  87588. export var waterPixelShader: {
  87589. name: string;
  87590. shader: string;
  87591. };
  87592. }
  87593. declare module BABYLON {
  87594. /** @hidden */
  87595. export var waterVertexShader: {
  87596. name: string;
  87597. shader: string;
  87598. };
  87599. }
  87600. declare module BABYLON {
  87601. export class WaterMaterial extends BABYLON.PushMaterial {
  87602. renderTargetSize: BABYLON.Vector2;
  87603. private _bumpTexture;
  87604. bumpTexture: BABYLON.BaseTexture;
  87605. diffuseColor: BABYLON.Color3;
  87606. specularColor: BABYLON.Color3;
  87607. specularPower: number;
  87608. private _disableLighting;
  87609. disableLighting: boolean;
  87610. private _maxSimultaneousLights;
  87611. maxSimultaneousLights: number;
  87612. /**
  87613. * Defines the wind force.
  87614. */
  87615. windForce: number;
  87616. /**
  87617. * Defines the direction of the wind in the plane (X, Z).
  87618. */
  87619. windDirection: BABYLON.Vector2;
  87620. /**
  87621. * Defines the height of the waves.
  87622. */
  87623. waveHeight: number;
  87624. /**
  87625. * Defines the bump height related to the bump map.
  87626. */
  87627. bumpHeight: number;
  87628. /**
  87629. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87630. */
  87631. private _bumpSuperimpose;
  87632. bumpSuperimpose: boolean;
  87633. /**
  87634. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87635. */
  87636. private _fresnelSeparate;
  87637. fresnelSeparate: boolean;
  87638. /**
  87639. * Defines wether or not bump Wwves modify the reflection.
  87640. */
  87641. private _bumpAffectsReflection;
  87642. bumpAffectsReflection: boolean;
  87643. /**
  87644. * Defines the water color blended with the refraction (near).
  87645. */
  87646. waterColor: BABYLON.Color3;
  87647. /**
  87648. * Defines the blend factor related to the water color.
  87649. */
  87650. colorBlendFactor: number;
  87651. /**
  87652. * Defines the water color blended with the reflection (far).
  87653. */
  87654. waterColor2: BABYLON.Color3;
  87655. /**
  87656. * Defines the blend factor related to the water color (reflection, far).
  87657. */
  87658. colorBlendFactor2: number;
  87659. /**
  87660. * Defines the maximum length of a wave.
  87661. */
  87662. waveLength: number;
  87663. /**
  87664. * Defines the waves speed.
  87665. */
  87666. waveSpeed: number;
  87667. /**
  87668. * 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.
  87669. */
  87670. waveCount: number;
  87671. /**
  87672. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87673. * will avoid calculating useless pixels in the pixel shader of the water material.
  87674. */
  87675. disableClipPlane: boolean;
  87676. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87677. private _mesh;
  87678. private _refractionRTT;
  87679. private _reflectionRTT;
  87680. private _reflectionTransform;
  87681. private _lastTime;
  87682. private _lastDeltaTime;
  87683. private _useLogarithmicDepth;
  87684. private _waitingRenderList;
  87685. private _imageProcessingConfiguration;
  87686. private _imageProcessingObserver;
  87687. /**
  87688. * Gets a boolean indicating that current material needs to register RTT
  87689. */
  87690. get hasRenderTargetTextures(): boolean;
  87691. /**
  87692. * Constructor
  87693. */
  87694. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87695. get useLogarithmicDepth(): boolean;
  87696. set useLogarithmicDepth(value: boolean);
  87697. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87698. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87699. addToRenderList(node: any): void;
  87700. enableRenderTargets(enable: boolean): void;
  87701. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87702. get renderTargetsEnabled(): boolean;
  87703. needAlphaBlending(): boolean;
  87704. needAlphaTesting(): boolean;
  87705. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87706. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87707. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87708. private _createRenderTargets;
  87709. getAnimatables(): BABYLON.IAnimatable[];
  87710. getActiveTextures(): BABYLON.BaseTexture[];
  87711. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87712. dispose(forceDisposeEffect?: boolean): void;
  87713. clone(name: string): WaterMaterial;
  87714. serialize(): any;
  87715. getClassName(): string;
  87716. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87717. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87718. }
  87719. }
  87720. declare module BABYLON {
  87721. /** @hidden */
  87722. export var asciiartPixelShader: {
  87723. name: string;
  87724. shader: string;
  87725. };
  87726. }
  87727. declare module BABYLON {
  87728. /**
  87729. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87730. *
  87731. * It basically takes care rendering the font front the given font size to a texture.
  87732. * This is used later on in the postprocess.
  87733. */
  87734. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87735. private _font;
  87736. private _text;
  87737. private _charSize;
  87738. /**
  87739. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87740. */
  87741. get charSize(): number;
  87742. /**
  87743. * Create a new instance of the Ascii Art FontTexture class
  87744. * @param name the name of the texture
  87745. * @param font the font to use, use the W3C CSS notation
  87746. * @param text the caracter set to use in the rendering.
  87747. * @param scene the scene that owns the texture
  87748. */
  87749. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87750. /**
  87751. * Gets the max char width of a font.
  87752. * @param font the font to use, use the W3C CSS notation
  87753. * @return the max char width
  87754. */
  87755. private getFontWidth;
  87756. /**
  87757. * Gets the max char height of a font.
  87758. * @param font the font to use, use the W3C CSS notation
  87759. * @return the max char height
  87760. */
  87761. private getFontHeight;
  87762. /**
  87763. * Clones the current AsciiArtTexture.
  87764. * @return the clone of the texture.
  87765. */
  87766. clone(): AsciiArtFontTexture;
  87767. /**
  87768. * Parses a json object representing the texture and returns an instance of it.
  87769. * @param source the source JSON representation
  87770. * @param scene the scene to create the texture for
  87771. * @return the parsed texture
  87772. */
  87773. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87774. }
  87775. /**
  87776. * Option available in the Ascii Art Post Process.
  87777. */
  87778. export interface IAsciiArtPostProcessOptions {
  87779. /**
  87780. * The font to use following the w3c font definition.
  87781. */
  87782. font?: string;
  87783. /**
  87784. * The character set to use in the postprocess.
  87785. */
  87786. characterSet?: string;
  87787. /**
  87788. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87789. * This number is defined between 0 and 1;
  87790. */
  87791. mixToTile?: number;
  87792. /**
  87793. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87794. * This number is defined between 0 and 1;
  87795. */
  87796. mixToNormal?: number;
  87797. }
  87798. /**
  87799. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87800. *
  87801. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87802. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87803. */
  87804. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87805. /**
  87806. * The font texture used to render the char in the post process.
  87807. */
  87808. private _asciiArtFontTexture;
  87809. /**
  87810. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87811. * This number is defined between 0 and 1;
  87812. */
  87813. mixToTile: number;
  87814. /**
  87815. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87816. * This number is defined between 0 and 1;
  87817. */
  87818. mixToNormal: number;
  87819. /**
  87820. * Instantiates a new Ascii Art Post Process.
  87821. * @param name the name to give to the postprocess
  87822. * @camera the camera to apply the post process to.
  87823. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87824. */
  87825. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87826. }
  87827. }
  87828. declare module BABYLON {
  87829. /** @hidden */
  87830. export var digitalrainPixelShader: {
  87831. name: string;
  87832. shader: string;
  87833. };
  87834. }
  87835. declare module BABYLON {
  87836. /**
  87837. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87838. *
  87839. * It basically takes care rendering the font front the given font size to a texture.
  87840. * This is used later on in the postprocess.
  87841. */
  87842. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87843. private _font;
  87844. private _text;
  87845. private _charSize;
  87846. /**
  87847. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87848. */
  87849. get charSize(): number;
  87850. /**
  87851. * Create a new instance of the Digital Rain FontTexture class
  87852. * @param name the name of the texture
  87853. * @param font the font to use, use the W3C CSS notation
  87854. * @param text the caracter set to use in the rendering.
  87855. * @param scene the scene that owns the texture
  87856. */
  87857. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87858. /**
  87859. * Gets the max char width of a font.
  87860. * @param font the font to use, use the W3C CSS notation
  87861. * @return the max char width
  87862. */
  87863. private getFontWidth;
  87864. /**
  87865. * Gets the max char height of a font.
  87866. * @param font the font to use, use the W3C CSS notation
  87867. * @return the max char height
  87868. */
  87869. private getFontHeight;
  87870. /**
  87871. * Clones the current DigitalRainFontTexture.
  87872. * @return the clone of the texture.
  87873. */
  87874. clone(): DigitalRainFontTexture;
  87875. /**
  87876. * Parses a json object representing the texture and returns an instance of it.
  87877. * @param source the source JSON representation
  87878. * @param scene the scene to create the texture for
  87879. * @return the parsed texture
  87880. */
  87881. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87882. }
  87883. /**
  87884. * Option available in the Digital Rain Post Process.
  87885. */
  87886. export interface IDigitalRainPostProcessOptions {
  87887. /**
  87888. * The font to use following the w3c font definition.
  87889. */
  87890. font?: string;
  87891. /**
  87892. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87893. * This number is defined between 0 and 1;
  87894. */
  87895. mixToTile?: number;
  87896. /**
  87897. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87898. * This number is defined between 0 and 1;
  87899. */
  87900. mixToNormal?: number;
  87901. }
  87902. /**
  87903. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87904. *
  87905. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87906. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87907. */
  87908. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87909. /**
  87910. * The font texture used to render the char in the post process.
  87911. */
  87912. private _digitalRainFontTexture;
  87913. /**
  87914. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87915. * This number is defined between 0 and 1;
  87916. */
  87917. mixToTile: number;
  87918. /**
  87919. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87920. * This number is defined between 0 and 1;
  87921. */
  87922. mixToNormal: number;
  87923. /**
  87924. * Instantiates a new Digital Rain Post Process.
  87925. * @param name the name to give to the postprocess
  87926. * @camera the camera to apply the post process to.
  87927. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87928. */
  87929. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87930. }
  87931. }
  87932. declare module BABYLON {
  87933. /** @hidden */
  87934. export var brickProceduralTexturePixelShader: {
  87935. name: string;
  87936. shader: string;
  87937. };
  87938. }
  87939. declare module BABYLON {
  87940. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87941. private _numberOfBricksHeight;
  87942. private _numberOfBricksWidth;
  87943. private _jointColor;
  87944. private _brickColor;
  87945. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87946. updateShaderUniforms(): void;
  87947. get numberOfBricksHeight(): number;
  87948. set numberOfBricksHeight(value: number);
  87949. get numberOfBricksWidth(): number;
  87950. set numberOfBricksWidth(value: number);
  87951. get jointColor(): BABYLON.Color3;
  87952. set jointColor(value: BABYLON.Color3);
  87953. get brickColor(): BABYLON.Color3;
  87954. set brickColor(value: BABYLON.Color3);
  87955. /**
  87956. * Serializes this brick procedural texture
  87957. * @returns a serialized brick procedural texture object
  87958. */
  87959. serialize(): any;
  87960. /**
  87961. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87962. * @param parsedTexture defines parsed texture data
  87963. * @param scene defines the current scene
  87964. * @param rootUrl defines the root URL containing brick procedural texture information
  87965. * @returns a parsed Brick Procedural BABYLON.Texture
  87966. */
  87967. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87968. }
  87969. }
  87970. declare module BABYLON {
  87971. /** @hidden */
  87972. export var cloudProceduralTexturePixelShader: {
  87973. name: string;
  87974. shader: string;
  87975. };
  87976. }
  87977. declare module BABYLON {
  87978. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87979. private _skyColor;
  87980. private _cloudColor;
  87981. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87982. updateShaderUniforms(): void;
  87983. get skyColor(): BABYLON.Color4;
  87984. set skyColor(value: BABYLON.Color4);
  87985. get cloudColor(): BABYLON.Color4;
  87986. set cloudColor(value: BABYLON.Color4);
  87987. /**
  87988. * Serializes this cloud procedural texture
  87989. * @returns a serialized cloud procedural texture object
  87990. */
  87991. serialize(): any;
  87992. /**
  87993. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87994. * @param parsedTexture defines parsed texture data
  87995. * @param scene defines the current scene
  87996. * @param rootUrl defines the root URL containing cloud procedural texture information
  87997. * @returns a parsed Cloud Procedural BABYLON.Texture
  87998. */
  87999. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88000. }
  88001. }
  88002. declare module BABYLON {
  88003. /** @hidden */
  88004. export var fireProceduralTexturePixelShader: {
  88005. name: string;
  88006. shader: string;
  88007. };
  88008. }
  88009. declare module BABYLON {
  88010. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88011. private _time;
  88012. private _speed;
  88013. private _autoGenerateTime;
  88014. private _fireColors;
  88015. private _alphaThreshold;
  88016. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88017. updateShaderUniforms(): void;
  88018. render(useCameraPostProcess?: boolean): void;
  88019. static get PurpleFireColors(): BABYLON.Color3[];
  88020. static get GreenFireColors(): BABYLON.Color3[];
  88021. static get RedFireColors(): BABYLON.Color3[];
  88022. static get BlueFireColors(): BABYLON.Color3[];
  88023. get autoGenerateTime(): boolean;
  88024. set autoGenerateTime(value: boolean);
  88025. get fireColors(): BABYLON.Color3[];
  88026. set fireColors(value: BABYLON.Color3[]);
  88027. get time(): number;
  88028. set time(value: number);
  88029. get speed(): BABYLON.Vector2;
  88030. set speed(value: BABYLON.Vector2);
  88031. get alphaThreshold(): number;
  88032. set alphaThreshold(value: number);
  88033. /**
  88034. * Serializes this fire procedural texture
  88035. * @returns a serialized fire procedural texture object
  88036. */
  88037. serialize(): any;
  88038. /**
  88039. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88040. * @param parsedTexture defines parsed texture data
  88041. * @param scene defines the current scene
  88042. * @param rootUrl defines the root URL containing fire procedural texture information
  88043. * @returns a parsed Fire Procedural BABYLON.Texture
  88044. */
  88045. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88046. }
  88047. }
  88048. declare module BABYLON {
  88049. /** @hidden */
  88050. export var grassProceduralTexturePixelShader: {
  88051. name: string;
  88052. shader: string;
  88053. };
  88054. }
  88055. declare module BABYLON {
  88056. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88057. private _grassColors;
  88058. private _groundColor;
  88059. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88060. updateShaderUniforms(): void;
  88061. get grassColors(): BABYLON.Color3[];
  88062. set grassColors(value: BABYLON.Color3[]);
  88063. get groundColor(): BABYLON.Color3;
  88064. set groundColor(value: BABYLON.Color3);
  88065. /**
  88066. * Serializes this grass procedural texture
  88067. * @returns a serialized grass procedural texture object
  88068. */
  88069. serialize(): any;
  88070. /**
  88071. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88072. * @param parsedTexture defines parsed texture data
  88073. * @param scene defines the current scene
  88074. * @param rootUrl defines the root URL containing grass procedural texture information
  88075. * @returns a parsed Grass Procedural BABYLON.Texture
  88076. */
  88077. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88078. }
  88079. }
  88080. declare module BABYLON {
  88081. /** @hidden */
  88082. export var marbleProceduralTexturePixelShader: {
  88083. name: string;
  88084. shader: string;
  88085. };
  88086. }
  88087. declare module BABYLON {
  88088. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88089. private _numberOfTilesHeight;
  88090. private _numberOfTilesWidth;
  88091. private _amplitude;
  88092. private _jointColor;
  88093. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88094. updateShaderUniforms(): void;
  88095. get numberOfTilesHeight(): number;
  88096. set numberOfTilesHeight(value: number);
  88097. get amplitude(): number;
  88098. set amplitude(value: number);
  88099. get numberOfTilesWidth(): number;
  88100. set numberOfTilesWidth(value: number);
  88101. get jointColor(): BABYLON.Color3;
  88102. set jointColor(value: BABYLON.Color3);
  88103. /**
  88104. * Serializes this marble procedural texture
  88105. * @returns a serialized marble procedural texture object
  88106. */
  88107. serialize(): any;
  88108. /**
  88109. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88110. * @param parsedTexture defines parsed texture data
  88111. * @param scene defines the current scene
  88112. * @param rootUrl defines the root URL containing marble procedural texture information
  88113. * @returns a parsed Marble Procedural BABYLON.Texture
  88114. */
  88115. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88116. }
  88117. }
  88118. declare module BABYLON {
  88119. /** @hidden */
  88120. export var normalMapProceduralTexturePixelShader: {
  88121. name: string;
  88122. shader: string;
  88123. };
  88124. }
  88125. declare module BABYLON {
  88126. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88127. private _baseTexture;
  88128. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88129. updateShaderUniforms(): void;
  88130. render(useCameraPostProcess?: boolean): void;
  88131. resize(size: any, generateMipMaps: any): void;
  88132. get baseTexture(): BABYLON.Texture;
  88133. set baseTexture(texture: BABYLON.Texture);
  88134. /**
  88135. * Serializes this normal map procedural texture
  88136. * @returns a serialized normal map procedural texture object
  88137. */
  88138. serialize(): any;
  88139. /**
  88140. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88141. * @param parsedTexture defines parsed texture data
  88142. * @param scene defines the current scene
  88143. * @param rootUrl defines the root URL containing normal map procedural texture information
  88144. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88145. */
  88146. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88147. }
  88148. }
  88149. declare module BABYLON {
  88150. /** @hidden */
  88151. export var perlinNoiseProceduralTexturePixelShader: {
  88152. name: string;
  88153. shader: string;
  88154. };
  88155. }
  88156. declare module BABYLON {
  88157. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88158. time: number;
  88159. timeScale: number;
  88160. translationSpeed: number;
  88161. private _currentTranslation;
  88162. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88163. updateShaderUniforms(): void;
  88164. render(useCameraPostProcess?: boolean): void;
  88165. resize(size: any, generateMipMaps: any): void;
  88166. /**
  88167. * Serializes this perlin noise procedural texture
  88168. * @returns a serialized perlin noise procedural texture object
  88169. */
  88170. serialize(): any;
  88171. /**
  88172. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88173. * @param parsedTexture defines parsed texture data
  88174. * @param scene defines the current scene
  88175. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88176. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88177. */
  88178. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88179. }
  88180. }
  88181. declare module BABYLON {
  88182. /** @hidden */
  88183. export var roadProceduralTexturePixelShader: {
  88184. name: string;
  88185. shader: string;
  88186. };
  88187. }
  88188. declare module BABYLON {
  88189. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88190. private _roadColor;
  88191. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88192. updateShaderUniforms(): void;
  88193. get roadColor(): BABYLON.Color3;
  88194. set roadColor(value: BABYLON.Color3);
  88195. /**
  88196. * Serializes this road procedural texture
  88197. * @returns a serialized road procedural texture object
  88198. */
  88199. serialize(): any;
  88200. /**
  88201. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88202. * @param parsedTexture defines parsed texture data
  88203. * @param scene defines the current scene
  88204. * @param rootUrl defines the root URL containing road procedural texture information
  88205. * @returns a parsed Road Procedural BABYLON.Texture
  88206. */
  88207. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88208. }
  88209. }
  88210. declare module BABYLON {
  88211. /** @hidden */
  88212. export var starfieldProceduralTexturePixelShader: {
  88213. name: string;
  88214. shader: string;
  88215. };
  88216. }
  88217. declare module BABYLON {
  88218. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88219. private _time;
  88220. private _alpha;
  88221. private _beta;
  88222. private _zoom;
  88223. private _formuparam;
  88224. private _stepsize;
  88225. private _tile;
  88226. private _brightness;
  88227. private _darkmatter;
  88228. private _distfading;
  88229. private _saturation;
  88230. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88231. updateShaderUniforms(): void;
  88232. get time(): number;
  88233. set time(value: number);
  88234. get alpha(): number;
  88235. set alpha(value: number);
  88236. get beta(): number;
  88237. set beta(value: number);
  88238. get formuparam(): number;
  88239. set formuparam(value: number);
  88240. get stepsize(): number;
  88241. set stepsize(value: number);
  88242. get zoom(): number;
  88243. set zoom(value: number);
  88244. get tile(): number;
  88245. set tile(value: number);
  88246. get brightness(): number;
  88247. set brightness(value: number);
  88248. get darkmatter(): number;
  88249. set darkmatter(value: number);
  88250. get distfading(): number;
  88251. set distfading(value: number);
  88252. get saturation(): number;
  88253. set saturation(value: number);
  88254. /**
  88255. * Serializes this starfield procedural texture
  88256. * @returns a serialized starfield procedural texture object
  88257. */
  88258. serialize(): any;
  88259. /**
  88260. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88261. * @param parsedTexture defines parsed texture data
  88262. * @param scene defines the current scene
  88263. * @param rootUrl defines the root URL containing startfield procedural texture information
  88264. * @returns a parsed Starfield Procedural BABYLON.Texture
  88265. */
  88266. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88267. }
  88268. }
  88269. declare module BABYLON {
  88270. /** @hidden */
  88271. export var woodProceduralTexturePixelShader: {
  88272. name: string;
  88273. shader: string;
  88274. };
  88275. }
  88276. declare module BABYLON {
  88277. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88278. private _ampScale;
  88279. private _woodColor;
  88280. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88281. updateShaderUniforms(): void;
  88282. get ampScale(): number;
  88283. set ampScale(value: number);
  88284. get woodColor(): BABYLON.Color3;
  88285. set woodColor(value: BABYLON.Color3);
  88286. /**
  88287. * Serializes this wood procedural texture
  88288. * @returns a serialized wood procedural texture object
  88289. */
  88290. serialize(): any;
  88291. /**
  88292. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88293. * @param parsedTexture defines parsed texture data
  88294. * @param scene defines the current scene
  88295. * @param rootUrl defines the root URL containing wood procedural texture information
  88296. * @returns a parsed Wood Procedural BABYLON.Texture
  88297. */
  88298. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88299. }
  88300. }